diff --git a/cmd/ef-tests-cl/consensus_tests/fork.go b/cmd/ef-tests-cl/consensus_tests/fork.go new file mode 100644 index 00000000000..432d2d10b53 --- /dev/null +++ b/cmd/ef-tests-cl/consensus_tests/fork.go @@ -0,0 +1,51 @@ +package consensustests + +import ( + "fmt" + "os" + + "github.com/ledgerwatch/erigon/cl/clparams" +) + +func forkTest(context testContext) error { + prevContext := context + prevContext.version-- + preState, err := decodeStateFromFile(prevContext, "pre.ssz_snappy") + if err != nil { + return err + } + postState, err := decodeStateFromFile(context, "post.ssz_snappy") + expectedError := os.IsNotExist(err) + if err != nil && !expectedError { + return err + } + + if preState.Version() == clparams.Phase0Version { + if err := preState.UpgradeToAltair(); err != nil { + return err + } + } else if preState.Version() == clparams.AltairVersion { + if err := preState.UpgradeToBellatrix(); err != nil { + return err + } + } else if preState.Version() == clparams.BellatrixVersion { + if err := preState.UpgradeToCapella(); err != nil { + return err + } + } + if expectedError { + return fmt.Errorf("expected error") + } + root, err := preState.HashSSZ() + if err != nil { + return err + } + expectedRoot, err := postState.HashSSZ() + if err != nil { + return err + } + if root != expectedRoot { + return fmt.Errorf("mismatching state roots") + } + return nil +} diff --git a/cmd/ef-tests-cl/consensus_tests/handlers.go b/cmd/ef-tests-cl/consensus_tests/handlers.go index 6002f09d2bc..ccf8e348a87 100644 --- a/cmd/ef-tests-cl/consensus_tests/handlers.go +++ b/cmd/ef-tests-cl/consensus_tests/handlers.go @@ -49,6 +49,9 @@ var ( // transitionCoreTest var finality = "finality/finality" +// fork +var fork = "fork/fork" + // sanity var sanityBlocks = "sanity/blocks" var sanitySlots = "sanity/slots" @@ -111,6 +114,7 @@ var handlers map[string]testFunc = map[string]testFunc{ path.Join(sszDivision, signedBeaconBlockCase): getSSZStaticConsensusTest(&cltypes.SignedBeaconBlock{}), path.Join(sszDivision, beaconBlockCase): getSSZStaticConsensusTest(&cltypes.BeaconBlock{}), path.Join(sszDivision, beaconBodyCase): getSSZStaticConsensusTest(&cltypes.BeaconBody{}), + fork: forkTest, transitionCore: transitionTestFunction, sanityBlocks: testSanityFunction, sanitySlots: testSanityFunctionSlot, diff --git a/cmd/erigon-cl/core/state/upgrade.go b/cmd/erigon-cl/core/state/upgrade.go index 8caaa3562b7..2ad0a126ae6 100644 --- a/cmd/erigon-cl/core/state/upgrade.go +++ b/cmd/erigon-cl/core/state/upgrade.go @@ -29,9 +29,10 @@ func (b *BeaconState) UpgradeToAltair() error { if err != nil { return err } + for _, index := range indicies { for _, flagIndex := range flags { - b.previousEpochParticipation[index].Add(int(flagIndex)) + b.previousEpochParticipation[index] = b.previousEpochParticipation[index].Add(int(flagIndex)) } } } diff --git a/cmd/sentinel/sentinel/sentinel.go b/cmd/sentinel/sentinel/sentinel.go index d0c2aebb2fc..1b9914ea9bd 100644 --- a/cmd/sentinel/sentinel/sentinel.go +++ b/cmd/sentinel/sentinel/sentinel.go @@ -149,7 +149,6 @@ func (s *Sentinel) pubsubOptions() []pubsub.Option { pubsubQueueSize := 600 gsp := pubsub.DefaultGossipSubParams() psOpts := []pubsub.Option{ - pubsub.WithMessageSignaturePolicy(pubsub.StrictNoSign), pubsub.WithMessageSignaturePolicy(pubsub.StrictNoSign), pubsub.WithMessageIdFn(func(pmsg *pubsub_pb.Message) string { return fork.MsgID(pmsg, s.cfg.NetworkConfig, s.cfg.BeaconConfig, s.cfg.GenesisConfig)