Skip to content

Commit

Permalink
Merge branch 'dimitris/comment' into 'master'
Browse files Browse the repository at this point in the history
chore: Update comment about seed used for raw_rand

The comment could be confusing making someone think that execution of subnet messages is already parallelized across many threads and using the same thread id to initialize the random number generator used for `raw_rand` would be a potential security issue. Updating it to make the current status (i.e. single threaded execution of subnet messages) more clear. 

See merge request dfinity-lab/public/ic!19608
  • Loading branch information
dsarlis committed Jun 4, 2024
2 parents 75f84a9 + 134a2f1 commit a7d2d45
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 a7d2d45

Please sign in to comment.