Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@gavofyork
Copy link
Member

@gavofyork gavofyork commented Nov 30, 2019

Democracy currently has a state bloat attack since public proposals are allowed to include Calls which get stored indefinitely in state. This revamps that system so that only a fixed-length hash of the Call is stored, and only when the motion is accepted does the underlying preimage Call get uploaded to the chain. To protect the chain from griefing, there is a substantial refundable deposit for uploading preimage data on the chain of around 1 cent per byte (around $10,000 for 1MB), but this is waived in the case that the preimage is for a motion that has already passed and is in the enactment period.

Once a proposal is enacted, then the preimage is dropped and the deposit refunded. A preimage deposit can also be dropped/refunded once it times out, the time out period is the voting_period + enactment_period.

Since there already exist proposals in Kusama, an additional sudo function is introduced; clear_proposals to get rid of them around upgrade time.

Additionally, the tests have been updated to reflect the fact that the per-block logic happens during initialize_block rather than at finalize_block.

Breaking change

Democracy module requires additional configuration items PreimageByteDeposit, Slash in the config trait. Here's an example of how it might look:

parameter_types! {
	...
	pub const PreimageByteDeposit: Balance = 1 * CENTS;
}
...
impl democracy::Trait for Runtime {
	...
	type PreimageByteDeposit = PreimageByteDeposit;
	type Slash = Treasury;
}

@gavofyork gavofyork added the A0-please_review Pull request needs code review. label Nov 30, 2019
@gavofyork gavofyork added this to the 2.0 milestone Nov 30, 2019
Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and makes sense to me.

Copy link
Contributor

@marcio-diaz marcio-diaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Although, I don't get why we can't reap the pre-image automatically (on bake_referendum?).

@gavofyork
Copy link
Member Author

Looks good. Although, I don't get why we can't reap the pre-image automatically (on bake_referendum?).

because it may not have an associated bake_referendum.

@gavofyork gavofyork merged commit 64177da into master Dec 1, 2019
@gavofyork gavofyork deleted the gav-fix-demo branch December 1, 2019 09:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A0-please_review Pull request needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants