Skip to content

Commit

Permalink
Remove active index roots and compact committee roots (#3869)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain authored Oct 30, 2019
1 parent 8eebd52 commit b6645d6
Show file tree
Hide file tree
Showing 32 changed files with 281 additions and 1,039 deletions.
2 changes: 0 additions & 2 deletions beacon-chain/archiver/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ func setupState(t *testing.T, validatorCount uint64) *pb.BeaconState {
BlockRoots: make([][]byte, 128),
Slashings: []uint64{0, 1e9, 1e9},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CurrentCrosslinks: crosslinks,
CurrentEpochAttestations: atts,
FinalizedCheckpoint: &ethpb.Checkpoint{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ func TestStore_OnAttestation(t *testing.T) {
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}, BlkWithValidStateRoot); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -132,14 +131,12 @@ func TestStore_SaveCheckpointState(t *testing.T) {
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
StateRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerHistoricalRoot),
LatestBlockHeader: &ethpb.BeaconBlockHeader{},
JustificationBits: []byte{0},
CurrentJustifiedCheckpoint: &ethpb.Checkpoint{},
CurrentCrosslinks: crosslinks,
CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
FinalizedCheckpoint: &ethpb.Checkpoint{},
}
Expand Down
27 changes: 10 additions & 17 deletions beacon-chain/core/blocks/block_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func TestProcessBlockHeader_DifferentSlots(t *testing.T) {
PreviousVersion: []byte{0, 0, 0, 0},
CurrentVersion: []byte{0, 0, 0, 0},
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

lbhsr, err := ssz.HashTreeRoot(state.LatestBlockHeader)
Expand Down Expand Up @@ -153,8 +152,7 @@ func TestProcessBlockHeader_PreviousBlockRootNotSignedRoot(t *testing.T) {
PreviousVersion: []byte{0, 0, 0, 0},
CurrentVersion: []byte{0, 0, 0, 0},
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

currentEpoch := helpers.CurrentEpoch(state)
Expand Down Expand Up @@ -202,8 +200,7 @@ func TestProcessBlockHeader_SlashedProposer(t *testing.T) {
PreviousVersion: []byte{0, 0, 0, 0},
CurrentVersion: []byte{0, 0, 0, 0},
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

parentRoot, err := ssz.SigningRoot(state.LatestBlockHeader)
Expand Down Expand Up @@ -257,8 +254,7 @@ func TestProcessBlockHeader_OK(t *testing.T) {
PreviousVersion: []byte{0, 0, 0, 0},
CurrentVersion: []byte{0, 0, 0, 0},
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

latestBlockSignedRoot, err := ssz.SigningRoot(state.LatestBlockHeader)
Expand Down Expand Up @@ -552,9 +548,8 @@ func TestProcessProposerSlashings_AppliesCorrectStatus(t *testing.T) {
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
Epoch: 0,
},
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

domain := helpers.Domain(
Expand Down Expand Up @@ -1504,10 +1499,9 @@ func TestConvertToIndexed_OK(t *testing.T) {
}

state := &pb.BeaconState{
Slot: 5,
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Slot: 5,
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}
tests := []struct {
aggregationBitfield bitfield.Bitlist
Expand Down Expand Up @@ -1592,8 +1586,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}
tests := []struct {
attestation *ethpb.IndexedAttestation
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/core/blocks/spectest/deposit_mainnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestDepositMainnetYaml(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runDepositTest(t, "mainnet")
}
1 change: 1 addition & 0 deletions beacon-chain/core/blocks/spectest/deposit_minimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestDepositMinimalYaml(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runDepositTest(t, "minimal")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestVoluntaryExitMainnet(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runVoluntaryExitTest(t, "mainnet")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestVoluntaryExitMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runVoluntaryExitTest(t, "minimal")
}
24 changes: 0 additions & 24 deletions beacon-chain/core/epoch/epoch_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,30 +490,6 @@ func ProcessFinalUpdates(state *pb.BeaconState) (*pb.BeaconState, error) {
}
}

// Set active index root.
// index_epoch = Epoch(next_epoch + ACTIVATION_EXIT_DELAY)
// index_root_position = index_epoch % EPOCHS_PER_HISTORICAL_VECTOR
// indices_list = List[ValidatorIndex, VALIDATOR_REGISTRY_LIMIT](get_active_validator_indices(state, index_epoch))
// state.active_index_roots[index_root_position] = hash_tree_root(indices_list)
activationDelay := params.BeaconConfig().MaxSeedLookhead
idxRootPosition := (nextEpoch + activationDelay) % params.BeaconConfig().EpochsPerHistoricalVector
activeIndices, err := helpers.ActiveValidatorIndices(state, nextEpoch+activationDelay)
if err != nil {
return nil, errors.Wrap(err, "could not get active indices")
}
idxRoot, err := ssz.HashTreeRootWithCapacity(activeIndices, uint64(1099511627776))
if err != nil {
return nil, errors.Wrap(err, "could not tree hash active indices")
}
state.ActiveIndexRoots[idxRootPosition] = idxRoot[:]

commRootPosition := nextEpoch % params.BeaconConfig().EpochsPerHistoricalVector
comRoot, err := helpers.CompactCommitteesRoot(state, nextEpoch)
if err != nil {
return nil, errors.Wrap(err, "could not get compact committee root")
}
state.CompactCommitteesRoots[commRootPosition] = comRoot[:]

// Set total slashed balances.
slashedExitLength := params.BeaconConfig().EpochsPerSlashingsVector
state.Slashings[nextEpoch%slashedExitLength] = 0
Expand Down
32 changes: 9 additions & 23 deletions beacon-chain/core/epoch/epoch_processing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ func TestUnslashedAttestingIndices_CanSortAndFilter(t *testing.T) {
}
}
state := &pb.BeaconState{
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

indices, err := unslashedAttestingIndices(state, atts)
Expand Down Expand Up @@ -99,9 +98,8 @@ func TestUnslashedAttestingIndices_DuplicatedAttestations(t *testing.T) {
}
}
state := &pb.BeaconState{
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Validators: validators,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

indices, err := unslashedAttestingIndices(state, atts)
Expand Down Expand Up @@ -146,11 +144,11 @@ func TestAttestingBalance_CorrectBalance(t *testing.T) {
balances[i] = params.BeaconConfig().MaxEffectiveBalance
}
state := &pb.BeaconState{
Slot: 0,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
Validators: validators,
Balances: balances,
Slot: 0,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),

Validators: validators,
Balances: balances,
}

balance, err := AttestingBalance(state, atts)
Expand Down Expand Up @@ -198,7 +196,6 @@ func TestMatchAttestations_PrevEpoch(t *testing.T) {
PreviousEpochAttestations: prevAtts,
BlockRoots: blockRoots,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

mAtts, err := MatchAttestations(state, 0)
Expand Down Expand Up @@ -427,7 +424,6 @@ func TestWinningCrosslink_CanGetWinningRoot(t *testing.T) {
BlockRoots: blockRoots,
CurrentCrosslinks: crosslinks,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}

winner, indices, err := WinningCrosslink(state, 1, ge)
Expand Down Expand Up @@ -474,7 +470,6 @@ func TestProcessCrosslinks_NoUpdate(t *testing.T) {
Balances: balances,
BlockRoots: blockRoots,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CurrentCrosslinks: crosslinks,
}
newState, err := ProcessCrosslinks(state)
Expand Down Expand Up @@ -540,7 +535,6 @@ func TestProcessCrosslinks_SuccessfulUpdate(t *testing.T) {
BlockRoots: blockRoots,
CurrentCrosslinks: crosslinks,
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
}
newState, err := ProcessCrosslinks(state)
if err != nil {
Expand Down Expand Up @@ -918,12 +912,6 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) {
t.Errorf("start shard incorrectly updated, got %d", 64)
}

// Verify latest active index root is correctly updated in the right position.
pos := (ne + params.BeaconConfig().MaxSeedLookhead) % params.BeaconConfig().EpochsPerHistoricalVector
if bytes.Equal(newS.ActiveIndexRoots[pos], params.BeaconConfig().ZeroHash[:]) {
t.Error("latest active index roots still zero hashes")
}

// Verify slashed balances correctly updated.
if newS.Slashings[ce] != newS.Slashings[ne] {
t.Errorf("wanted slashed balance %d, got %d",
Expand Down Expand Up @@ -1541,8 +1529,6 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState {
Validators: validators,
CurrentCrosslinks: make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerSlashingsVector),
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerEpoch*10),
FinalizedCheckpoint: &ethpb.Checkpoint{},
Expand Down
2 changes: 0 additions & 2 deletions beacon-chain/core/epoch/participation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func TestComputeValidatorParticipation(t *testing.T) {
BlockRoots: make([][]byte, 128),
Slashings: []uint64{0, 1e9, 1e9},
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CurrentCrosslinks: crosslinks,
CurrentEpochAttestations: atts,
FinalizedCheckpoint: &ethpb.Checkpoint{},
Expand Down
2 changes: 0 additions & 2 deletions beacon-chain/core/epoch/precompute/reward_penalty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ func buildState(slot uint64, validatorCount uint64) *pb.BeaconState {
Validators: validators,
CurrentCrosslinks: make([]*ethpb.Crosslink, params.BeaconConfig().ShardCount),
RandaoMixes: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
ActiveIndexRoots: make([][]byte, params.BeaconConfig().EpochsPerHistoricalVector),
CompactCommitteesRoots: make([][]byte, params.BeaconConfig().EpochsPerSlashingsVector),
Slashings: make([]uint64, params.BeaconConfig().EpochsPerSlashingsVector),
BlockRoots: make([][]byte, params.BeaconConfig().SlotsPerEpoch*10),
FinalizedCheckpoint: &ethpb.Checkpoint{},
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/core/epoch/spectest/crosslink_minimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestCrosslinksProcessingMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runCrosslinkProcessingTests(t, "minimal")
}
1 change: 1 addition & 0 deletions beacon-chain/core/epoch/spectest/registry_minimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestRegistryUpdatesMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runRegistryUpdatesTests(t, "minimal")
}
1 change: 1 addition & 0 deletions beacon-chain/core/epoch/spectest/slashings_minimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestSlashingsMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runSlashingsTests(t, "minimal")
}
1 change: 0 additions & 1 deletion beacon-chain/core/helpers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ go_library(
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
Expand Down
Loading

0 comments on commit b6645d6

Please sign in to comment.