Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do Not Update Validator Registry on Nil Block #2326

Merged
merged 3 commits into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions beacon-chain/core/state/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func ExecuteStateTransition(

// Execute per epoch transition.
if e.CanProcessEpoch(state) {
state, err = ProcessEpoch(ctx, state, config)
state, err = ProcessEpoch(ctx, state, block, config)
}
if err != nil {
return nil, fmt.Errorf("could not process epoch: %v", err)
Expand Down Expand Up @@ -195,7 +195,7 @@ func ProcessBlock(
// process_crosslink_reward_penalties(state)
// update_validator_registry(state)
// final_book_keeping(state)
func ProcessEpoch(ctx context.Context, state *pb.BeaconState, config *TransitionConfig) (*pb.BeaconState, error) {
func ProcessEpoch(ctx context.Context, state *pb.BeaconState, block *pb.BeaconBlock, config *TransitionConfig) (*pb.BeaconState, error) {
ctx, span := trace.StartSpan(ctx, "beacon-chain.ChainService.state.ProcessEpoch")
defer span.End()

Expand Down Expand Up @@ -400,9 +400,11 @@ func ProcessEpoch(ctx context.Context, state *pb.BeaconState, config *Transition
state = e.ProcessPrevSlotShardSeed(state)
state = v.ProcessPenaltiesAndExits(state)
if e.CanProcessValidatorRegistry(state) {
state, err = v.UpdateRegistry(state)
if err != nil {
return nil, fmt.Errorf("could not update validator registry: %v", err)
if block != nil {
state, err = v.UpdateRegistry(state)
if err != nil {
return nil, fmt.Errorf("could not update validator registry: %v", err)
}
}
state, err = e.ProcessCurrSlotShardSeed(state)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions beacon-chain/core/state/transition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func TestProcessEpoch_PassesProcessingConditions(t *testing.T) {
params.BeaconConfig().LatestSlashedExitLength),
}

_, err := state.ProcessEpoch(context.Background(), newState, state.DefaultConfig())
_, err := state.ProcessEpoch(context.Background(), newState, &pb.BeaconBlock{}, state.DefaultConfig())
if err != nil {
t.Errorf("Expected epoch transition to pass processing conditions: %v", err)
}
Expand Down Expand Up @@ -517,7 +517,7 @@ func TestProcessEpoch_InactiveConditions(t *testing.T) {
params.BeaconConfig().LatestSlashedExitLength),
}

_, err := state.ProcessEpoch(context.Background(), newState, state.DefaultConfig())
_, err := state.ProcessEpoch(context.Background(), newState, &pb.BeaconBlock{}, state.DefaultConfig())
if err != nil {
t.Errorf("Expected epoch transition to pass processing conditions: %v", err)
}
Expand All @@ -536,7 +536,7 @@ func TestProcessEpoch_CantGetBoundaryAttestation(t *testing.T) {
0,
newState.Slot-params.BeaconConfig().GenesisSlot,
)
if _, err := state.ProcessEpoch(context.Background(), newState, state.DefaultConfig()); !strings.Contains(err.Error(), want) {
if _, err := state.ProcessEpoch(context.Background(), newState, &pb.BeaconBlock{}, state.DefaultConfig()); !strings.Contains(err.Error(), want) {
t.Errorf("Expected: %s, received: %v", want, err)
}
}
Expand Down Expand Up @@ -566,7 +566,7 @@ func TestProcessEpoch_CantGetCurrentValidatorIndices(t *testing.T) {
}

wanted := fmt.Sprintf("wanted participants bitfield length %d, got: %d", 0, 1)
if _, err := state.ProcessEpoch(context.Background(), newState, state.DefaultConfig()); !strings.Contains(err.Error(), wanted) {
if _, err := state.ProcessEpoch(context.Background(), newState, &pb.BeaconBlock{}, state.DefaultConfig()); !strings.Contains(err.Error(), wanted) {
t.Errorf("Expected: %s, received: %v", wanted, err)
}
}