From e9c23673c53421b5af5131085f9bb69c9d7ffc2b Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 12 Oct 2020 23:08:21 -0700 Subject: [PATCH] Remove inital sync don't verify att sig flag (#7517) --- beacon-chain/blockchain/process_block.go | 7 +- beacon-chain/core/state/transition.go | 92 ------------------- .../core/state/transition_fuzz_test.go | 36 -------- shared/featureconfig/config.go | 6 -- shared/featureconfig/flags.go | 7 -- 5 files changed, 1 insertion(+), 147 deletions(-) diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index b283136e2..3dd82f4cf 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -175,12 +175,7 @@ func (s *Service) onBlockInitialSyncStateTransition(ctx context.Context, signed return nil } - var postState *stateTrie.BeaconState - if featureconfig.Get().InitSyncNoVerify { - postState, err = state.ExecuteStateTransitionNoVerifyAttSigs(ctx, preState, signed) - } else { - postState, err = state.ExecuteStateTransition(ctx, preState, signed) - } + postState, err := state.ExecuteStateTransition(ctx, preState, signed) if err != nil { return errors.Wrap(err, "could not execute state transition") } diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index f3d1252e9..687050efa 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -100,52 +100,6 @@ func ExecuteStateTransition( return state, nil } -// ExecuteStateTransitionNoVerifyAttSigs defines the procedure for a state transition function. -// This does not validate any BLS signatures of attestations in a block, it is used for performing a state transition as quickly -// as possible. This function should only be used when we can trust the data we're receiving entirely, such as -// initial sync or for processing past accepted blocks. -// -// WARNING: This method does not validate any signatures in a block. This method also modifies the passed in state. -// -// Spec pseudocode definition: -// def state_transition(state: BeaconState, block: BeaconBlock, validate_state_root: bool=False) -> BeaconState: -// # Process slots (including those with no blocks) since block -// process_slots(state, block.slot) -// # Process block -// process_block(state, block) -// # Return post-state -// return state -func ExecuteStateTransitionNoVerifyAttSigs( - ctx context.Context, - state *stateTrie.BeaconState, - signed *ethpb.SignedBeaconBlock, -) (*stateTrie.BeaconState, error) { - if ctx.Err() != nil { - return nil, ctx.Err() - } - if signed == nil || signed.Block == nil { - return nil, errors.New("nil block") - } - - ctx, span := trace.StartSpan(ctx, "beacon-chain.ChainService.ExecuteStateTransitionNoVerifyAttSigs") - defer span.End() - var err error - - // Execute per slots transition. - state, err = ProcessSlots(ctx, state, signed.Block.Slot) - if err != nil { - return nil, errors.Wrap(err, "could not process slot") - } - - // Execute per block transition. - state, err = ProcessBlockNoVerifyAttSigs(ctx, state, signed) - if err != nil { - return nil, errors.Wrap(err, "could not process block") - } - - return state, nil -} - // ExecuteStateTransitionNoVerifyAnySig defines the procedure for a state transition function. // This does not validate any BLS signatures of attestations, block proposer signature, randao signature, // it is used for performing a state transition as quickly as possible. This function also returns a signature @@ -428,52 +382,6 @@ func ProcessBlock( return state, nil } -// ProcessBlockNoVerifyAttSigs creates a new, modified beacon state by applying block operation -// transformations as defined in the Ethereum Serenity specification. It does not validate -// block attestation signatures. -// -// Spec pseudocode definition: -// -// def process_block(state: BeaconState, block: BeaconBlock) -> None: -// process_block_header(state, block) -// process_randao(state, block.body) -// process_eth1_data(state, block.body) -// process_operations(state, block.body) -func ProcessBlockNoVerifyAttSigs( - ctx context.Context, - state *stateTrie.BeaconState, - signed *ethpb.SignedBeaconBlock, -) (*stateTrie.BeaconState, error) { - ctx, span := trace.StartSpan(ctx, "beacon-chain.ChainService.state.ProcessBlockNoVerifyAttSigs") - defer span.End() - - state, err := b.ProcessBlockHeader(ctx, state, signed) - if err != nil { - traceutil.AnnotateError(span, err) - return nil, errors.Wrap(err, "could not process block header") - } - - state, err = b.ProcessRandao(ctx, state, signed) - if err != nil { - traceutil.AnnotateError(span, err) - return nil, errors.Wrap(err, "could not verify and process randao") - } - - state, err = b.ProcessEth1DataInBlock(ctx, state, signed) - if err != nil { - traceutil.AnnotateError(span, err) - return nil, errors.Wrap(err, "could not process eth1 data") - } - - state, err = ProcessOperationsNoVerifyAttsSigs(ctx, state, signed) - if err != nil { - traceutil.AnnotateError(span, err) - return nil, errors.Wrap(err, "could not process block operation") - } - - return state, nil -} - // ProcessBlockNoVerifyAnySig creates a new, modified beacon state by applying block operation // transformations as defined in the Ethereum Serenity specification. It does not validate // any block signature except for deposit and slashing signatures. It also returns the relevant diff --git a/beacon-chain/core/state/transition_fuzz_test.go b/beacon-chain/core/state/transition_fuzz_test.go index 3c0beeb4f..2fffe304d 100644 --- a/beacon-chain/core/state/transition_fuzz_test.go +++ b/beacon-chain/core/state/transition_fuzz_test.go @@ -27,24 +27,6 @@ func TestFuzzExecuteStateTransition_1000(t *testing.T) { } } -func TestFuzzExecuteStateTransitionNoVerifyAttSigs_1000(t *testing.T) { - SkipSlotCache.Disable() - defer SkipSlotCache.Enable() - ctx := context.Background() - state := &stateTrie.BeaconState{} - sb := ðpb.SignedBeaconBlock{} - fuzzer := fuzz.NewWithSeed(0) - fuzzer.NilChance(0.1) - for i := 0; i < 1000; i++ { - fuzzer.Fuzz(state) - fuzzer.Fuzz(sb) - s, err := ExecuteStateTransitionNoVerifyAttSigs(ctx, state, sb) - if err != nil && s != nil { - t.Fatalf("state should be nil on err. found: %v on error: %v for state: %v and signed block: %v", s, err, state, sb) - } - } -} - func TestFuzzCalculateStateRoot_1000(t *testing.T) { SkipSlotCache.Disable() defer SkipSlotCache.Enable() @@ -115,24 +97,6 @@ func TestFuzzProcessBlock_1000(t *testing.T) { } } -func TestFuzzProcessBlockNoVerifyAttSigs_1000(t *testing.T) { - SkipSlotCache.Disable() - defer SkipSlotCache.Enable() - ctx := context.Background() - state := &stateTrie.BeaconState{} - sb := ðpb.SignedBeaconBlock{} - fuzzer := fuzz.NewWithSeed(0) - fuzzer.NilChance(0.1) - for i := 0; i < 1000; i++ { - fuzzer.Fuzz(state) - fuzzer.Fuzz(sb) - s, err := ProcessBlockNoVerifyAttSigs(ctx, state, sb) - if err != nil && s != nil { - t.Fatalf("state should be nil on err. found: %v on error: %v for signed block: %v", s, err, sb) - } - } -} - func TestFuzzProcessOperations_1000(t *testing.T) { SkipSlotCache.Disable() defer SkipSlotCache.Enable() diff --git a/shared/featureconfig/config.go b/shared/featureconfig/config.go index 9043b6d91..ed8e4bb9c 100644 --- a/shared/featureconfig/config.go +++ b/shared/featureconfig/config.go @@ -43,7 +43,6 @@ type Flags struct { // Feature related flags. WriteSSZStateTransitions bool // WriteSSZStateTransitions to tmp directory. - InitSyncNoVerify bool // InitSyncNoVerify when initial syncing w/o verifying block's contents. DisableDynamicCommitteeSubnets bool // Disables dynamic attestation committee subnets via p2p. SkipBLSVerify bool // Skips BLS verification across the runtime. EnableBlst bool // Enables new BLS library from supranational. @@ -187,11 +186,6 @@ func ConfigureBeaconChain(ctx *cli.Context) { log.Warn("Disabled ssz cache") cfg.EnableSSZCache = false } - cfg.InitSyncNoVerify = false - if ctx.Bool(disableInitSyncVerifyEverythingFlag.Name) { - log.Warn("Initial syncing while verifying only the block proposer signatures.") - cfg.InitSyncNoVerify = true - } if ctx.Bool(skipBLSVerifyFlag.Name) { log.Warn("UNSAFE: Skipping BLS verification at runtime") cfg.SkipBLSVerify = true diff --git a/shared/featureconfig/flags.go b/shared/featureconfig/flags.go index 8d5790fa5..b91ef7361 100644 --- a/shared/featureconfig/flags.go +++ b/shared/featureconfig/flags.go @@ -70,12 +70,6 @@ var ( Name: "kafka-url", Usage: "Stream attestations and blocks to specified kafka servers. This field is used for bootstrap.servers kafka config field.", } - disableInitSyncVerifyEverythingFlag = &cli.BoolFlag{ - Name: "disable-initial-sync-verify-all-signatures", - Usage: "Initial sync to finalized checkpoint with verifying block's signature, RANDAO " + - "and attestation's aggregated signatures. With this flag, only the proposer " + - "signature is verified until the node reaches the end of the finalized chain.", - } cacheFilteredBlockTreeFlag = &cli.BoolFlag{ Name: "cache-filtered-block-tree", Usage: "Cache filtered block tree by maintaining it rather than continually recalculating on the fly, " + @@ -690,7 +684,6 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{ disableForkChoiceUnsafeFlag, disableDynamicCommitteeSubnets, disableSSZCache, - disableInitSyncVerifyEverythingFlag, skipBLSVerifyFlag, kafkaBootstrapServersFlag, enableBackupWebhookFlag,