Skip to content

Commit

Permalink
feat(collator): add seqno to rand seed
Browse files Browse the repository at this point in the history
  • Loading branch information
serejkaaa512 committed Sep 12, 2024
1 parent 0f53b7b commit 77c830c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions collator/src/collator/do_collate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 77c830c

Please # to comment.