diff --git a/cl/cltypes/beacon_block_test.go b/cl/cltypes/beacon_block_test.go index 73e4c111ec1..ae9c18347c1 100644 --- a/cl/cltypes/beacon_block_test.go +++ b/cl/cltypes/beacon_block_test.go @@ -39,7 +39,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 6565ae02b01..933dbba2118 100644 --- a/cl/phase1/execution_client/block_collector/block_collector.go +++ b/cl/phase1/execution_client/block_collector/block_collector.go @@ -109,7 +109,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 { if err := b.engine.InsertBlocks(ctx, blocksBatch, true); err != nil { b.logger.Warn("failed to insert blocks", "err", err) diff --git a/cl/phase1/execution_client/execution_client_direct.go b/cl/phase1/execution_client/execution_client_direct.go index 387753f1554..389442d59cd 100644 --- a/cl/phase1/execution_client/execution_client_direct.go +++ b/cl/phase1/execution_client/execution_client_direct.go @@ -40,7 +40,7 @@ func (cc *ExecutionClientDirect) NewPayload(ctx context.Context, payload *cltype return true, 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 false, err } diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 96f109c555f..96550bd1a87 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -61,7 +61,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 6be31364284..af30326e1e1 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 72efbbd2c17..c003c4c844e 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -241,10 +241,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 { @@ -283,7 +279,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 39ff645b249..78f2c617bbd 100644 --- a/cmd/state/commands/opcode_tracer.go +++ b/cmd/state/commands/opcode_tracer.go @@ -732,7 +732,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/consensus/aura/aura.go b/consensus/aura/aura.go index df889aaf4a0..cde874135e3 100644 --- a/consensus/aura/aura.go +++ b/consensus/aura/aura.go @@ -846,7 +846,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 2a08d4f4dee..cc03ca33206 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -388,7 +388,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 b3d3886b54d..f4ad9841bc0 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -584,7 +584,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 36c86a79b7e..792d8ba2cf6 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -205,16 +205,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 07d64c35b0f..70719a343e5 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -166,7 +166,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 2de165ef70e..2c40bb087ab 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -391,7 +391,7 @@ func GenerateChain(config *chain.Config, parent *types.Block, engine consensus.E return nil, nil, fmt.Errorf("call to CalcTrieRoot: %w", err) } // 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, fmt.Errorf("no engine to generate blocks") diff --git a/core/genesis_write.go b/core/genesis_write.go index 139f9cfc793..8ad84d4679b 100644 --- a/core/genesis_write.go +++ b/core/genesis_write.go @@ -547,10 +547,7 @@ func GenesisToBlock(g *types.Genesis, tmpDir string, logger log.Logger) (*types. } } - 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 @@ -634,7 +631,7 @@ func GenesisToBlock(g *types.Genesis, tmpDir string, logger log.Logger) (*types. 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 e98f2332864..56c8b402100 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -618,7 +618,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.TxAmount < 2 { panic(fmt.Sprintf("block body hash too few txs amount: %d, %d", number, bodyForStorage.TxAmount)) @@ -663,7 +662,6 @@ func WriteRawBody(db kv.RwTx, hash common.Hash, number uint64, body *types.RawBo TxAmount: uint32(len(body.Transactions)) + 2, /*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) @@ -687,7 +685,6 @@ func WriteBody(db kv.RwTx, hash common.Hash, number uint64, body *types.Body) (e TxAmount: uint32(len(body.Transactions)) + 2, 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) @@ -994,7 +991,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 6c7e7dfcf58..88040aa026c 100644 --- a/core/rawdb/accessors_chain_test.go +++ b/core/rawdb/accessors_chain_test.go @@ -25,7 +25,6 @@ import ( "testing" libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon-lib/common/hexutility" // "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv/memdb" @@ -576,33 +575,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), @@ -622,7 +594,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) } @@ -676,28 +648,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 2845724b61e..6901a6c5eb3 100644 --- a/core/rawdb/accessors_indexes_test.go +++ b/core/rawdb/accessors_indexes_test.go @@ -63,7 +63,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 b7de7f3b614..86c60eb157e 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -649,7 +649,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 @@ -659,7 +658,6 @@ type RawBody struct { Transactions [][]byte Uncles []*Header Withdrawals []*Withdrawal - Requests Requests } type BodyForStorage struct { @@ -667,7 +665,6 @@ type BodyForStorage struct { TxAmount uint32 Uncles []*Header Withdrawals []*Withdrawal - Requests Requests } // Alternative representation of the Block. @@ -680,7 +677,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, tx := range r.Body.Transactions { @@ -700,7 +696,6 @@ type Block struct { uncles []*Header transactions Transactions withdrawals []*Withdrawal - requests Requests // caches size atomic.Uint64 @@ -728,11 +723,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 _, tx := range rb.Transactions { txsLen += len(tx) @@ -749,17 +744,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 { @@ -784,10 +773,6 @@ func (rb RawBody) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if rb.Requests != nil { - rb.Requests.EncodeRLP(w) - } return nil } @@ -823,15 +808,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) { baseTxIdLen := 1 + rlp.IntLenExcludingHead(bfs.BaseTxId) txAmountLen := 1 + rlp.IntLenExcludingHead(uint64(bfs.TxAmount)) @@ -848,17 +829,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 @@ -887,10 +862,7 @@ func (bfs BodyForStorage) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if bfs.Requests != nil { - bfs.Requests.EncodeRLP(w) - } + return nil } @@ -917,19 +889,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 @@ -944,18 +912,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 { @@ -975,10 +936,6 @@ func (bb Body) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if bb.Requests != nil { - bb.Requests.EncodeRLP(w) - } return nil } @@ -1000,10 +957,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() } @@ -1014,7 +967,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) @@ -1060,38 +1013,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 } @@ -1110,7 +1047,6 @@ func NewBlockFromNetwork(header *Header, body *Body) *Block { transactions: body.Transactions, uncles: body.Uncles, withdrawals: body.Withdrawals, - requests: body.Requests, } } @@ -1192,15 +1128,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 @@ -1219,24 +1151,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 { @@ -1260,10 +1185,7 @@ func (bb *Block) EncodeRLP(w io.Writer) error { return err } } - // encode Requests - if bb.requests != nil { - bb.requests.EncodeRLP(w) - } + return nil } @@ -1307,7 +1229,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) } @@ -1315,7 +1236,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 } @@ -1331,7 +1252,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, tx := range b.transactions { var err error br.Transactions[i], err = rlp.EncodeToBytes(tx) @@ -1344,7 +1265,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, tx := range b.Transactions { var err error br.Transactions[i], err = rlp.EncodeToBytes(tx) @@ -1373,7 +1294,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() error { if hash := DeriveSha(b.Transactions()); hash != b.TxHash() { return fmt.Errorf("block has invalid transaction hash: have %x, exp: %x", hash, b.TxHash()) @@ -1405,17 +1326,6 @@ func (b *Block) HashCheck() 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 } @@ -1473,20 +1383,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) @@ -1503,7 +1404,6 @@ func (b *Block) WithSeal(header *Header) *Block { transactions: b.transactions, uncles: b.uncles, withdrawals: b.withdrawals, - requests: b.requests, } } @@ -1606,11 +1506,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 2990cd8c255..2a9b2fd38ed 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -359,7 +359,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) { @@ -508,7 +508,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) @@ -520,7 +520,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 ea918fbb57b..31f16f96d9d 100644 --- a/core/types/encdec_test.go +++ b/core/types/encdec_test.go @@ -11,7 +11,6 @@ import ( "github.com/holiman/uint256" libcommon "github.com/ledgerwatch/erigon-lib/common" - "github.com/ledgerwatch/erigon-lib/common/hexutility" types2 "github.com/ledgerwatch/erigon-lib/types" "github.com/ledgerwatch/erigon/rlp" ) @@ -70,12 +69,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)), @@ -86,20 +79,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 } @@ -286,7 +269,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)), } } @@ -313,7 +295,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)), } } @@ -392,47 +373,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 { @@ -459,15 +406,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 } @@ -486,8 +433,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 } @@ -504,7 +449,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 } @@ -555,58 +499,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 7ee9cafaf76..c62aef03155 100644 --- a/eth/protocols/eth/protocol.go +++ b/eth/protocols/eth/protocol.go @@ -356,19 +356,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 23a0c32cab6..eee5c9581ae 100644 --- a/eth/stagedsync/exec3.go +++ b/eth/stagedsync/exec3.go @@ -593,7 +593,6 @@ Loop: GetHashFn: getHashFn, EvmBlockContext: blockContext, Withdrawals: b.Withdrawals(), - Requests: b.Requests(), } if txIndex >= 0 && txIndex < len(txs) { txTask.Tx = txs[txIndex] @@ -1081,7 +1080,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 728965a7d12..98ac5f471ae 100644 --- a/eth/stagedsync/stage_mining_exec.go +++ b/eth/stagedsync/stage_mining_exec.go @@ -164,12 +164,10 @@ func SpawnMiningExecStage(s *StageState, tx kv.RwTx, cfg MiningExecCfg, quit <-c } var err error - var block *types.Block - block, current.Txs, current.Receipts, err = core.FinalizeBlockExecution(cfg.engine, stateReader, current.Header, current.Txs, current.Uncles, stateWriter, &cfg.chainConfig, ibs, current.Receipts, current.Withdrawals, current.Requests, ChainReaderImpl{config: &cfg.chainConfig, tx: tx, blockReader: cfg.blockReader, logger: logger}, true, logger) + _, current.Txs, current.Receipts, err = core.FinalizeBlockExecution(cfg.engine, stateReader, current.Header, current.Txs, current.Uncles, stateWriter, &cfg.chainConfig, ibs, current.Receipts, current.Withdrawals, current.Requests, ChainReaderImpl{config: &cfg.chainConfig, tx: tx, blockReader: cfg.blockReader, logger: logger}, true, logger) if err != nil { return fmt.Errorf("cannot finalize block execution: %s", err) } - current.Requests = block.Requests() logger.Debug("FinalizeBlockExecution", "block", current.Header.Number, "txn", current.Txs.Len(), "gas", current.Header.GasUsed, "receipt", current.Receipts.Len(), "payload", cfg.payloadId) diff --git a/eth/stagedsync/stage_mining_finish.go b/eth/stagedsync/stage_mining_finish.go index fad148fa414..08585ec3e57 100644 --- a/eth/stagedsync/stage_mining_finish.go +++ b/eth/stagedsync/stage_mining_finish.go @@ -52,7 +52,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 dad9a57eeab..e095d823bab 100644 --- a/p2p/sentry/sentry_multi_client/sentry_multi_client.go +++ b/p2p/sentry/sentry_multi_client/sentry_multi_client.go @@ -585,12 +585,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 a2a8c3a3bcf..4791a8d9cfd 100644 --- a/polygon/bor/bor.go +++ b/polygon/bor/bor.go @@ -1083,7 +1083,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 d9990caf264..a30195c033a 100644 --- a/polygon/p2p/message_listener_test.go +++ b/polygon/p2p/message_listener_test.go @@ -416,7 +416,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 ed9411dca9b..e10b0bea219 100644 --- a/tests/statedb_insert_chain_transaction_test.go +++ b/tests/statedb_insert_chain_transaction_test.go @@ -52,7 +52,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") @@ -119,7 +119,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") @@ -181,7 +181,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") @@ -243,7 +243,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") @@ -304,7 +304,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 { @@ -385,7 +385,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 @@ -492,7 +492,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 { @@ -581,7 +581,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 { @@ -669,7 +669,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 2e2c65d7f9b..16b652c8109 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -363,10 +363,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 adad3780215..227392452e4 100644 --- a/turbo/engineapi/engine_block_downloader/block_downloader.go +++ b/turbo/engineapi/engine_block_downloader/block_downloader.go @@ -245,7 +245,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 c26b51ca4ad..b0fa2f0930c 100644 --- a/turbo/engineapi/engine_server.go +++ b/turbo/engineapi/engine_server.go @@ -280,7 +280,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 { @@ -586,11 +586,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 d785c9079da..04e6fcd4ffd 100644 --- a/turbo/execution/eth1/block_building.go +++ b/turbo/execution/eth1/block_building.go @@ -17,7 +17,6 @@ import ( "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/builder" "github.com/ledgerwatch/erigon/turbo/engineapi/engine_helpers" - "github.com/ledgerwatch/erigon/turbo/engineapi/engine_types" "github.com/ledgerwatch/erigon/turbo/execution/eth1/eth1_utils" ) @@ -167,13 +166,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 b0dfb72fc5c..ddce4993606 100644 --- a/turbo/execution/eth1/eth1_chain_reader.go/chain_reader.go +++ b/turbo/execution/eth1/eth1_chain_reader.go/chain_reader.go @@ -107,7 +107,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 { @@ -136,7 +136,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 ea973037708..d4642f8f5dc 100644 --- a/turbo/execution/eth1/eth1_utils/grpc.go +++ b/turbo/execution/eth1/eth1_utils/grpc.go @@ -199,15 +199,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, } } @@ -228,12 +225,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 ce8b5110086..9a67acf0bbc 100644 --- a/turbo/execution/eth1/eth1_utils/grpc_test.go +++ b/turbo/execution/eth1/eth1_utils/grpc_test.go @@ -66,7 +66,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 ca0f36cf2c2..7673622a331 100644 --- a/turbo/execution/eth1/getters.go +++ b/turbo/execution/eth1/getters.go @@ -145,14 +145,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, }) } @@ -193,14 +191,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 5423ce5aec7..51ebaa02635 100644 --- a/turbo/snapshotsync/freezeblocks/block_reader.go +++ b/turbo/snapshotsync/freezeblocks/block_reader.go @@ -713,7 +713,7 @@ func (r *BlockReader) blockWithSenders(ctx context.Context, tx kv.Getter, hash c return } if txsAmount == 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))) @@ -739,7 +739,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))) @@ -827,7 +827,6 @@ func (r *BlockReader) bodyFromSnapshot(blockHeight uint64, sn *Segment, buf []by body := new(types.Body) body.Uncles = b.Uncles body.Withdrawals = b.Withdrawals - body.Requests = b.Requests var txsAmount uint32 if b.TxAmount >= 2 { txsAmount = b.TxAmount - 2 diff --git a/turbo/stages/bodydownload/body_algos.go b/turbo/stages/bodydownload/body_algos.go index 0e7b1b20a5b..d47532bf3f2 100644 --- a/turbo/stages/bodydownload/body_algos.go +++ b/turbo/stages/bodydownload/body_algos.go @@ -150,10 +150,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 @@ -235,9 +231,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{}{}: @@ -296,17 +292,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 @@ -318,10 +311,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 @@ -338,7 +327,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)