diff --git a/Cargo.lock b/Cargo.lock index 801f8eb34d..7c0d16073f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10506,6 +10506,8 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "parking_lot 0.12.1", + "rand 0.8.5", + "rand_chacha 0.3.1", "sc-basic-authorship", "sc-chain-spec", "sc-client-api", diff --git a/crates/subspace-service/Cargo.toml b/crates/subspace-service/Cargo.toml index ccf6aa97b3..89b6982991 100644 --- a/crates/subspace-service/Cargo.toml +++ b/crates/subspace-service/Cargo.toml @@ -29,6 +29,8 @@ jsonrpsee = { version = "0.16.2", features = ["server"] } pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/substrate", rev = "28e33f78a3aa8ac4c6753108bc0471273ff6bf6f" } parity-scale-codec = "3.6.1" parking_lot = "0.12.1" +rand = "0.8.5" +rand_chacha = "0.3.1" sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/subspace/substrate", rev = "28e33f78a3aa8ac4c6753108bc0471273ff6bf6f" } sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/substrate", rev = "28e33f78a3aa8ac4c6753108bc0471273ff6bf6f" } sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/substrate", rev = "28e33f78a3aa8ac4c6753108bc0471273ff6bf6f" } diff --git a/crates/subspace-service/src/genesis_block_builder.rs b/crates/subspace-service/src/genesis_block_builder.rs index 3d4ab89746..676bbf7cf3 100644 --- a/crates/subspace-service/src/genesis_block_builder.rs +++ b/crates/subspace-service/src/genesis_block_builder.rs @@ -1,3 +1,5 @@ +use rand::prelude::*; +use rand_chacha::ChaCha8Rng; use sc_client_api::backend::Backend; use sc_client_api::BlockImportOperation; use sc_executor::RuntimeVersionOf; @@ -67,7 +69,7 @@ impl, E: RuntimeVersionOf> BuildGenesisBlock( state_root: Block::Hash, state_version: StateVersion, @@ -79,7 +81,14 @@ fn construct_genesis_block( // We fill genesis block with extra data such that the very first archived // segment can be produced right away, bootstrapping the farming process. - let ballast = vec![0; RecordedHistorySegment::SIZE]; + let mut ballast = vec![0; RecordedHistorySegment::SIZE]; + let mut rng = ChaCha8Rng::from_seed( + state_root + .as_ref() + .try_into() + .expect("State root in Subspace must be 32 bytes, panic otherwise; qed"), + ); + rng.fill(ballast.as_mut_slice()); let digest = Digest { logs: vec![DigestItem::Other(ballast)], };