Skip to content

Commit

Permalink
Add preimage pallet (#241)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe what change this PR is implementing -->

Adds preimage pallet to cere & cere-dev

### Types of Changes
<!--- What types of changes does your code introduce? -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Dependency upgrade (A change in substrate or any 3rd party crate
version)

### Migrations and Hooks
<!--- Check the following box with an x if the following applies: -->
- [x] This change requires a runtime migration.
- [ ] Modifies `on_initialize`
- [ ] Modifies `on_finalize`

### Checklist
<!--- All boxes need to be checked. Follow this checklist before
requiring PR review -->
- [ ] Change has been tested locally.
- [ ] Change adds / updates tests.
- [x] Changelog doc updated.
  • Loading branch information
rakanalh authored Jan 23, 2024
1 parent 802aa67 commit 247bb02
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- [C,D] Updated Substrate to polkadot-v0.9.38
- [C] Added pallet-preimage to support democracy functionality.

## [4.8.6]

Expand Down
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions runtime/cere-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/su
pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
pallet-offences = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false, optional = true }
pallet-preimage = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-proxy = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-recovery = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
Expand Down Expand Up @@ -143,6 +144,7 @@ std = [
"node-primitives/std",
"pallet-offences/std",
"pallet-proxy/std",
"pallet-preimage/std",
"sp-core/std",
"pallet-randomness-collective-flip/std",
"sp-std/std",
Expand Down Expand Up @@ -210,6 +212,7 @@ runtime-benchmarks = [
"pallet-nomination-pools-benchmarking/runtime-benchmarks",
"pallet-offences-benchmarking/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-session-benchmarking/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
Expand Down Expand Up @@ -254,6 +257,7 @@ try-runtime = [
"pallet-nomination-pools/try-runtime",
"pallet-offences/try-runtime",
"pallet-proxy/try-runtime",
"pallet-preimage/try-runtime",
"pallet-randomness-collective-flip/try-runtime",
"pallet-recovery/try-runtime",
"pallet-scheduler/try-runtime",
Expand Down
22 changes: 20 additions & 2 deletions runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 48700,
spec_version: 48701,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 12,
transaction_version: 13,
state_version: 0,
};

Expand Down Expand Up @@ -342,6 +342,21 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

parameter_types! {
pub const PreimageMaxSize: u32 = 4096 * 1024;
pub const PreimageBaseDeposit: Balance = deposit(2, 64);
pub const PreimageByteDeposit: Balance = deposit(0, 1);
}

impl pallet_preimage::Config for Runtime {
type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = PreimageBaseDeposit;
type ByteDeposit = PreimageByteDeposit;
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
RuntimeBlockWeights::get().max_block;
Expand Down Expand Up @@ -1411,6 +1426,7 @@ construct_runtime!(
Society: pallet_society,
Recovery: pallet_recovery,
Vesting: pallet_vesting,
Preimage: pallet_preimage,
Scheduler: pallet_scheduler,
Proxy: pallet_proxy,
Multisig: pallet_multisig,
Expand Down Expand Up @@ -1477,6 +1493,7 @@ type Migrations = (
// this release they will be properly pruned after the bonding duration has
// elapsed)
pallet_grandpa::migrations::CleanupSetIdSessionMap<Runtime>,
pallet_preimage::migration::v1::Migration<Runtime>,
);

/// Executive: handles dispatch to the various modules.
Expand Down Expand Up @@ -1531,6 +1548,7 @@ mod benches {
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
[pallet_offences, OffencesBench::<Runtime>]
[pallet_proxy, Proxy]
[pallet_preimage, Preimage]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_staking, Staking]
Expand Down
4 changes: 4 additions & 0 deletions runtime/cere/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/su
pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
pallet-offences = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38", default-features = false, optional = true }
pallet-preimage = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-proxy = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-randomness-collective-flip = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
pallet-recovery = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.38" }
Expand Down Expand Up @@ -143,6 +144,7 @@ std = [
"node-primitives/std",
"pallet-offences/std",
"pallet-proxy/std",
"pallet-preimage/std",
"sp-core/std",
"pallet-randomness-collective-flip/std",
"sp-std/std",
Expand Down Expand Up @@ -212,7 +214,9 @@ runtime-benchmarks = [
"pallet-nomination-pools/runtime-benchmarks",
"pallet-nomination-pools-benchmarking/runtime-benchmarks",
"pallet-offences-benchmarking/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-session-benchmarking/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
Expand Down
26 changes: 22 additions & 4 deletions runtime/cere/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 48700,
spec_version: 48701,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 12,
transaction_version: 13,
state_version: 0,
};

Expand Down Expand Up @@ -337,6 +337,21 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

parameter_types! {
pub const PreimageMaxSize: u32 = 4096 * 1024;
pub const PreimageBaseDeposit: Balance = deposit(4, 128);
pub const PreimageByteDeposit: Balance = deposit(0, 2);
}

impl pallet_preimage::Config for Runtime {
type WeightInfo = pallet_preimage::weights::SubstrateWeight<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = PreimageBaseDeposit;
type ByteDeposit = PreimageByteDeposit;
}

parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
RuntimeBlockWeights::get().max_block;
Expand All @@ -352,7 +367,7 @@ impl pallet_scheduler::Config for Runtime {
type MaxScheduledPerBlock = ConstU32<512>;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type Preimages = ();
type Preimages = Preimage;
}

parameter_types! {
Expand Down Expand Up @@ -792,7 +807,7 @@ impl pallet_democracy::Config for Runtime {
type MaxVotes = ConstU32<100>;
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type MaxProposals = MaxProposals;
type Preimages = ();
type Preimages = Preimage;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
}
Expand Down Expand Up @@ -1416,6 +1431,7 @@ construct_runtime!(
Society: pallet_society,
Recovery: pallet_recovery,
Vesting: pallet_vesting,
Preimage: pallet_preimage,
Scheduler: pallet_scheduler,
Proxy: pallet_proxy,
Multisig: pallet_multisig,
Expand Down Expand Up @@ -1482,6 +1498,7 @@ type Migrations = (
// this release they will be properly pruned after the bonding duration has
// elapsed)
pallet_grandpa::migrations::CleanupSetIdSessionMap<Runtime>,
pallet_preimage::migration::v1::Migration<Runtime>,
);
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Expand Down Expand Up @@ -1527,6 +1544,7 @@ mod benches {
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
[pallet_offences, OffencesBench::<Runtime>]
[pallet_proxy, Proxy]
[pallet_preimage, Preimage]
[pallet_scheduler, Scheduler]
[pallet_session, SessionBench::<Runtime>]
[pallet_staking, Staking]
Expand Down

0 comments on commit 247bb02

Please sign in to comment.