From 134a2f1dac08f567b25b6db4eea79891ac867d72 Mon Sep 17 00:00:00 2001 From: Dimitris Sarlis Date: Mon, 3 Jun 2024 12:45:26 +0000 Subject: [PATCH] chore: Update comment about seed used for raw_rand --- rs/execution_environment/src/scheduler.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/rs/execution_environment/src/scheduler.rs b/rs/execution_environment/src/scheduler.rs index 0674c357de9..1aa62330fa3 100644 --- a/rs/execution_environment/src/scheduler.rs +++ b/rs/execution_environment/src/scheduler.rs @@ -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),