From 419343123a51ff5b76e54617a3ef0048c254b629 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Fri, 8 May 2020 21:56:51 -0700 Subject: [PATCH] Fix e2e flakynes for new state mgmt (#5790) --- beacon-chain/blockchain/process_block_helpers.go | 12 ++++++++++++ shared/featureconfig/flags.go | 1 + 2 files changed, 13 insertions(+) diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index a81ca14c3..835c8e5bf 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -43,6 +43,18 @@ func (s *Service) getBlockPreState(ctx context.Context, b *ethpb.BeaconBlock) (* return nil, err } + // For new state management, this ensures the state does not get mutated since initial syncing + // uses verifyBlkPreState. + if featureconfig.Get().NewStateMgmt { + preState, err = s.stateGen.StateByRoot(ctx, bytesutil.ToBytes32(b.ParentRoot)) + if err != nil { + return nil, errors.Wrapf(err, "could not get pre state for slot %d", b.Slot) + } + if preState == nil { + return nil, errors.Wrapf(err, "nil pre state for slot %d", b.Slot) + } + } + // Verify block slot time is not from the feature. if err := helpers.VerifySlotTime(preState.GenesisTime(), b.Slot, helpers.TimeShiftTolerance); err != nil { return nil, err diff --git a/shared/featureconfig/flags.go b/shared/featureconfig/flags.go index 5774f0e83..686d28ac4 100644 --- a/shared/featureconfig/flags.go +++ b/shared/featureconfig/flags.go @@ -433,4 +433,5 @@ var E2EBeaconChainFlags = []string{ "--check-head-state", "--enable-state-field-trie", "--enable-state-ref-copy", + "--enable-new-state-mgmt", }