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

Update seed domains #3872

Merged
merged 8 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions beacon-chain/archiver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
"//beacon-chain/db:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//proto/eth/v1alpha1:go_default_library",
"//shared/params:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
Expand Down
3 changes: 2 additions & 1 deletion beacon-chain/archiver/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/db"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -72,7 +73,7 @@ func (s *Service) archiveCommitteeInfo(ctx context.Context, headState *pb.Beacon
if err != nil {
return errors.Wrap(err, "could not get committee count")
}
seed, err := helpers.Seed(headState, currentEpoch)
seed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester)
if err != nil {
return errors.Wrap(err, "could not generate seed")
}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/archiver/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestArchiverService_SavesCommitteeInfo(t *testing.T) {
if err != nil {
t.Fatal(err)
}
seed, err := helpers.Seed(headState, currentEpoch)
seed, err := helpers.Seed(headState, currentEpoch, params.BeaconConfig().DomainBeaconAttester)
if err != nil {
t.Fatal(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestStore_AggregateAttestation(t *testing.T) {
CurrentVersion: params.BeaconConfig().GenesisForkVersion,
Epoch: 0,
}
domain := helpers.Domain(f, 0, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(f, 0, params.BeaconConfig().DomainBeaconAttester)
sig := privKeys[0].Sign([]byte{}, domain)

store := &Store{attsQueue: make(map[[32]byte]*ethpb.Attestation)}
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/core/blocks/block_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ func VerifyIndexedAttestation(ctx context.Context, beaconState *pb.BeaconState,
return fmt.Errorf("custody Bit1 indices are not sorted, got %v", custodyBit1Indices)
}

domain := helpers.Domain(beaconState.Fork, indexedAtt.Data.Target.Epoch, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(beaconState.Fork, indexedAtt.Data.Target.Epoch, params.BeaconConfig().DomainBeaconAttester)
var pubkeys []*bls.PublicKey
if len(custodyBit0Indices) > 0 {
pubkey, err := bls.PublicKeyFromBytes(beaconState.Validators[custodyBit0Indices[0]].PublicKey)
Expand Down
21 changes: 11 additions & 10 deletions beacon-chain/core/blocks/block_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ func TestProcessAttesterSlashings_AppliesCorrectStatus(t *testing.T) {
if err != nil {
t.Error(err)
}
domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester)
sig0 := privKeys[0].Sign(hashTreeRoot[:], domain)
sig1 := privKeys[1].Sign(hashTreeRoot[:], domain)
aggregateSig := bls.AggregateSignatures([]*bls.Signature{sig0, sig1})
Expand Down Expand Up @@ -1220,7 +1220,7 @@ func TestProcessAttestations_OK(t *testing.T) {
if err != nil {
t.Error(err)
}
domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester)
sigs := make([]*bls.Signature, len(attestingIndices))
for i, indice := range attestingIndices {
sig := privKeys[indice].Sign(hashTreeRoot[:], domain)
Expand Down Expand Up @@ -1249,7 +1249,7 @@ func TestProcessAggregatedAttestation_OverlappingBits(t *testing.T) {
t.Fatal(err)
}

domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester)
data := &ethpb.AttestationData{
Source: &ethpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")},
Target: &ethpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")},
Expand Down Expand Up @@ -1344,7 +1344,7 @@ func TestProcessAggregatedAttestation_NoOverlappingBits(t *testing.T) {
t.Fatal(err)
}

domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(beaconState.Fork, 0, params.BeaconConfig().DomainBeaconAttester)
data := &ethpb.AttestationData{
Source: &ethpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")},
Target: &ethpb.Checkpoint{Epoch: 0, Root: []byte("hello-world")},
Expand Down Expand Up @@ -1519,20 +1519,20 @@ func TestConvertToIndexed_OK(t *testing.T) {
{
aggregationBitfield: bitfield.Bitlist{0x07},
custodyBitfield: bitfield.Bitlist{0x05},
wantedCustodyBit0Indices: []uint64{71},
wantedCustodyBit1Indices: []uint64{127},
wantedCustodyBit0Indices: []uint64{28},
wantedCustodyBit1Indices: []uint64{125},
},
{
aggregationBitfield: bitfield.Bitlist{0x07},
custodyBitfield: bitfield.Bitlist{0x06},
wantedCustodyBit0Indices: []uint64{127},
wantedCustodyBit1Indices: []uint64{71},
wantedCustodyBit0Indices: []uint64{125},
wantedCustodyBit1Indices: []uint64{28},
},
{
aggregationBitfield: bitfield.Bitlist{0x07},
custodyBitfield: bitfield.Bitlist{0x07},
wantedCustodyBit0Indices: []uint64{},
wantedCustodyBit1Indices: []uint64{71, 127},
wantedCustodyBit1Indices: []uint64{28, 125},
},
}

Expand Down Expand Up @@ -1563,6 +1563,7 @@ func TestConvertToIndexed_OK(t *testing.T) {
}
if !reflect.DeepEqual(wanted, ia) {
diff, _ := messagediff.PrettyDiff(ia, wanted)
fmt.Println(ia, wanted)
t.Log(diff)
t.Error("convert attestation to indexed attestation didn't result as wanted")
}
Expand Down Expand Up @@ -1640,7 +1641,7 @@ func TestVerifyIndexedAttestation_OK(t *testing.T) {
CustodyBit: false,
}

domain := helpers.Domain(state.Fork, tt.attestation.Data.Target.Epoch, params.BeaconConfig().DomainAttestation)
domain := helpers.Domain(state.Fork, tt.attestation.Data.Target.Epoch, params.BeaconConfig().DomainBeaconAttester)

root, err := ssz.HashTreeRoot(attDataAndCustodyBit)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

func TestAttestationMainnet(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runAttestationTest(t, "mainnet")
}
2 changes: 2 additions & 0 deletions beacon-chain/core/blocks/spectest/attestation_minimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ import (
)

func TestAttestationMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")

runAttestationTest(t, "minimal")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

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

func TestAttesterSlashingMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")

runAttesterSlashingTest(t, "minimal")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

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

func TestBlockHeaderMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")

runBlockHeaderTest(t, "minimal")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

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

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

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

func TestProposerSlashingMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")

runProposerSlashingTest(t, "minimal")
}
2 changes: 1 addition & 1 deletion beacon-chain/core/epoch/epoch_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ func ProcessFinalUpdates(state *pb.BeaconState) (*pb.BeaconState, error) {
// 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().ActivationExitDelay
activationDelay := params.BeaconConfig().MaxSeedLookhead
idxRootPosition := (nextEpoch + activationDelay) % params.BeaconConfig().EpochsPerHistoricalVector
activeIndices, err := helpers.ActiveValidatorIndices(state, nextEpoch+activationDelay)
if err != nil {
Expand Down
34 changes: 17 additions & 17 deletions beacon-chain/core/epoch/epoch_processing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ func TestProcessFinalUpdates_CanProcess(t *testing.T) {
}

// Verify latest active index root is correctly updated in the right position.
pos := (ne + params.BeaconConfig().ActivationExitDelay) % params.BeaconConfig().EpochsPerHistoricalVector
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")
}
Expand Down Expand Up @@ -977,8 +977,8 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
state := &pb.BeaconState{
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
Validators: []*ethpb.Validator{
{ExitEpoch: params.BeaconConfig().ActivationExitDelay},
{ExitEpoch: params.BeaconConfig().ActivationExitDelay},
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead},
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead},
},
Balances: []uint64{
params.BeaconConfig().MaxEffectiveBalance,
Expand All @@ -991,9 +991,9 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
t.Fatal(err)
}
for i, validator := range newState.Validators {
if validator.ExitEpoch != params.BeaconConfig().ActivationExitDelay {
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead {
t.Errorf("Could not update registry %d, wanted exit slot %d got %d",
i, params.BeaconConfig().ActivationExitDelay, validator.ExitEpoch)
i, params.BeaconConfig().MaxSeedLookhead, validator.ExitEpoch)
}
}
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ func TestCrosslinkDelta_SomeAttested(t *testing.T) {
t.Fatal(err)
}

attestedIndices := []uint64{5, 16, 336, 797, 1082, 1450, 1770, 1958}
attestedIndices := []uint64{24, 100, 106, 196, 285, 534, 641, 654}
for _, i := range attestedIndices {
// Since all these validators attested, they should get the same rewards.
want := uint64(12649)
Expand Down Expand Up @@ -1210,7 +1210,7 @@ func TestAttestationDelta_SomeAttested(t *testing.T) {
t.Fatal(err)
}

attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192}
attestedIndices := []uint64{24, 100, 106, 196, 285, 288, 389}
for _, i := range attestedIndices {
base, err := BaseReward(state, i)
if err != nil {
Expand Down Expand Up @@ -1293,7 +1293,7 @@ func TestAttestationDelta_SomeAttestedFinalityDelay(t *testing.T) {
t.Fatal(err)
}

attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192}
attestedIndices := []uint64{24, 100, 106, 196, 285, 288, 389}
for _, i := range attestedIndices {
base, err := BaseReward(state, i)
if err != nil {
Expand Down Expand Up @@ -1373,10 +1373,10 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
state := &pb.BeaconState{
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
Validators: []*ethpb.Validator{
{ExitEpoch: params.BeaconConfig().ActivationExitDelay,
ActivationEpoch: 5 + params.BeaconConfig().ActivationExitDelay + 1},
{ExitEpoch: params.BeaconConfig().ActivationExitDelay,
ActivationEpoch: 5 + params.BeaconConfig().ActivationExitDelay + 1},
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead,
ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookhead + 1},
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead,
ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookhead + 1},
},
FinalizedCheckpoint: &ethpb.Checkpoint{},
}
Expand All @@ -1385,9 +1385,9 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
t.Error(err)
}
for i, validator := range newState.Validators {
if validator.ExitEpoch != params.BeaconConfig().ActivationExitDelay {
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead {
t.Errorf("Could not update registry %d, wanted exit slot %d got %d",
i, params.BeaconConfig().ActivationExitDelay, validator.ExitEpoch)
i, params.BeaconConfig().MaxSeedLookhead, validator.ExitEpoch)
}
}
}
Expand All @@ -1412,9 +1412,9 @@ func TestProcessRegistryUpdates_ValidatorsEjected(t *testing.T) {
t.Error(err)
}
for i, validator := range newState.Validators {
if validator.ExitEpoch != params.BeaconConfig().ActivationExitDelay+1 {
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead+1 {
t.Errorf("Could not update registry %d, wanted exit slot %d got %d",
i, params.BeaconConfig().ActivationExitDelay+1, validator.ExitEpoch)
i, params.BeaconConfig().MaxSeedLookhead+1, validator.ExitEpoch)
}
}
}
Expand Down Expand Up @@ -1502,7 +1502,7 @@ func TestProcessRewardsAndPenalties_SomeAttested(t *testing.T) {
t.Errorf("wanted balance: %d, got: %d",
wanted, state.Balances[0])
}
wanted = uint64(31999995452)
wanted = uint64(31999797616)
if state.Balances[4] != wanted {
t.Errorf("wanted balance: %d, got: %d",
wanted, state.Balances[1])
Expand Down
6 changes: 3 additions & 3 deletions beacon-chain/core/epoch/precompute/reward_penalty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestProcessRewardsAndPenaltiesPrecompute(t *testing.T) {
}

// Indices that voted everything except for head, lost a bit money
wanted := uint64(31999995452)
wanted := uint64(31999797616)
if state.Balances[4] != wanted {
t.Errorf("wanted balance: %d, got: %d",
wanted, state.Balances[4])
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestAttestationDeltaPrecompute(t *testing.T) {
t.Fatal(err)
}

attestedIndices := []uint64{5, 754, 797, 1637, 1770, 1862, 1192}
attestedIndices := []uint64{24, 100, 106, 196, 285, 534, 641, 654}
for _, i := range attestedIndices {
base, err := epoch.BaseReward(state, i)
if err != nil {
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestCrosslinkDeltaPrecompute(t *testing.T) {
t.Fatal(err)
}

attestedIndices := []uint64{5, 16, 336, 797, 1082, 1450, 1770, 1958}
attestedIndices := []uint64{24, 100, 106, 196, 285, 534, 641, 654}
for _, i := range attestedIndices {
// Since all these validators attested, they should get the same rewards.
want := uint64(12649)
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/core/epoch/spectest/crosslink_mainnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

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

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

func TestFinalUpdatesMinimal(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")

runFinalUpdatesTests(t, "minimal")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import (
)

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

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

func TestSlashingsMainnet(t *testing.T) {
t.Skip("Disabled until v0.9.0 (#3865) completes")
runSlashingsTests(t, "mainnet")
}
Loading