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

chore(core/types): remove block.go and import Block and Body from libevm (6) #760

Merged
merged 39 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bd8c78a
feat(core/types): `Body` and `Block` hooks
qdm12 Jan 17, 2025
cdd8775
Add tests
qdm12 Feb 14, 2025
1deea08
Fix sync/client test TestGetBlocks
qdm12 Feb 14, 2025
122356d
Remove exported but only local functions
qdm12 Feb 21, 2025
e1154a1
sync/client: has its expectation closer to how it was
qdm12 Feb 26, 2025
d5715e3
ethclient: fix setting extras on block in `getBlock`
qdm12 Feb 26, 2025
2c9f9e4
core/types: move comment on RLP field differences with geth to rlp en…
qdm12 Feb 26, 2025
7ec7bcc
core/types: improve comment on Copy method to have godoc links to met…
qdm12 Feb 26, 2025
b1b7b8a
core/types: small simplifications in BlockBodyExtra.Copy method
ARR4N Feb 26, 2025
6e3a2d5
core/types: small simplification for `BlockExtData`
qdm12 Feb 26, 2025
a8d090c
core/types: fix comment of BlockRLPFieldsForEncoding
qdm12 Feb 26, 2025
0568fb4
core/types: safer and more concise BlockGasCost function
qdm12 Feb 26, 2025
7e16659
core/types: use slices.Clone in NewBlockWithExtData
qdm12 Feb 26, 2025
817bede
core/types: fix bad commit suggestion
qdm12 Feb 26, 2025
64ca33d
core/types: reverting slices.Clone in NewBlockWithExtData
qdm12 Feb 26, 2025
6c32a6a
core/types: fix bad suggestion in BlockGasCost
qdm12 Feb 26, 2025
d271e39
core/types: revet to use slices.Clone in NewBlockWithExtData
qdm12 Feb 26, 2025
0332484
refactor(core/types): body and block hooks tests (#841)
ARR4N Feb 26, 2025
5b0f05c
core/types: revert again to not use slices.Clone in NewBlockWithExtDa…
qdm12 Feb 26, 2025
6c81d6d
core/types: add golden data test TestBodyRLP
qdm12 Feb 26, 2025
876aaf3
core/types: add golden data test TestBlockRLP
qdm12 Feb 26, 2025
aed154c
Fix `TestBlockWithNonZeroFields` by ignoring block fields that cannot…
qdm12 Feb 26, 2025
c973e56
core/types: improve comment on body withdrawals field drop
qdm12 Feb 27, 2025
50e3adb
core/types: blockWithNonZeroFields uses SetBlockExtra
qdm12 Feb 27, 2025
9701624
ethclient: make return statement closer to geth
qdm12 Feb 27, 2025
dd6e438
core/types: name ignoreFields var in TestBlockWithNonZeroFields
qdm12 Feb 27, 2025
1c3d8c2
to also check unexported fields (for Block)
qdm12 Feb 27, 2025
909d843
core/types: `bodyWithNonZeroFields` uses `blockWithNonZeroFields`
qdm12 Feb 27, 2025
64c22bf
Merge TestBodyRLP and TestBodyExtraRLP together
qdm12 Feb 27, 2025
0c5eca8
core/types: merge TestBlockRLP into TestBlockExtraRLP
qdm12 Feb 27, 2025
114fc2a
core/types: TestBlockBody uses constant version and shared extData va…
qdm12 Feb 27, 2025
aa0c116
core/types: add comment on nil withdrawals in TestBlockExtraRLP
qdm12 Feb 27, 2025
619a51a
core/types: allFieldsSet handles unexported fields in common switch case
qdm12 Feb 28, 2025
d335448
core/types: bump values in blockWithNonZeroFields
qdm12 Feb 28, 2025
39c516a
core/types: TestBodyExtraRLP re-generates copy of wanted body and extra
qdm12 Feb 28, 2025
cc11dba
core/types: TestBlockExtraRLP re-generates copy of wanted block and e…
qdm12 Feb 28, 2025
4b6ff48
core/types: allFieldsSet remove ineffective t.Helper()
qdm12 Feb 28, 2025
e99a77c
core/types: BlockBodyExtra Copy leaves ExtData to nil if it's nil pre…
qdm12 Feb 28, 2025
37797f0
deps: bump go-cmp to v0.7.0
qdm12 Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions consensus/dummy/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ func (eng *DummyEngine) Finalize(chain consensus.ChainHeaderReader, block *types
if extDataGasUsed == nil {
extDataGasUsed = new(big.Int).Set(common.Big0)
}
if blockExtDataGasUsed := block.ExtDataGasUsed(); blockExtDataGasUsed == nil || !blockExtDataGasUsed.IsUint64() || blockExtDataGasUsed.Cmp(extDataGasUsed) != 0 {
if blockExtDataGasUsed := types.BlockExtDataGasUsed(block); blockExtDataGasUsed == nil || !blockExtDataGasUsed.IsUint64() || blockExtDataGasUsed.Cmp(extDataGasUsed) != 0 {
return fmt.Errorf("invalid extDataGasUsed: have %d, want %d", blockExtDataGasUsed, extDataGasUsed)
}

// Verify the BlockGasCost set in the header matches the expected value.
blockGasCost := block.BlockGasCost()
blockGasCost := types.BlockGasCost(block)
expectedBlockGasCost := customheader.BlockGasCost(
configExtra,
parent,
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ func (bc *BlockChain) insertBlock(block *types.Block, writes bool) error {
"parentHash", block.ParentHash(),
"uncles", len(block.Uncles()), "txs", len(block.Transactions()), "gas", block.GasUsed(),
"elapsed", common.PrettyDuration(time.Since(start)),
"root", block.Root(), "baseFeePerGas", block.BaseFee(), "blockGasCost", block.BlockGasCost(),
"root", block.Root(), "baseFeePerGas", block.BaseFee(), "blockGasCost", types.BlockGasCost(block),
)

processedBlockGasUsedCounter.Inc(int64(block.GasUsed()))
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func ReadBlock(db ethdb.Reader, hash common.Hash, number uint64) *types.Block {
if body == nil {
return nil
}
return types.NewBlockWithHeader(header).WithBody(body.Transactions, body.Uncles).WithExtData(body.Version, body.ExtData)
return types.NewBlockWithHeader(header).WithBody(*body)
}

// WriteBlock serializes a block into the database, header and body separately.
Expand Down
301 changes: 0 additions & 301 deletions core/types/block.go

This file was deleted.

Loading
Loading