Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EIP-7685 requests from body, block and exeution payload #12370

Merged
merged 10 commits into from
Oct 23, 2024
2 changes: 1 addition & 1 deletion cl/cltypes/beacon_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 @@ -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
}

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 @@ -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"`
}

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 @@ -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 {
Expand Down Expand Up @@ -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 {
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 @@ -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)
}

Expand Down
1 change: 0 additions & 1 deletion cmd/state/exec3/historical_trace_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 3 additions & 7 deletions consensus/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 1 addition & 4 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ 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"
"github.com/erigontech/erigon-lib/common/length"
"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"
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.
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 @@ -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"
Expand Down Expand Up @@ -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),
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
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 @@ -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 {
Expand Down
Loading
Loading