From 77c830cf19abe4a9e06a716ffe2c585b08e59d01 Mon Sep 17 00:00:00 2001 From: serejkaaa512 <5125402@mail.ru> Date: Thu, 12 Sep 2024 12:01:33 +0300 Subject: [PATCH] feat(collator): add seqno to rand seed --- collator/src/collator/do_collate.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/collator/src/collator/do_collate.rs b/collator/src/collator/do_collate.rs index 1f196a95d..53aeada49 100644 --- a/collator/src/collator/do_collate.rs +++ b/collator/src/collator/do_collate.rs @@ -73,11 +73,20 @@ impl CollatorStdImpl { .get_last_imported_anchor_ct_and_author() .unwrap(); - // TODO: need to generate unique for each block - // generate seed from the chain_time from the anchor - let hash_bytes = sha2::Sha256::digest(next_chain_time.to_be_bytes()); + // Generate unique rand seed from the anchor chain_time and the next block seqno + let hash_bytes = sha2::Sha256::digest( + [ + next_chain_time.to_be_bytes().as_slice(), + working_state + .next_block_id_short + .seqno + .to_be_bytes() + .as_slice(), + ] + .concat(), + ); let rand_seed = HashBytes::from_slice(hash_bytes.as_slice()); - tracing::trace!(target: tracing_targets::COLLATOR, "rand_seed from chain time: {}", rand_seed); + tracing::trace!(target: tracing_targets::COLLATOR, "rand_seed from chain time and block seqno: {}", rand_seed); let is_masterchain = self.shard_id.is_masterchain();