From 62279489a37adac7e7325103c5638f2481ef357b Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sun, 14 Apr 2019 04:17:39 -0400 Subject: [PATCH] Add deposit index to beacon state (#2232) * Begin adding Deposit Index to beacon state * Move deposit index increment to ProcessDeposit * Fix initial deposits bug * Fix bug in RPC * More bug fixes * Fix RPC bug, ensure deposits are processed in the right order * Fix tests * Fix merge * Attempt to fix pruning deposits on regular sync * Fix pending deposits on node restart * Fix test * Fix tests properly * Gofmt * Remove unneeded logs * Fix build --- .../blockchain/block_processing_test.go | 5 +- beacon-chain/blockchain/service_test.go | 9 +- beacon-chain/chaintest/backend/helpers.go | 6 +- .../chaintest/backend/simulated_backend.go | 1 + .../tests/state-tests/block-processing.yaml | 6 +- beacon-chain/core/blocks/block_operations.go | 11 +- .../core/blocks/block_operations_test.go | 87 ++++- beacon-chain/core/state/state.go | 1 + beacon-chain/core/state/state_test.go | 6 +- beacon-chain/core/validators/validator.go | 2 + beacon-chain/db/pending_deposits.go | 26 +- beacon-chain/db/pending_deposits_test.go | 8 +- beacon-chain/powchain/block_reader_test.go | 8 + beacon-chain/powchain/log_processing.go | 9 + beacon-chain/powchain/service_test.go | 8 + beacon-chain/rpc/beacon_server.go | 14 +- beacon-chain/rpc/beacon_server_test.go | 84 ++++- beacon-chain/sync/initial-sync/sync_state.go | 4 +- proto/beacon/p2p/v1/types.pb.go | 312 ++++++++++-------- proto/beacon/p2p/v1/types.proto | 3 +- scripts/start-single-validator.sh | 66 ++++ shared/trieutil/sparse_merkle.go | 8 +- 22 files changed, 494 insertions(+), 190 deletions(-) create mode 100755 scripts/start-single-validator.sh diff --git a/beacon-chain/blockchain/block_processing_test.go b/beacon-chain/blockchain/block_processing_test.go index 687b6e5098..45ee72d4ae 100644 --- a/beacon-chain/blockchain/block_processing_test.go +++ b/beacon-chain/blockchain/block_processing_test.go @@ -280,7 +280,7 @@ func TestReceiveBlock_RemovesPendingDeposits(t *testing.T) { randaoReveal := createRandaoReveal(t, beaconState, privKeys) pendingDeposits := []*pb.Deposit{ - createPreChainStartDeposit(t, []byte{'F'}), + createPreChainStartDeposit(t, []byte{'F'}, beaconState.DepositIndex), } pendingDepositsData := make([][]byte, len(pendingDeposits)) for i, pd := range pendingDeposits { @@ -296,7 +296,7 @@ func TestReceiveBlock_RemovesPendingDeposits(t *testing.T) { if err != nil { t.Fatalf("Could not generate proof: %v", err) } - pendingDeposits[i].MerkleBranchHash32S = proof + pendingDeposits[i].MerkleProofHash32S = proof } depositRoot := depositTrie.Root() beaconState.LatestEth1Data.DepositRootHash32 = depositRoot[:] @@ -319,6 +319,7 @@ func TestReceiveBlock_RemovesPendingDeposits(t *testing.T) { } beaconState.Slot-- + beaconState.DepositIndex = 0 if err := chainService.beaconDB.SaveState(ctx, beaconState); err != nil { t.Fatal(err) } diff --git a/beacon-chain/blockchain/service_test.go b/beacon-chain/blockchain/service_test.go index 2967b27c65..3ae2f4089a 100644 --- a/beacon-chain/blockchain/service_test.go +++ b/beacon-chain/blockchain/service_test.go @@ -172,20 +172,23 @@ func setupInitialDeposits(t *testing.T, numDeposits int) ([]*pb.Deposit, []*bls. if err != nil { t.Fatalf("Cannot encode data: %v", err) } - deposits[i] = &pb.Deposit{DepositData: depositData} + deposits[i] = &pb.Deposit{ + DepositData: depositData, + MerkleTreeIndex: uint64(i), + } privKeys[i] = priv } return deposits, privKeys } -func createPreChainStartDeposit(t *testing.T, pk []byte) *pb.Deposit { +func createPreChainStartDeposit(t *testing.T, pk []byte, index uint64) *pb.Deposit { depositInput := &pb.DepositInput{Pubkey: pk} balance := params.BeaconConfig().MaxDepositAmount depositData, err := helpers.EncodeDepositData(depositInput, balance, time.Now().Unix()) if err != nil { t.Fatalf("Cannot encode data: %v", err) } - return &pb.Deposit{DepositData: depositData} + return &pb.Deposit{DepositData: depositData, MerkleTreeIndex: index} } func createRandaoReveal(t *testing.T, beaconState *pb.BeaconState, privKeys []*bls.SecretKey) []byte { diff --git a/beacon-chain/chaintest/backend/helpers.go b/beacon-chain/chaintest/backend/helpers.go index 5473b75418..30109f7710 100644 --- a/beacon-chain/chaintest/backend/helpers.go +++ b/beacon-chain/chaintest/backend/helpers.go @@ -86,9 +86,9 @@ func generateSimulatedBlock( root := newTrie.Root() block.Eth1Data.DepositRootHash32 = root[:] block.Body.Deposits = append(block.Body.Deposits, &pb.Deposit{ - DepositData: data, - MerkleBranchHash32S: proof, - MerkleTreeIndex: simObjects.simDeposit.MerkleIndex, + DepositData: data, + MerkleProofHash32S: proof, + MerkleTreeIndex: simObjects.simDeposit.MerkleIndex, }) } if simObjects.simProposerSlashing != nil { diff --git a/beacon-chain/chaintest/backend/simulated_backend.go b/beacon-chain/chaintest/backend/simulated_backend.go index 7d9bcfa4c0..07f4b4d068 100644 --- a/beacon-chain/chaintest/backend/simulated_backend.go +++ b/beacon-chain/chaintest/backend/simulated_backend.go @@ -275,6 +275,7 @@ func (sb *SimulatedBackend) setupBeaconStateAndGenesisBlock(initialDeposits []*p if err != nil { return fmt.Errorf("could not initialize simulated beacon state: %v", err) } + sb.historicalDeposits = initialDeposits // We do not expect hashing initial beacon state and genesis block to // fail, so we can safely ignore the error below. diff --git a/beacon-chain/chaintest/tests/state-tests/block-processing.yaml b/beacon-chain/chaintest/tests/state-tests/block-processing.yaml index 34eebc0997..0d20bad981 100644 --- a/beacon-chain/chaintest/tests/state-tests/block-processing.yaml +++ b/beacon-chain/chaintest/tests/state-tests/block-processing.yaml @@ -18,17 +18,17 @@ test_cases: deposits: - slot: 9223372036854775809 amount: 32 - merkle_index: 0 + merkle_index: 64 pubkey: !!binary | SlAAbShSkUg7PLiPHZI/rTS1uAvKiieOrifPN6Moso0= - slot: 9223372036854775823 amount: 32 - merkle_index: 1 + merkle_index: 65 pubkey: !!binary | Oklajsjdkaklsdlkajsdjlajslkdjlkasjlkdjlajdsd - slot: 9223372036854775863 amount: 32 - merkle_index: 2 + merkle_index: 66 pubkey: !!binary | LkmqmqoodLKAslkjdkajsdljasdkajlksjdasldjasdd proposer_slashings: diff --git a/beacon-chain/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index 7b1e1b5f1e..8247032bd7 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -601,13 +601,22 @@ func ProcessValidatorDeposits( } func verifyDeposit(beaconState *pb.BeaconState, deposit *pb.Deposit) error { + // Deposits must be processed in order + if deposit.MerkleTreeIndex != beaconState.DepositIndex { + return fmt.Errorf( + "expected deposit merkle tree index to match beacon state deposit index, wanted: %d, received: %d", + beaconState.DepositIndex, + deposit.MerkleTreeIndex, + ) + } + // Verify Merkle proof of deposit and deposit trie root. receiptRoot := beaconState.LatestEth1Data.DepositRootHash32 if ok := trieutil.VerifyMerkleProof( receiptRoot, deposit.DepositData, int(deposit.MerkleTreeIndex), - deposit.MerkleBranchHash32S, + deposit.MerkleProofHash32S, ); !ok { return fmt.Errorf( "deposit merkle branch of deposit root did not verify for root: %#x", diff --git a/beacon-chain/core/blocks/block_operations_test.go b/beacon-chain/core/blocks/block_operations_test.go index 994a892b79..5898fe2367 100644 --- a/beacon-chain/core/blocks/block_operations_test.go +++ b/beacon-chain/core/blocks/block_operations_test.go @@ -1078,9 +1078,9 @@ func TestProcessValidatorDeposits_MerkleBranchFailsVerification(t *testing.T) { } deposit := &pb.Deposit{ - DepositData: data, - MerkleBranchHash32S: proof, - MerkleTreeIndex: 0, + DepositData: data, + MerkleProofHash32S: proof, + MerkleTreeIndex: 0, } block := &pb.BeaconBlock{ Body: &pb.BeaconBlockBody{ @@ -1151,9 +1151,9 @@ func TestProcessValidatorDeposits_ProcessDepositHelperFuncFails(t *testing.T) { t.Fatalf("Could not generate proof: %v", err) } deposit := &pb.Deposit{ - DepositData: data, - MerkleBranchHash32S: proof, - MerkleTreeIndex: 0, + DepositData: data, + MerkleProofHash32S: proof, + MerkleTreeIndex: 0, } block := &pb.BeaconBlock{ Body: &pb.BeaconBlockBody{ @@ -1190,6 +1190,75 @@ func TestProcessValidatorDeposits_ProcessDepositHelperFuncFails(t *testing.T) { } } +func TestProcessValidatorDeposits_IncorrectMerkleIndex(t *testing.T) { + depositInput := &pb.DepositInput{ + Pubkey: []byte{1}, + WithdrawalCredentialsHash32: []byte{1, 2, 3}, + ProofOfPossession: []byte{}, + } + wBuf := new(bytes.Buffer) + if err := ssz.Encode(wBuf, depositInput); err != nil { + t.Fatalf("failed to encode deposit input: %v", err) + } + encodedInput := wBuf.Bytes() + data := []byte{} + + // We set a deposit value of 1000. + value := make([]byte, 8) + depositValue := uint64(1000) + binary.LittleEndian.PutUint64(value, depositValue) + + // We then serialize a unix time into the timestamp []byte slice + // and ensure it has size of 8 bytes. + timestamp := make([]byte, 8) + + // Set deposit time to 1000 seconds since unix time 0. + depositTime := time.Unix(1000, 0).Unix() + // Set genesis time to unix time 0. + genesisTime := time.Unix(0, 0).Unix() + + currentSlot := 1000 * params.BeaconConfig().SecondsPerSlot + binary.LittleEndian.PutUint64(timestamp, uint64(depositTime)) + + // We then create a serialized deposit data slice of type []byte + // by appending all 3 items above together. + data = append(data, value...) + data = append(data, timestamp...) + data = append(data, encodedInput...) + + deposit := &pb.Deposit{ + DepositData: data, + MerkleProofHash32S: [][]byte{{0}}, + MerkleTreeIndex: 1, + } + block := &pb.BeaconBlock{ + Body: &pb.BeaconBlockBody{ + Deposits: []*pb.Deposit{deposit}, + }, + } + registry := []*pb.Validator{ + { + Pubkey: []byte{1}, + WithdrawalCredentialsHash32: []byte{1, 2, 3}, + }, + } + balances := []uint64{0} + beaconState := &pb.BeaconState{ + ValidatorRegistry: registry, + ValidatorBalances: balances, + Slot: currentSlot, + GenesisTime: uint64(genesisTime), + } + + want := "expected deposit merkle tree index to match beacon state deposit index" + if _, err := blocks.ProcessValidatorDeposits( + beaconState, + block, + ); !strings.Contains(err.Error(), want) { + t.Errorf("Expected error: %s, received %v", want, err) + } +} + func TestProcessValidatorDeposits_ProcessCorrectly(t *testing.T) { depositInput := &pb.DepositInput{ Pubkey: []byte{1}, @@ -1237,9 +1306,9 @@ func TestProcessValidatorDeposits_ProcessCorrectly(t *testing.T) { } deposit := &pb.Deposit{ - DepositData: data, - MerkleBranchHash32S: proof, - MerkleTreeIndex: 0, + DepositData: data, + MerkleProofHash32S: proof, + MerkleTreeIndex: 0, } block := &pb.BeaconBlock{ Body: &pb.BeaconBlockBody{ diff --git a/beacon-chain/core/state/state.go b/beacon-chain/core/state/state.go index 6401482169..b7752acb2f 100644 --- a/beacon-chain/core/state/state.go +++ b/beacon-chain/core/state/state.go @@ -120,6 +120,7 @@ func GenesisBeaconState( // Eth1 data. LatestEth1Data: eth1Data, Eth1DataVotes: []*pb.Eth1DataVote{}, + DepositIndex: 0, } // Process initial deposits. diff --git a/beacon-chain/core/state/state_test.go b/beacon-chain/core/state/state_test.go index 68a3c31740..737207ca93 100644 --- a/beacon-chain/core/state/state_test.go +++ b/beacon-chain/core/state/state_test.go @@ -76,9 +76,9 @@ func TestGenesisBeaconState_OK(t *testing.T) { t.Fatalf("Could not encode deposit data: %v", err) } deposits = append(deposits, &pb.Deposit{ - MerkleBranchHash32S: [][]byte{{1}, {2}, {3}}, - MerkleTreeIndex: 0, - DepositData: depositData, + MerkleProofHash32S: [][]byte{{1}, {2}, {3}}, + MerkleTreeIndex: 0, + DepositData: depositData, }) } diff --git a/beacon-chain/core/validators/validator.go b/beacon-chain/core/validators/validator.go index 0dc0606c6d..22d4e9017e 100644 --- a/beacon-chain/core/validators/validator.go +++ b/beacon-chain/core/validators/validator.go @@ -111,6 +111,8 @@ func ProcessDeposit( var publicKeyExists bool var existingValidatorIdx int + state.DepositIndex++ + existingValidatorIdx, publicKeyExists = validatorIdxMap[bytesutil.ToBytes32(pubkey)] if !publicKeyExists { // If public key does not exist in the registry, we add a new validator diff --git a/beacon-chain/db/pending_deposits.go b/beacon-chain/db/pending_deposits.go index 2f9f4379ab..2290ad6842 100644 --- a/beacon-chain/db/pending_deposits.go +++ b/beacon-chain/db/pending_deposits.go @@ -94,34 +94,26 @@ func (db *BeaconDB) RemovePendingDeposit(ctx context.Context, d *pb.Deposit) { } } -// PrunePendingDeposits removes any deposit which is older than the given block number. -func (db *BeaconDB) PrunePendingDeposits(ctx context.Context, b *big.Int) { +// PrunePendingDeposits removes any deposit which is older than the given deposit merkle tree index. +func (db *BeaconDB) PrunePendingDeposits(ctx context.Context, merkleTreeIndex uint64) { ctx, span := trace.StartSpan(ctx, "BeaconDB.PrunePendingDeposits") defer span.End() - if b == nil { - log.Debug("Ignoring nil deposit removal") + if merkleTreeIndex == 0 { + log.Debug("Ignoring 0 deposit removal") return } db.depositsLock.Lock() defer db.depositsLock.Unlock() - depositListSize := len(db.pendingDeposits) - - // since list is sorted by block number it checks from the last - // added deposit and works backwards. - idx := -1 - for i := depositListSize - 1; i >= 0; i-- { - if db.pendingDeposits[i].block.Cmp(b) == -1 { - idx = i - break + var cleanDeposits []*depositContainer + for _, dp := range db.pendingDeposits { + if dp.deposit.MerkleTreeIndex >= merkleTreeIndex { + cleanDeposits = append(cleanDeposits, dp) } } - if idx >= 0 { - db.pendingDeposits = db.pendingDeposits[idx+1:] - } - + db.pendingDeposits = cleanDeposits pendingDepositsCount.Set(float64(len(db.pendingDeposits))) } diff --git a/beacon-chain/db/pending_deposits_test.go b/beacon-chain/db/pending_deposits_test.go index dea71cec8e..51be0c0e51 100644 --- a/beacon-chain/db/pending_deposits_test.go +++ b/beacon-chain/db/pending_deposits_test.go @@ -87,7 +87,7 @@ func TestPendingDeposits_OK(t *testing.T) { } } -func TestPrunePendingDeposits_NilBlock(t *testing.T) { +func TestPrunePendingDeposits_ZeroMerkleIndex(t *testing.T) { db := BeaconDB{} db.pendingDeposits = []*depositContainer{ @@ -99,7 +99,7 @@ func TestPrunePendingDeposits_NilBlock(t *testing.T) { {block: big.NewInt(12), deposit: &pb.Deposit{MerkleTreeIndex: 12}}, } - db.PrunePendingDeposits(context.Background(), nil) + db.PrunePendingDeposits(context.Background(), 0) expected := []*depositContainer{ {block: big.NewInt(2), deposit: &pb.Deposit{MerkleTreeIndex: 2}}, {block: big.NewInt(4), deposit: &pb.Deposit{MerkleTreeIndex: 4}}, @@ -126,7 +126,7 @@ func TestPrunePendingDeposits_OK(t *testing.T) { {block: big.NewInt(12), deposit: &pb.Deposit{MerkleTreeIndex: 12}}, } - db.PrunePendingDeposits(context.Background(), big.NewInt(6)) + db.PrunePendingDeposits(context.Background(), 6) expected := []*depositContainer{ {block: big.NewInt(6), deposit: &pb.Deposit{MerkleTreeIndex: 6}}, {block: big.NewInt(8), deposit: &pb.Deposit{MerkleTreeIndex: 8}}, @@ -147,7 +147,7 @@ func TestPrunePendingDeposits_OK(t *testing.T) { {block: big.NewInt(12), deposit: &pb.Deposit{MerkleTreeIndex: 12}}, } - db.PrunePendingDeposits(context.Background(), big.NewInt(10)) + db.PrunePendingDeposits(context.Background(), 10) expected = []*depositContainer{ {block: big.NewInt(10), deposit: &pb.Deposit{MerkleTreeIndex: 10}}, {block: big.NewInt(12), deposit: &pb.Deposit{MerkleTreeIndex: 12}}, diff --git a/beacon-chain/powchain/block_reader_test.go b/beacon-chain/powchain/block_reader_test.go index b5b5cdb3e1..4bd1b3f497 100644 --- a/beacon-chain/powchain/block_reader_test.go +++ b/beacon-chain/powchain/block_reader_test.go @@ -7,6 +7,8 @@ import ( "testing" "time" + "github.com/prysmaticlabs/prysm/beacon-chain/db" + "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" ) @@ -17,6 +19,11 @@ func TestLatestMainchainInfo_OK(t *testing.T) { if err != nil { t.Fatalf("Unable to set up simulated backend %v", err) } + + beaconDB, err := db.SetupDB() + if err != nil { + t.Fatalf("unable to set up simulated db instance: %v", err) + } web3Service, err := NewWeb3Service(context.Background(), &Web3ServiceConfig{ Endpoint: endpoint, DepositContract: testAcc.contractAddr, @@ -24,6 +31,7 @@ func TestLatestMainchainInfo_OK(t *testing.T) { Logger: &goodLogger{}, BlockFetcher: &goodFetcher{}, ContractBackend: testAcc.backend, + BeaconDB: beaconDB, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) diff --git a/beacon-chain/powchain/log_processing.go b/beacon-chain/powchain/log_processing.go index 92c0bfc028..27dad2e846 100644 --- a/beacon-chain/powchain/log_processing.go +++ b/beacon-chain/powchain/log_processing.go @@ -173,6 +173,15 @@ func (w *Web3Service) processPastLogs() error { w.ProcessLog(log) } w.lastRequestedBlock.Set(w.blockHeight) + + currentState, err := w.beaconDB.HeadState(w.ctx) + if err != nil { + return fmt.Errorf("could not get head state: %v", err) + } + if currentState != nil && currentState.DepositIndex > 0 { + w.beaconDB.PrunePendingDeposits(w.ctx, currentState.DepositIndex) + } + return nil } diff --git a/beacon-chain/powchain/service_test.go b/beacon-chain/powchain/service_test.go index 1b8bd05483..09d0a08b26 100644 --- a/beacon-chain/powchain/service_test.go +++ b/beacon-chain/powchain/service_test.go @@ -11,6 +11,8 @@ import ( "testing" "time" + "github.com/prysmaticlabs/prysm/beacon-chain/db" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" @@ -201,6 +203,11 @@ func TestStart_OK(t *testing.T) { if err != nil { t.Fatalf("Unable to set up simulated backend %v", err) } + + beaconDB, err := db.SetupDB() + if err != nil { + t.Fatalf("Could not set up simulated beacon DB: %v", err) + } web3Service, err := NewWeb3Service(context.Background(), &Web3ServiceConfig{ Endpoint: endpoint, DepositContract: testAcc.contractAddr, @@ -208,6 +215,7 @@ func TestStart_OK(t *testing.T) { Logger: &goodLogger{}, BlockFetcher: &goodFetcher{}, ContractBackend: testAcc.backend, + BeaconDB: beaconDB, }) if err != nil { t.Fatalf("unable to setup web3 ETH1.0 chain service: %v", err) diff --git a/beacon-chain/rpc/beacon_server.go b/beacon-chain/rpc/beacon_server.go index 83718cef31..45e2c4fed5 100644 --- a/beacon-chain/rpc/beacon_server.go +++ b/beacon-chain/rpc/beacon_server.go @@ -214,7 +214,6 @@ func (bs *BeaconServer) PendingDeposits(ctx context.Context, _ *ptypes.Empty) (* return &pb.PendingDepositsResponse{PendingDeposits: nil}, nil } - pendingDeps := bs.beaconDB.PendingDeposits(ctx, bNum) // Need to fetch if the deposits up to the state's latest eth 1 data matches // the number of all deposits in this RPC call. If not, then we return nil. beaconState, err := bs.beaconDB.HeadState(ctx) @@ -244,6 +243,17 @@ func (bs *BeaconServer) PendingDeposits(ctx context.Context, _ *ptypes.Empty) (* return nil, fmt.Errorf("could not generate historical deposit trie from deposits: %v", err) } + allPendingDeps := bs.beaconDB.PendingDeposits(ctx, bNum) + + // Deposits need to be received in order of merkle index root, so this has to make sure + // deposits are sorted from lowest to highest. + var pendingDeps []*pbp2p.Deposit + for _, dep := range allPendingDeps { + if dep.MerkleTreeIndex >= beaconState.DepositIndex { + pendingDeps = append(pendingDeps, dep) + } + } + for i := range pendingDeps { // Don't construct merkle proof if the number of deposits is more than max allowed in block. if uint64(i) == params.BeaconConfig().MaxDeposits { @@ -306,6 +316,6 @@ func constructMerkleProof(trie *trieutil.MerkleTrie, deposit *pbp2p.Deposit) (*p // For every deposit, we construct a Merkle proof using the powchain service's // in-memory deposits trie, which is updated only once the state's LatestETH1Data // property changes during a state transition after a voting period. - deposit.MerkleBranchHash32S = proof + deposit.MerkleProofHash32S = proof return deposit, nil } diff --git a/beacon-chain/rpc/beacon_server_test.go b/beacon-chain/rpc/beacon_server_test.go index ccb9945950..52c428969e 100644 --- a/beacon-chain/rpc/beacon_server_test.go +++ b/beacon-chain/rpc/beacon_server_test.go @@ -305,6 +305,7 @@ func TestPendingDeposits_OutsideEth1FollowWindow(t *testing.T) { LatestEth1Data: &pbp2p.Eth1Data{ BlockHash32: []byte("0x0"), }, + DepositIndex: 2, } if err := d.SaveState(ctx, beaconState); err != nil { t.Fatal(err) @@ -359,11 +360,89 @@ func TestPendingDeposits_OutsideEth1FollowWindow(t *testing.T) { if err != nil { t.Fatal(err) } - if len(allResp.PendingDeposits) != len(readyDeposits) { + if len(allResp.PendingDeposits) != len(recentDeposits) { t.Errorf( "Received unexpected number of pending deposits: %d, wanted: %d", len(allResp.PendingDeposits), - len(recentDeposits)+len(readyDeposits), + len(recentDeposits), + ) + } +} + +func TestPendingDeposits_CantReturnBelowStateDepositIndex(t *testing.T) { + ctx := context.Background() + + height := big.NewInt(int64(params.BeaconConfig().Eth1FollowDistance)) + p := &mockPOWChainService{ + latestBlockNumber: height, + hashesByHeight: map[int][]byte{ + int(height.Int64()): []byte("0x0"), + }, + } + d := internal.SetupDB(t) + + beaconState := &pbp2p.BeaconState{ + LatestEth1Data: &pbp2p.Eth1Data{ + BlockHash32: []byte("0x0"), + }, + DepositIndex: 10, + } + if err := d.SaveState(ctx, beaconState); err != nil { + t.Fatal(err) + } + + readyDeposits := []*pbp2p.Deposit{ + { + MerkleTreeIndex: 0, + DepositData: []byte("a"), + }, + { + MerkleTreeIndex: 1, + DepositData: []byte("b"), + }, + } + + var recentDeposits []*pbp2p.Deposit + for i := 2; i < 16; i++ { + recentDeposits = append(recentDeposits, &pbp2p.Deposit{ + MerkleTreeIndex: uint64(i), + DepositData: []byte{byte(i)}, + }) + } + + for _, dp := range append(readyDeposits, recentDeposits...) { + d.InsertDeposit(ctx, dp, big.NewInt(int64(dp.MerkleTreeIndex))) + } + for _, dp := range recentDeposits { + d.InsertPendingDeposit(ctx, dp, big.NewInt(int64(dp.MerkleTreeIndex))) + } + + bs := &BeaconServer{ + beaconDB: d, + powChainService: p, + chainService: newMockChainService(), + } + + // It should also return the recent deposits after their follow window. + p.latestBlockNumber = big.NewInt(0).Add(p.latestBlockNumber, big.NewInt(10000)) + allResp, err := bs.PendingDeposits(ctx, nil) + if err != nil { + t.Fatal(err) + } + + expectedDeposits := 6 + if len(allResp.PendingDeposits) != expectedDeposits { + t.Errorf( + "Received unexpected number of pending deposits: %d, wanted: %d", + len(allResp.PendingDeposits), + expectedDeposits, + ) + } + if allResp.PendingDeposits[0].MerkleTreeIndex != beaconState.DepositIndex { + t.Errorf( + "Received unexpected merkle index: %d, wanted: %d", + allResp.PendingDeposits[0].MerkleTreeIndex, + beaconState.DepositIndex, ) } } @@ -384,6 +463,7 @@ func TestPendingDeposits_CantReturnMoreThanMax(t *testing.T) { LatestEth1Data: &pbp2p.Eth1Data{ BlockHash32: []byte("0x0"), }, + DepositIndex: 2, } if err := d.SaveState(ctx, beaconState); err != nil { t.Fatal(err) diff --git a/beacon-chain/sync/initial-sync/sync_state.go b/beacon-chain/sync/initial-sync/sync_state.go index 53c4bf78fa..718b13a9b9 100644 --- a/beacon-chain/sync/initial-sync/sync_state.go +++ b/beacon-chain/sync/initial-sync/sync_state.go @@ -47,7 +47,7 @@ func (s *InitialSync) processState(msg p2p.Message) { return } - exists, blkNum, err := s.powchain.BlockExists(ctx, bytesutil.ToBytes32(finalizedState.LatestEth1Data.BlockHash32)) + exists, _, err := s.powchain.BlockExists(ctx, bytesutil.ToBytes32(finalizedState.LatestEth1Data.BlockHash32)) if err != nil { log.Errorf("Unable to get powchain block %v", err) } @@ -57,7 +57,7 @@ func (s *InitialSync) processState(msg p2p.Message) { return } - s.db.PrunePendingDeposits(ctx, blkNum) + s.db.PrunePendingDeposits(ctx, finalizedState.DepositIndex) if err := s.db.UpdateChainHead(ctx, finalizedState.LatestBlock, finalizedState); err != nil { log.Errorf("Could not update chain head: %v", err) diff --git a/proto/beacon/p2p/v1/types.pb.go b/proto/beacon/p2p/v1/types.pb.go index 4f1193f24b..9064a2a1cc 100755 --- a/proto/beacon/p2p/v1/types.pb.go +++ b/proto/beacon/p2p/v1/types.pb.go @@ -78,6 +78,7 @@ type BeaconState struct { LatestBlock *BeaconBlock `protobuf:"bytes,3008,opt,name=latest_block,json=latestBlock,proto3" json:"latest_block,omitempty"` LatestEth1Data *Eth1Data `protobuf:"bytes,4001,opt,name=latest_eth1_data,json=latestEth1Data,proto3" json:"latest_eth1_data,omitempty"` Eth1DataVotes []*Eth1DataVote `protobuf:"bytes,4002,rep,name=eth1_data_votes,json=eth1DataVotes,proto3" json:"eth1_data_votes,omitempty"` + DepositIndex uint64 `protobuf:"varint,4003,opt,name=deposit_index,json=depositIndex,proto3" json:"deposit_index,omitempty"` GenesisTime uint64 `protobuf:"varint,5001,opt,name=genesis_time,json=genesisTime,proto3" json:"genesis_time,omitempty"` Fork *Fork `protobuf:"bytes,5002,opt,name=fork,proto3" json:"fork,omitempty"` Slot uint64 `protobuf:"varint,5003,opt,name=slot,proto3" json:"slot,omitempty"` @@ -301,6 +302,13 @@ func (m *BeaconState) GetEth1DataVotes() []*Eth1DataVote { return nil } +func (m *BeaconState) GetDepositIndex() uint64 { + if m != nil { + return m.DepositIndex + } + return 0 +} + func (m *BeaconState) GetGenesisTime() uint64 { if m != nil { return m.GenesisTime @@ -1467,7 +1475,7 @@ func (m *AttesterSlashing) GetSlashableAttestation_2() *SlashableAttestation { } type Deposit struct { - MerkleBranchHash32S [][]byte `protobuf:"bytes,1,rep,name=merkle_branch_hash32s,json=merkleBranchHash32s,proto3" json:"merkle_branch_hash32s,omitempty"` + MerkleProofHash32S [][]byte `protobuf:"bytes,1,rep,name=merkle_proof_hash32s,json=merkleProofHash32s,proto3" json:"merkle_proof_hash32s,omitempty"` MerkleTreeIndex uint64 `protobuf:"varint,2,opt,name=merkle_tree_index,json=merkleTreeIndex,proto3" json:"merkle_tree_index,omitempty"` DepositData []byte `protobuf:"bytes,3,opt,name=deposit_data,json=depositData,proto3" json:"deposit_data,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1508,9 +1516,9 @@ func (m *Deposit) XXX_DiscardUnknown() { var xxx_messageInfo_Deposit proto.InternalMessageInfo -func (m *Deposit) GetMerkleBranchHash32S() [][]byte { +func (m *Deposit) GetMerkleProofHash32S() [][]byte { if m != nil { - return m.MerkleBranchHash32S + return m.MerkleProofHash32S } return nil } @@ -1730,132 +1738,133 @@ func init() { func init() { proto.RegisterFile("proto/beacon/p2p/v1/types.proto", fileDescriptor_e719e7d82cfa7b0d) } var fileDescriptor_e719e7d82cfa7b0d = []byte{ - // 1999 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x59, 0x6f, 0x23, 0x59, - 0x15, 0xa6, 0xe2, 0xac, 0xc7, 0x8e, 0xed, 0xdc, 0x74, 0xe2, 0xa2, 0xb7, 0xa4, 0xab, 0x67, 0xe8, - 0x74, 0x33, 0xe3, 0x60, 0x8f, 0x44, 0x0b, 0x9a, 0x91, 0x88, 0x3b, 0x19, 0x26, 0xd0, 0x33, 0xd3, - 0x2a, 0x87, 0x6e, 0x1e, 0x80, 0xd2, 0xb5, 0xeb, 0xda, 0xae, 0x4e, 0xb9, 0x6e, 0xa9, 0xee, 0xb5, - 0xa7, 0x83, 0xf8, 0x03, 0x2c, 0xe2, 0x8d, 0x07, 0x78, 0x03, 0xf1, 0x27, 0xd8, 0x79, 0x41, 0xe2, - 0x05, 0x89, 0x75, 0x10, 0x12, 0x42, 0xa8, 0x9f, 0xd9, 0x7f, 0x01, 0xba, 0x4b, 0x2d, 0x5e, 0x2a, - 0xe9, 0x66, 0x78, 0xe1, 0xc9, 0xaa, 0x73, 0xbe, 0x73, 0xee, 0xb9, 0x67, 0xbf, 0x86, 0x9d, 0x30, - 0xa2, 0x9c, 0xee, 0x77, 0x08, 0xee, 0xd2, 0x60, 0x3f, 0x6c, 0x86, 0xfb, 0xe3, 0xc6, 0x3e, 0x3f, - 0x0b, 0x09, 0xab, 0x4b, 0x0e, 0xda, 0x26, 0x7c, 0x40, 0x22, 0x32, 0x1a, 0xd6, 0x15, 0xa6, 0x1e, - 0x36, 0xc3, 0xfa, 0xb8, 0x71, 0xf9, 0x8a, 0x12, 0xec, 0xd2, 0xe1, 0x90, 0x06, 0xfb, 0x43, 0xc2, - 0x18, 0xee, 0xc7, 0x42, 0xd6, 0x2f, 0xd7, 0xa1, 0xd8, 0x92, 0xf0, 0x36, 0xc7, 0x9c, 0xa0, 0x87, - 0x80,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2009 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x59, 0x6f, 0x1c, 0x59, + 0x15, 0xa6, 0xdc, 0x5e, 0x4f, 0xaf, 0xbe, 0x8e, 0xdd, 0x45, 0x36, 0x3b, 0x95, 0x0c, 0x71, 0xc2, + 0x4c, 0x9b, 0xee, 0x91, 0x88, 0x20, 0x8c, 0x84, 0x3b, 0xf6, 0x30, 0x86, 0xcc, 0x8c, 0x55, 0x6d, + 0x12, 0x1e, 0x80, 0xd2, 0xed, 0xae, 0xdb, 0xdd, 0x15, 0x57, 0xd7, 0x2d, 0xd5, 0xbd, 0xdd, 0x13, + 0x23, 0xfe, 0x00, 0x83, 0xc4, 0x1b, 0x0f, 0xf0, 0xc6, 0xf2, 0x27, 0xd8, 0x79, 0x41, 0xe2, 0x91, + 0x75, 0x10, 0x12, 0x42, 0x28, 0xcf, 0xec, 0xfc, 0x01, 0x74, 0x97, 0x5a, 0x7a, 0xb3, 0x13, 0x86, + 0x97, 0x79, 0x6a, 0xd5, 0x39, 0xdf, 0x39, 0xf7, 0x9c, 0x73, 0xcf, 0x76, 0x1b, 0xb6, 0xc3, 0x88, + 0x72, 0xba, 0xd7, 0x26, 0xb8, 0x43, 0x83, 0xbd, 0xb0, 0x11, 0xee, 0x8d, 0xea, 0x7b, 0xfc, 0x2c, + 0x24, 0xac, 0x26, 0x39, 0x68, 0x8b, 0xf0, 0x3e, 0x89, 0xc8, 0x70, 0x50, 0x53, 0x98, 0x5a, 0xd8, + 0x08, 0x6b, 0xa3, 0xfa, 0xe5, 0x2b, 0x4a, 0xb0, 0x43, 0x07, 0x03, 0x1a, 0xec, 0x0d, 0x08, 0x63, + 0xb8, 0x17, 0x0b, 0x59, 0xff, 0x29, 0x42, 0xbe, 0x29, 0xe1, 0x2d, 0x8e, 0x39, 0x41, 0xc7, 0x80, + 0x46, 0xd8, 0xf7, 0x5c, 0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0x8c, 0x53, 0xf7, 0x2c, 0x85, 0xe7, 0x24, 0xbc, 0xac, 0xe9, 0x09, 0xf4, 0x25, 0x28, 0x79, 0x41, + 0xc7, 0x1f, 0x0a, 0xa7, 0x1c, 0x19, 0xc2, 0x45, 0xe9, 0x50, 0x31, 0xa1, 0xb6, 0x44, 0x28, 0xff, + 0x68, 0x40, 0xfe, 0x03, 0xe2, 0xd1, 0x1e, 0x24, 0x1a, 0x88, 0xc3, 0xbc, 0x5e, 0x80, 0xf9, 0x30, + 0x22, 0xd2, 0xad, 0x82, 0x8d, 0x12, 0x56, 0x2b, 0xe6, 0x58, 0xdf, 0xcf, 0x41, 0x79, 0xc2, 0x50, + 0x84, 0x74, 0x3e, 0x19, 0x69, 0x3a, 0x89, 0x2b, 0x57, 0xd3, 0x5d, 0x65, 0x84, 0xfa, 0x40, 0xf7, + 0xc0, 0x54, 0x3e, 0x4f, 0xf7, 0x3a, 0x6d, 0xe1, 0x66, 0x3b, 0x53, 0xce, 0x49, 0x57, 0x40, 0xf7, + 0xe1, 0xb2, 0x4c, 0x1a, 0xa7, 0x4d, 0x87, 0x81, 0x8b, 0xa3, 0xb3, 0x31, 0x51, 0x65, 0x6e, 0x55, + 0x22, 0x9a, 0x1a, 0x30, 0x2e, 0x9c, 0x34, 0x7a, 0x55, 0xc0, 0x59, 0xe1, 0x25, 0x25, 0x9c, 0x20, + 0x64, 0xec, 0x53, 0xe1, 0x87, 0x49, 0x17, 0x49, 0x10, 0xe6, 0xb2, 0xbc, 0xc8, 0xe7, 0x18, 0x15, + 0xe5, 0x89, 0x51, 0x21, 0x4a, 0x66, 0x72, 0xac, 0xae, 0xcc, 0x9c, 0xaa, 0xaf, 0xc1, 0x95, 0x14, + 0x38, 0x1d, 0xac, 0x55, 0x69, 0xb4, 0x99, 0x40, 0x26, 0xe2, 0x65, 0x7d, 0x15, 0xae, 0x4e, 0xdc, + 0xd2, 0x7e, 0xe0, 0x3e, 0x48, 0x2e, 0xff, 0xfd, 0xa5, 0xe4, 0x36, 0xe4, 0x33, 0xf9, 0x25, 0x6f, + 0x78, 0xd5, 0x86, 0x34, 0xb5, 0xac, 0x6f, 0xe6, 0x60, 0x2d, 0x59, 0x80, 0xd1, 0x16, 0x2c, 0x87, + 0xc3, 0xf6, 0x29, 0x39, 0x93, 0xa7, 0x15, 0x6c, 0xfd, 0x25, 0x56, 0xa3, 0x77, 0x3c, 0xde, 0x77, + 0x23, 0xfc, 0x0e, 0xf6, 0x9d, 0x4e, 0x44, 0x5c, 0x12, 0x70, 0x0f, 0xfb, 0x2c, 0x76, 0x52, 0xa5, + 0xf8, 0x95, 0x14, 0xf4, 0x20, 0xc5, 0xe8, 0xdb, 0xb9, 0x03, 0x15, 0xdc, 0xe1, 0xde, 0x48, 0x15, + 0x87, 0x0a, 0xe8, 0x92, 0xea, 0x56, 0x29, 0x5d, 0x45, 0xf4, 0x1a, 0x00, 0x79, 0xea, 0x71, 0x0d, + 0x5a, 0x96, 0xa0, 0x35, 0x41, 0x51, 0xec, 0x3b, 0x50, 0xc9, 0x58, 0x93, 0xbd, 0x9a, 0x72, 0x4a, + 0x57, 0xd0, 0x9b, 0x50, 0x8c, 0xa7, 0xad, 0xc2, 0xad, 0xaa, 0xde, 0xad, 0x89, 0x0a, 0x74, 0x0c, + 0x05, 0x11, 0xb9, 0x21, 0x73, 0xba, 0x3e, 0xee, 0x31, 0x73, 0x6d, 0xc7, 0xd8, 0x2d, 0x35, 0x5e, + 0xb9, 0xf0, 0xbd, 0x50, 0x6b, 0x49, 0xa9, 0xd7, 0x85, 0x90, 0x9d, 0x67, 0xe9, 0x87, 0xf5, 0x69, + 0xc8, 0x67, 0x78, 0x28, 0x0f, 0x2b, 0x47, 0x6f, 0x1d, 0x9d, 0x1c, 0xed, 0x3f, 0xac, 0x7c, 0x08, + 0x21, 0x28, 0xa9, 0x8f, 0x93, 0xc3, 0x03, 0xe7, 0xf0, 0x0b, 0x47, 0x27, 0x15, 0x03, 0x55, 0xa0, + 0xf0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, 0x1c, 0xec, 0x31, 0x41, 0xf4, 0x18, 0x50, 0x18, 0xd1, 0x90, + 0x32, 0x12, 0xa9, 0xbd, 0xd4, 0x0b, 0x7a, 0xcc, 0x5c, 0x90, 0xea, 0x76, 0xe7, 0xae, 0x96, 0x5a, + 0xa2, 0xa5, 0x05, 0xec, 0xf5, 0x70, 0x82, 0x22, 0x15, 0xab, 0x83, 0xc6, 0x14, 0xe7, 0xce, 0x57, + 0xbc, 0xaf, 0x25, 0x52, 0xc5, 0x78, 0x82, 0xc2, 0xd0, 0x7d, 0x58, 0xd5, 0x9b, 0x17, 0x33, 0x17, + 0xa5, 0xba, 0xed, 0x79, 0xea, 0x0e, 0x14, 0xce, 0x4e, 0x04, 0xd0, 0x5b, 0x50, 0x1e, 0x51, 0x7f, + 0x18, 0x70, 0x31, 0x97, 0x44, 0x47, 0x61, 0xe6, 0x92, 0xd4, 0xf1, 0xd2, 0xdc, 0x6a, 0x8f, 0xe1, + 0x87, 0x4f, 0x3d, 0x6e, 0x97, 0x46, 0xd9, 0x4f, 0x66, 0x7d, 0xdb, 0x80, 0xc2, 0x41, 0xbc, 0x07, + 0x86, 0x43, 0x3e, 0xb7, 0x83, 0xd6, 0x60, 0x23, 0x8c, 0x28, 0xed, 0x3a, 0xb4, 0xeb, 0x84, 0x94, + 0x31, 0xc2, 0x92, 0x25, 0xac, 0x20, 0xc3, 0x47, 0xbb, 0x6f, 0x77, 0x8f, 0x13, 0xc6, 0xc5, 0x1d, + 0x37, 0x77, 0x61, 0xc7, 0xb5, 0x9e, 0x00, 0x52, 0x37, 0x85, 0x7d, 0xb1, 0x15, 0x10, 0xf7, 0x05, + 0x57, 0x80, 0xbb, 0xb0, 0x3e, 0x6f, 0xf6, 0x97, 0xdb, 0x13, 0x53, 0xec, 0x4f, 0x06, 0x5c, 0x92, + 0x77, 0x84, 0xdb, 0x3e, 0xc9, 0x6e, 0x54, 0x1f, 0x85, 0xf5, 0xb1, 0x6e, 0xe5, 0x89, 0x07,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d, 0x1d, 0xff, 0x87, 0x53, 0x1a, 0xd6, 0xbb, 0x06, 0xac, 0xe8, 0xec, 0x13, + 0xe1, 0x19, 0x90, 0xe8, 0xd4, 0x27, 0x8e, 0xea, 0x45, 0xf1, 0x33, 0xdf, 0x90, 0xaf, 0x7c, 0xa4, + 0x78, 0xc7, 0x82, 0x15, 0xbf, 0xf0, 0xef, 0xc2, 0xba, 0x96, 0xe0, 0x11, 0x21, 0x3a, 0xa9, 0x54, + 0x9e, 0x96, 0x15, 0xe3, 0x24, 0x22, 0x44, 0xa5, 0xd5, 0x0d, 0x88, 0x13, 0xdb, 0x49, 0x2a, 0xb3, + 0x60, 0xe7, 0xdd, 0xb4, 0x6c, 0x2c, 0x1f, 0x8a, 0x63, 0xfd, 0x74, 0xce, 0xae, 0x31, 0x63, 0xc3, + 0x59, 0x98, 0xb9, 0xe1, 0x8c, 0x4d, 0xdd, 0xdc, 0xc4, 0xd4, 0xb5, 0xbe, 0x04, 0xab, 0xc9, 0x9f, + 0x02, 0x35, 0xd8, 0x88, 0x8d, 0xcb, 0x76, 0x33, 0xd5, 0xa4, 0xd7, 0x35, 0x2b, 0xb3, 0x33, 0xdc, + 0x80, 0x82, 0xea, 0x7d, 0x63, 0x7b, 0x48, 0x5e, 0xd2, 0x74, 0xcb, 0xf3, 0xa1, 0x90, 0xfd, 0xdf, + 0x60, 0x7c, 0x83, 0x30, 0x5e, 0x78, 0x83, 0xb8, 0x06, 0x30, 0xa2, 0x9c, 0x38, 0x9d, 0x4c, 0x2f, + 0x58, 0x13, 0x94, 0x07, 0x82, 0xd0, 0x2c, 0xfc, 0xf2, 0xd9, 0x75, 0xe3, 0x57, 0xcf, 0xae, 0x1b, + 0x7f, 0x79, 0x76, 0xdd, 0x68, 0x2f, 0xcb, 0xff, 0xbf, 0x5f, 0xfd, 0x6f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xc4, 0x8d, 0x74, 0xea, 0x57, 0x17, 0x00, 0x00, } func (m *BeaconState) Marshal() (dAtA []byte, err error) { @@ -2146,6 +2155,15 @@ func (m *BeaconState) MarshalTo(dAtA []byte) (int, error) { i += n } } + if m.DepositIndex != 0 { + dAtA[i] = 0x98 + i++ + dAtA[i] = 0xfa + i++ + dAtA[i] = 0x1 + i++ + i = encodeVarintTypes(dAtA, i, uint64(m.DepositIndex)) + } if m.GenesisTime != 0 { dAtA[i] = 0xc8 i++ @@ -2996,8 +3014,8 @@ func (m *Deposit) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.MerkleBranchHash32S) > 0 { - for _, b := range m.MerkleBranchHash32S { + if len(m.MerkleProofHash32S) > 0 { + for _, b := range m.MerkleProofHash32S { dAtA[i] = 0xa i++ i = encodeVarintTypes(dAtA, i, uint64(len(b))) @@ -3259,6 +3277,9 @@ func (m *BeaconState) Size() (n int) { n += 3 + l + sovTypes(uint64(l)) } } + if m.DepositIndex != 0 { + n += 3 + sovTypes(uint64(m.DepositIndex)) + } if m.GenesisTime != 0 { n += 3 + sovTypes(uint64(m.GenesisTime)) } @@ -3723,8 +3744,8 @@ func (m *Deposit) Size() (n int) { } var l int _ = l - if len(m.MerkleBranchHash32S) > 0 { - for _, b := range m.MerkleBranchHash32S { + if len(m.MerkleProofHash32S) > 0 { + for _, b := range m.MerkleProofHash32S { l = len(b) n += 1 + l + sovTypes(uint64(l)) } @@ -4674,6 +4695,25 @@ func (m *BeaconState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4003: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositIndex", wireType) + } + m.DepositIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DepositIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 5001: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GenesisTime", wireType) @@ -7600,7 +7640,7 @@ func (m *Deposit) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MerkleBranchHash32S", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MerkleProofHash32S", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -7627,8 +7667,8 @@ func (m *Deposit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MerkleBranchHash32S = append(m.MerkleBranchHash32S, make([]byte, postIndex-iNdEx)) - copy(m.MerkleBranchHash32S[len(m.MerkleBranchHash32S)-1], dAtA[iNdEx:postIndex]) + m.MerkleProofHash32S = append(m.MerkleProofHash32S, make([]byte, postIndex-iNdEx)) + copy(m.MerkleProofHash32S[len(m.MerkleProofHash32S)-1], dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { diff --git a/proto/beacon/p2p/v1/types.proto b/proto/beacon/p2p/v1/types.proto index bf3f2df495..22c19c0995 100644 --- a/proto/beacon/p2p/v1/types.proto +++ b/proto/beacon/p2p/v1/types.proto @@ -41,6 +41,7 @@ message BeaconState { // Ethereum 1.0 chain data [4001-5000] Eth1Data latest_eth1_data = 4001; repeated Eth1DataVote eth1_data_votes = 4002; + uint64 deposit_index = 4003; // Miscellaneous [5001-6000] uint64 genesis_time = 5001; @@ -173,7 +174,7 @@ message AttesterSlashing { } message Deposit { - repeated bytes merkle_branch_hash32s = 1; + repeated bytes merkle_proof_hash32s = 1; uint64 merkle_tree_index = 2; bytes deposit_data = 3; } diff --git a/scripts/start-single-validator.sh b/scripts/start-single-validator.sh new file mode 100755 index 0000000000..1844070a67 --- /dev/null +++ b/scripts/start-single-validator.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +PRIVATE_KEY_PATH=~/priv + +DATA_PATH=/tmp/data + +PASSWORD="password" +PASSWORD_PATH=$DATA_PATH/password.txt + +UNAME=$(echo `uname` | tr '[A-Z]' '[a-z]') + +echo $PASSWORD > $PASSWORD_PATH + +INDEX=9 + +while test $# -gt 0; do + case "$1" in + --deposit-contract) + shift + DEPOSIT_CONTRACT=$1 + shift + ;; + --index) + shift + INDEX=$1 + shift + ;; + --privkey-path) + shift + PRIVATE_KEY_PATH=$1 + shift + ;; + *) + echo "$1 is not a recognized flag!" + exit 1; + ;; + esac +done + +KEYSTORE=$DATA_PATH/keystore$INDEX + +echo "Generating validator $INDEX" + +ACCOUNTCMD="bazel-bin/validator/${UNAME}_amd64_pure_stripped/validator accounts create --password $(cat $PASSWORD_PATH) --keystore-path $KEYSTORE" +$ACCOUNTCMD + + +echo "Sending TX for validator $INDEX" + +HTTPFLAG="--httpPath=https://goerli.infura.io/v3/be3fb7ed377c418087602876a40affa1" +PASSFLAG="--passwordFile=$PASSWORD_PATH" +CONTRACTFLAG="--depositContract=$DEPOSIT_CONTRACT" +PRIVFLAG="--privKey=$(cat $PRIVATE_KEY_PATH)" +KEYFLAG="--prysm-keystore=$KEYSTORE" +AMOUNTFLAG="--depositAmount=3200000" + +CMD="bazel-bin/contracts/deposit-contract/sendDepositTx/${UNAME}_amd64_stripped/sendDepositTx" + +DEPOSITCMD="$CMD $HTTPFLAG $PASSFLAG $CONTRACTFLAG $PRIVFLAG $KEYFLAG $AMOUNTFLAG" + +$DEPOSITCMD + +echo "Started validator $INDEX" + +CMD="bazel-bin/validator/${UNAME}_amd64_pure_stripped/validator --beacon-rpc-provider localhost:4545 --password $(cat $PASSWORD_PATH) --keystore-path $KEYSTORE" +$CMD diff --git a/shared/trieutil/sparse_merkle.go b/shared/trieutil/sparse_merkle.go index 771f123ec2..e459d2ff46 100644 --- a/shared/trieutil/sparse_merkle.go +++ b/shared/trieutil/sparse_merkle.go @@ -3,6 +3,7 @@ package trieutil import ( "bytes" "errors" + "fmt" "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/hashutil" @@ -86,8 +87,11 @@ func (m *MerkleTrie) Items() [][]byte { // index in the Merkle trie up to the root of the trie. func (m *MerkleTrie) MerkleProof(merkleIndex int) ([][]byte, error) { lastLevel := m.branches[len(m.branches)-1] - if merkleIndex < 0 || merkleIndex >= len(lastLevel) || bytes.Equal(lastLevel[merkleIndex], []byte{}) { - return nil, errors.New("merkle index out of range in trie") + if merkleIndex < 0 || merkleIndex >= len(lastLevel) { + return nil, fmt.Errorf("merkle index out of range in trie, max range: %d, received: %d", len(lastLevel), merkleIndex) + } + if bytes.Equal(lastLevel[merkleIndex], []byte{}) { + return nil, fmt.Errorf("merkle index out of range in trie, key is empty at index: %d", merkleIndex) } branchIndices := BranchIndices(merkleIndex, len(m.branches)) // We create a list of proof indices, which do not include the root so the length