diff --git a/engine/execution/computation/computer/computer_test.go b/engine/execution/computation/computer/computer_test.go index 1f7e5429761..ce74b69347c 100644 --- a/engine/execution/computation/computer/computer_test.go +++ b/engine/execution/computation/computer/computer_test.go @@ -601,7 +601,8 @@ func TestBlockExecutor_ExecuteBlock(t *testing.T) { serviceEvents := systemcontracts.ServiceEventsForChain(execCtx.Chain.ChainID()) - payload, err := ccf.Decode(nil, unittest.EpochSetupFixtureCCF) + randomSource := unittest.EpochSetupRandomSourceFixture() + payload, err := ccf.Decode(nil, unittest.EpochSetupFixtureCCF(randomSource)) require.NoError(t, err) serviceEventA, ok := payload.(cadence.Event) @@ -1255,7 +1256,7 @@ func Test_ExecutingSystemCollection(t *testing.T) { noopCollector := metrics.NewNoopCollector() expectedNumberOfEvents := 3 - expectedEventSize := 1434 + expectedEventSize := 1493 // bootstrapping does not cache programs expectedCachedPrograms := 0 diff --git a/engine/execution/state/bootstrap/bootstrap_test.go b/engine/execution/state/bootstrap/bootstrap_test.go index 1231434b3af..4969baa9208 100644 --- a/engine/execution/state/bootstrap/bootstrap_test.go +++ b/engine/execution/state/bootstrap/bootstrap_test.go @@ -53,7 +53,7 @@ func TestBootstrapLedger(t *testing.T) { } func TestBootstrapLedger_ZeroTokenSupply(t *testing.T) { - expectedStateCommitmentBytes, _ := hex.DecodeString("33ff069b59f8eab1e58a15875bf859ebfc2068432c5cd7680ca084dbfc6c60ed") + expectedStateCommitmentBytes, _ := hex.DecodeString("4c5b099dae68a858dd8da0944e6fad6f6d1b943b83c5acb39aeee659e165adb5") expectedStateCommitment, err := flow.ToStateCommitment(expectedStateCommitmentBytes) require.NoError(t, err) diff --git a/go.mod b/go.mod index cb12916e0be..3bb2722deb9 100644 --- a/go.mod +++ b/go.mod @@ -53,8 +53,8 @@ require ( github.com/onflow/atree v0.6.0 github.com/onflow/cadence v0.42.7 github.com/onflow/flow v0.3.4 - github.com/onflow/flow-core-contracts/lib/go/contracts v0.14.0 - github.com/onflow/flow-core-contracts/lib/go/templates v0.14.0 + github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da + github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da github.com/onflow/flow-go-sdk v0.41.18 github.com/onflow/flow-go/crypto v0.25.0 github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231213135419-ae911cc351a2 @@ -81,7 +81,7 @@ require ( go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/atomic v1.11.0 go.uber.org/multierr v1.11.0 - golang.org/x/crypto v0.16.0 + golang.org/x/crypto v0.17.0 golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 golang.org/x/sync v0.5.0 golang.org/x/sys v0.15.0 diff --git a/go.sum b/go.sum index 6feeacd3ab8..3fdeced4d9a 100644 --- a/go.sum +++ b/go.sum @@ -1347,10 +1347,10 @@ github.com/onflow/cadence v0.42.7 h1:Qp9VYX901saO7wPwF/rwV4cMS+0mfWxnm9EqbYElYy4 github.com/onflow/cadence v0.42.7/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= github.com/onflow/flow v0.3.4/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c= -github.com/onflow/flow-core-contracts/lib/go/contracts v0.14.0 h1:DpkgyNAP3SAe7dMQX/Tb7BWFstodqtREo4hxWFHwdS0= -github.com/onflow/flow-core-contracts/lib/go/contracts v0.14.0/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v0.14.0 h1:qZoMYSe7LaO2s6DWyB781FDntyded/gX5Guihldiv54= -github.com/onflow/flow-core-contracts/lib/go/templates v0.14.0/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da h1:8CEioYNnP0rwjnRbKDgs8SmiQTsdaroeX4d/Q3pQuh4= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da/go.mod h1:WHp24VkUQfcfZi0XjI1uRVRt5alM5SHVkwOil1U2Tpc= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da h1:V2zI6AfDtPykMGhgw69ZEGcvyMudRUFOVHYCMN4BbQo= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da/go.mod h1:c09d6sNyF/j5/pAynK7sNPb1XKqJqk1rxZPEqEL+dUo= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 h1:B4ll7e3j+MqTJv2122Enq3RtDNzmIGRu9xjV7fo7un0= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU= github.com/onflow/flow-go-sdk v0.24.0/go.mod h1:IoptMLPyFXWvyd9yYA6/4EmSeeozl6nJoIv4FaEMg74= @@ -1818,8 +1818,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/insecure/go.mod b/insecure/go.mod index 32f2e9780ef..2038272f442 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -206,8 +206,8 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.6.0 // indirect github.com/onflow/cadence v0.42.7 // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f // indirect - github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da // indirect + github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect github.com/onflow/flow-go-sdk v0.41.18 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.0 // indirect @@ -279,7 +279,7 @@ require ( go.uber.org/fx v1.19.2 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index 278d5734ead..475b31d6c6b 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -1322,10 +1322,10 @@ github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVF github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= github.com/onflow/cadence v0.42.7 h1:Qp9VYX901saO7wPwF/rwV4cMS+0mfWxnm9EqbYElYy4= github.com/onflow/cadence v0.42.7/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ= -github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da h1:8CEioYNnP0rwjnRbKDgs8SmiQTsdaroeX4d/Q3pQuh4= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da/go.mod h1:WHp24VkUQfcfZi0XjI1uRVRt5alM5SHVkwOil1U2Tpc= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da h1:V2zI6AfDtPykMGhgw69ZEGcvyMudRUFOVHYCMN4BbQo= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da/go.mod h1:c09d6sNyF/j5/pAynK7sNPb1XKqJqk1rxZPEqEL+dUo= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 h1:B4ll7e3j+MqTJv2122Enq3RtDNzmIGRu9xjV7fo7un0= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU= github.com/onflow/flow-go-sdk v0.24.0/go.mod h1:IoptMLPyFXWvyd9yYA6/4EmSeeozl6nJoIv4FaEMg74= @@ -1793,8 +1793,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/integration/dkg/dkg_emulator_test.go b/integration/dkg/dkg_emulator_test.go index 8d349bd8899..c7e248a3c9d 100644 --- a/integration/dkg/dkg_emulator_test.go +++ b/integration/dkg/dkg_emulator_test.go @@ -51,7 +51,7 @@ func (s *EmulatorSuite) runTest(goodNodes int, emulatorProblems bool) { DKGPhase3FinalView: 250, FinalView: 300, Participants: s.netIDs, - RandomSource: []byte("random bytes for seed"), + RandomSource: unittest.EpochSetupRandomSourceFixture(), } // create the EpochSetup that will trigger the next DKG run with all the @@ -59,7 +59,7 @@ func (s *EmulatorSuite) runTest(goodNodes int, emulatorProblems bool) { nextEpochSetup := flow.EpochSetup{ Counter: currentCounter + 1, Participants: s.netIDs, - RandomSource: []byte("random bytes for seed"), + RandomSource: unittest.EpochSetupRandomSourceFixture(), FirstView: 301, FinalView: 600, } diff --git a/integration/dkg/dkg_whiteboard_test.go b/integration/dkg/dkg_whiteboard_test.go index 490561eb94e..6b2085ffc68 100644 --- a/integration/dkg/dkg_whiteboard_test.go +++ b/integration/dkg/dkg_whiteboard_test.go @@ -221,7 +221,7 @@ func TestWithWhiteboard(t *testing.T) { DKGPhase3FinalView: 250, FinalView: 300, Participants: conIdentities, - RandomSource: []byte("random bytes for seed"), + RandomSource: unittest.EpochSetupRandomSourceFixture(), } // create the EpochSetup that will trigger the next DKG run with all the @@ -229,7 +229,7 @@ func TestWithWhiteboard(t *testing.T) { nextEpochSetup := flow.EpochSetup{ Counter: currentCounter + 1, Participants: conIdentities, - RandomSource: []byte("random bytes for seed"), + RandomSource: unittest.EpochSetupRandomSourceFixture(), } nodes, _ := createNodes( diff --git a/integration/go.mod b/integration/go.mod index f6f81dbbab3..029f67df559 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -20,9 +20,9 @@ require ( github.com/ipfs/go-ds-badger2 v0.1.3 github.com/ipfs/go-ipfs-blockstore v1.3.0 github.com/onflow/cadence v0.42.7 - github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f - github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f - github.com/onflow/flow-emulator v0.58.1-0.20231130142844-f22e54339f85 + github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da + github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da + github.com/onflow/flow-emulator v0.59.0 github.com/onflow/flow-go v0.32.7 github.com/onflow/flow-go-sdk v0.41.18 github.com/onflow/flow-go/crypto v0.25.0 @@ -331,7 +331,7 @@ require ( go.uber.org/fx v1.19.2 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.16.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.11.0 // indirect diff --git a/integration/go.sum b/integration/go.sum index a3cbe9ef0f8..cf94d792ebe 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -1412,12 +1412,12 @@ github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVF github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= github.com/onflow/cadence v0.42.7 h1:Qp9VYX901saO7wPwF/rwV4cMS+0mfWxnm9EqbYElYy4= github.com/onflow/cadence v0.42.7/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= -github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= -github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ= -github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:ZeLxwaBkzuSInESGjL8/IPZWezF+YOYsYbMrZlhN+q4= -github.com/onflow/flow-emulator v0.58.1-0.20231130142844-f22e54339f85 h1:GWAZqWQmckvmvGtoFxpM1q+LMTNUT3DKxHnl266Ke9A= -github.com/onflow/flow-emulator v0.58.1-0.20231130142844-f22e54339f85/go.mod h1:Iv+lFLKbN4aGZeFOlrF7v7LIjpclfrdyGLsOTNXyLUQ= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da h1:8CEioYNnP0rwjnRbKDgs8SmiQTsdaroeX4d/Q3pQuh4= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20231219201108-fbdb10b0a2da/go.mod h1:WHp24VkUQfcfZi0XjI1uRVRt5alM5SHVkwOil1U2Tpc= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da h1:V2zI6AfDtPykMGhgw69ZEGcvyMudRUFOVHYCMN4BbQo= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20231219201108-fbdb10b0a2da/go.mod h1:c09d6sNyF/j5/pAynK7sNPb1XKqJqk1rxZPEqEL+dUo= +github.com/onflow/flow-emulator v0.59.0 h1:KIfm9/+x62KqcZDjqE35fkuvVuY506OZ917xNtb3U6E= +github.com/onflow/flow-emulator v0.59.0/go.mod h1:Js1KKaXrui2yKKkXAlKTqmByRySis6/FH+vkGA6Kqu0= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 h1:B4ll7e3j+MqTJv2122Enq3RtDNzmIGRu9xjV7fo7un0= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13/go.mod h1:kTMFIySzEJJeupk+7EmXs0EJ6CBWY/MV9fv9iYQk+RU= github.com/onflow/flow-go-sdk v0.24.0/go.mod h1:IoptMLPyFXWvyd9yYA6/4EmSeeozl6nJoIv4FaEMg74= @@ -1924,8 +1924,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/model/convert/service_event.go b/model/convert/service_event.go index f2c0c9c3056..21bf853a956 100644 --- a/model/convert/service_event.go +++ b/model/convert/service_event.go @@ -198,22 +198,25 @@ func convertServiceEventEpochSetup(event flow.Event) (*flow.ServiceEvent, error) DKGPhase3FinalView: uint64(dkgPhase3FinalView), } - // Cadence's unsafeRandom().toString() produces a string of variable length. - // Here we pad it with enough 0s to meet the required length. - paddedRandomSrcHex := fmt.Sprintf( - "%0*s", - 2*flow.EpochSetupRandomSourceLength, - string(randomSrcHex), - ) - setup.RandomSource, err = hex.DecodeString(paddedRandomSrcHex) + // random source from the event must be a hex string + // containing exactly 128 bits (equivalent to 16 bytes or 32 hex characters) + setup.RandomSource, err = hex.DecodeString(string(randomSrcHex)) if err != nil { return nil, fmt.Errorf( "could not decode random source hex (%v): %w", - paddedRandomSrcHex, + randomSrcHex, err, ) } + if len(setup.RandomSource) != flow.EpochSetupRandomSourceLength { + return nil, fmt.Errorf( + "random source in epoch setup event must be of (%d) bytes, got (%d)", + flow.EpochSetupRandomSourceLength, + len(setup.RandomSource), + ) + } + // parse cluster assignments setup.Assignments, err = convertClusterAssignments(cdcClusters.Values) if err != nil { diff --git a/model/convert/service_event_test.go b/model/convert/service_event_test.go index 9c50a98d1c3..9afd3a32499 100644 --- a/model/convert/service_event_test.go +++ b/model/convert/service_event_test.go @@ -4,11 +4,10 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/onflow/cadence" "github.com/onflow/cadence/encoding/ccf" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/onflow/flow-go/fvm/systemcontracts" "github.com/onflow/flow-go/model/convert" @@ -39,6 +38,55 @@ func TestEventConversion(t *testing.T) { }, ) + t.Run( + "epoch setup with random source with leading zeroes", func(t *testing.T) { + + fixture, _ := unittest.EpochSetupFixtureByChainID(chainID) + // all zero source to cover all cases of endiannesses + randomSource := make([]byte, flow.EpochSetupRandomSourceLength) + // update the random source in event fixture + fixture.Payload = unittest.EpochSetupFixtureCCF(randomSource) + + // convert Cadence types to Go types + event, err := convert.ServiceEvent(chainID, fixture) + require.NoError(t, err) + require.NotNil(t, event) + + // cast event type to epoch setup + _, ok := event.Event.(*flow.EpochSetup) + require.True(t, ok) + }, + ) + + t.Run( + "epoch setup with short random source", func(t *testing.T) { + + fixture, _ := unittest.EpochSetupFixtureByChainID(chainID) + // update the random source in event fixture + randomSource := unittest.EpochSetupRandomSourceFixture() + fixture.Payload = unittest.EpochSetupFixtureCCF(randomSource[:flow.EpochSetupRandomSourceLength-1]) + + // convert Cadence types to Go types + event, err := convert.ServiceEvent(chainID, fixture) + require.Error(t, err) + require.Nil(t, event) + }, + ) + + t.Run( + "epoch setup with non-hex random source", func(t *testing.T) { + + fixture, _ := unittest.EpochSetupFixtureByChainID(chainID) + // update the random source in event fixture + fixture.Payload = unittest.EpochSetupCCFWithNonHexRandomSource() + + // convert Cadence types to Go types + event, err := convert.ServiceEvent(chainID, fixture) + require.Error(t, err) + require.Nil(t, event) + }, + ) + t.Run( "epoch commit", func(t *testing.T) { diff --git a/utils/unittest/execution_state.go b/utils/unittest/execution_state.go index 2bdb44ae0a8..11927f9df3e 100644 --- a/utils/unittest/execution_state.go +++ b/utils/unittest/execution_state.go @@ -24,7 +24,7 @@ const ServiceAccountPrivateKeySignAlgo = crypto.ECDSAP256 const ServiceAccountPrivateKeyHashAlgo = hash.SHA2_256 // Pre-calculated state commitment with root account with the above private key -const GenesisStateCommitmentHex = "8476e9a47da2f993fd0d04efc10238113f217b0c037ccf903613088d51027d6a" +const GenesisStateCommitmentHex = "6c394b798bcabfdbdcfddb98f33a818de81efc160d99a4697db57b7b099d1ab1" var GenesisStateCommitment flow.StateCommitment @@ -88,10 +88,10 @@ func genesisCommitHexByChainID(chainID flow.ChainID) string { return GenesisStateCommitmentHex } if chainID == flow.Testnet { - return "7df9e8ac804d283b27052abda8278866edcb6cae298862a21634ca62892049e7" + return "5dc11f195653540c1cc3c2fd42ac9d9dca415be6080276eebd1e2fa5dba07a1c" } if chainID == flow.Sandboxnet { return "e1c08b17f9e5896f03fe28dd37ca396c19b26628161506924fbf785834646ea1" } - return "8476b2a11c9bf11e70b82adfa2daee598ba08e6e7d40e78958768b7aed4e6a4d" + return "0d5dcd6cd42cbc41c2aae1a4a6ee950758cc2f75f21ad0ccf84b9e9fa35305ff" } diff --git a/utils/unittest/service_events_fixtures.go b/utils/unittest/service_events_fixtures.go index d95148938ce..5563a40dc28 100644 --- a/utils/unittest/service_events_fixtures.go +++ b/utils/unittest/service_events_fixtures.go @@ -1,6 +1,9 @@ package unittest import ( + "crypto/rand" + "encoding/hex" + "github.com/onflow/cadence" "github.com/onflow/cadence/encoding/ccf" "github.com/onflow/cadence/runtime/common" @@ -12,19 +15,23 @@ import ( // This file contains service event fixtures for testing purposes. +func EpochSetupRandomSourceFixture() []byte { + source := make([]byte, flow.EpochSetupRandomSourceLength) + _, err := rand.Read(source) + if err != nil { + panic(err) + } + return source +} + // EpochSetupFixtureByChainID returns an EpochSetup service event as a Cadence event // representation and as a protocol model representation. func EpochSetupFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.EpochSetup) { events := systemcontracts.ServiceEventsForChain(chain) event := EventFixture(events.EpochSetup.EventType(), 1, 1, IdentifierFixture(), 0) - event.Payload = EpochSetupFixtureCCF - - // randomSource is [0,0,...,1,2,3,4] - randomSource := make([]uint8, flow.EpochSetupRandomSourceLength) - for i := 0; i < 4; i++ { - randomSource[flow.EpochSetupRandomSourceLength-1-i] = uint8(4 - i) - } + randomSource := EpochSetupRandomSourceFixture() + event.Payload = EpochSetupFixtureCCF(randomSource) expected := &flow.EpochSetup{ Counter: 1, @@ -165,7 +172,8 @@ func VersionBeaconFixtureByChainID(chain flow.ChainID) (flow.Event, *flow.Versio return event, expected } -func createEpochSetupEvent() cadence.Event { +func createEpochSetupEvent(randomSource []byte) cadence.Event { + randomSourceHex := hex.EncodeToString(randomSource) return cadence.NewEvent([]cadence.Value{ // counter @@ -184,7 +192,7 @@ func createEpochSetupEvent() cadence.Event { createEpochCollectors(), // randomSource - cadence.String("01020304"), + cadence.String(randomSourceHex), // DKGPhase1FinalView cadence.UInt64(150), @@ -1019,8 +1027,8 @@ func ufix64FromString(s string) cadence.UFix64 { return f } -var EpochSetupFixtureCCF = func() []byte { - b, err := ccf.Encode(createEpochSetupEvent()) +func EpochSetupFixtureCCF(randomSource []byte) []byte { + b, err := ccf.Encode(createEpochSetupEvent(randomSource)) if err != nil { panic(err) } @@ -1029,7 +1037,54 @@ var EpochSetupFixtureCCF = func() []byte { panic(err) } return b -}() +} + +func EpochSetupCCFWithNonHexRandomSource() []byte { + // randomSource of correct length but made of non hex characters + randomSource := "ZZ" + for len(randomSource) != 2*flow.EpochSetupRandomSourceLength { + randomSource = randomSource + "aa" + } + + event := cadence.NewEvent([]cadence.Value{ + // counter + cadence.NewUInt64(1), + + // nodeInfo + createEpochNodes(), + + // firstView + cadence.NewUInt64(100), + + // finalView + cadence.NewUInt64(200), + + // collectorClusters + createEpochCollectors(), + + // randomSource + cadence.String(randomSource), + + // DKGPhase1FinalView + cadence.UInt64(150), + + // DKGPhase2FinalView + cadence.UInt64(160), + + // DKGPhase3FinalView + cadence.UInt64(170), + }).WithType(newFlowEpochEpochSetupEventType()) + + b, err := ccf.Encode(event) + if err != nil { + panic(err) + } + _, err = ccf.Decode(nil, b) + if err != nil { + panic(err) + } + return b +} var EpochCommitFixtureCCF = func() []byte { b, err := ccf.Encode(createEpochCommittedEvent())