Skip to content

Commit 5ee50c9

Browse files
committed
add customizers for bootstrapping RNG
1 parent dc26195 commit 5ee50c9

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

cmd/bootstrap/cmd/finalize_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestClusterAssignment(t *testing.T) {
122122
seed := make([]byte, 32)
123123
_, err := cryptoRand.Read(seed)
124124
require.NoError(t, err)
125-
prng, err := prg.New(seed, nil, nil)
125+
prng, err := prg.New(seed, prg.BootstrapClusterAssignment, nil)
126126
require.NoError(t, err)
127127

128128
log := zerolog.Nop()

cmd/bootstrap/cmd/rootblock.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func rootBlock(cmd *cobra.Command, args []string) {
250250
if err != nil {
251251
log.Fatal().Err(err).Msg("unable to generate random seed")
252252
}
253-
csprg, err := prg.New(randomSeed[:], nil, nil)
253+
csprg, err := prg.New(randomSeed[:], prg.BootstrapClusterAssignment, nil)
254254
if err != nil {
255255
log.Fatal().Err(err).Msg("unable to initialize pseudorandom generator")
256256
}
@@ -277,8 +277,12 @@ func rootBlock(cmd *cobra.Command, args []string) {
277277
log.Info().Msg("")
278278

279279
// use the same randomness for the RandomSource of the new epoch
280+
randomSourcePrg, err := prg.New(randomSeed[:], prg.BootstrapEpochRandomSource, nil)
281+
if err != nil {
282+
log.Fatal().Err(err).Msg("failed to initialize pseudorandom generator")
283+
}
280284
log.Info().Msg("constructing intermediary bootstrapping data")
281-
epochSetup, epochCommit, err := constructRootEpochEvents(headerBody.View, participants, assignments, clusterQCs, randomBeaconData, dkgIndexMap, csprg)
285+
epochSetup, epochCommit, err := constructRootEpochEvents(headerBody.View, participants, assignments, clusterQCs, randomBeaconData, dkgIndexMap, randomSourcePrg)
282286
if err != nil {
283287
log.Fatal().Err(err).Msg("failed to construct root epoch events")
284288
}

cmd/bootstrap/run/epochs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func GenerateRecoverTxArgsWithDKG(
176176
}
177177
}
178178

179-
csprg, err := prg.New(epoch.RandomSource(), nil, nil)
179+
csprg, err := prg.New(epoch.RandomSource(), prg.BootstrapClusterAssignment, nil)
180180
if err != nil {
181181
return nil, fmt.Errorf("could not initialize PRNG: %w", err)
182182
}

state/protocol/prg/customizers.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ var (
2525
// ExecutionRandomSourceHistory is the customizer for Flow's transaction execution environment
2626
// (used for the source of randomness history core-contract)
2727
ExecutionRandomSourceHistory = customizerFromIndices(1, 1)
28+
// BootstrapClusterAssignment is the customizer for assignment of collectors to clusters during bootstrapping
29+
BootstrapClusterAssignment = customizerFromIndices(2, 0)
30+
// BootstrapEpochRandomSource is the customizer for the RandomSource of the new epoch during bootstrapping
31+
BootstrapEpochRandomSource = customizerFromIndices(2, 1)
2832
//
2933
// clusterLeaderSelectionPrefix is the prefix used for CollectorClusterLeaderSelection
3034
clusterLeaderSelectionPrefix = []uint16{3}

0 commit comments

Comments
 (0)