Skip to content

Commit

Permalink
remove insecure randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmattgray authored and mattdean-digicatapult committed Sep 6, 2023
1 parent e8981e4 commit 8fdc86a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 63 deletions.
44 changes: 1 addition & 43 deletions Cargo.lock

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

28 changes: 15 additions & 13 deletions pallets/symmetric-key/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0)
/// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen)
/// Storage: IpfsKey Key (r:0 w:1)
/// Proof: IpfsKey Key (max_values: Some(1), max_size: Some(33), added: 528, mode: MaxEncodedLen)
fn rotate_key() -> Weight {
// Proof Size summary in bytes:
// Measured: `6`
// Estimated: `4079`
// Minimum execution time: 4_000_000 picoseconds.
Weight::from_parts(5_000_000, 0)
.saturating_add(Weight::from_parts(0, 4079))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
/// Storage: Babe NextRandomness (r:1 w:0)
/// Proof: Babe NextRandomness (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)
/// Storage: Babe EpochStart (r:1 w:0)
/// Proof: Babe EpochStart (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen)
/// Storage: IpfsKey Key (r:0 w:1)
/// Proof: IpfsKey Key (max_values: Some(1), max_size: Some(33), added: 528, mode: MaxEncodedLen)
fn rotate_key() -> Weight {
// Proof Size summary in bytes:
// Measured: `132`
// Estimated: `1517`
// Minimum execution time: 5_000_000 picoseconds.
Weight::from_parts(6_000_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}

Expand Down
3 changes: 0 additions & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pallet-babe = { version = "4.0.0-dev", default-features = false, git = "https://
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }
frame-try-runtime = { version = "0.10.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.42" }
Expand Down Expand Up @@ -93,7 +92,6 @@ std = [
"pallet-node-authorization/std",
"pallet-preimage/std",
"pallet-process-validation/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-free/std",
Expand Down Expand Up @@ -145,7 +143,6 @@ try-runtime = [
"pallet-node-authorization/try-runtime",
"pallet-preimage/try-runtime",
"pallet-process-validation/try-runtime",
"pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-utxo-nft/try-runtime",
"pallet-sudo/try-runtime",
Expand Down
5 changes: 1 addition & 4 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ impl frame_system::Config for Runtime {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}

impl pallet_insecure_randomness_collective_flip::Config for Runtime {}

parameter_types! {
// NOTE: Currently it is not possible to change the epoch duration after the chain has started.
// Attempting to do so will brick block production.
Expand Down Expand Up @@ -461,7 +459,7 @@ impl pallet_symmetric_key::Config for Runtime {
type ScheduleCall = RuntimeCall;
type UpdateOrigin = MoreThanHalfMembers;
type RotateOrigin = MoreThanTwoMembers;
type Randomness = RandomnessCollectiveFlip;
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
type PalletsOrigin = OriginCaller;
type Scheduler = Scheduler;
type WeightInfo = pallet_symmetric_key::weights::SubstrateWeight<Runtime>;
Expand All @@ -476,7 +474,6 @@ construct_runtime!(
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system,
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
Timestamp: pallet_timestamp,
Babe: pallet_babe,
Grandpa: pallet_grandpa,
Expand Down

0 comments on commit 8fdc86a

Please sign in to comment.