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 fc2c1d6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions collator/src/collator/do_collate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ 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
// 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());
let rand_seed = HashBytes::from_slice(hash_bytes.as_slice());
tracing::trace!(target: tracing_targets::COLLATOR, "rand_seed from chain time: {}", rand_seed);
let seqno = working_state.next_block_id_short.seqno.to_be_bytes();
let rand_seed = HashBytes::from_slice(
[&hash_bytes.as_slice()[..32 - 4], &seqno[..]]
.concat()
.as_slice(),
);
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 fc2c1d6

Please # to comment.