diff --git a/cl/cltypes/beacon_block_test.go b/cl/cltypes/beacon_block_test.go index 6320f5d097e..92a84633ca9 100644 --- a/cl/cltypes/beacon_block_test.go +++ b/cl/cltypes/beacon_block_test.go @@ -56,7 +56,7 @@ func TestBeaconBody(t *testing.T) { BaseFee: big.NewInt(1), }, []types.Transaction{types.NewTransaction(1, [20]byte{}, uint256.NewInt(1), 5, uint256.NewInt(2), nil)}, nil, nil, types.Withdrawals{&types.Withdrawal{ Index: 69, - }}, nil /*requests*/) + }}) // Test BeaconBody body := &BeaconBody{ diff --git a/cl/phase1/execution_client/block_collector/block_collector.go b/cl/phase1/execution_client/block_collector/block_collector.go index 10f011afad1..2def8da0fd9 100644 --- a/cl/phase1/execution_client/block_collector/block_collector.go +++ b/cl/phase1/execution_client/block_collector/block_collector.go @@ -123,7 +123,7 @@ func (b *blockCollector) Flush(ctx context.Context) error { b.logger.Warn("bad blocks segment received", "err", err) return err } - blocksBatch = append(blocksBatch, types.NewBlockFromStorage(executionPayload.BlockHash, header, txs, nil, body.Withdrawals, body.Requests)) + blocksBatch = append(blocksBatch, types.NewBlockFromStorage(executionPayload.BlockHash, header, txs, nil, body.Withdrawals)) if len(blocksBatch) >= batchSize { b.logger.Info("[Caplin] Inserting blocks", "from", blocksBatch[0].NumberU64(), "to", blocksBatch[len(blocksBatch)-1].NumberU64()) if err := b.engine.InsertBlocks(ctx, blocksBatch, true); err != nil { diff --git a/cl/phase1/execution_client/execution_client_direct.go b/cl/phase1/execution_client/execution_client_direct.go index 0881d14c89e..de08eb62012 100644 --- a/cl/phase1/execution_client/execution_client_direct.go +++ b/cl/phase1/execution_client/execution_client_direct.go @@ -59,7 +59,7 @@ func (cc *ExecutionClientDirect) NewPayload(ctx context.Context, payload *cltype return PayloadStatusInvalidated, err } - if err := cc.chainRW.InsertBlockAndWait(ctx, types.NewBlockFromStorage(payload.BlockHash, header, txs, nil, body.Withdrawals, body.Requests)); err != nil { + if err := cc.chainRW.InsertBlockAndWait(ctx, types.NewBlockFromStorage(payload.BlockHash, header, txs, nil, body.Withdrawals)); err != nil { return PayloadStatusNone, err } diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 829a3edce23..4dd289d0de3 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -66,7 +66,6 @@ type stEnv struct { UncleHash libcommon.Hash `json:"uncleHash,omitempty"` Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` WithdrawalsHash *libcommon.Hash `json:"withdrawalsRoot,omitempty"` - Requests types.Requests `json:"requests,omitempty"` RequestsHash *libcommon.Hash `json:"requestsHash,omitempty"` } diff --git a/cmd/evm/internal/t8ntool/gen_stenv.go b/cmd/evm/internal/t8ntool/gen_stenv.go index 89de04a8e08..9be2ac8d853 100644 --- a/cmd/evm/internal/t8ntool/gen_stenv.go +++ b/cmd/evm/internal/t8ntool/gen_stenv.go @@ -34,7 +34,6 @@ func (s stEnv) MarshalJSON() ([]byte, error) { UncleHash common.Hash `json:"uncleHash,omitempty"` Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot,omitempty"` - Requests types.Requests `json:"requests,omitempty"` RequestsHash *common.Hash `json:"requestsHash,omitempty"` } var enc stEnv @@ -54,7 +53,6 @@ func (s stEnv) MarshalJSON() ([]byte, error) { enc.UncleHash = s.UncleHash enc.Withdrawals = s.Withdrawals enc.WithdrawalsHash = s.WithdrawalsHash - enc.Requests = s.Requests enc.RequestsHash = s.RequestsHash return json.Marshal(&enc) } @@ -78,7 +76,6 @@ func (s *stEnv) UnmarshalJSON(input []byte) error { UncleHash *common.Hash `json:"uncleHash,omitempty"` Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot,omitempty"` - Requests *types.Requests `json:"requests,omitempty"` RequestsHash *common.Hash `json:"requestsHash,omitempty"` } var dec stEnv @@ -137,9 +134,6 @@ func (s *stEnv) UnmarshalJSON(input []byte) error { if dec.WithdrawalsHash != nil { s.WithdrawalsHash = dec.WithdrawalsHash } - if dec.Requests != nil { - s.Requests = *dec.Requests - } if dec.RequestsHash != nil { s.RequestsHash = dec.RequestsHash } diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index 2d4856a0f30..d47a7af21c9 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -245,10 +245,6 @@ func Main(ctx *cli.Context) error { return NewError(ErrorVMConfig, errors.New("shanghai config but missing 'withdrawals' in env section")) } - if chainConfig.IsPrague(prestate.Env.Timestamp) && prestate.Env.Requests == nil { - return NewError(ErrorVMConfig, errors.New("prague config but missing 'requests' in env section")) - } - isMerged := chainConfig.TerminalTotalDifficulty != nil && chainConfig.TerminalTotalDifficulty.BitLen() == 0 env := prestate.Env if isMerged { @@ -287,7 +283,7 @@ func Main(ctx *cli.Context) error { ommerN.SetUint64(header.Number.Uint64() - ommer.Delta) ommerHeaders[i] = &types.Header{Coinbase: ommer.Address, Number: &ommerN} } - block := types.NewBlock(header, txs, ommerHeaders, nil /* receipts */, prestate.Env.Withdrawals, prestate.Env.Requests) + block := types.NewBlock(header, txs, ommerHeaders, nil /* receipts */, prestate.Env.Withdrawals) var hashError error getHash := func(num uint64) libcommon.Hash { diff --git a/cmd/state/commands/opcode_tracer.go b/cmd/state/commands/opcode_tracer.go index 3c2ebce25c3..c581ca7c36b 100644 --- a/cmd/state/commands/opcode_tracer.go +++ b/cmd/state/commands/opcode_tracer.go @@ -740,7 +740,7 @@ func runBlock(engine consensus.Engine, ibs *state.IntraBlockState, txnWriter sta if !vmConfig.ReadOnly { // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) tx := block.Transactions() - if _, _, _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, tx, block.Uncles(), receipts, block.Withdrawals(), block.Requests(), nil, nil, nil, logger); err != nil { + if _, _, _, err := engine.FinalizeAndAssemble(chainConfig, header, ibs, tx, block.Uncles(), receipts, block.Withdrawals(), nil, nil, nil, nil, logger); err != nil { return nil, fmt.Errorf("finalize of block %d failed: %w", block.NumberU64(), err) } diff --git a/cmd/state/exec3/historical_trace_worker.go b/cmd/state/exec3/historical_trace_worker.go index 1356fcf08ec..dcb4dd50276 100644 --- a/cmd/state/exec3/historical_trace_worker.go +++ b/cmd/state/exec3/historical_trace_worker.go @@ -461,7 +461,6 @@ func CustomTraceMapReduce(fromBlock, toBlock uint64, consumer TraceConsumer, ctx GetHashFn: getHashFn, EvmBlockContext: blockContext, Withdrawals: b.Withdrawals(), - Requests: b.Requests(), // use history reader instead of state reader to catch up to the tx where we left off HistoryExecution: true, diff --git a/consensus/aura/aura.go b/consensus/aura/aura.go index 976ed9895dd..84aa18ad471 100644 --- a/consensus/aura/aura.go +++ b/consensus/aura/aura.go @@ -852,7 +852,7 @@ func (c *AuRa) FinalizeAndAssemble(config *chain.Config, header *types.Header, s } // Assemble and return the final block for sealing - return types.NewBlockForAsembling(header, outTxs, uncles, outReceipts, withdrawals, requests), outTxs, outReceipts, nil + return types.NewBlockForAsembling(header, outTxs, uncles, outReceipts, withdrawals), outTxs, outReceipts, nil } // Authorize injects a private key into the consensus engine to mint new blocks diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 6492029b4fc..de82ea675ce 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -392,7 +392,7 @@ func (c *Clique) FinalizeAndAssemble(chainConfig *chain.Config, header *types.He txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, requests types.Requests, chain consensus.ChainReader, syscall consensus.SystemCall, call consensus.Call, logger log.Logger, ) (*types.Block, types.Transactions, types.Receipts, error) { // Assemble and return the final block for sealing - return types.NewBlockForAsembling(header, txs, nil, receipts, withdrawals, requests), txs, receipts, nil + return types.NewBlockForAsembling(header, txs, nil, receipts, withdrawals), txs, receipts, nil } // Authorize injects a private key into the consensus engine to mint new blocks diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index d18547d08f8..5aead0b343b 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -588,7 +588,7 @@ func (ethash *Ethash) FinalizeAndAssemble(chainConfig *chain.Config, header *typ return nil, nil, nil, err } // Header seems complete, assemble into a block and return - return types.NewBlock(header, outTxs, uncles, outR, withdrawals, requests), outTxs, outR, nil + return types.NewBlock(header, outTxs, uncles, outR, withdrawals), outTxs, outR, nil } // SealHash returns the hash of a block prior to it being sealed. diff --git a/consensus/merge/merge.go b/consensus/merge/merge.go index 76134fbba06..27b66f8be4b 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -229,16 +229,12 @@ func (s *Merge) FinalizeAndAssemble(config *chain.Config, header *types.Header, return s.eth1Engine.FinalizeAndAssemble(config, header, state, txs, uncles, receipts, withdrawals, requests, chain, syscall, call, logger) } header.RequestsHash = nil - outTxs, outReceipts, rs, err := s.Finalize(config, header, state, txs, uncles, receipts, withdrawals, requests, chain, syscall, logger) + outTxs, outReceipts, _, err := s.Finalize(config, header, state, txs, uncles, receipts, withdrawals, requests, chain, syscall, logger) + if err != nil { return nil, nil, nil, err } - if config.IsPrague(header.Time) { - if rs == nil { - rs = make(types.Requests, 0) - } - } - return types.NewBlockForAsembling(header, outTxs, uncles, outReceipts, withdrawals, rs), outTxs, outReceipts, nil + return types.NewBlockForAsembling(header, outTxs, uncles, outReceipts, withdrawals), outTxs, outReceipts, nil } func (s *Merge) SealHash(header *types.Header) (hash libcommon.Hash) { diff --git a/core/blockchain.go b/core/blockchain.go index 068de0b2c0e..a2d567cf943 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -170,7 +170,7 @@ func ExecuteBlockEphemerally( if !vmConfig.ReadOnly { txs := block.Transactions() - if _, _, _, err := FinalizeBlockExecution(engine, stateReader, block.Header(), txs, block.Uncles(), stateWriter, chainConfig, ibs, receipts, block.Withdrawals(), block.Requests(), chainReader, false, logger); err != nil { + if _, _, _, err := FinalizeBlockExecution(engine, stateReader, block.Header(), txs, block.Uncles(), stateWriter, chainConfig, ibs, receipts, block.Withdrawals(), nil, chainReader, false, logger); err != nil { return nil, err } } diff --git a/core/chain_makers.go b/core/chain_makers.go index c3e3894cad5..5ff9264dcf5 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -392,7 +392,7 @@ func GenerateChain(config *chain.Config, parent *types.Block, engine consensus.E b.header.Root = libcommon.BytesToHash(stateRoot) // Recreating block to make sure Root makes it into the header - block := types.NewBlockForAsembling(b.header, b.txs, b.uncles, b.receipts, nil /* withdrawals */, nil /*requests*/) + block := types.NewBlockForAsembling(b.header, b.txs, b.uncles, b.receipts, nil /* withdrawals */) return block, b.receipts, nil } return nil, nil, errors.New("no engine to generate blocks") diff --git a/core/genesis_write.go b/core/genesis_write.go index 180b705972c..6b0c061a3f4 100644 --- a/core/genesis_write.go +++ b/core/genesis_write.go @@ -486,10 +486,7 @@ func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*ty } } - var requests types.Requests if g.Config != nil && g.Config.IsPrague(g.Timestamp) { - requests = types.Requests{} - // TODO @somnathb1 - if later iterations and/or tests don't need this from genesis.json, remove the following if g.RequestsHash != nil { head.RequestsHash = g.RequestsHash @@ -596,7 +593,7 @@ func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*ty head.Root = root - return types.NewBlock(head, nil, nil, nil, withdrawals, requests), statedb, nil + return types.NewBlock(head, nil, nil, nil, withdrawals), statedb, nil } func sortedAllocKeys(m types.GenesisAlloc) []string { diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 8f6e1b13a71..1b7b2909ec4 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -30,6 +30,8 @@ import ( "github.com/gballet/go-verkle" + "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/dbg" "github.com/erigontech/erigon-lib/common/hexutility" @@ -37,7 +39,7 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/dbutils" "github.com/erigontech/erigon-lib/kv/rawdbv3" - "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon/core/types" "github.com/erigontech/erigon/ethdb/cbor" "github.com/erigontech/erigon/rlp" @@ -571,7 +573,6 @@ func ReadBody(db kv.Getter, hash common.Hash, number uint64) (*types.Body, uint6 body := new(types.Body) body.Uncles = bodyForStorage.Uncles body.Withdrawals = bodyForStorage.Withdrawals - body.Requests = bodyForStorage.Requests if bodyForStorage.TxCount < 2 { panic(fmt.Sprintf("block body hash too few txs amount: %d, %d", number, bodyForStorage.TxCount)) @@ -616,7 +617,6 @@ func WriteRawBody(db kv.RwTx, hash common.Hash, number uint64, body *types.RawBo TxCount: types.TxCountToTxAmount(len(body.Transactions)), /*system txs*/ Uncles: body.Uncles, Withdrawals: body.Withdrawals, - Requests: body.Requests, } if err = WriteBodyForStorage(db, hash, number, &data); err != nil { return false, fmt.Errorf("WriteBodyForStorage: %w", err) @@ -639,7 +639,6 @@ func WriteBody(db kv.RwTx, hash common.Hash, number uint64, body *types.Body) (e TxCount: types.TxCountToTxAmount(len(body.Transactions)), Uncles: body.Uncles, Withdrawals: body.Withdrawals, - Requests: body.Requests, } if err = WriteBodyForStorage(db, hash, number, &data); err != nil { return fmt.Errorf("failed to write body: %w", err) @@ -910,7 +909,7 @@ func ReadBlock(tx kv.Getter, hash common.Hash, number uint64) *types.Block { if body == nil { return nil } - return types.NewBlockFromStorage(hash, header, body.Transactions, body.Uncles, body.Withdrawals, body.Requests) + return types.NewBlockFromStorage(hash, header, body.Transactions, body.Uncles, body.Withdrawals) } // HasBlock - is more efficient than ReadBlock because doesn't read transactions. diff --git a/core/rawdb/accessors_chain_test.go b/core/rawdb/accessors_chain_test.go index 115667a89a8..7c03ef3d543 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -33,7 +33,6 @@ import ( "github.com/erigontech/erigon-lib/log/v3" libcommon "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/common/hexutility" // "github.com/erigontech/erigon-lib/common/hexutility" "github.com/erigontech/erigon-lib/kv/memdb" @@ -588,33 +587,6 @@ func TestBlockWithdrawalsStorage(t *testing.T) { withdrawals = append(withdrawals, &w) withdrawals = append(withdrawals, &w2) - pk := [48]byte{} - copy(pk[:], libcommon.Hex2Bytes("3d1291c96ad36914068b56d93974c1b1d5afcb3fcd37b2ac4b144afd3f6fec5b")) - sig := [96]byte{} - copy(sig[:], libcommon.Hex2Bytes("20a0a807c717055ecb60dc9d5071fbd336f7f238d61a288173de20f33f79ebf4")) - r1 := types.DepositRequest{ - Pubkey: pk, - WithdrawalCredentials: libcommon.Hash(hexutility.Hex2Bytes("15095f80cde9763665d2eee3f8dfffc4a4405544c6fece33130e6e98809c4b98")), - Amount: 12324, - Signature: sig, - Index: 0, - } - pk2 := [48]byte{} - copy(pk2[:], libcommon.Hex2Bytes("d40ffb510bfc52b058d5e934026ce3eddaf0a4b1703920f03b32b97de2196a93")) - sig2 := [96]byte{} - copy(sig2[:], libcommon.Hex2Bytes("dc40cf2c33c6fb17e11e3ffe455063f1bf2280a3b08563f8b33aa359a16a383c")) - r2 := types.DepositRequest{ - Pubkey: pk2, - WithdrawalCredentials: libcommon.Hash(hexutility.Hex2Bytes("d73d9332eb1229e58aa7e33e9a5079d9474f68f747544551461bf3ff9f7ccd64")), - Amount: 12324, - Signature: sig2, - Index: 0, - } - deposits := make(types.DepositRequests, 0) - deposits = append(deposits, &r1) - deposits = append(deposits, &r2) - var reqs types.Requests - reqs = deposits.Requests() // Create a test block to move around the database and make sure it's really new block := types.NewBlockWithHeader(&types.Header{ Number: big.NewInt(1), @@ -634,7 +606,7 @@ func TestBlockWithdrawalsStorage(t *testing.T) { } // Write withdrawals to block - wBlock := types.NewBlockFromStorage(block.Hash(), block.Header(), block.Transactions(), block.Uncles(), withdrawals, reqs) + wBlock := types.NewBlockFromStorage(block.Hash(), block.Header(), block.Transactions(), block.Uncles(), withdrawals) if err := rawdb.WriteHeader(tx, wBlock.HeaderNoCopy()); err != nil { t.Fatalf("Could not write body: %v", err) } @@ -688,28 +660,6 @@ func TestBlockWithdrawalsStorage(t *testing.T) { require.Equal(libcommon.Address{0: 0xff}, rw2.Address) require.Equal(uint64(1001), rw2.Amount) - readRequests := entry.Requests - require.True(len(entry.Requests) == 2) - rd1 := readRequests[0] - rd2 := readRequests[1] - require.True(rd1.RequestType() == types.DepositRequestType) - require.True(rd2.RequestType() == types.DepositRequestType) - - readDeposits := readRequests.Deposits() - d1 := readDeposits[0] - d2 := readDeposits[1] - require.Equal(d1.Pubkey, r1.Pubkey) - require.Equal(d1.Amount, r1.Amount) - require.Equal(d1.Signature, r1.Signature) - require.Equal(d1.WithdrawalCredentials, r1.WithdrawalCredentials) - require.Equal(d1.Index, r1.Index) - - require.Equal(d2.Pubkey, r2.Pubkey) - require.Equal(d2.Amount, r2.Amount) - require.Equal(d2.Signature, r2.Signature) - require.Equal(d2.WithdrawalCredentials, r2.WithdrawalCredentials) - require.Equal(d2.Index, r2.Index) - // Delete the block and verify the execution if err := rawdb.TruncateBlocks(context.Background(), tx, block.NumberU64()); err != nil { t.Fatal(err) diff --git a/core/rawdb/accessors_indexes_test.go b/core/rawdb/accessors_indexes_test.go index 2f0291a4562..8dd02b14a13 100644 --- a/core/rawdb/accessors_indexes_test.go +++ b/core/rawdb/accessors_indexes_test.go @@ -67,7 +67,7 @@ func TestLookupStorage(t *testing.T) { tx3 := types.NewTransaction(3, libcommon.BytesToAddress([]byte{0x33}), uint256.NewInt(333), 3333, uint256.NewInt(33333), []byte{0x33, 0x33, 0x33}) txs := []types.Transaction{tx1, tx2, tx3} - block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, nil, nil, nil /*requests*/) + block := types.NewBlock(&types.Header{Number: big.NewInt(314)}, txs, nil, nil, nil) // Check that no transactions entries are in a pristine database for i, txn := range txs { diff --git a/core/types/block.go b/core/types/block.go index e2e1753deb5..c58086c5d1e 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -652,7 +652,6 @@ type Body struct { Transactions []Transaction Uncles []*Header Withdrawals []*Withdrawal - Requests Requests } // RawBody is semi-parsed variant of Body, where transactions are still unparsed RLP strings @@ -662,7 +661,6 @@ type RawBody struct { Transactions [][]byte Uncles []*Header Withdrawals []*Withdrawal - Requests Requests } // BaseTxnID represents internal auto-incremented transaction number in block, may be different across the nodes @@ -705,7 +703,6 @@ type BodyForStorage struct { TxCount uint32 Uncles []*Header Withdrawals []*Withdrawal - Requests Requests } // Alternative representation of the Block. @@ -718,7 +715,6 @@ func (r RawBlock) AsBlock() (*Block, error) { b := &Block{header: r.Header} b.uncles = r.Body.Uncles b.withdrawals = r.Body.Withdrawals - b.requests = r.Body.Requests txs := make([]Transaction, len(r.Body.Transactions)) for i, txn := range r.Body.Transactions { @@ -738,7 +734,6 @@ type Block struct { uncles []*Header transactions Transactions withdrawals []*Withdrawal - requests Requests // caches size atomic.Uint64 @@ -766,11 +761,11 @@ func (b *Body) SendersFromTxs() []libcommon.Address { } func (rb RawBody) EncodingSize() int { - payloadSize, _, _, _, _ := rb.payloadSize() + payloadSize, _, _, _ := rb.payloadSize() return payloadSize } -func (rb RawBody) payloadSize() (payloadSize, txsLen, unclesLen, withdrawalsLen, requestsLen int) { +func (rb RawBody) payloadSize() (payloadSize, txsLen, unclesLen, withdrawalsLen int) { // size of Transactions for _, txn := range rb.Transactions { txsLen += len(txn) @@ -787,17 +782,11 @@ func (rb RawBody) payloadSize() (payloadSize, txsLen, unclesLen, withdrawalsLen, payloadSize += rlp2.ListPrefixLen(withdrawalsLen) + withdrawalsLen } - // size of requests - if rb.Requests != nil { - requestsLen = rb.Requests.EncodingSize() - payloadSize += rlp2.ListPrefixLen(requestsLen) + requestsLen - } - - return payloadSize, txsLen, unclesLen, withdrawalsLen, requestsLen + return payloadSize, txsLen, unclesLen, withdrawalsLen } func (rb RawBody) EncodeRLP(w io.Writer) error { - payloadSize, txsLen, unclesLen, withdrawalsLen, _ /* requestsLen */ := rb.payloadSize() + payloadSize, txsLen, unclesLen, withdrawalsLen := rb.payloadSize() var b [33]byte // prefix if err := EncodeStructSizePrefix(payloadSize, w, b[:]); err != nil { @@ -822,10 +811,6 @@ func (rb RawBody) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if rb.Requests != nil { - rb.Requests.EncodeRLP(w) - } return nil } @@ -861,15 +846,11 @@ func (rb *RawBody) DecodeRLP(s *rlp.Stream) error { if err := decodeWithdrawals(&rb.Withdrawals, s); err != nil { return err } - // decode Requests - if err := decodeRequests(&rb.Requests, s); err != nil { - return err - } return s.ListEnd() } -func (bfs BodyForStorage) payloadSize() (payloadSize, unclesLen, withdrawalsLen, requestsLen int) { +func (bfs BodyForStorage) payloadSize() (payloadSize, unclesLen, withdrawalsLen int) { baseTxnIDLen := 1 + rlp.IntLenExcludingHead(bfs.BaseTxnID.U64()) txCountLen := 1 + rlp.IntLenExcludingHead(uint64(bfs.TxCount)) @@ -886,17 +867,11 @@ func (bfs BodyForStorage) payloadSize() (payloadSize, unclesLen, withdrawalsLen, payloadSize += rlp2.ListPrefixLen(withdrawalsLen) + withdrawalsLen } - // size of Requests - if bfs.Requests != nil { - requestsLen = bfs.Requests.EncodingSize() - payloadSize += rlp2.ListPrefixLen(requestsLen) + requestsLen - } - - return payloadSize, unclesLen, withdrawalsLen, requestsLen + return payloadSize, unclesLen, withdrawalsLen } func (bfs BodyForStorage) EncodeRLP(w io.Writer) error { - payloadSize, unclesLen, withdrawalsLen, _ /* requestsLen */ := bfs.payloadSize() + payloadSize, unclesLen, withdrawalsLen := bfs.payloadSize() var b [33]byte // prefix @@ -925,10 +900,7 @@ func (bfs BodyForStorage) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if bfs.Requests != nil { - bfs.Requests.EncodeRLP(w) - } + return nil } @@ -955,19 +927,15 @@ func (bfs *BodyForStorage) DecodeRLP(s *rlp.Stream) error { if err := decodeWithdrawals(&bfs.Withdrawals, s); err != nil { return err } - // decode Requests - if err := decodeRequests(&bfs.Requests, s); err != nil { - return err - } return s.ListEnd() } func (bb Body) EncodingSize() int { - payloadSize, _, _, _, _ := bb.payloadSize() + payloadSize, _, _, _ := bb.payloadSize() return payloadSize } -func (bb Body) payloadSize() (payloadSize int, txsLen, unclesLen, withdrawalsLen, requestsLen int) { +func (bb Body) payloadSize() (payloadSize int, txsLen, unclesLen, withdrawalsLen int) { // size of Transactions txsLen += encodingSizeGeneric(bb.Transactions) payloadSize += rlp2.ListPrefixLen(txsLen) + txsLen @@ -982,18 +950,11 @@ func (bb Body) payloadSize() (payloadSize int, txsLen, unclesLen, withdrawalsLen payloadSize += rlp2.ListPrefixLen(withdrawalsLen) + withdrawalsLen } - // size of Requests - if bb.Requests != nil { - requestsLen = bb.Requests.EncodingSize() - payloadSize += rlp2.ListPrefixLen(requestsLen) + requestsLen - - } - - return payloadSize, txsLen, unclesLen, withdrawalsLen, requestsLen + return payloadSize, txsLen, unclesLen, withdrawalsLen } func (bb Body) EncodeRLP(w io.Writer) error { - payloadSize, txsLen, unclesLen, withdrawalsLen /* requestsLen */, _ := bb.payloadSize() + payloadSize, txsLen, unclesLen, withdrawalsLen := bb.payloadSize() var b [33]byte // prefix if err := EncodeStructSizePrefix(payloadSize, w, b[:]); err != nil { @@ -1013,10 +974,6 @@ func (bb Body) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if bb.Requests != nil { - bb.Requests.EncodeRLP(w) - } return nil } @@ -1038,10 +995,6 @@ func (bb *Body) DecodeRLP(s *rlp.Stream) error { if err := decodeWithdrawals(&bb.Withdrawals, s); err != nil { return err } - // decode Requests - if err := decodeRequests(&bb.Requests, s); err != nil { - return err - } return s.ListEnd() } @@ -1052,7 +1005,7 @@ func (bb *Body) DecodeRLP(s *rlp.Stream) error { // The values of TxHash, UncleHash, ReceiptHash, Bloom, and WithdrawalHash // in the header are ignored and set to the values derived from // the given txs, uncles, receipts, and withdrawals. -func NewBlock(header *Header, txs []Transaction, uncles []*Header, receipts []*Receipt, withdrawals []*Withdrawal, requests Requests) *Block { +func NewBlock(header *Header, txs []Transaction, uncles []*Header, receipts []*Receipt, withdrawals []*Withdrawal) *Block { b := &Block{header: CopyHeader(header)} // TODO: panic if len(txs) != len(receipts) @@ -1098,38 +1051,22 @@ func NewBlock(header *Header, txs []Transaction, uncles []*Header, receipts []*R } b.header.ParentBeaconBlockRoot = header.ParentBeaconBlockRoot - - if requests == nil { - b.header.RequestsHash = nil - } else if len(requests) == 0 { - b.header.RequestsHash = &EmptyRootHash - b.requests = make(Requests, len(requests)) - } else { - h := DeriveSha(requests) - b.header.RequestsHash = &h - b.requests = make(Requests, len(requests)) - for i, r := range requests { - rCopy := r.copy() - b.requests[i] = rCopy - } - } - b.header.mutable = false //Force immutability of block and header. Use `NewBlockForAsembling` if you need mutable block return b } // NewBlockForAsembling - creating new block - which allow mutation of fileds. Use it for block-assembly -func NewBlockForAsembling(header *Header, txs []Transaction, uncles []*Header, receipts []*Receipt, withdrawals []*Withdrawal, requests Requests) *Block { - b := NewBlock(header, txs, uncles, receipts, withdrawals, requests) +func NewBlockForAsembling(header *Header, txs []Transaction, uncles []*Header, receipts []*Receipt, withdrawals []*Withdrawal) *Block { + b := NewBlock(header, txs, uncles, receipts, withdrawals) b.header.mutable = true return b } // NewBlockFromStorage like NewBlock but used to create Block object when read it from DB // in this case no reason to copy parts, or re-calculate headers fields - they are all stored in DB -func NewBlockFromStorage(hash libcommon.Hash, header *Header, txs []Transaction, uncles []*Header, withdrawals []*Withdrawal, requests Requests) *Block { +func NewBlockFromStorage(hash libcommon.Hash, header *Header, txs []Transaction, uncles []*Header, withdrawals []*Withdrawal) *Block { header.hash.Store(&hash) - b := &Block{header: header, transactions: txs, uncles: uncles, withdrawals: withdrawals, requests: requests} + b := &Block{header: header, transactions: txs, uncles: uncles, withdrawals: withdrawals} return b } @@ -1148,7 +1085,6 @@ func NewBlockFromNetwork(header *Header, body *Body) *Block { transactions: body.Transactions, uncles: body.Uncles, withdrawals: body.Withdrawals, - requests: body.Requests, } } @@ -1230,15 +1166,11 @@ func (bb *Block) DecodeRLP(s *rlp.Stream) error { if err := decodeWithdrawals(&bb.withdrawals, s); err != nil { return err } - // decode Requests - if err := decodeRequests(&bb.requests, s); err != nil { - return err - } return s.ListEnd() } -func (bb *Block) payloadSize() (payloadSize int, txsLen, unclesLen, withdrawalsLen, requestsLen int) { +func (bb *Block) payloadSize() (payloadSize int, txsLen, unclesLen, withdrawalsLen int) { // size of Header headerLen := bb.header.EncodingSize() payloadSize += rlp2.ListPrefixLen(headerLen) + headerLen @@ -1257,24 +1189,17 @@ func (bb *Block) payloadSize() (payloadSize int, txsLen, unclesLen, withdrawalsL payloadSize += rlp2.ListPrefixLen(withdrawalsLen) + withdrawalsLen } - // size of Requests - if bb.requests != nil { - requestsLen = bb.requests.EncodingSize() - payloadSize += rlp2.ListPrefixLen(requestsLen) + requestsLen - - } - - return payloadSize, txsLen, unclesLen, withdrawalsLen, requestsLen + return payloadSize, txsLen, unclesLen, withdrawalsLen } func (bb *Block) EncodingSize() int { - payloadSize, _, _, _, _ := bb.payloadSize() + payloadSize, _, _, _ := bb.payloadSize() return payloadSize } // EncodeRLP serializes b into the Ethereum RLP block format. func (bb *Block) EncodeRLP(w io.Writer) error { - payloadSize, txsLen, unclesLen, withdrawalsLen, _ /* requestsLen */ := bb.payloadSize() + payloadSize, txsLen, unclesLen, withdrawalsLen := bb.payloadSize() var b [33]byte // prefix if err := EncodeStructSizePrefix(payloadSize, w, b[:]); err != nil { @@ -1298,10 +1223,7 @@ func (bb *Block) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if bb.requests != nil { - bb.requests.EncodeRLP(w) - } + return nil } @@ -1345,7 +1267,6 @@ func (b *Block) WithdrawalsHash() *libcommon.Hash { return b.header.Withdr func (b *Block) Withdrawals() Withdrawals { return b.withdrawals } func (b *Block) ParentBeaconBlockRoot() *libcommon.Hash { return b.header.ParentBeaconBlockRoot } func (b *Block) RequestsHash() *libcommon.Hash { return b.header.RequestsHash } -func (b *Block) Requests() Requests { return b.requests } // Header returns a deep-copy of the entire block header using CopyHeader() func (b *Block) Header() *Header { return CopyHeader(b.header) } @@ -1353,7 +1274,7 @@ func (b *Block) HeaderNoCopy() *Header { return b.header } // Body returns the non-header content of the block. func (b *Block) Body() *Body { - bd := &Body{Transactions: b.transactions, Uncles: b.uncles, Withdrawals: b.withdrawals, Requests: b.requests} + bd := &Body{Transactions: b.transactions, Uncles: b.uncles, Withdrawals: b.withdrawals} bd.SendersFromTxs() return bd } @@ -1369,7 +1290,7 @@ func (b *Block) SendersToTxs(senders []libcommon.Address) { // RawBody creates a RawBody based on the block. It is not very efficient, so // will probably be removed in favour of RawBlock. Also it panics func (b *Block) RawBody() *RawBody { - br := &RawBody{Transactions: make([][]byte, len(b.transactions)), Uncles: b.uncles, Withdrawals: b.withdrawals, Requests: b.requests} + br := &RawBody{Transactions: make([][]byte, len(b.transactions)), Uncles: b.uncles, Withdrawals: b.withdrawals} for i, txn := range b.transactions { var err error br.Transactions[i], err = rlp.EncodeToBytes(txn) @@ -1382,7 +1303,7 @@ func (b *Block) RawBody() *RawBody { // RawBody creates a RawBody based on the body. func (b *Body) RawBody() *RawBody { - br := &RawBody{Transactions: make([][]byte, len(b.Transactions)), Uncles: b.Uncles, Withdrawals: b.Withdrawals, Requests: b.Requests} + br := &RawBody{Transactions: make([][]byte, len(b.Transactions)), Uncles: b.Uncles, Withdrawals: b.Withdrawals} for i, txn := range b.Transactions { var err error br.Transactions[i], err = rlp.EncodeToBytes(txn) @@ -1411,7 +1332,7 @@ func (b *Block) SanityCheck() error { return b.header.SanityCheck() } -// HashCheck checks that transactions, receipts, uncles, withdrawals, and requests hashes are correct. +// HashCheck checks that transactions, receipts, uncles, and withdrawals hashes are correct. func (b *Block) HashCheck(fullCheck bool) error { if hash := DeriveSha(b.Transactions()); hash != b.TxHash() { return fmt.Errorf("block has invalid transaction hash: have %x, exp: %x", hash, b.TxHash()) @@ -1448,17 +1369,6 @@ func (b *Block) HashCheck(fullCheck bool) error { return fmt.Errorf("block has invalid withdrawals hash: have %x, exp: %x", hash, b.WithdrawalsHash()) } - if b.RequestsHash() == nil { - if b.Requests() != nil { - return errors.New("header missing RequestsHash") - } - return nil - } - - if hash := DeriveSha(b.Requests()); hash != *b.RequestsHash() { - return fmt.Errorf("block has invalid requests root: have %x, exp: %x", hash, b.RequestsHash()) - } - return nil } @@ -1516,20 +1426,11 @@ func (b *Block) Copy() *Block { } } - var requests []Request - if b.requests != nil { - requests = make([]Request, 0, len(b.requests)) - for _, request := range b.requests { - requests = append(requests, request.copy()) - } - } - newB := &Block{ header: CopyHeader(b.header), uncles: uncles, transactions: CopyTxs(b.transactions), withdrawals: withdrawals, - requests: requests, } szCopy := b.size.Load() newB.size.Store(szCopy) @@ -1546,7 +1447,6 @@ func (b *Block) WithSeal(header *Header) *Block { transactions: b.transactions, uncles: b.uncles, withdrawals: b.withdrawals, - requests: b.requests, } } @@ -1652,11 +1552,6 @@ func decodeWithdrawals(appendList *[]*Withdrawal, s *rlp.Stream) error { return checkErrListEnd(s, err) } -func decodeRequests(r *Requests, s *rlp.Stream) error { - err := r.DecodeRLP(s) - return checkErrListEnd(s, err) -} - func checkErrListEnd(s *rlp.Stream, err error) error { if !errors.Is(err, rlp.EOL) { return err diff --git a/core/types/block_test.go b/core/types/block_test.go index 64febc946db..39fce61b0d4 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -363,7 +363,7 @@ func makeBenchBlock() *Block { Extra: []byte("benchmark uncle"), } } - return NewBlock(header, txs, uncles, receipts, nil /* withdrawals */, nil /*requests*/) + return NewBlock(header, txs, uncles, receipts, nil /* withdrawals */) } func TestCanEncodeAndDecodeRawBody(t *testing.T) { @@ -512,7 +512,7 @@ func TestWithdrawalsEncoding(t *testing.T) { Amount: 5_000_000_000, } - block := NewBlock(&header, nil, nil, nil, withdrawals, nil /*requests*/) + block := NewBlock(&header, nil, nil, nil, withdrawals) _ = block.Size() encoded, err := rlp.EncodeToBytes(block) @@ -524,7 +524,7 @@ func TestWithdrawalsEncoding(t *testing.T) { assert.Equal(t, block, &decoded) // Now test with empty withdrawals - block2 := NewBlock(&header, nil, nil, nil, []*Withdrawal{}, nil /*requests*/) + block2 := NewBlock(&header, nil, nil, nil, []*Withdrawal{}) _ = block2.Size() encoded2, err := rlp.EncodeToBytes(block2) diff --git a/core/types/encdec_test.go b/core/types/encdec_test.go index 9415e9a4bd3..3412f3277f6 100644 --- a/core/types/encdec_test.go +++ b/core/types/encdec_test.go @@ -28,7 +28,6 @@ import ( "github.com/holiman/uint256" libcommon "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/common/hexutility" types2 "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/rlp" ) @@ -87,12 +86,6 @@ func (tr *TRand) RandWithdrawal() *Withdrawal { } } -func (tr *TRand) RandWithdrawalRequest() *WithdrawalRequest { - return &WithdrawalRequest{ - RequestData: [WithdrawalRequestDataLen]byte(tr.RandBytes(WithdrawalRequestDataLen)), - } -} - func (tr *TRand) RandDepositRequest() *DepositRequest { return &DepositRequest{ Pubkey: [48]byte(tr.RandBytes(48)), @@ -103,20 +96,10 @@ func (tr *TRand) RandDepositRequest() *DepositRequest { } } -func (tr *TRand) RandConsolidationRequest() *ConsolidationRequest { - return &ConsolidationRequest{ - RequestData: [ConsolidationRequestDataLen]byte(tr.RandBytes(ConsolidationRequestDataLen)), - } -} - -func (tr *TRand) RandRequest() Request { +func (tr *TRand) RandRequest() *DepositRequest { switch tr.rnd.Intn(3) { case 0: return tr.RandDepositRequest() - case 1: - return tr.RandWithdrawalRequest() - case 2: - return tr.RandConsolidationRequest() default: return nil // unreachable code } @@ -303,7 +286,6 @@ func (tr *TRand) RandRawBody() *RawBody { Transactions: tr.RandRawTransactions(tr.RandIntInRange(1, 6)), Uncles: tr.RandHeaders(tr.RandIntInRange(1, 6)), Withdrawals: tr.RandWithdrawals(tr.RandIntInRange(1, 6)), - Requests: tr.RandRequests(tr.RandIntInRange(1, 6)), } } @@ -330,7 +312,6 @@ func (tr *TRand) RandBody() *Body { Transactions: tr.RandTransactions(tr.RandIntInRange(1, 6)), Uncles: tr.RandHeaders(tr.RandIntInRange(1, 6)), Withdrawals: tr.RandWithdrawals(tr.RandIntInRange(1, 6)), - Requests: tr.RandRequests(tr.RandIntInRange(1, 6)), } } @@ -409,47 +390,13 @@ func compareDeposits(t *testing.T, a, b *DepositRequest) { check(t, "Deposit.Index", a.Index, b.Index) } -func compareWithdrawalRequests(t *testing.T, a, b *WithdrawalRequest) { - check(t, "WithdrawalRequest.Amount", a.RequestData, b.RequestData) -} - -func compareConsolidationRequests(t *testing.T, a, b *ConsolidationRequest) { - check(t, "ConsolidationRequest.RequestData", a.RequestData, b.RequestData) -} - -func checkRequests(t *testing.T, a, b Request) { +func checkRequests(t *testing.T, a, b DepositRequest) { if a.RequestType() != b.RequestType() { t.Errorf("request type mismatch: request-a: %v, request-b: %v", a.RequestType(), b.RequestType()) } - switch a.RequestType() { - case DepositRequestType: - a, aok := a.(*DepositRequest) - b, bok := b.(*DepositRequest) - if aok && bok { - compareDeposits(t, a, b) - } else { - t.Errorf("type assertion failed: %v %v %v %v", a.RequestType(), aok, b.RequestType(), bok) - } - case WithdrawalRequestType: - a, aok := a.(*WithdrawalRequest) - b, bok := b.(*WithdrawalRequest) - if aok && bok { - compareWithdrawalRequests(t, a, b) - } else { - t.Errorf("type assertion failed: %v %v %v %v", a.RequestType(), aok, b.RequestType(), bok) - } - case ConsolidationRequestType: - a, aok := a.(*ConsolidationRequest) - b, bok := b.(*ConsolidationRequest) - if aok && bok { - compareConsolidationRequests(t, a, b) - } else { - t.Errorf("type assertion failed: %v %v %v %v", a.RequestType(), aok, b.RequestType(), bok) - } - default: - t.Errorf("unknown request type: %v", a.RequestType()) - } + compareDeposits(t, &a, &b) + } func compareHeaders(t *testing.T, a, b []*Header) error { @@ -476,15 +423,15 @@ func compareWithdrawals(t *testing.T, a, b []*Withdrawal) error { return nil } -func compareRequests(t *testing.T, a, b Requests) error { - arLen, brLen := len(a), len(b) - if arLen != brLen { - return fmt.Errorf("requests len mismatch: expected: %v, got: %v", arLen, brLen) - } +func compareRequests(t *testing.T, a, b DepositRequests) error { + // arLen, brLen := len(a), len(b) + // if arLen != brLen { + // return fmt.Errorf("requests len mismatch: expected: %v, got: %v", arLen, brLen) + // } - for i := 0; i < arLen; i++ { - checkRequests(t, a[i], b[i]) - } + // for i := 0; i < arLen; i++ { + // checkRequests(t, &a[i], &b[i]) + // } return nil } @@ -503,8 +450,6 @@ func compareRawBodies(t *testing.T, a, b *RawBody) error { compareHeaders(t, a.Uncles, b.Uncles) compareWithdrawals(t, a.Withdrawals, b.Withdrawals) - compareRequests(t, a.Requests, b.Requests) - return nil } @@ -521,7 +466,6 @@ func compareBodies(t *testing.T, a, b *Body) error { compareHeaders(t, a.Uncles, b.Uncles) compareWithdrawals(t, a.Withdrawals, b.Withdrawals) - compareRequests(t, a.Requests, b.Requests) return nil } @@ -572,58 +516,3 @@ func TestBodyEncodeDecodeRLP(t *testing.T) { } } } - -func TestDepositEncodeDecode(t *testing.T) { - tr := NewTRand() - var buf bytes.Buffer - for i := 0; i < RUNS; i++ { - a := tr.RandDepositRequest() - buf.Reset() - if err := a.EncodeRLP(&buf); err != nil { - t.Errorf("error: deposit.EncodeRLP(): %v", err) - } - b := new(DepositRequest) - if err := b.DecodeRLP(buf.Bytes()); err != nil { - t.Errorf("error: Deposit.DecodeRLP(): %v", err) - } - compareDeposits(t, a, b) - } -} - -func TestConsolidationReqsEncodeDecode(t *testing.T) { - tr := NewTRand() - var buf bytes.Buffer - for i := 0; i < RUNS; i++ { - a := tr.RandConsolidationRequest() - buf.Reset() - if err := a.EncodeRLP(&buf); err != nil { - t.Errorf("error: deposit.EncodeRLP(): %v", err) - } - b := new(ConsolidationRequest) - if err := b.DecodeRLP(buf.Bytes()); err != nil { - t.Errorf("error: Deposit.DecodeRLP(): %v", err) - } - compareConsolidationRequests(t, a, b) - } -} - -func TestWithdrawalReqsEncodeDecode(t *testing.T) { - wx1 := WithdrawalRequest{ - RequestData: [WithdrawalRequestDataLen]byte(hexutility.MustDecodeHex("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fefefefefefefefe")), - } - wx2 := WithdrawalRequest{ - RequestData: [WithdrawalRequestDataLen]byte(hexutility.MustDecodeHex("0x8a0a19589531694250d570040a0c4b74576919b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fefefefefefefefe")), - } - - var wx3, wx4 WithdrawalRequest - var buf1, buf2 bytes.Buffer - wx1.EncodeRLP(&buf1) - wx2.EncodeRLP(&buf2) - - wx3.DecodeRLP(buf1.Bytes()) - wx4.DecodeRLP(buf2.Bytes()) - - if wx1.RequestData != wx3.RequestData || wx2.RequestData != wx4.RequestData { - t.Errorf("error: incorrect encode/decode for WithdrawalRequest") - } -} diff --git a/eth/protocols/eth/protocol.go b/eth/protocols/eth/protocol.go index 776bb52c0ea..e79b3cca351 100644 --- a/eth/protocols/eth/protocol.go +++ b/eth/protocols/eth/protocol.go @@ -359,19 +359,18 @@ type BlockBodiesRLPPacket66 struct { BlockBodiesRLPPacket } -// Unpack retrieves the transactions, uncles, withdrawals, and requests from the range packet and returns +// Unpack retrieves the transactions, uncles, withdrawals from the range packet and returns // them in a split flat format that's more consistent with the internal data structures. -func (p *BlockRawBodiesPacket) Unpack() ([][][]byte, [][]*types.Header, []types.Withdrawals, []types.Requests) { +func (p *BlockRawBodiesPacket) Unpack() ([][][]byte, [][]*types.Header, []types.Withdrawals) { var ( txSet = make([][][]byte, len(*p)) uncleSet = make([][]*types.Header, len(*p)) withdrawalSet = make([]types.Withdrawals, len(*p)) - requestSet = make([]types.Requests, len(*p)) ) for i, body := range *p { - txSet[i], uncleSet[i], withdrawalSet[i], requestSet[i] = body.Transactions, body.Uncles, body.Withdrawals, body.Requests + txSet[i], uncleSet[i], withdrawalSet[i] = body.Transactions, body.Uncles, body.Withdrawals } - return txSet, uncleSet, withdrawalSet, requestSet + return txSet, uncleSet, withdrawalSet } // GetReceiptsPacket represents a block receipts query. diff --git a/eth/stagedsync/exec3.go b/eth/stagedsync/exec3.go index 8b93de7868c..ab51833809f 100644 --- a/eth/stagedsync/exec3.go +++ b/eth/stagedsync/exec3.go @@ -809,7 +809,6 @@ Loop: GetHashFn: getHashFn, EvmBlockContext: blockContext, Withdrawals: b.Withdrawals(), - Requests: b.Requests(), PruneNonEssentials: pruneNonEssentials, // use history reader instead of state reader to catch up to the tx where we left off @@ -1616,7 +1615,6 @@ func reconstituteStep(last bool, GetHashFn: getHashFn, EvmBlockContext: blockContext, Withdrawals: b.Withdrawals(), - Requests: b.Requests(), } if txIndex >= 0 && txIndex < len(txs) { txTask.Tx = txs[txIndex] diff --git a/eth/stagedsync/stage_mining_exec.go b/eth/stagedsync/stage_mining_exec.go index a98387dac6d..a72c54cf245 100644 --- a/eth/stagedsync/stage_mining_exec.go +++ b/eth/stagedsync/stage_mining_exec.go @@ -204,7 +204,6 @@ func SpawnMiningExecStage(s *StageState, txc wrap.TxContainer, cfg MiningExecCfg if err != nil { return fmt.Errorf("cannot finalize block execution: %s", err) } - current.Requests = block.Requests() // Simulate the block execution to get the final state root if err = rawdb.WriteHeader(txc.Tx, block.Header()); err != nil { diff --git a/eth/stagedsync/stage_mining_finish.go b/eth/stagedsync/stage_mining_finish.go index d74f6dfcffa..9586bcb7709 100644 --- a/eth/stagedsync/stage_mining_finish.go +++ b/eth/stagedsync/stage_mining_finish.go @@ -68,7 +68,7 @@ func SpawnMiningFinishStage(s *StageState, tx kv.RwTx, cfg MiningFinishCfg, quit // continue //} - block := types.NewBlockForAsembling(current.Header, current.Txs, current.Uncles, current.Receipts, current.Withdrawals, current.Requests) + block := types.NewBlockForAsembling(current.Header, current.Txs, current.Uncles, current.Receipts, current.Withdrawals) blockWithReceipts := &types.BlockWithReceipts{Block: block, Receipts: current.Receipts} *current = MiningBlock{} // hack to clean global data diff --git a/p2p/sentry/sentry_multi_client/sentry_multi_client.go b/p2p/sentry/sentry_multi_client/sentry_multi_client.go index ff266330c5d..c15a91a2889 100644 --- a/p2p/sentry/sentry_multi_client/sentry_multi_client.go +++ b/p2p/sentry/sentry_multi_client/sentry_multi_client.go @@ -470,12 +470,12 @@ func (cs *MultiClient) blockBodies66(ctx context.Context, inreq *proto_sentry.In if err := rlp.DecodeBytes(inreq.Data, &request); err != nil { return fmt.Errorf("decode BlockBodiesPacket66: %w", err) } - txs, uncles, withdrawals, requests := request.BlockRawBodiesPacket.Unpack() - if len(txs) == 0 && len(uncles) == 0 && len(withdrawals) == 0 && len(requests) == 0 { + txs, uncles, withdrawals := request.BlockRawBodiesPacket.Unpack() + if len(txs) == 0 && len(uncles) == 0 && len(withdrawals) == 0 { // No point processing empty response return nil } - cs.Bd.DeliverBodies(txs, uncles, withdrawals, requests, uint64(len(inreq.Data)), sentry.ConvertH512ToPeerID(inreq.PeerId)) + cs.Bd.DeliverBodies(txs, uncles, withdrawals, nil, uint64(len(inreq.Data)), sentry.ConvertH512ToPeerID(inreq.PeerId)) return nil } diff --git a/polygon/bor/bor.go b/polygon/bor/bor.go index 5d3bc0ce5d1..0b564f15fb0 100644 --- a/polygon/bor/bor.go +++ b/polygon/bor/bor.go @@ -1141,7 +1141,7 @@ func (c *Bor) FinalizeAndAssemble(chainConfig *chain.Config, header *types.Heade } // Assemble block - block := types.NewBlockForAsembling(header, txs, nil, receipts, withdrawals, requests) + block := types.NewBlockForAsembling(header, txs, nil, receipts, withdrawals) // set state sync // bc := chain.(*core.BlockChain) diff --git a/polygon/p2p/message_listener_test.go b/polygon/p2p/message_listener_test.go index 9c7309ec655..814ea7cbea4 100644 --- a/polygon/p2p/message_listener_test.go +++ b/polygon/p2p/message_listener_test.go @@ -433,7 +433,7 @@ func blockHeadersPacket66Bytes(t *testing.T, requestId uint64, headers []*types. func newMockNewBlockPacketBytes(t *testing.T) []byte { newBlockPacket := eth.NewBlockPacket{ - Block: types.NewBlock(newMockBlockHeaders(1)[0], nil, nil, nil, nil, nil), + Block: types.NewBlock(newMockBlockHeaders(1)[0], nil, nil, nil, nil), } newBlockPacketBytes, err := rlp.EncodeToBytes(&newBlockPacket) require.NoError(t, err) diff --git a/tests/statedb_insert_chain_transaction_test.go b/tests/statedb_insert_chain_transaction_test.go index 935e61ac73e..986f02cb7a6 100644 --- a/tests/statedb_insert_chain_transaction_test.go +++ b/tests/statedb_insert_chain_transaction_test.go @@ -68,7 +68,7 @@ func TestInsertIncorrectStateRootDifferentAccounts(t *testing.T) { t.Fatal("roots are the same") } - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { t.Fatal("should fail") @@ -135,7 +135,7 @@ func TestInsertIncorrectStateRootSameAccount(t *testing.T) { t.Fatal("roots are the same") } - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { t.Fatal("should fail") @@ -197,7 +197,7 @@ func TestInsertIncorrectStateRootSameAccountSameAmount(t *testing.T) { incorrectHeader := types.CopyHeader(chain.Headers[0]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[1].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { t.Fatal("should fail") @@ -259,7 +259,7 @@ func TestInsertIncorrectStateRootAllFundsRoot(t *testing.T) { incorrectHeader := types.CopyHeader(chain.Headers[0]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[1].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { t.Fatal("should fail") @@ -320,7 +320,7 @@ func TestInsertIncorrectStateRootAllFunds(t *testing.T) { // BLOCK 1 incorrectHeader := types.CopyHeader(chain.Headers[0]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[1].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[0].Transactions(), chain.Blocks[0].Uncles(), chain.Receipts[0], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { @@ -401,7 +401,7 @@ func TestAccountDeployIncorrectRoot(t *testing.T) { incorrectHeader := types.CopyHeader(chain.Headers[1]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[0].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[1].Transactions(), chain.Blocks[1].Uncles(), chain.Receipts[1], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[1].Transactions(), chain.Blocks[1].Uncles(), chain.Receipts[1], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} // BLOCK 2 - INCORRECT @@ -508,7 +508,7 @@ func TestAccountCreateIncorrectRoot(t *testing.T) { // BLOCK 3 - INCORRECT incorrectHeader := types.CopyHeader(chain.Headers[2]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[1].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[2].Transactions(), chain.Blocks[2].Uncles(), chain.Receipts[2], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[2].Transactions(), chain.Blocks[2].Uncles(), chain.Receipts[2], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { @@ -597,7 +597,7 @@ func TestAccountUpdateIncorrectRoot(t *testing.T) { // BLOCK 4 - INCORRECT incorrectHeader := types.CopyHeader(chain.Headers[3]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[1].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[3].Transactions(), chain.Blocks[3].Uncles(), chain.Receipts[3], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[3].Transactions(), chain.Blocks[3].Uncles(), chain.Receipts[3], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { @@ -685,7 +685,7 @@ func TestAccountDeleteIncorrectRoot(t *testing.T) { // BLOCK 4 - INCORRECT incorrectHeader := types.CopyHeader(chain.Headers[3]) // Copy header, not just pointer incorrectHeader.Root = chain.Headers[1].Root - incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[3].Transactions(), chain.Blocks[3].Uncles(), chain.Receipts[3], nil, nil) + incorrectBlock := types.NewBlock(incorrectHeader, chain.Blocks[3].Transactions(), chain.Blocks[3].Uncles(), chain.Receipts[3], nil) incorrectChain := &core.ChainPack{Blocks: []*types.Block{incorrectBlock}, Headers: []*types.Header{incorrectHeader}, TopBlock: incorrectBlock} if err = m.InsertChain(incorrectChain); err == nil { t.Fatal("should fail") diff --git a/turbo/adapter/ethapi/api.go b/turbo/adapter/ethapi/api.go index 311e0fe730f..3891926093d 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -367,10 +367,6 @@ func RPCMarshalBlockExDeprecated(block *types.Block, inclTx bool, fullTx bool, b fields["withdrawals"] = block.Withdrawals() } - if block.Requests() != nil { - fields["requests"] = block.Requests() - } - return fields, nil } diff --git a/turbo/engineapi/engine_block_downloader/block_downloader.go b/turbo/engineapi/engine_block_downloader/block_downloader.go index 50283851ffc..b2449124595 100644 --- a/turbo/engineapi/engine_block_downloader/block_downloader.go +++ b/turbo/engineapi/engine_block_downloader/block_downloader.go @@ -294,7 +294,7 @@ func (e *EngineBlockDownloader) insertHeadersAndBodies(ctx context.Context, tx k if body == nil { return fmt.Errorf("missing body at block=%d", number) } - blocksBatch = append(blocksBatch, types.NewBlockFromStorage(hash, header, body.Transactions, body.Uncles, body.Withdrawals, body.Requests)) + blocksBatch = append(blocksBatch, types.NewBlockFromStorage(hash, header, body.Transactions, body.Uncles, body.Withdrawals)) if number%uint64(blockWrittenLogSize) == 0 { e.logger.Info("[insertHeadersAndBodies] Written blocks", "progress", number, "to", toBlock) } diff --git a/turbo/engineapi/engine_server.go b/turbo/engineapi/engine_server.go index 854fb6c7e51..b224a322c4a 100644 --- a/turbo/engineapi/engine_server.go +++ b/turbo/engineapi/engine_server.go @@ -305,7 +305,7 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi defer s.lock.Unlock() s.logger.Debug("[NewPayload] sending block", "height", header.Number, "hash", blockHash) - block := types.NewBlockFromStorage(blockHash, &header, transactions, nil /* uncles */, withdrawals, requests) + block := types.NewBlockFromStorage(blockHash, &header, transactions, nil /* uncles */, withdrawals) payloadStatus, err := s.HandleNewPayload(ctx, "NewPayload", block, expectedBlobHashes) if err != nil { @@ -619,11 +619,6 @@ func extractPayloadBodyFromBody(body *types.RawBody, version clparams.StateVersi } ret := &engine_types.ExecutionPayloadBody{Transactions: bdTxs, Withdrawals: body.Withdrawals} - if version >= clparams.ElectraVersion && body.Requests != nil { - ret.DepositRequests = body.Requests.Deposits() - ret.WithdrawalRequests = body.Requests.Withdrawals() - ret.ConsolidationRequests = body.Requests.Consolidations() - } return ret } diff --git a/turbo/execution/eth1/block_building.go b/turbo/execution/eth1/block_building.go index 0ffefd7a934..e5d9860e5c6 100644 --- a/turbo/execution/eth1/block_building.go +++ b/turbo/execution/eth1/block_building.go @@ -33,7 +33,6 @@ import ( "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/turbo/builder" "github.com/erigontech/erigon/turbo/engineapi/engine_helpers" - "github.com/erigontech/erigon/turbo/engineapi/engine_types" "github.com/erigontech/erigon/turbo/execution/eth1/eth1_utils" ) @@ -183,13 +182,6 @@ func (e *EthereumExecutionModule) GetAssembledBlock(ctx context.Context, req *ex payload.BlobGasUsed = header.BlobGasUsed payload.ExcessBlobGas = header.ExcessBlobGas } - reqs := block.Requests() - if reqs != nil { - payload.Version = 4 - payload.DepositRequests = engine_types.ConvertDepositRequestsToRpc(reqs.Deposits()) - payload.WithdrawalRequests = engine_types.ConvertWithdrawalRequestsToRpc(reqs.Withdrawals()) - payload.ConsolidationRequests = engine_types.ConvertConsolidationRequestsToRpc(reqs.Consolidations()) - } blockValue := blockValue(blockWithReceipts, baseFee) diff --git a/turbo/execution/eth1/eth1_chain_reader.go/chain_reader.go b/turbo/execution/eth1/eth1_chain_reader.go/chain_reader.go index e0730a84da8..12b88428044 100644 --- a/turbo/execution/eth1/eth1_chain_reader.go/chain_reader.go +++ b/turbo/execution/eth1/eth1_chain_reader.go/chain_reader.go @@ -125,7 +125,7 @@ func (c ChainReaderWriterEth1) GetBlockByHash(ctx context.Context, hash libcommo log.Warn("[engine] GetBlockByHash", "err", err) return nil } - return types.NewBlock(header, txs, nil, nil, body.Withdrawals, body.Requests) + return types.NewBlock(header, txs, nil, nil, body.Withdrawals) } func (c ChainReaderWriterEth1) GetBlockByNumber(ctx context.Context, number uint64) *types.Block { @@ -154,7 +154,7 @@ func (c ChainReaderWriterEth1) GetBlockByNumber(ctx context.Context, number uint log.Warn("[engine] GetBlockByNumber", "err", err) return nil } - return types.NewBlock(header, txs, nil, nil, body.Withdrawals, body.Requests) + return types.NewBlock(header, txs, nil, nil, body.Withdrawals) } func (c ChainReaderWriterEth1) GetHeaderByHash(ctx context.Context, hash libcommon.Hash) *types.Header { diff --git a/turbo/execution/eth1/eth1_utils/grpc.go b/turbo/execution/eth1/eth1_utils/grpc.go index c40c50eb70e..2add340f7a3 100644 --- a/turbo/execution/eth1/eth1_utils/grpc.go +++ b/turbo/execution/eth1/eth1_utils/grpc.go @@ -216,15 +216,12 @@ func ConvertRawBlockBodyToRpc(in *types.RawBody, blockNumber uint64, blockHash l return nil } - reqs, _ := types.MarshalRequestsBinary(in.Requests) - return &execution.BlockBody{ BlockNumber: blockNumber, BlockHash: gointerfaces.ConvertHashToH256(blockHash), Transactions: in.Transactions, Uncles: HeadersToHeadersRPC(in.Uncles), Withdrawals: ConvertWithdrawalsToRpc(in.Withdrawals), - Requests: reqs, } } @@ -245,12 +242,10 @@ func ConvertRawBlockBodyFromRpc(in *execution.BlockBody) (*types.RawBody, error) if err != nil { return nil, err } - reqs, _ := types.UnmarshalRequestsFromBinary(in.Requests) return &types.RawBody{ Transactions: in.Transactions, Uncles: uncles, Withdrawals: ConvertWithdrawalsFromRpc(in.Withdrawals), - Requests: reqs, }, nil } diff --git a/turbo/execution/eth1/eth1_utils/grpc_test.go b/turbo/execution/eth1/eth1_utils/grpc_test.go index 8f88bf2a998..b1212a4a98c 100644 --- a/turbo/execution/eth1/eth1_utils/grpc_test.go +++ b/turbo/execution/eth1/eth1_utils/grpc_test.go @@ -83,7 +83,7 @@ func makeBlock(txCount, uncleCount, withdrawalCount int) *types.Block { Amount: uint64(10 * i), } } - return types.NewBlock(header, txs, uncles, receipts, withdrawals, nil) // TODO(racytech): add requests + return types.NewBlock(header, txs, uncles, receipts, withdrawals) } func TestBlockRpcConversion(t *testing.T) { diff --git a/turbo/execution/eth1/getters.go b/turbo/execution/eth1/getters.go index 9b6deecae2d..4d1e047be17 100644 --- a/turbo/execution/eth1/getters.go +++ b/turbo/execution/eth1/getters.go @@ -168,14 +168,12 @@ func (e *EthereumExecutionModule) GetBodiesByHashes(ctx context.Context, req *ex return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByHashes: MarshalTransactionsBinary error %w", err) } - reqs, err := types.MarshalRequestsBinary(body.Requests) if err != nil { return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByHashes: MarshalRequestsBinary error %w", err) } bodies = append(bodies, &execution.BlockBody{ Transactions: txs, Withdrawals: eth1_utils.ConvertWithdrawalsToRpc(body.Withdrawals), - Requests: reqs, }) } @@ -216,14 +214,12 @@ func (e *EthereumExecutionModule) GetBodiesByRange(ctx context.Context, req *exe return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByRange: MarshalTransactionsBinary error %w", err) } - reqs, err := types.MarshalRequestsBinary(body.Requests) if err != nil { return nil, fmt.Errorf("ethereumExecutionModule.GetBodiesByHashes: MarshalRequestsBinary error %w", err) } bodies = append(bodies, &execution.BlockBody{ Transactions: txs, Withdrawals: eth1_utils.ConvertWithdrawalsToRpc(body.Withdrawals), - Requests: reqs, }) } // Remove trailing nil values as per spec diff --git a/turbo/snapshotsync/freezeblocks/block_reader.go b/turbo/snapshotsync/freezeblocks/block_reader.go index fb332ccd477..a6a25bb9179 100644 --- a/turbo/snapshotsync/freezeblocks/block_reader.go +++ b/turbo/snapshotsync/freezeblocks/block_reader.go @@ -837,7 +837,7 @@ func (r *BlockReader) blockWithSenders(ctx context.Context, tx kv.Getter, hash c return } if txCount == 0 { - block = types.NewBlockFromStorage(hash, h, nil, b.Uncles, b.Withdrawals, b.Requests) + block = types.NewBlockFromStorage(hash, h, nil, b.Uncles, b.Withdrawals) if len(senders) != block.Transactions().Len() { if dbgLogs { log.Info(dbgPrefix + fmt.Sprintf("found block with %d transactions, but %d senders", block.Transactions().Len(), len(senders))) @@ -863,7 +863,7 @@ func (r *BlockReader) blockWithSenders(ctx context.Context, tx kv.Getter, hash c } release() - block = types.NewBlockFromStorage(hash, h, txs, b.Uncles, b.Withdrawals, b.Requests) + block = types.NewBlockFromStorage(hash, h, txs, b.Uncles, b.Withdrawals) if len(senders) != block.Transactions().Len() { if dbgLogs { log.Info(dbgPrefix + fmt.Sprintf("found block with %d transactions, but %d senders", block.Transactions().Len(), len(senders))) @@ -955,7 +955,6 @@ func (r *BlockReader) bodyFromSnapshot(blockHeight uint64, sn *VisibleSegment, b body := new(types.Body) body.Uncles = b.Uncles body.Withdrawals = b.Withdrawals - body.Requests = b.Requests var txCount uint32 if b.TxCount >= 2 { txCount = b.TxCount - 2 diff --git a/turbo/stages/bodydownload/body_algos.go b/turbo/stages/bodydownload/body_algos.go index b2061787f79..8b372b35ce3 100644 --- a/turbo/stages/bodydownload/body_algos.go +++ b/turbo/stages/bodydownload/body_algos.go @@ -172,10 +172,6 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB // implies *header.WithdrawalsHash == types.EmptyRootHash body.Withdrawals = make([]*types.Withdrawal, 0) } - if header.RequestsHash != nil { - // implies *header.RequestsHash == types.EmptyRootHash - body.Requests = make(types.Requests, 0) - } bd.addBodyToCache(blockNum, body) dataflow.BlockBodyDownloadStates.AddChange(blockNum, dataflow.BlockBodyEmpty) request = false @@ -257,9 +253,9 @@ func (bd *BodyDownload) RequestSent(bodyReq *BodyRequest, timeWithTimeout uint64 // DeliverBodies takes the block body received from a peer and adds it to the various data structures func (bd *BodyDownload) DeliverBodies(txs [][][]byte, uncles [][]*types.Header, withdrawals []types.Withdrawals, - requests []types.Requests, lenOfP2PMsg uint64, peerID [64]byte, + requests []types.Request, lenOfP2PMsg uint64, peerID [64]byte, ) { - bd.deliveryCh <- Delivery{txs: txs, uncles: uncles, withdrawals: withdrawals, requests: requests, lenOfP2PMessage: lenOfP2PMsg, peerID: peerID} + bd.deliveryCh <- Delivery{txs: txs, uncles: uncles, withdrawals: withdrawals, lenOfP2PMessage: lenOfP2PMsg, peerID: peerID} select { case bd.DeliveryNotify <- struct{}{}: @@ -318,17 +314,14 @@ Loop: if delivery.withdrawals == nil { bd.logger.Warn("nil withdrawals delivered", "peer_id", delivery.peerID, "p2p_msg_len", delivery.lenOfP2PMessage) } - if delivery.requests == nil { - bd.logger.Warn("nil requests delivered", "peer_id", delivery.peerID, "p2p_msg_len", delivery.lenOfP2PMessage) - } - if delivery.txs == nil || delivery.uncles == nil || delivery.withdrawals == nil || delivery.requests == nil { + if delivery.txs == nil || delivery.uncles == nil || delivery.withdrawals == nil { bd.logger.Debug("delivery body processing has been skipped due to nil tx|data") continue } //var deliveredNums []uint64 toClean := map[uint64]struct{}{} - txs, uncles, withdrawals, requests, lenOfP2PMessage := delivery.txs, delivery.uncles, delivery.withdrawals, delivery.requests, delivery.lenOfP2PMessage + txs, uncles, withdrawals, lenOfP2PMessage := delivery.txs, delivery.uncles, delivery.withdrawals, delivery.lenOfP2PMessage for i := range txs { var bodyHashes BodyHashes @@ -340,10 +333,6 @@ Loop: withdrawalsHash := types.DeriveSha(withdrawals[i]) copy(bodyHashes[2*length.Hash:], withdrawalsHash.Bytes()) } - if requests[i] != nil { - requestsHash := types.DeriveSha(requests[i]) - copy(bodyHashes[3*length.Hash:], requestsHash.Bytes()) - } // Block numbers are added to the bd.delivered bitmap here, only for blocks for which the body has been received, and their double hashes are present in the bd.requestedMap // Also, block numbers can be added to bd.delivered for empty blocks, above @@ -360,7 +349,7 @@ Loop: } delete(bd.requestedMap, bodyHashes) // Delivered, cleaning up - bd.addBodyToCache(blockNum, &types.RawBody{Transactions: txs[i], Uncles: uncles[i], Withdrawals: withdrawals[i], Requests: requests[i]}) + bd.addBodyToCache(blockNum, &types.RawBody{Transactions: txs[i], Uncles: uncles[i], Withdrawals: withdrawals[i]}) bd.delivered.Add(blockNum) delivered++ dataflow.BlockBodyDownloadStates.AddChange(blockNum, dataflow.BlockBodyReceived)