Skip to content

Commit b2c9e55

Browse files
committed
Revert "Even closer to geth, modifying WithBody to copy the body withdrawals"
This reverts commit b117d9a.
1 parent b117d9a commit b2c9e55

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

beacon/engine/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash,
255255
ParentBeaconRoot: beaconRoot,
256256
}
257257
block := types.NewBlockWithHeader(header).
258-
WithBody(types.Body{Transactions: txs, Uncles: nil, Withdrawals: params.Withdrawals})
258+
WithBody(types.Body{Transactions: txs, Uncles: nil}).WithWithdrawals(params.Withdrawals)
259259
if block.Hash() != params.BlockHash {
260260
return nil, fmt.Errorf("blockhash mismatch, want %x, got %x", params.BlockHash, block.Hash())
261261
}

cmd/evm/internal/t8ntool/block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (i *bbInput) ToBlock() *types.Block {
160160
if i.Header.Difficulty != nil {
161161
header.Difficulty = i.Header.Difficulty
162162
}
163-
return types.NewBlockWithHeader(header).WithBody(types.Body{Transactions: i.Txs, Uncles: i.Ommers, Withdrawals: i.Withdrawals})
163+
return types.NewBlockWithHeader(header).WithBody(types.Body{Transactions: i.Txs, Uncles: i.Ommers}).WithWithdrawals(i.Withdrawals)
164164
}
165165

166166
// SealBlock seals the given block using the configured engine.

core/rawdb/accessors_chain.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ func ReadBlock(db ethdb.Reader, hash common.Hash, number uint64) *types.Block {
753753
if body == nil {
754754
return nil
755755
}
756-
return types.NewBlockWithHeader(header).WithBody(*body)
756+
return types.NewBlockWithHeader(header).WithBody(*body).WithWithdrawals(body.Withdrawals)
757757
}
758758

759759
// WriteBlock serializes a block into the database, header and body separately.
@@ -846,6 +846,7 @@ func ReadBadBlock(db ethdb.Reader, hash common.Hash) *types.Block {
846846
block := types.NewBlockWithHeader(bad.Header)
847847
if bad.Body != nil {
848848
block = block.WithBody(*bad.Body)
849+
block = block.WithWithdrawals(bad.Body.Withdrawals)
849850
}
850851
return block
851852
}
@@ -869,6 +870,7 @@ func ReadAllBadBlocks(db ethdb.Reader) []*types.Block {
869870
block := types.NewBlockWithHeader(bad.Header)
870871
if bad.Body != nil {
871872
block = block.WithBody(*bad.Body)
873+
block = block.WithWithdrawals(bad.Body.Withdrawals)
872874
}
873875
blocks = append(blocks, block)
874876
}

core/types/block.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"io"
2424
"math/big"
2525
"reflect"
26-
"slices"
2726
"sync/atomic"
2827
"time"
2928

@@ -466,7 +465,7 @@ func (b *Block) WithBody(body Body) *Block {
466465
header: b.header,
467466
transactions: make([]*Transaction, len(body.Transactions)),
468467
uncles: make([]*Header, len(body.Uncles)),
469-
withdrawals: slices.Clone(body.Withdrawals),
468+
withdrawals: b.withdrawals,
470469
}
471470
copy(block.transactions, body.Transactions)
472471
for i := range body.Uncles {

eth/downloader/downloader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ func (d *Downloader) importBlockResults(results []*fetchResult) error {
15001500
)
15011501
blocks := make([]*types.Block, len(results))
15021502
for i, result := range results {
1503-
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body())
1503+
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body()).WithWithdrawals(result.Withdrawals)
15041504
}
15051505
// Downloaded blocks are always regarded as trusted after the
15061506
// transition. Because the downloaded chain is guided by the
@@ -1718,7 +1718,7 @@ func (d *Downloader) commitSnapSyncData(results []*fetchResult, stateSync *state
17181718
blocks := make([]*types.Block, len(results))
17191719
receipts := make([]types.Receipts, len(results))
17201720
for i, result := range results {
1721-
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body())
1721+
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body()).WithWithdrawals(result.Withdrawals)
17221722
receipts[i] = result.Receipts
17231723
}
17241724
if index, err := d.blockchain.InsertReceiptChain(blocks, receipts, d.ancientLimit); err != nil {
@@ -1729,7 +1729,7 @@ func (d *Downloader) commitSnapSyncData(results []*fetchResult, stateSync *state
17291729
}
17301730

17311731
func (d *Downloader) commitPivotBlock(result *fetchResult) error {
1732-
block := types.NewBlockWithHeader(result.Header).WithBody(result.body())
1732+
block := types.NewBlockWithHeader(result.Header).WithBody(result.body()).WithWithdrawals(result.Withdrawals)
17331733
log.Debug("Committing snap sync pivot as new head", "number", block.Number(), "hash", block.Hash())
17341734

17351735
// Commit the pivot block as the new head, will require full sync from here on

ethclient/ethclient.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface
195195
types.Body{
196196
Transactions: txs,
197197
Uncles: uncles,
198-
Withdrawals: body.Withdrawals,
199-
}), nil
198+
}).WithWithdrawals(body.Withdrawals), nil
200199
}
201200

202201
// HeaderByHash returns the block header with the given hash.

0 commit comments

Comments
 (0)