Skip to content

Commit

Permalink
Remove EIP-7685 requests from body, block and exeution payload (#12467)
Browse files Browse the repository at this point in the history
Cherry pick #12370 into `release/2.61`

Co-authored-by: Somnath <[email protected]>
  • Loading branch information
yperbasis and somnathb1 authored Oct 24, 2024
1 parent 24d8d9b commit b37c6d4
Show file tree
Hide file tree
Showing 38 changed files with 90 additions and 420 deletions.
2 changes: 1 addition & 1 deletion cl/cltypes/beacon_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/execution_client/execution_client_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
6 changes: 0 additions & 6 deletions cmd/evm/internal/t8ntool/gen_stenv.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/state/commands/opcode_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions consensus/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 1 addition & 4 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
52 changes: 1 addition & 51 deletions core/rawdb/accessors_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/accessors_indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit b37c6d4

Please sign in to comment.