Fix ineffectual assignments (#7403)

* update rpc/beacon
* more fixes to beacon-chain/rpc
* update beacon-chain/sync
* Merge refs/heads/master into fix-ineffectual-assignments
* updates beacon-chain/p2p
* Merge branch 'fix-ineffectual-assignments' of github.com:prysmaticlabs/prysm into fix-ineffectual-assignments
* update beacon-chain/*
* fix imports
* update beacon-chain/blockchain
* more updates
* Merge refs/heads/master into fix-ineffectual-assignments
* Merge branch 'master' into fix-ineffectual-assignments
* Merge refs/heads/master into fix-ineffectual-assignments
* next round of updated
* Merge branch 'fix-ineffectual-assignments' of github.com:prysmaticlabs/prysm into fix-ineffectual-assignments
* wrap up remaining items
This commit is contained in:
Victor Farazdagi
2020-10-01 21:53:36 +03:00
committed by GitHub
parent 490cf9b7ba
commit d169b490fa
61 changed files with 136 additions and 65 deletions

View File

@@ -33,6 +33,7 @@ func TestService_TreeHandler(t *testing.T) {
StateGen: stategen.New(db, sCache), StateGen: stategen.New(db, sCache),
} }
s, err := NewService(ctx, cfg) s, err := NewService(ctx, cfg)
require.NoError(t, err)
require.NoError(t, s.forkChoiceStore.ProcessBlock(ctx, 0, [32]byte{'a'}, [32]byte{'g'}, [32]byte{'c'}, 0, 0)) require.NoError(t, s.forkChoiceStore.ProcessBlock(ctx, 0, [32]byte{'a'}, [32]byte{'g'}, [32]byte{'c'}, 0, 0))
require.NoError(t, s.forkChoiceStore.ProcessBlock(ctx, 1, [32]byte{'b'}, [32]byte{'a'}, [32]byte{'c'}, 0, 0)) require.NoError(t, s.forkChoiceStore.ProcessBlock(ctx, 1, [32]byte{'b'}, [32]byte{'a'}, [32]byte{'c'}, 0, 0))
s.setHead([32]byte{'a'}, testutil.NewBeaconBlock(), headState) s.setHead([32]byte{'a'}, testutil.NewBeaconBlock(), headState)

View File

@@ -235,7 +235,7 @@ func (s *Service) onBlockBatch(ctx context.Context, blks []*ethpb.SignedBeaconBl
PublicKeys: []bls.PublicKey{}, PublicKeys: []bls.PublicKey{},
Messages: [][32]byte{}, Messages: [][32]byte{},
} }
set := new(bls.SignatureSet) var set *bls.SignatureSet
boundaries := make(map[[32]byte]*stateTrie.BeaconState) boundaries := make(map[[32]byte]*stateTrie.BeaconState)
for i, b := range blks { for i, b := range blks {
set, preState, err = state.ExecuteStateTransitionNoVerifyAnySig(ctx, preState, b) set, preState, err = state.ExecuteStateTransitionNoVerifyAnySig(ctx, preState, b)

View File

@@ -139,6 +139,7 @@ func TestService_ReceiveBlock(t *testing.T) {
gBlk, err := s.beaconDB.GenesisBlock(ctx) gBlk, err := s.beaconDB.GenesisBlock(ctx)
require.NoError(t, err) require.NoError(t, err)
gRoot, err := gBlk.Block.HashTreeRoot() gRoot, err := gBlk.Block.HashTreeRoot()
require.NoError(t, err)
s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]} s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]}
root, err := tt.args.block.Block.HashTreeRoot() root, err := tt.args.block.Block.HashTreeRoot()
require.NoError(t, err) require.NoError(t, err)
@@ -179,6 +180,7 @@ func TestService_ReceiveBlockUpdateHead(t *testing.T) {
gBlk, err := s.beaconDB.GenesisBlock(ctx) gBlk, err := s.beaconDB.GenesisBlock(ctx)
require.NoError(t, err) require.NoError(t, err)
gRoot, err := gBlk.Block.HashTreeRoot() gRoot, err := gBlk.Block.HashTreeRoot()
require.NoError(t, err)
s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]} s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]}
root, err := b.Block.HashTreeRoot() root, err := b.Block.HashTreeRoot()
require.NoError(t, err) require.NoError(t, err)
@@ -261,6 +263,7 @@ func TestService_ReceiveBlockInitialSync(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
gRoot, err := gBlk.Block.HashTreeRoot() gRoot, err := gBlk.Block.HashTreeRoot()
require.NoError(t, err)
s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]} s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]}
root, err := tt.args.block.Block.HashTreeRoot() root, err := tt.args.block.Block.HashTreeRoot()
require.NoError(t, err) require.NoError(t, err)
@@ -341,6 +344,7 @@ func TestService_ReceiveBlockBatch(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
gRoot, err := gBlk.Block.HashTreeRoot() gRoot, err := gBlk.Block.HashTreeRoot()
require.NoError(t, err)
s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]} s.finalizedCheckpt = &ethpb.Checkpoint{Root: gRoot[:]}
root, err := tt.args.block.Block.HashTreeRoot() root, err := tt.args.block.Block.HashTreeRoot()
require.NoError(t, err) require.NoError(t, err)

View File

@@ -204,6 +204,7 @@ func TestChainService_InitializeBeaconChain(t *testing.T) {
DepositCount: uint64(len(deposits)), DepositCount: uint64(len(deposits)),
BlockHash: make([]byte, 32), BlockHash: make([]byte, 32),
}) })
require.NoError(t, err)
genState, err = b.ProcessPreGenesisDeposits(ctx, genState, deposits) genState, err = b.ProcessPreGenesisDeposits(ctx, genState, deposits)
require.NoError(t, err) require.NoError(t, err)

View File

@@ -89,9 +89,7 @@ func TestCommitteeCache_ActiveCount(t *testing.T) {
func TestCommitteeCache_AddProposerIndicesList(t *testing.T) { func TestCommitteeCache_AddProposerIndicesList(t *testing.T) {
cache := NewCommitteesCache() cache := NewCommitteesCache()
seed := [32]byte{'A'} seed := [32]byte{'A'}
indices := []uint64{1, 2, 3, 4, 5}
indices, err := cache.ProposerIndices(seed) indices, err := cache.ProposerIndices(seed)
require.NoError(t, err) require.NoError(t, err)
if indices != nil { if indices != nil {

View File

@@ -807,6 +807,7 @@ func TestVerifyAttestations_HandlesPlannedFork(t *testing.T) {
Signature: make([]byte, 96), Signature: make([]byte, 96),
} }
currDomain, err := helpers.Domain(st.Fork(), st.Fork().Epoch, params.BeaconConfig().DomainBeaconAttester, st.GenesisValidatorRoot()) currDomain, err := helpers.Domain(st.Fork(), st.Fork().Epoch, params.BeaconConfig().DomainBeaconAttester, st.GenesisValidatorRoot())
require.NoError(t, err)
root, err = helpers.ComputeSigningRoot(att2.Data, currDomain) root, err = helpers.ComputeSigningRoot(att2.Data, currDomain)
require.NoError(t, err) require.NoError(t, err)
sigs = nil sigs = nil

View File

@@ -6,13 +6,12 @@ import (
fuzz "github.com/google/gofuzz" fuzz "github.com/google/gofuzz"
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
//"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state"
ethereum_beacon_p2p_v1 "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
) )
func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) { func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
@@ -25,6 +24,7 @@ func TestFuzzProcessAttestationNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(att) fuzzer.Fuzz(att)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
_, err = ProcessAttestationNoVerifySignature(ctx, s, att) _, err = ProcessAttestationNoVerifySignature(ctx, s, att)
_ = err _ = err
} }
@@ -40,6 +40,7 @@ func TestFuzzProcessBlockHeader_10000(t *testing.T) {
fuzzer.Fuzz(block) fuzzer.Fuzz(block)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
_, err = ProcessBlockHeader(context.Background(), s, block) _, err = ProcessBlockHeader(context.Background(), s, block)
_ = err _ = err
} }
@@ -63,6 +64,7 @@ func TestFuzzverifyDepositDataSigningRoot_10000(t *testing.T) {
fuzzer.Fuzz(&s) fuzzer.Fuzz(&s)
fuzzer.Fuzz(&d) fuzzer.Fuzz(&d)
err := verifySignature(ba, pubkey[:], sig[:], domain[:]) err := verifySignature(ba, pubkey[:], sig[:], domain[:])
_ = err
err = verifySignature(ba, p, s, d) err = verifySignature(ba, p, s, d)
_ = err _ = err
} }
@@ -105,6 +107,7 @@ func TestFuzzEth1DataHasEnoughSupport_10000(t *testing.T) {
s, err := beaconstate.InitializeFromProto(&ethereum_beacon_p2p_v1.BeaconState{ s, err := beaconstate.InitializeFromProto(&ethereum_beacon_p2p_v1.BeaconState{
Eth1DataVotes: stateVotes, Eth1DataVotes: stateVotes,
}) })
require.NoError(t, err)
_, err = Eth1DataHasEnoughSupport(s, eth1data) _, err = Eth1DataHasEnoughSupport(s, eth1data)
_ = err _ = err
} }
@@ -120,6 +123,7 @@ func TestFuzzProcessBlockHeaderNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(block) fuzzer.Fuzz(block)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
_, err = ProcessBlockHeaderNoVerify(s, block) _, err = ProcessBlockHeaderNoVerify(s, block)
_ = err _ = err
} }
@@ -134,6 +138,7 @@ func TestFuzzProcessRandao_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessRandao(context.Background(), s, b) r, err := ProcessRandao(context.Background(), s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -150,6 +155,7 @@ func TestFuzzProcessRandaoNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(blockBody) fuzzer.Fuzz(blockBody)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessRandaoNoVerify(s, blockBody) r, err := ProcessRandaoNoVerify(s, blockBody)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, blockBody)
@@ -166,6 +172,7 @@ func TestFuzzProcessProposerSlashings_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessProposerSlashings(ctx, s, b) r, err := ProcessProposerSlashings(ctx, s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -181,6 +188,7 @@ func TestFuzzVerifyProposerSlashing_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(proposerSlashing) fuzzer.Fuzz(proposerSlashing)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
err = VerifyProposerSlashing(s, proposerSlashing) err = VerifyProposerSlashing(s, proposerSlashing)
_ = err _ = err
} }
@@ -195,6 +203,7 @@ func TestFuzzProcessAttesterSlashings_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessAttesterSlashings(ctx, s, b) r, err := ProcessAttesterSlashings(ctx, s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -211,6 +220,7 @@ func TestFuzzVerifyAttesterSlashing_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(attesterSlashing) fuzzer.Fuzz(attesterSlashing)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
err = VerifyAttesterSlashing(ctx, s, attesterSlashing) err = VerifyAttesterSlashing(ctx, s, attesterSlashing)
_ = err _ = err
} }
@@ -247,6 +257,7 @@ func TestFuzzProcessAttestations_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessAttestations(ctx, s, b) r, err := ProcessAttestations(ctx, s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -263,6 +274,7 @@ func TestFuzzProcessAttestationsNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessAttestationsNoVerifySignature(ctx, s, b) r, err := ProcessAttestationsNoVerifySignature(ctx, s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -279,6 +291,7 @@ func TestFuzzProcessAttestation_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(attestation) fuzzer.Fuzz(attestation)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessAttestation(ctx, s, attestation) r, err := ProcessAttestation(ctx, s, attestation)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, attestation) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, attestation)
@@ -295,6 +308,7 @@ func TestFuzzVerifyIndexedAttestationn_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(idxAttestation) fuzzer.Fuzz(idxAttestation)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
err = VerifyIndexedAttestation(ctx, s, idxAttestation) err = VerifyIndexedAttestation(ctx, s, idxAttestation)
_ = err _ = err
} }
@@ -309,6 +323,7 @@ func TestFuzzVerifyAttestation_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(attestation) fuzzer.Fuzz(attestation)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
err = VerifyAttestationSignature(ctx, s, attestation) err = VerifyAttestationSignature(ctx, s, attestation)
_ = err _ = err
} }
@@ -323,6 +338,7 @@ func TestFuzzProcessDeposits_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessDeposits(ctx, s, b) r, err := ProcessDeposits(ctx, s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -340,6 +356,7 @@ func TestFuzzProcessPreGenesisDeposit_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(deposit) fuzzer.Fuzz(deposit)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessPreGenesisDeposits(ctx, s, []*eth.Deposit{deposit}) r, err := ProcessPreGenesisDeposits(ctx, s, []*eth.Deposit{deposit})
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit)
@@ -356,6 +373,7 @@ func TestFuzzProcessDeposit_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(deposit) fuzzer.Fuzz(deposit)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessDeposit(s, deposit, true) r, err := ProcessDeposit(s, deposit, true)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, deposit)
@@ -371,6 +389,7 @@ func TestFuzzverifyDeposit_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(deposit) fuzzer.Fuzz(deposit)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
err = verifyDeposit(s, deposit) err = verifyDeposit(s, deposit)
_ = err _ = err
} }
@@ -385,6 +404,7 @@ func TestFuzzProcessVoluntaryExits_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessVoluntaryExits(ctx, s, b) r, err := ProcessVoluntaryExits(ctx, s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)
@@ -400,6 +420,7 @@ func TestFuzzProcessVoluntaryExitsNoVerify_10000(t *testing.T) {
fuzzer.Fuzz(state) fuzzer.Fuzz(state)
fuzzer.Fuzz(b) fuzzer.Fuzz(b)
s, err := beaconstate.InitializeFromProtoUnsafe(state) s, err := beaconstate.InitializeFromProtoUnsafe(state)
require.NoError(t, err)
r, err := ProcessVoluntaryExits(context.Background(), s, b) r, err := ProcessVoluntaryExits(context.Background(), s, b)
if err != nil && r != nil { if err != nil && r != nil {
t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b) t.Fatalf("return value should be nil on err. found: %v on error: %v for state: %v and block: %v", r, err, state, b)

View File

@@ -18,5 +18,6 @@ func TestFuzzFinalUpdates_10000(t *testing.T) {
s, err := beaconstate.InitializeFromProtoUnsafe(base) s, err := beaconstate.InitializeFromProtoUnsafe(base)
require.NoError(t, err) require.NoError(t, err)
_, err = ProcessFinalUpdates(s) _, err = ProcessFinalUpdates(s)
_ = err
} }
} }

View File

@@ -333,6 +333,7 @@ func TestProcessRegistryUpdates_EligibleToActivate(t *testing.T) {
}) })
} }
state, err := state.InitializeFromProto(base) state, err := state.InitializeFromProto(base)
require.NoError(t, err)
currentEpoch := helpers.CurrentEpoch(state) currentEpoch := helpers.CurrentEpoch(state)
newState, err := epoch.ProcessRegistryUpdates(state) newState, err := epoch.ProcessRegistryUpdates(state)
require.NoError(t, err) require.NoError(t, err)

View File

@@ -178,8 +178,7 @@ func TestProcessAttestations(t *testing.T) {
for i := 0; i < len(pVals); i++ { for i := 0; i < len(pVals); i++ {
pVals[i] = &precompute.Validator{CurrentEpochEffectiveBalance: 100} pVals[i] = &precompute.Validator{CurrentEpochEffectiveBalance: 100}
} }
pBal := &precompute.Balance{} pVals, _, err = precompute.ProcessAttestations(context.Background(), beaconState, pVals, &precompute.Balance{})
pVals, pBal, err = precompute.ProcessAttestations(context.Background(), beaconState, pVals, pBal)
require.NoError(t, err) require.NoError(t, err)
committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex) committee, err := helpers.BeaconCommitteeFromState(beaconState, att1.Data.Slot, att1.Data.CommitteeIndex)

View File

@@ -202,7 +202,7 @@ func TestAttestationDeltas_ZeroInclusionDelay(t *testing.T) {
pVals, pBal, err := New(context.Background(), state) pVals, pBal, err := New(context.Background(), state)
require.NoError(t, err) require.NoError(t, err)
pVals, pBal, err = ProcessAttestations(context.Background(), state, pVals, pBal) _, _, err = ProcessAttestations(context.Background(), state, pVals, pBal)
require.ErrorContains(t, "attestation with inclusion delay of 0", err) require.ErrorContains(t, "attestation with inclusion delay of 0", err)
} }

View File

@@ -76,6 +76,7 @@ func TestFuzzverifySigningRoot_10000(t *testing.T) {
fuzzer.Fuzz(&s) fuzzer.Fuzz(&s)
fuzzer.Fuzz(&d) fuzzer.Fuzz(&d)
err := helpers.VerifySigningRoot(state, pubkey[:], sig[:], domain[:]) err := helpers.VerifySigningRoot(state, pubkey[:], sig[:], domain[:])
_ = err
err = helpers.VerifySigningRoot(state, p, s, d) err = helpers.VerifySigningRoot(state, p, s, d)
_ = err _ = err
} }

View File

@@ -81,7 +81,7 @@ func TestNoVote_CanFindHead(t *testing.T) {
// head -> 4 3 // head -> 4 3
// | // |
// 5 <- starting from 5 with justified epoch 0 should error // 5 <- starting from 5 with justified epoch 0 should error
r, err = f.Head(context.Background(), 1, indexToHash(5), balances, 1) _, err = f.Head(context.Background(), 1, indexToHash(5), balances, 1)
wanted := "head at slot 0 with weight 0 is not eligible, finalizedEpoch 1 != 1, justifiedEpoch 2 != 1" wanted := "head at slot 0 with weight 0 is not eligible, finalizedEpoch 1 != 1, justifiedEpoch 2 != 1"
require.ErrorContains(t, wanted, err) require.ErrorContains(t, wanted, err)

View File

@@ -209,7 +209,7 @@ func (s *Store) updateBestChildAndDescendant(parentIndex uint64, childIndex uint
} }
changeToChild := []uint64{childIndex, bestDescendant} changeToChild := []uint64{childIndex, bestDescendant}
noChange := []uint64{parent.bestChild, parent.bestDescendant} noChange := []uint64{parent.bestChild, parent.bestDescendant}
newParentChild := make([]uint64, 0) var newParentChild []uint64
if parent.bestChild != NonExistentNode { if parent.bestChild != NonExistentNode {
if parent.bestChild == childIndex && !childLeadsToViableHead { if parent.bestChild == childIndex && !childLeadsToViableHead {

View File

@@ -53,6 +53,7 @@ func TestPeer_AtMaxLimit(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
}() }()
multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr, 2000, h1.ID())) multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr, 2000, h1.ID()))
require.NoError(t, err)
addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress) addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress)
require.NoError(t, err) require.NoError(t, err)
err = h2.Connect(context.Background(), *addrInfo) err = h2.Connect(context.Background(), *addrInfo)
@@ -121,6 +122,7 @@ func TestPeer_BelowMaxLimit(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
}() }()
multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr, 2000, h1.ID())) multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr, 2000, h1.ID()))
require.NoError(t, err)
addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress) addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress)
require.NoError(t, err) require.NoError(t, err)
err = h2.Connect(context.Background(), *addrInfo) err = h2.Connect(context.Background(), *addrInfo)
@@ -162,6 +164,7 @@ func TestPeerAllowList(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
}() }()
multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr2, 3000, h2.ID())) multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr2, 3000, h2.ID()))
require.NoError(t, err)
addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress) addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress)
require.NoError(t, err) require.NoError(t, err)
err = h1.Connect(context.Background(), *addrInfo) err = h1.Connect(context.Background(), *addrInfo)
@@ -204,6 +207,7 @@ func TestPeerDenyList(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
}() }()
multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr2, 3000, h2.ID())) multiAddress, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ipAddr2, 3000, h2.ID()))
require.NoError(t, err)
addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress) addrInfo, err := peer.AddrInfoFromP2pAddr(multiAddress)
require.NoError(t, err) require.NoError(t, err)
err = h1.Connect(context.Background(), *addrInfo) err = h1.Connect(context.Background(), *addrInfo)

View File

@@ -88,6 +88,9 @@ func (e SszNetworkEncoder) doDecode(b []byte, to interface{}) error {
// DecodeGossip decodes the bytes to the protobuf gossip message provided. // DecodeGossip decodes the bytes to the protobuf gossip message provided.
func (e SszNetworkEncoder) DecodeGossip(b []byte, to interface{}) error { func (e SszNetworkEncoder) DecodeGossip(b []byte, to interface{}) error {
size, err := snappy.DecodedLen(b) size, err := snappy.DecodedLen(b)
if err != nil {
return err
}
if uint64(size) > MaxGossipSize { if uint64(size) > MaxGossipSize {
return errors.Errorf("gossip message exceeds max gossip size: %d bytes > %d bytes", size, MaxGossipSize) return errors.Errorf("gossip message exceeds max gossip size: %d bytes > %d bytes", size, MaxGossipSize)
} }

View File

@@ -88,7 +88,7 @@ func addForkEntry(
currentSlot := helpers.SlotsSince(genesisTime) currentSlot := helpers.SlotsSince(genesisTime)
currentEpoch := helpers.SlotToEpoch(currentSlot) currentEpoch := helpers.SlotToEpoch(currentSlot)
if timeutils.Now().Before(genesisTime) { if timeutils.Now().Before(genesisTime) {
currentSlot, currentEpoch = 0, 0 currentEpoch = 0
} }
fork, err := p2putils.Fork(currentEpoch) fork, err := p2putils.Fork(currentEpoch)
if err != nil { if err != nil {

View File

@@ -53,6 +53,7 @@ func TestPrivateKeyLoading(t *testing.T) {
func TestIPV6Support(t *testing.T) { func TestIPV6Support(t *testing.T) {
key, err := gethCrypto.GenerateKey() key, err := gethCrypto.GenerateKey()
require.NoError(t, err)
db, err := enode.OpenDB("") db, err := enode.OpenDB("")
if err != nil { if err != nil {
log.Error("could not open node's peer database") log.Error("could not open node's peer database")

View File

@@ -460,12 +460,12 @@ func TestPrune(t *testing.T) {
// Not so good peer is pruned away so that we can reduce the // Not so good peer is pruned away so that we can reduce the
// total size of the handler. // total size of the handler.
badRes, err = scorer.Count(secondPID) _, err = scorer.Count(secondPID)
assert.NotNil(t, err, "error is supposed to be not nil") assert.ErrorContains(t, "peer unknown", err)
// Last peer has been removed. // Last peer has been removed.
badRes, err = scorer.Count(thirdPID) _, err = scorer.Count(thirdPID)
assert.NotNil(t, err, "error is supposed to be not nil") assert.ErrorContains(t, "peer unknown", err)
} }
func TestTrimmedOrderedPeers(t *testing.T) { func TestTrimmedOrderedPeers(t *testing.T) {

View File

@@ -61,8 +61,8 @@ func (mockListener) RandomNodes() enode.Iterator {
} }
func createHost(t *testing.T, port int) (host.Host, *ecdsa.PrivateKey, net.IP) { func createHost(t *testing.T, port int) (host.Host, *ecdsa.PrivateKey, net.IP) {
ipAddr, pkey := createAddrAndPrivKey(t) _, pkey := createAddrAndPrivKey(t)
ipAddr = net.ParseIP("127.0.0.1") ipAddr := net.ParseIP("127.0.0.1")
listen, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, port)) listen, err := multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, port))
require.NoError(t, err, "Failed to p2p listen") require.NoError(t, err, "Failed to p2p listen")
h, err := libp2p.New(context.Background(), []libp2p.Option{privKeyOption(pkey), libp2p.ListenAddrs(listen)}...) h, err := libp2p.New(context.Background(), []libp2p.Option{privKeyOption(pkey), libp2p.ListenAddrs(listen)}...)

View File

@@ -63,6 +63,9 @@ func (m *MockPeersProvider) Peers() *peers.Status {
func createENR() *enr.Record { func createENR() *enr.Record {
key, err := crypto.GenerateKey() key, err := crypto.GenerateKey()
if err != nil {
log.Error(err)
}
db, err := enode.OpenDB("") db, err := enode.OpenDB("")
if err != nil { if err != nil {
log.Error("could not open node's peer database") log.Error("could not open node's peer database")

View File

@@ -114,7 +114,7 @@ func (bs *Server) ListAttestations(
func (bs *Server) ListIndexedAttestations( func (bs *Server) ListIndexedAttestations(
ctx context.Context, req *ethpb.ListIndexedAttestationsRequest, ctx context.Context, req *ethpb.ListIndexedAttestationsRequest,
) (*ethpb.ListIndexedAttestationsResponse, error) { ) (*ethpb.ListIndexedAttestationsResponse, error) {
blocks := make([]*ethpb.SignedBeaconBlock, 0) var blocks []*ethpb.SignedBeaconBlock
var err error var err error
switch q := req.QueryFilter.(type) { switch q := req.QueryFilter.(type) {
case *ethpb.ListIndexedAttestationsRequest_GenesisEpoch: case *ethpb.ListIndexedAttestationsRequest_GenesisEpoch:

View File

@@ -497,6 +497,7 @@ func TestServer_StreamChainHead_OnHeadUpdated(t *testing.T) {
b := testutil.NewBeaconBlock() b := testutil.NewBeaconBlock()
b.Block.Slot, err = helpers.StartSlot(s.PreviousJustifiedCheckpoint().Epoch) b.Block.Slot, err = helpers.StartSlot(s.PreviousJustifiedCheckpoint().Epoch)
require.NoError(t, err)
hRoot, err := b.Block.HashTreeRoot() hRoot, err := b.Block.HashTreeRoot()
require.NoError(t, err) require.NoError(t, err)

View File

@@ -41,8 +41,6 @@ func (bs *Server) ListValidatorBalances(
requestedEpoch = q.Epoch requestedEpoch = q.Epoch
case *ethpb.ListValidatorBalancesRequest_Genesis: case *ethpb.ListValidatorBalancesRequest_Genesis:
requestedEpoch = 0 requestedEpoch = 0
default:
requestedEpoch = currentEpoch
} }
if requestedEpoch > currentEpoch { if requestedEpoch > currentEpoch {
@@ -193,7 +191,8 @@ func (bs *Server) ListValidators(
var reqState *statetrie.BeaconState var reqState *statetrie.BeaconState
var err error var err error
if requestedEpoch != currentEpoch { if requestedEpoch != currentEpoch {
s, err := helpers.StartSlot(requestedEpoch) var s uint64
s, err = helpers.StartSlot(requestedEpoch)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -382,11 +381,6 @@ func (bs *Server) GetValidatorActiveSetChanges(
) )
} }
activatedIndices := make([]uint64, 0)
exitedIndices := make([]uint64, 0)
slashedIndices := make([]uint64, 0)
ejectedIndices := make([]uint64, 0)
s, err := helpers.StartSlot(requestedEpoch) s, err := helpers.StartSlot(requestedEpoch)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -401,13 +395,13 @@ func (bs *Server) GetValidatorActiveSetChanges(
return nil, status.Errorf(codes.Internal, "Could not get active validator count: %v", err) return nil, status.Errorf(codes.Internal, "Could not get active validator count: %v", err)
} }
vs := requestedState.Validators() vs := requestedState.Validators()
activatedIndices = validators.ActivatedValidatorIndices(helpers.CurrentEpoch(requestedState), vs) activatedIndices := validators.ActivatedValidatorIndices(helpers.CurrentEpoch(requestedState), vs)
exitedIndices, err = validators.ExitedValidatorIndices(helpers.CurrentEpoch(requestedState), vs, activeValidatorCount) exitedIndices, err := validators.ExitedValidatorIndices(helpers.CurrentEpoch(requestedState), vs, activeValidatorCount)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not determine exited validator indices: %v", err) return nil, status.Errorf(codes.Internal, "Could not determine exited validator indices: %v", err)
} }
slashedIndices = validators.SlashedValidatorIndices(helpers.CurrentEpoch(requestedState), vs) slashedIndices := validators.SlashedValidatorIndices(helpers.CurrentEpoch(requestedState), vs)
ejectedIndices, err = validators.EjectedValidatorIndices(helpers.CurrentEpoch(requestedState), vs, activeValidatorCount) ejectedIndices, err := validators.EjectedValidatorIndices(helpers.CurrentEpoch(requestedState), vs, activeValidatorCount)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not determine ejected validator indices: %v", err) return nil, status.Errorf(codes.Internal, "Could not determine ejected validator indices: %v", err)
} }
@@ -552,7 +546,6 @@ func (bs *Server) GetValidatorQueue(
}) })
// Only activate just enough validators according to the activation churn limit. // Only activate just enough validators according to the activation churn limit.
activationQueueChurn := uint64(len(activationQ))
activeValidatorCount, err := helpers.ActiveValidatorCount(headState, helpers.CurrentEpoch(headState)) activeValidatorCount, err := helpers.ActiveValidatorCount(headState, helpers.CurrentEpoch(headState))
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get active validator count: %v", err) return nil, status.Errorf(codes.Internal, "Could not get active validator count: %v", err)
@@ -575,13 +568,9 @@ func (bs *Server) GetValidatorQueue(
} }
} }
// Prevent churn limit from causing index out of bound issues. // Prevent churn limit from causing index out of bound issues.
if churnLimit < activationQueueChurn {
activationQueueChurn = churnLimit
}
if churnLimit < exitQueueChurn { if churnLimit < exitQueueChurn {
// If we are above the churn limit, we simply increase the churn by one. // If we are above the churn limit, we simply increase the churn by one.
exitQueueEpoch++ exitQueueEpoch++
exitQueueChurn = churnLimit
} }
// We use the exit queue churn to determine if we have passed a churn limit. // We use the exit queue churn to determine if we have passed a churn limit.
@@ -786,11 +775,11 @@ func (bs *Server) GetIndividualVotes(
return filteredIndices[i] < filteredIndices[j] return filteredIndices[i] < filteredIndices[j]
}) })
v, b, err := precompute.New(ctx, requestedState) v, bal, err := precompute.New(ctx, requestedState)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not set up pre compute instance: %v", err) return nil, status.Errorf(codes.Internal, "Could not set up pre compute instance: %v", err)
} }
v, b, err = precompute.ProcessAttestations(ctx, requestedState, v, b) v, _, err = precompute.ProcessAttestations(ctx, requestedState, v, bal)
if err != nil { if err != nil {
return nil, status.Errorf(codes.Internal, "Could not pre compute attestations: %v", err) return nil, status.Errorf(codes.Internal, "Could not pre compute attestations: %v", err)
} }

View File

@@ -1608,7 +1608,7 @@ func TestGetValidatorPerformance_Indices(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
vp, bp, err = precompute.ProcessAttestations(ctx, c, vp, bp) vp, bp, err = precompute.ProcessAttestations(ctx, c, vp, bp)
require.NoError(t, err) require.NoError(t, err)
c, err = precompute.ProcessRewardsAndPenaltiesPrecompute(c, bp, vp) _, err = precompute.ProcessRewardsAndPenaltiesPrecompute(c, bp, vp)
require.NoError(t, err) require.NoError(t, err)
farFuture := params.BeaconConfig().FarFutureEpoch farFuture := params.BeaconConfig().FarFutureEpoch
want := &ethpb.ValidatorPerformanceResponse{ want := &ethpb.ValidatorPerformanceResponse{
@@ -1679,7 +1679,7 @@ func TestGetValidatorPerformance_IndicesPubkeys(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
vp, bp, err = precompute.ProcessAttestations(ctx, c, vp, bp) vp, bp, err = precompute.ProcessAttestations(ctx, c, vp, bp)
require.NoError(t, err) require.NoError(t, err)
c, err = precompute.ProcessRewardsAndPenaltiesPrecompute(c, bp, vp) _, err = precompute.ProcessRewardsAndPenaltiesPrecompute(c, bp, vp)
require.NoError(t, err) require.NoError(t, err)
farFuture := params.BeaconConfig().FarFutureEpoch farFuture := params.BeaconConfig().FarFutureEpoch
want := &ethpb.ValidatorPerformanceResponse{ want := &ethpb.ValidatorPerformanceResponse{

View File

@@ -102,7 +102,7 @@ func (ns *Server) GetHost(ctx context.Context, _ *ptypes.Empty) (*ethpb.HostData
} }
record := ns.PeerManager.ENR() record := ns.PeerManager.ENR()
enr := "" enr := ""
err := error(nil) var err error
if record != nil { if record != nil {
enr, err = p2p.SerializeENR(record) enr, err = p2p.SerializeENR(record)
if err != nil { if err != nil {

View File

@@ -96,6 +96,7 @@ func TestNodeServer_GetHost(t *testing.T) {
peersProvider := &mockP2p.MockPeersProvider{} peersProvider := &mockP2p.MockPeersProvider{}
mP2P := mockP2p.NewTestP2P(t) mP2P := mockP2p.NewTestP2P(t)
key, err := crypto.GenerateKey() key, err := crypto.GenerateKey()
require.NoError(t, err)
db, err := enode.OpenDB("") db, err := enode.OpenDB("")
require.NoError(t, err) require.NoError(t, err)
lNode := enode.NewLocalNode(db, key) lNode := enode.NewLocalNode(db, key)

View File

@@ -108,7 +108,7 @@ func (vs *Server) GetAttestationData(ctx context.Context, req *ethpb.Attestation
if err != nil { if err != nil {
return nil, err return nil, err
} }
targetRoot := make([]byte, 32) var targetRoot []byte
if epochStartSlot == headState.Slot() { if epochStartSlot == headState.Slot() {
targetRoot = headRoot targetRoot = headRoot
} else { } else {

View File

@@ -282,8 +282,6 @@ func TestWaitForActivation_MultipleStatuses(t *testing.T) {
func TestWaitForChainStart_ContextClosed(t *testing.T) { func TestWaitForChainStart_ContextClosed(t *testing.T) {
db, _ := dbutil.SetupDB(t) db, _ := dbutil.SetupDB(t)
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
chainService := &mockChain.ChainService{} chainService := &mockChain.ChainService{}
Server := &Server{ Server := &Server{
@@ -427,8 +425,6 @@ func TestWaitForChainStart_NotStartedThenLogFired(t *testing.T) {
func TestWaitForSynced_ContextClosed(t *testing.T) { func TestWaitForSynced_ContextClosed(t *testing.T) {
db, _ := dbutil.SetupDB(t) db, _ := dbutil.SetupDB(t)
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
chainService := &mockChain.ChainService{} chainService := &mockChain.ChainService{}
Server := &Server{ Server := &Server{

View File

@@ -521,6 +521,7 @@ func TestActivationStatus_OK(t *testing.T) {
ctx := context.Background() ctx := context.Background()
deposits, _, err := testutil.DeterministicDepositsAndKeys(4) deposits, _, err := testutil.DeterministicDepositsAndKeys(4)
require.NoError(t, err)
pubKeys := [][]byte{deposits[0].Data.PublicKey, deposits[1].Data.PublicKey, deposits[2].Data.PublicKey, deposits[3].Data.PublicKey} pubKeys := [][]byte{deposits[0].Data.PublicKey, deposits[1].Data.PublicKey, deposits[2].Data.PublicKey, deposits[3].Data.PublicKey}
stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{ stateObj, err := stateTrie.InitializeFromProtoUnsafe(&pbp2p.BeaconState{
Slot: 4000, Slot: 4000,
@@ -543,6 +544,7 @@ func TestActivationStatus_OK(t *testing.T) {
}, },
}, },
}) })
require.NoError(t, err)
block := testutil.NewBeaconBlock() block := testutil.NewBeaconBlock()
genesisRoot, err := block.Block.HashTreeRoot() genesisRoot, err := block.Block.HashTreeRoot()
require.NoError(t, err, "Could not get signing root") require.NoError(t, err, "Could not get signing root")
@@ -837,6 +839,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) {
ctx := context.Background() ctx := context.Background()
deposits, _, err := testutil.DeterministicDepositsAndKeys(6) deposits, _, err := testutil.DeterministicDepositsAndKeys(6)
require.NoError(t, err)
pubKeys := [][]byte{ pubKeys := [][]byte{
deposits[0].Data.PublicKey, deposits[0].Data.PublicKey,
deposits[1].Data.PublicKey, deposits[1].Data.PublicKey,
@@ -877,6 +880,7 @@ func TestMultipleValidatorStatus_Pubkeys(t *testing.T) {
}, },
}, },
}) })
require.NoError(t, err)
block := testutil.NewBeaconBlock() block := testutil.NewBeaconBlock()
genesisRoot, err := block.Block.HashTreeRoot() genesisRoot, err := block.Block.HashTreeRoot()
require.NoError(t, err, "Could not get signing root") require.NoError(t, err, "Could not get signing root")
@@ -985,6 +989,7 @@ func TestMultipleValidatorStatus_Indices(t *testing.T) {
}, },
} }
stateObj, err := stateTrie.InitializeFromProtoUnsafe(beaconState) stateObj, err := stateTrie.InitializeFromProtoUnsafe(beaconState)
require.NoError(t, err)
block := testutil.NewBeaconBlock() block := testutil.NewBeaconBlock()
genesisRoot, err := block.Block.HashTreeRoot() genesisRoot, err := block.Block.HashTreeRoot()
require.NoError(t, err, "Could not get signing root") require.NoError(t, err, "Could not get signing root")

View File

@@ -21,6 +21,7 @@ func TestFieldTrie_NewTrie(t *testing.T) {
root, err := stateutil.RootsArrayHashTreeRoot(newState.StateRoots(), params.BeaconConfig().SlotsPerHistoricalRoot, "StateRoots") root, err := stateutil.RootsArrayHashTreeRoot(newState.StateRoots(), params.BeaconConfig().SlotsPerHistoricalRoot, "StateRoots")
require.NoError(t, err) require.NoError(t, err)
newRoot, err := trie.TrieRoot() newRoot, err := trie.TrieRoot()
require.NoError(t, err)
assert.Equal(t, root, newRoot) assert.Equal(t, root, newRoot)
} }

View File

@@ -47,6 +47,7 @@ func TestNilState_NoPanic(t *testing.T) {
_ = st.ParentRoot() _ = st.ParentRoot()
_ = st.BlockRoots() _ = st.BlockRoots()
_, err := st.BlockRootAtIndex(0) _, err := st.BlockRootAtIndex(0)
_ = err
_ = st.StateRoots() _ = st.StateRoots()
_ = st.HistoricalRoots() _ = st.HistoricalRoots()
_ = st.Eth1Data() _ = st.Eth1Data()
@@ -54,16 +55,20 @@ func TestNilState_NoPanic(t *testing.T) {
_ = st.Eth1DepositIndex() _ = st.Eth1DepositIndex()
_ = st.ValidatorsReadOnly() _ = st.ValidatorsReadOnly()
_, err = st.ValidatorAtIndex(0) _, err = st.ValidatorAtIndex(0)
_ = err
_, err = st.ValidatorAtIndexReadOnly(0) _, err = st.ValidatorAtIndexReadOnly(0)
_ = err
_, _ = st.ValidatorIndexByPubkey([48]byte{}) _, _ = st.ValidatorIndexByPubkey([48]byte{})
_ = st.validatorIndexMap() _ = st.validatorIndexMap()
_ = st.PubkeyAtIndex(0) _ = st.PubkeyAtIndex(0)
_ = st.NumValidators() _ = st.NumValidators()
_ = st.Balances() _ = st.Balances()
_, err = st.BalanceAtIndex(0) _, err = st.BalanceAtIndex(0)
_ = err
_ = st.BalancesLength() _ = st.BalancesLength()
_ = st.RandaoMixes() _ = st.RandaoMixes()
_, err = st.RandaoMixAtIndex(0) _, err = st.RandaoMixAtIndex(0)
_ = err
_ = st.RandaoMixesLength() _ = st.RandaoMixesLength()
_ = st.Slashings() _ = st.Slashings()
_ = st.PreviousEpochAttestations() _ = st.PreviousEpochAttestations()
@@ -72,7 +77,6 @@ func TestNilState_NoPanic(t *testing.T) {
_ = st.PreviousJustifiedCheckpoint() _ = st.PreviousJustifiedCheckpoint()
_ = st.CurrentJustifiedCheckpoint() _ = st.CurrentJustifiedCheckpoint()
_ = st.FinalizedCheckpoint() _ = st.FinalizedCheckpoint()
_ = err
} }
func TestReadOnlyValidator_NoPanic(t *testing.T) { func TestReadOnlyValidator_NoPanic(t *testing.T) {

View File

@@ -436,9 +436,7 @@ func (b *BeaconState) recomputeFieldTrie(index fieldIndex, elements interface{})
} }
func (b *BeaconState) resetFieldTrie(index fieldIndex, elements interface{}, length uint64) error { func (b *BeaconState) resetFieldTrie(index fieldIndex, elements interface{}, length uint64) error {
fTrie := b.stateFieldLeaves[index] fTrie, err := NewFieldTrie(index, elements, length)
var err error
fTrie, err = NewFieldTrie(index, elements, length)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -207,6 +207,9 @@ func (s *State) loadStateBySlot(ctx context.Context, slot uint64) (*state.Beacon
// Gather last saved state, that is where node starts to replay the blocks. // Gather last saved state, that is where node starts to replay the blocks.
startState, err := s.lastSavedState(ctx, slot) startState, err := s.lastSavedState(ctx, slot)
if err != nil {
return nil, err
}
// Gather the last saved block root and the slot number. // Gather the last saved block root and the slot number.
lastValidRoot, lastValidSlot, err := s.lastSavedBlock(ctx, slot) lastValidRoot, lastValidSlot, err := s.lastSavedBlock(ctx, slot)

View File

@@ -738,5 +738,6 @@ func TestLoadFinalizedBlocks(t *testing.T) {
require.NoError(t, s.beaconDB.SaveFinalizedCheckpoint(ctx, &ethpb.Checkpoint{Root: roots[8][:]})) require.NoError(t, s.beaconDB.SaveFinalizedCheckpoint(ctx, &ethpb.Checkpoint{Root: roots[8][:]}))
filteredBlocks, err = s.loadFinalizedBlocks(ctx, 0, 8) filteredBlocks, err = s.loadFinalizedBlocks(ctx, 0, 8)
require.NoError(t, err)
require.Equal(t, 10, len(filteredBlocks)) require.Equal(t, 10, len(filteredBlocks))
} }

View File

@@ -497,7 +497,7 @@ func TestBlocksFetcher_requestBeaconBlocksByRange(t *testing.T) {
// Test context cancellation. // Test context cancellation.
ctx, cancel = context.WithCancel(context.Background()) ctx, cancel = context.WithCancel(context.Background())
cancel() cancel()
blocks, err = fetcher.requestBlocks(ctx, req, peerIDs[0]) _, err = fetcher.requestBlocks(ctx, req, peerIDs[0])
assert.ErrorContains(t, "context canceled", err) assert.ErrorContains(t, "context canceled", err)
} }

View File

@@ -106,6 +106,7 @@ func TestRegularSync_InsertDuplicateBlocks(t *testing.T) {
b0r := [32]byte{'a'} b0r := [32]byte{'a'}
require.NoError(t, r.db.SaveBlock(context.Background(), b0)) require.NoError(t, r.db.SaveBlock(context.Background(), b0))
b0Root, err := b0.Block.HashTreeRoot() b0Root, err := b0.Block.HashTreeRoot()
require.NoError(t, err)
b1 := testutil.NewBeaconBlock() b1 := testutil.NewBeaconBlock()
b1.Block.Slot = 1 b1.Block.Slot = 1
b1.Block.ParentRoot = b0Root[:] b1.Block.ParentRoot = b0Root[:]

View File

@@ -36,8 +36,6 @@ func (s *Service) goodbyeRPCHandler(ctx context.Context, msg interface{}, stream
log.WithError(err).Error("Failed to close stream") log.WithError(err).Error("Failed to close stream")
} }
}() }()
ctx, cancel := context.WithTimeout(ctx, ttfbTimeout)
defer cancel()
SetRPCStreamDeadlines(stream) SetRPCStreamDeadlines(stream)
m, ok := msg.(*uint64) m, ok := msg.(*uint64)

View File

@@ -18,8 +18,6 @@ func (s *Service) metaDataHandler(ctx context.Context, msg interface{}, stream l
log.WithError(err).Debug("Failed to close stream") log.WithError(err).Debug("Failed to close stream")
} }
}() }()
ctx, cancel := context.WithTimeout(ctx, ttfbTimeout)
defer cancel()
SetRPCStreamDeadlines(stream) SetRPCStreamDeadlines(stream)
if err := s.rateLimiter.validateRequest(stream, 1); err != nil { if err := s.rateLimiter.validateRequest(stream, 1); err != nil {

View File

@@ -187,5 +187,6 @@ func TestPingRPCHandler_BadSequenceNumber(t *testing.T) {
} }
res, err := p1.Peers().Scorers().BadResponsesScorer().Count(p2.BHost.ID()) res, err := p1.Peers().Scorers().BadResponsesScorer().Count(p2.BHost.ID())
assert.Equal(t, int(1), res, "Peer wasn't penalised for providing a bad sequence number") assert.NoError(t, err)
assert.Equal(t, 1, res, "Peer wasn't penalised for providing a bad sequence number")
} }

View File

@@ -695,6 +695,7 @@ func TestValidateBeaconBlockPubSub_RejectEvilBlocksFromFuture(t *testing.T) {
// valid block // valid block
msg.Block.ParentRoot = bRoot[:] msg.Block.ParentRoot = bRoot[:]
msg.Signature, err = helpers.ComputeDomainAndSign(beaconState, 0, msg.Block, params.BeaconConfig().DomainBeaconProposer, privKeys[proposerIdx]) msg.Signature, err = helpers.ComputeDomainAndSign(beaconState, 0, msg.Block, params.BeaconConfig().DomainBeaconProposer, privKeys[proposerIdx])
require.NoError(t, err)
genesisTime := time.Now() genesisTime := time.Now()
c, err := lru.New(10) c, err := lru.New(10)

View File

@@ -46,7 +46,6 @@ func NaiveAttestationAggregation(atts []*ethpb.Attestation) ([]*ethpb.Attestatio
} else if b.AggregationBits.Contains(a.AggregationBits) { } else if b.AggregationBits.Contains(a.AggregationBits) {
// if a is fully contained in b, then a can be removed. // if a is fully contained in b, then a can be removed.
atts = append(atts[:i], atts[i+1:]...) atts = append(atts[:i], atts[i+1:]...)
i--
break // Stop the inner loop, advance a. break // Stop the inner loop, advance a.
} }
} }

View File

@@ -142,6 +142,9 @@ func GenerateDepositTransaction(
depositData.Signature, depositData.Signature,
depositRoot, depositRoot,
) )
if err != nil {
return nil, nil, err
}
return tx, depositData, nil return tx, depositData, nil
} }

View File

@@ -125,7 +125,6 @@ func TestGetSlotTickerWithOffset_OK(t *testing.T) {
if firstTicked != 1 { if firstTicked != 1 {
t.Fatal("Expected other ticker to tick first") t.Fatal("Expected other ticker to tick first")
} }
firstTicked = 2
return return
case <-normalTicker.C(): case <-normalTicker.C():
if firstTicked != 0 { if firstTicked != 0 {

View File

@@ -360,7 +360,7 @@ func GenerateAttestations(bState *stateTrie.BeaconState, privs []bls.SecretKey,
} }
targetRoot := make([]byte, 32) targetRoot := make([]byte, 32)
headRoot := make([]byte, 32) var headRoot []byte
var err error var err error
// Only calculate head state if its an attestation for the current slot or future slot. // Only calculate head state if its an attestation for the current slot or future slot.
if generateHeadState || slot == bState.Slot() { if generateHeadState || slot == bState.Slot() {

View File

@@ -102,7 +102,7 @@ func (m *SparseMerkleTrie) Insert(item []byte, index int) {
for i := 0; i < int(m.depth); i++ { for i := 0; i < int(m.depth); i++ {
isLeft := currentIndex%2 == 0 isLeft := currentIndex%2 == 0
neighborIdx := currentIndex ^ 1 neighborIdx := currentIndex ^ 1
neighbor := make([]byte, 32) var neighbor []byte
if neighborIdx >= len(m.branches[i]) { if neighborIdx >= len(m.branches[i]) {
neighbor = ZeroHashes[i][:] neighbor = ZeroHashes[i][:]
} else { } else {

View File

@@ -164,6 +164,7 @@ func TestStore_UpdateAttesterSlashingStatus(t *testing.T) {
require.Equal(t, tt.ss, st, "Failed to find attester slashing with the correct status: %v", tt.as) require.Equal(t, tt.ss, st, "Failed to find attester slashing with the correct status: %v", tt.as)
err = db.SaveAttesterSlashing(ctx, types.SlashingStatus(types.Included), tt.as) err = db.SaveAttesterSlashing(ctx, types.SlashingStatus(types.Included), tt.as)
require.NoError(t, err)
has, st, err = db.HasAttesterSlashing(ctx, tt.as) has, st, err = db.HasAttesterSlashing(ctx, tt.as)
require.NoError(t, err, "Failed to get attester slashing") require.NoError(t, err, "Failed to get attester slashing")
require.Equal(t, true, has, "Failed to find attester slashing: %v", tt.as) require.Equal(t, true, has, "Failed to find attester slashing: %v", tt.as)

View File

@@ -239,6 +239,7 @@ func TestStore_UpdateProposerSlashingStatus(t *testing.T) {
require.Equal(t, tt.ss, st, "Failed to find proposer slashing with the correct status") require.Equal(t, tt.ss, st, "Failed to find proposer slashing with the correct status")
err = db.SaveProposerSlashing(ctx, types.SlashingStatus(types.Included), tt.ps) err = db.SaveProposerSlashing(ctx, types.SlashingStatus(types.Included), tt.ps)
require.NoError(t, err)
has, st, err = db.HasProposerSlashing(ctx, tt.ps) has, st, err = db.HasProposerSlashing(ctx, tt.ps)
require.NoError(t, err, "Failed to get proposer slashing") require.NoError(t, err, "Failed to get proposer slashing")
require.Equal(t, true, has, "Failed to find proposer slashing") require.Equal(t, true, has, "Failed to find proposer slashing")

View File

@@ -64,8 +64,10 @@ func TestEpochStore_GetValidatorSpan_Format(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
} }
span0, err := es.GetValidatorSpan(0) span0, err := es.GetValidatorSpan(0)
assert.NoError(t, err)
assert.DeepEqual(t, tt.expectedSpan[0], span0, "Unexpected span") assert.DeepEqual(t, tt.expectedSpan[0], span0, "Unexpected span")
span1, err := es.GetValidatorSpan(1) span1, err := es.GetValidatorSpan(1)
assert.NoError(t, err)
assert.DeepEqual(t, tt.expectedSpan[1], span1, "Unexpected span") assert.DeepEqual(t, tt.expectedSpan[1], span1, "Unexpected span")
}) })
} }

View File

@@ -182,6 +182,7 @@ func TestDetect_detectAttesterSlashings_Surround(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, tt.slashingsFound, len(slashings), "Unexpected amount of slashings found") require.Equal(t, tt.slashingsFound, len(slashings), "Unexpected amount of slashings found")
attsl, err := db.AttesterSlashings(ctx, status.Active) attsl, err := db.AttesterSlashings(ctx, status.Active)
require.NoError(t, err)
require.Equal(t, tt.slashingsFound, len(attsl), "Didnt save slashing to db") require.Equal(t, tt.slashingsFound, len(attsl), "Didnt save slashing to db")
for _, ss := range slashings { for _, ss := range slashings {
slashingAtt1 := ss.Attestation_1 slashingAtt1 := ss.Attestation_1
@@ -332,6 +333,7 @@ func TestDetect_detectAttesterSlashings_Double(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, tt.slashingsFound, len(slashings), "Unexpected amount of slashings found") require.Equal(t, tt.slashingsFound, len(slashings), "Unexpected amount of slashings found")
savedSlashings, err := db.AttesterSlashings(ctx, status.Active) savedSlashings, err := db.AttesterSlashings(ctx, status.Active)
require.NoError(t, err)
require.Equal(t, tt.slashingsFound, len(savedSlashings), "Did not save slashing to db") require.Equal(t, tt.slashingsFound, len(savedSlashings), "Did not save slashing to db")
for _, ss := range slashings { for _, ss := range slashings {
@@ -397,6 +399,7 @@ func TestDetect_detectProposerSlashing(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
assert.DeepEqual(t, tt.slashing, slashing) assert.DeepEqual(t, tt.slashing, slashing)
savedSlashings, err := db.ProposalSlashingsByStatus(ctx, status.Active) savedSlashings, err := db.ProposalSlashingsByStatus(ctx, status.Active)
require.NoError(t, err)
if tt.slashing != nil { if tt.slashing != nil {
require.Equal(t, 1, len(savedSlashings), "Did not save slashing to db") require.Equal(t, 1, len(savedSlashings), "Did not save slashing to db")
} }

View File

@@ -63,6 +63,7 @@ func TestServer_IsSlashableAttestation(t *testing.T) {
bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db} bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db}
bs, err := beaconclient.NewService(ctx, bcCfg) bs, err := beaconclient.NewService(ctx, bcCfg)
require.NoError(t, err)
ds := detection.NewService(ctx, cfg) ds := detection.NewService(ctx, cfg)
server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs} server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs}
nClient.EXPECT().GetGenesis(gomock.Any(), gomock.Any()).Return(wantedGenesis, nil).AnyTimes() nClient.EXPECT().GetGenesis(gomock.Any(), gomock.Any()).Return(wantedGenesis, nil).AnyTimes()
@@ -165,6 +166,7 @@ func TestServer_IsSlashableAttestationNoUpdate(t *testing.T) {
bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db} bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db}
bs, err := beaconclient.NewService(ctx, bcCfg) bs, err := beaconclient.NewService(ctx, bcCfg)
require.NoError(t, err)
ds := detection.NewService(ctx, cfg) ds := detection.NewService(ctx, cfg)
server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs} server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs}
slashings, err := server.IsSlashableAttestation(ctx, savedAttestation) slashings, err := server.IsSlashableAttestation(ctx, savedAttestation)
@@ -223,6 +225,7 @@ func TestServer_IsSlashableBlock(t *testing.T) {
bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db} bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db}
bs, err := beaconclient.NewService(ctx, bcCfg) bs, err := beaconclient.NewService(ctx, bcCfg)
require.NoError(t, err)
ds := detection.NewService(ctx, cfg) ds := detection.NewService(ctx, cfg)
server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs} server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs}
@@ -311,6 +314,7 @@ func TestServer_IsSlashableBlockNoUpdate(t *testing.T) {
savedBlock.Signature = marshalledSig savedBlock.Signature = marshalledSig
bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db} bcCfg := &beaconclient.Config{BeaconClient: bClient, NodeClient: nClient, SlasherDB: db}
bs, err := beaconclient.NewService(ctx, bcCfg) bs, err := beaconclient.NewService(ctx, bcCfg)
require.NoError(t, err)
ds := detection.NewService(ctx, cfg) ds := detection.NewService(ctx, cfg)
server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs} server := Server{ctx: ctx, detector: ds, slasherDB: db, beaconClient: bs}
slashings, err := server.IsSlashableBlock(ctx, savedBlock) slashings, err := server.IsSlashableBlock(ctx, savedBlock)

View File

@@ -102,6 +102,9 @@ func decrypt(cliCtx *cli.Context) error {
// Any password is valid. // Any password is valid.
return nil return nil
}) })
if err != nil {
return err
}
} }
isDir, err := fileutil.HasDir(fullPath) isDir, err := fileutil.HasDir(fullPath)
if err != nil { if err != nil {
@@ -139,6 +142,9 @@ func encrypt(cliCtx *cli.Context) error {
// Any password is valid. // Any password is valid.
return nil return nil
}) })
if err != nil {
return err
}
} }
privateKeyString := cliCtx.String(privateKeyFlag.Name) privateKeyString := cliCtx.String(privateKeyFlag.Name)
if privateKeyString == "" { if privateKeyString == "" {

View File

@@ -177,6 +177,9 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
postRoot, err := postState.HashTreeRoot(context.Background()) postRoot, err := postState.HashTreeRoot(context.Background())
if err != nil {
log.Fatal(err)
}
log.Infof("Finished state transition with post state root of %#x", postRoot) log.Infof("Finished state transition with post state root of %#x", postRoot)
// Diff the state if a post state is provided. // Diff the state if a post state is provided.

View File

@@ -106,7 +106,7 @@ func Test_KeysConsistency_Direct(t *testing.T) {
// Now we change the password to "SecoNDxyzPass__9!@#" // Now we change the password to "SecoNDxyzPass__9!@#"
require.NoError(t, ioutil.WriteFile(walletPasswordFile, []byte("SecoNDxyzPass__9!@#"), os.ModePerm)) require.NoError(t, ioutil.WriteFile(walletPasswordFile, []byte("SecoNDxyzPass__9!@#"), os.ModePerm))
w, err = wallet.OpenWalletOrElseCli(cliCtx, CreateAndSaveWalletCli) _, err = wallet.OpenWalletOrElseCli(cliCtx, CreateAndSaveWalletCli)
require.ErrorContains(t, "wrong password for wallet", err) require.ErrorContains(t, "wrong password for wallet", err)
require.NoError(t, ioutil.WriteFile(walletPasswordFile, []byte("Pa$sW0rD0__Fo0xPr"), os.ModePerm)) require.NoError(t, ioutil.WriteFile(walletPasswordFile, []byte("Pa$sW0rD0__Fo0xPr"), os.ModePerm))

View File

@@ -184,6 +184,9 @@ func OpenWalletOrElseCli(cliCtx *cli.Context, otherwise func(cliCtx *cli.Context
false, /* Do not confirm password */ false, /* Do not confirm password */
ValidateExistingPass, ValidateExistingPass,
) )
if err != nil {
return nil, err
}
if fileutil.FileExists(filepath.Join(walletDir, HashedPasswordFileName)) { if fileutil.FileExists(filepath.Join(walletDir, HashedPasswordFileName)) {
hashedPassword, err := fileutil.ReadFileAsBytes(filepath.Join(walletDir, HashedPasswordFileName)) hashedPassword, err := fileutil.ReadFileAsBytes(filepath.Join(walletDir, HashedPasswordFileName))
if err != nil { if err != nil {

View File

@@ -172,6 +172,7 @@ func Test_LockUnlockFile(t *testing.T) {
WalletDir: walletDir, WalletDir: walletDir,
WalletPassword: password, WalletPassword: password,
}) })
require.NoError(t, err)
defer unlock(t, w) defer unlock(t, w)
_, err = w.InitializeKeymanager(cliCtx.Context, true) _, err = w.InitializeKeymanager(cliCtx.Context, true)
require.NoError(t, err) require.NoError(t, err)

View File

@@ -680,8 +680,7 @@ func TestSaveProtections_OK(t *testing.T) {
history1 := cleanHistories[pubKey1] history1 := cleanHistories[pubKey1]
history1 = markAttestationForTargetEpoch(history1, 0, 1) history1 = markAttestationForTargetEpoch(history1, 0, 1)
history2 := cleanHistories[pubKey1] history2 := markAttestationForTargetEpoch(history1, 2, 3)
history2 = markAttestationForTargetEpoch(history1, 2, 3)
cleanHistories[pubKey1] = history1 cleanHistories[pubKey1] = history1
cleanHistories[pubKey2] = history2 cleanHistories[pubKey2] = history2

View File

@@ -294,6 +294,9 @@ func (dr *Keymanager) CreateAccount(ctx context.Context, logAccountInfo bool) ([
nil, /*forkVersion*/ nil, /*forkVersion*/
nil, /*genesisValidatorsRoot*/ nil, /*genesisValidatorsRoot*/
) )
if err != nil {
return nil, err
}
if err := depositutil.VerifyDepositSignature(data, domain); err != nil { if err := depositutil.VerifyDepositSignature(data, domain); err != nil {
return nil, errors.Wrap(err, "failed to verify deposit signature, please make sure your account was created properly") return nil, errors.Wrap(err, "failed to verify deposit signature, please make sure your account was created properly")
} }

View File

@@ -244,6 +244,9 @@ func (dr *Keymanager) CreateAccount(ctx context.Context) ([]byte, error) {
nil, /*forkVersion*/ nil, /*forkVersion*/
nil, /*genesisValidatorsRoot*/ nil, /*genesisValidatorsRoot*/
) )
if err != nil {
return nil, err
}
if err := depositutil.VerifyDepositSignature(data, domain); err != nil { if err := depositutil.VerifyDepositSignature(data, domain); err != nil {
return nil, errors.Wrap(err, "failed to verify deposit signature, please make sure your account was created properly") return nil, errors.Wrap(err, "failed to verify deposit signature, please make sure your account was created properly")
} }

View File

@@ -11,7 +11,6 @@ import (
// GetBeaconNodeConnection retrieves the current beacon node connection // GetBeaconNodeConnection retrieves the current beacon node connection
// information, as well as its sync status. // information, as well as its sync status.
func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) { func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (*pb.NodeConnectionResponse, error) {
genesis, err := s.genesisFetcher.GenesisInfo(ctx)
syncStatus, err := s.syncChecker.Syncing(ctx) syncStatus, err := s.syncChecker.Syncing(ctx)
if err != nil || s.validatorService.Status() != nil { if err != nil || s.validatorService.Status() != nil {
return &pb.NodeConnectionResponse{ return &pb.NodeConnectionResponse{
@@ -21,6 +20,10 @@ func (s *Server) GetBeaconNodeConnection(ctx context.Context, _ *ptypes.Empty) (
Syncing: false, Syncing: false,
}, nil }, nil
} }
genesis, err := s.genesisFetcher.GenesisInfo(ctx)
if err != nil {
return nil, err
}
return &pb.NodeConnectionResponse{ return &pb.NodeConnectionResponse{
GenesisTime: uint64(time.Unix(genesis.GenesisTime.Seconds, 0).Unix()), GenesisTime: uint64(time.Unix(genesis.GenesisTime.Seconds, 0).Unix()),
DepositContractAddress: genesis.DepositContractAddress, DepositContractAddress: genesis.DepositContractAddress,

View File

@@ -195,6 +195,7 @@ func TestServer_WalletConfig(t *testing.T) {
expectedConfig := direct.DefaultKeymanagerOpts() expectedConfig := direct.DefaultKeymanagerOpts()
enc, err := json.Marshal(expectedConfig) enc, err := json.Marshal(expectedConfig)
require.NoError(t, err)
var jsonMap map[string]string var jsonMap map[string]string
require.NoError(t, json.Unmarshal(enc, &jsonMap)) require.NoError(t, json.Unmarshal(enc, &jsonMap))
assert.DeepEqual(t, resp, &pb.WalletResponse{ assert.DeepEqual(t, resp, &pb.WalletResponse{