Skip to content

Commit

Permalink
chore: Update comment about seed used for raw_rand
Browse files Browse the repository at this point in the history
  • Loading branch information
dsarlis committed Jun 3, 2024
1 parent 4fd4484 commit 134a2f1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions rs/execution_environment/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,12 +1479,17 @@ impl Scheduler for SchedulerImpl {
self.purge_expired_ingress_messages(&mut state);
}

// Once the subnet messages are executed in threads, each thread will
// need its own Csprng instance which is initialized with a distinct
// "ExecutionThread". Otherwise, two Csprng instances that are
// initialized with the same Randomness and ExecutionThread would
// reveal the same bytes and break the guarantees that we provide for
// raw_rand method of the virtual canister.
// In the future, subnet messages might be executed in threads. In
// that case each thread will need its own Csprng instance which
// is initialized with a distinct "ExecutionThread". Otherwise,
// two Csprng instances that are initialized with the same Randomness
// and ExecutionThread would reveal the same bytes and break the
// guarantees that we provide for raw_rand method of the virtual canister.
//
// Currently subnet messages are still executed in a single thread so
// passing the number of scheduler cores is ok. It would need to be
// updated in case the execution of subnet messages is running across
// many threads to ensure a unique execution thread id.
csprng = Csprng::from_seed_and_purpose(
&randomness,
&ExecutionThread(self.config.scheduler_cores as u32),
Expand Down

0 comments on commit 134a2f1

Please sign in to comment.