Skip to content

Commit d0fa857

Browse files
authored
Merge branch 'ethereum:master' into gethintegration
2 parents d73538e + c088242 commit d0fa857

File tree

13 files changed

+106
-85
lines changed

13 files changed

+106
-85
lines changed

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
run:
44
timeout: 20m
55
tests: true
6-
# default is true. Enables skipping of directories:
7-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
8-
skip-dirs-use-default: true
96

107
linters:
118
disable-all: true
@@ -54,6 +51,9 @@ linters-settings:
5451
exclude: [""]
5552

5653
issues:
54+
# default is true. Enables skipping of directories:
55+
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
56+
exclude-dirs-use-default: true
5757
exclude-files:
5858
- core/genesis_alloc.go
5959
exclude-rules:

build/checksums.txt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,37 @@ fc77c0531406d092c5356167e45c05a22d16bea84e3fa555e0f03af085c11763 go1.23.4.windo
5656
8347c1aa4e1e67954d12830f88dbe44bd7ac0ec134bb472783dbfb5a3a8865d0 go1.23.4.windows-arm64.msi
5757
db69cae5006753c785345c3215ad941f8b6224e2f81fec471c42d6857bee0e6f go1.23.4.windows-arm64.zip
5858

59-
# version:golangci 1.61.0
59+
# version:golangci 1.63.4
6060
# https://github.com/golangci/golangci-lint/releases/
61-
# https://github.com/golangci/golangci-lint/releases/download/v1.61.0/
62-
5c280ef3284f80c54fd90d73dc39ca276953949da1db03eb9dd0fbf868cc6e55 golangci-lint-1.61.0-darwin-amd64.tar.gz
63-
544334890701e4e04a6e574bc010bea8945205c08c44cced73745a6378012d36 golangci-lint-1.61.0-darwin-arm64.tar.gz
64-
e885a6f561092055930ebd298914d80e8fd2e10d2b1e9942836c2c6a115301fa golangci-lint-1.61.0-freebsd-386.tar.gz
65-
b13f6a3f11f65e7ff66b734d7554df3bbae0f485768848424e7554ed289e19c2 golangci-lint-1.61.0-freebsd-amd64.tar.gz
66-
cd8e7bbe5b8f33ed1597aa1cc588da96a3b9f22e1b9ae60d93511eae1a0ee8c5 golangci-lint-1.61.0-freebsd-armv6.tar.gz
67-
7ade524dbd88bd250968f45e190af90e151fa5ee63dd6aa7f7bb90e8155db61d golangci-lint-1.61.0-freebsd-armv7.tar.gz
68-
0fe3cd8a1ed8d9f54f48670a5af3df056d6040d94017057f0f4d65c930660ad9 golangci-lint-1.61.0-illumos-amd64.tar.gz
69-
b463fc5053a612abd26393ebaff1d85d7d56058946f4f0f7bf25ed44ea899415 golangci-lint-1.61.0-linux-386.tar.gz
70-
77cb0af99379d9a21d5dc8c38364d060e864a01bd2f3e30b5e8cc550c3a54111 golangci-lint-1.61.0-linux-amd64.tar.gz
71-
af60ac05566d9351615cb31b4cc070185c25bf8cbd9b09c1873aa5ec6f3cc17e golangci-lint-1.61.0-linux-arm64.tar.gz
72-
1f307f2fcc5d7d674062a967a0d83a7091e300529aa237ec6ad2b3dd14c897f5 golangci-lint-1.61.0-linux-armv6.tar.gz
73-
3ad8cbaae75a547450844811300f99c4cd290277398e43d22b9eb1792d15af4c golangci-lint-1.61.0-linux-armv7.tar.gz
74-
9be2ca67d961d7699079739cf6f7c8291c5183d57e34d1677de21ca19d0bd3ed golangci-lint-1.61.0-linux-loong64.tar.gz
75-
90d005e1648115ebf0861b408eab9c936079a24763e883058b0a227cd3135d31 golangci-lint-1.61.0-linux-mips64.tar.gz
76-
6d2ed4f49407115460b8c10ccfc40fd177e0887a48864a2879dd16e84ba2a48c golangci-lint-1.61.0-linux-mips64le.tar.gz
77-
633089589af5a58b7430afb6eee107d4e9c99e8d91711ddc219eb13a07e8d3b8 golangci-lint-1.61.0-linux-ppc64le.tar.gz
78-
4c1a097d9e0d1b4a8144dae6a1f5583a38d662f3bdc1498c4e954b6ed856be98 golangci-lint-1.61.0-linux-riscv64.tar.gz
79-
30581d3c987d287b7064617f1a2694143e10dffc40bc25be6636006ee82d7e1c golangci-lint-1.61.0-linux-s390x.tar.gz
80-
42530bf8100bd43c07f5efe6d92148ba6c5a7a712d510c6f24be85af6571d5eb golangci-lint-1.61.0-netbsd-386.tar.gz
81-
b8bb07c920f6601edf718d5e82ec0784fd590b0992b42b6ec18da99f26013ed4 golangci-lint-1.61.0-netbsd-amd64.tar.gz
82-
353a51527c60bd0776b0891b03f247c791986f625fca689d121972c624e54198 golangci-lint-1.61.0-netbsd-arm64.tar.gz
83-
957a6272c3137910514225704c5dac0723b9c65eb7d9587366a997736e2d7580 golangci-lint-1.61.0-netbsd-armv6.tar.gz
84-
a89eb28ff7f18f5cd52b914739360fa95cf2f643de4adeca46e26bec3a07e8d8 golangci-lint-1.61.0-netbsd-armv7.tar.gz
85-
d8d74c43600b271393000717a4ed157d7a15bb85bab7db2efad9b63a694d4634 golangci-lint-1.61.0-windows-386.zip
86-
e7bc2a81929a50f830244d6d2e657cce4f19a59aff49fa9000176ff34fda64ce golangci-lint-1.61.0-windows-amd64.zip
87-
ed97c221596dd771e3dd9344872c140340bee2e819cd7a90afa1de752f1f2e0f golangci-lint-1.61.0-windows-arm64.zip
88-
4b365233948b13d02d45928a5c390045e00945e919747b9887b5f260247541ae golangci-lint-1.61.0-windows-armv6.zip
89-
595538fb64d152173959d28f6235227f9cd969a828e5af0c4e960d02af4ffd0e golangci-lint-1.61.0-windows-armv7.zip
61+
# https://github.com/golangci/golangci-lint/releases/download/v1.63.4/
62+
878d017cc360e4fb19510d39852c8189852e3c48e7ce0337577df73507c97d68 golangci-lint-1.63.4-darwin-amd64.tar.gz
63+
a2b630c2ac8466393f0ccbbede4462387b6c190697a70bc2298c6d2123f21bbf golangci-lint-1.63.4-darwin-arm64.tar.gz
64+
8938b74aa92888e561a1c5a4c175110b92f84e7d24733703e6d9ebc39e9cd5f8 golangci-lint-1.63.4-freebsd-386.tar.gz
65+
054903339d620df2e760b978920100986e3b03bcb058f669d520a71dac9c34ed golangci-lint-1.63.4-freebsd-amd64.tar.gz
66+
a19d499f961a02608348e8b626537a88edfaab6e1b6534f1eff742b5d6d750e4 golangci-lint-1.63.4-freebsd-armv6.tar.gz
67+
00d616f0fb275b780ce4d26604bdd7fdbfe6bc9c63acd5a0b31498e1f7511108 golangci-lint-1.63.4-freebsd-armv7.tar.gz
68+
d453688e0eabded3c1a97ff5a2777bb0df5a18851efdaaaf6b472e3e5713c33e golangci-lint-1.63.4-illumos-amd64.tar.gz
69+
6b1bec847fc9f347d53712d05606a49d55d0e3b5c1bacadfed2393f3503de0e9 golangci-lint-1.63.4-linux-386.tar.gz
70+
01abb14a4df47b5ca585eff3c34b105023cba92ec34ff17212dbb83855581690 golangci-lint-1.63.4-linux-amd64.tar.gz
71+
51f0c79d19a92353e0465fb30a4901a0644a975d34e6f399ad2eebc0160bbb24 golangci-lint-1.63.4-linux-arm64.tar.gz
72+
8d0a43f41e8424fbae10f7aa2dc29999f98112817c6dba63d7dc76832940a673 golangci-lint-1.63.4-linux-armv6.tar.gz
73+
1045a047b31e9302c9160c7b0f199f4ac1bd02a1b221a2d9521bd3507f0cf671 golangci-lint-1.63.4-linux-armv7.tar.gz
74+
933fe10ab50ce3bb0806e15a4ae69fe20f0549abf91dea0161236000ca706e67 golangci-lint-1.63.4-linux-loong64.tar.gz
75+
45798630cbad5642862766051199fa862ef3c33d569cab12f01cac4f68e2ddd5 golangci-lint-1.63.4-linux-mips64.tar.gz
76+
86ae25335ddb24975d2c915c1af0c7fad70dce99d0b4614fa4bee392de714aa2 golangci-lint-1.63.4-linux-mips64le.tar.gz
77+
33dabd11aaba4b602938da98bcf49aabab55019557e0115cdc3dbcc3009768fa golangci-lint-1.63.4-linux-ppc64le.tar.gz
78+
4e7a81230a663bcdf30bba5689ce96040abc76994dbc2003dce32c8dca8c06f3 golangci-lint-1.63.4-linux-riscv64.tar.gz
79+
21370b49c7c47f4d9b8f982c952f940b01e65710174c3b4dad7b6452d58f92ec golangci-lint-1.63.4-linux-s390x.tar.gz
80+
255866a6464c7e11bb7edd8e6e6ad54f11e1f01b82ba9ca229698ac788cd9724 golangci-lint-1.63.4-netbsd-386.tar.gz
81+
2798c040ac658bda97224f204795199c81ac97bb207b21c02b664aaed380d5d2 golangci-lint-1.63.4-netbsd-amd64.tar.gz
82+
b910eecffd0064103837e7e1abe870deb8ade22331e6dffe319f430d49399c8e golangci-lint-1.63.4-netbsd-arm64.tar.gz
83+
df2693ef37147b457c3e2089614537dd2ae2e18e53641e756a5b404f4c72d3fa golangci-lint-1.63.4-netbsd-armv6.tar.gz
84+
a28a533366974bd7834c4516cd6075bff3419a508d1ed7aa63ae8182768b352e golangci-lint-1.63.4-netbsd-armv7.tar.gz
85+
368932775fb5c620b324dabf018155f3365f5e33c5af5b26e9321db373f96eea golangci-lint-1.63.4-windows-386.zip
86+
184d13c2b8f5441576bec2a0d8ba7b2d45445595cf796b879a73bcc98c39f8c1 golangci-lint-1.63.4-windows-amd64.zip
87+
4fabf175d5b05ef0858ded49527948eebac50e9093814979fd84555a75fb80a6 golangci-lint-1.63.4-windows-arm64.zip
88+
e92be3f3ff30d4a849fb4b9a4c8d56837dee45269cb405a3ecad52fa034c781b golangci-lint-1.63.4-windows-armv6.zip
89+
c71d348653b8f7fbb109bb10c1a481722bc6b0b2b6e731b897f99ac869f7653e golangci-lint-1.63.4-windows-armv7.zip
9090

9191
# This is the builder on PPA that will build Go itself (inception-y), don't modify!
9292
#

core/genesis.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,12 @@ func hashAlloc(ga *types.GenesisAlloc, isVerkle bool) (common.Hash, error) {
127127
}
128128
// Create an ephemeral in-memory database for computing hash,
129129
// all the derived states will be discarded to not pollute disk.
130+
emptyRoot := types.EmptyRootHash
131+
if isVerkle {
132+
emptyRoot = types.EmptyVerkleHash
133+
}
130134
db := rawdb.NewMemoryDatabase()
131-
statedb, err := state.New(types.EmptyRootHash, state.NewDatabase(triedb.NewDatabase(db, config), nil))
135+
statedb, err := state.New(emptyRoot, state.NewDatabase(triedb.NewDatabase(db, config), nil))
132136
if err != nil {
133137
return common.Hash{}, err
134138
}
@@ -148,7 +152,11 @@ func hashAlloc(ga *types.GenesisAlloc, isVerkle bool) (common.Hash, error) {
148152
// flushAlloc is very similar with hash, but the main difference is all the
149153
// generated states will be persisted into the given database.
150154
func flushAlloc(ga *types.GenesisAlloc, triedb *triedb.Database) (common.Hash, error) {
151-
statedb, err := state.New(types.EmptyRootHash, state.NewDatabase(triedb, nil))
155+
emptyRoot := types.EmptyRootHash
156+
if triedb.IsVerkle() {
157+
emptyRoot = types.EmptyVerkleHash
158+
}
159+
statedb, err := state.New(emptyRoot, state.NewDatabase(triedb, nil))
152160
if err != nil {
153161
return common.Hash{}, err
154162
}

core/state/stateupdate.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"maps"
2121

2222
"github.com/ethereum/go-ethereum/common"
23-
"github.com/ethereum/go-ethereum/core/types"
2423
"github.com/ethereum/go-ethereum/trie/trienode"
2524
"github.com/ethereum/go-ethereum/triedb"
2625
)
@@ -133,8 +132,8 @@ func newStateUpdate(originRoot common.Hash, root common.Hash, deletes map[common
133132
}
134133
}
135134
return &stateUpdate{
136-
originRoot: types.TrieRootHash(originRoot),
137-
root: types.TrieRootHash(root),
135+
originRoot: originRoot,
136+
root: root,
138137
accounts: accounts,
139138
accountsOrigin: accountsOrigin,
140139
storages: storages,

core/txpool/blobpool/blobpool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ func (p *BlobPool) Clear() {
17511751
// The transaction addition may attempt to reserve the sender addr which
17521752
// can't happen until Clear releases the reservation lock. Clear cannot
17531753
// acquire the subpool lock until the transaction addition is completed.
1754-
for acct, _ := range p.index {
1754+
for acct := range p.index {
17551755
p.reserve(acct, false)
17561756
}
17571757
p.lookup = newLookup()

core/txpool/legacypool/legacypool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ func (pool *LegacyPool) Clear() {
19861986
senderAddr, _ := types.Sender(pool.signer, tx)
19871987
pool.reserve(senderAddr, false)
19881988
}
1989-
for localSender, _ := range pool.locals.accounts {
1989+
for localSender := range pool.locals.accounts {
19901990
pool.reserve(localSender, false)
19911991
}
19921992

core/types/hashes.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package types
1919
import (
2020
"github.com/ethereum/go-ethereum/common"
2121
"github.com/ethereum/go-ethereum/crypto"
22-
"github.com/ethereum/go-ethereum/log"
2322
)
2423

2524
var (
@@ -47,13 +46,3 @@ var (
4746
// EmptyVerkleHash is the known hash of an empty verkle trie.
4847
EmptyVerkleHash = common.Hash{}
4948
)
50-
51-
// TrieRootHash returns the hash itself if it's non-empty or the predefined
52-
// emptyHash one instead.
53-
func TrieRootHash(hash common.Hash) common.Hash {
54-
if hash == (common.Hash{}) {
55-
log.Error("Zero trie root hash!")
56-
return EmptyRootHash
57-
}
58-
return hash
59-
}

internal/ethapi/override/override_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/ethereum/go-ethereum/common/hexutil"
2525
"github.com/ethereum/go-ethereum/core/rawdb"
2626
"github.com/ethereum/go-ethereum/core/state"
27+
"github.com/ethereum/go-ethereum/core/types"
2728
"github.com/ethereum/go-ethereum/core/vm"
2829
"github.com/ethereum/go-ethereum/triedb"
2930
)
@@ -36,7 +37,7 @@ func (p *precompileContract) Run(input []byte) ([]byte, error) { return nil, nil
3637

3738
func TestStateOverrideMovePrecompile(t *testing.T) {
3839
db := state.NewDatabase(triedb.NewDatabase(rawdb.NewMemoryDatabase(), nil), nil)
39-
statedb, err := state.New(common.Hash{}, db)
40+
statedb, err := state.New(types.EmptyRootHash, db)
4041
if err != nil {
4142
t.Fatalf("failed to create statedb: %v", err)
4243
}

trie/trie_reader.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package trie
1919
import (
2020
"github.com/ethereum/go-ethereum/common"
2121
"github.com/ethereum/go-ethereum/core/types"
22-
"github.com/ethereum/go-ethereum/log"
2322
"github.com/ethereum/go-ethereum/triedb/database"
2423
)
2524

@@ -34,9 +33,6 @@ type trieReader struct {
3433
// newTrieReader initializes the trie reader with the given node reader.
3534
func newTrieReader(stateRoot, owner common.Hash, db database.NodeDatabase) (*trieReader, error) {
3635
if stateRoot == (common.Hash{}) || stateRoot == types.EmptyRootHash {
37-
if stateRoot == (common.Hash{}) {
38-
log.Error("Zero state root hash!")
39-
}
4036
return &trieReader{owner: owner}, nil
4137
}
4238
reader, err := db.NodeReader(stateRoot)

triedb/pathdb/database.go

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/ethereum/go-ethereum/log"
3232
"github.com/ethereum/go-ethereum/params"
3333
"github.com/ethereum/go-ethereum/trie/trienode"
34+
"github.com/ethereum/go-verkle"
3435
)
3536

3637
const (
@@ -148,6 +149,29 @@ var Defaults = &Config{
148149
// ReadOnly is the config in order to open database in read only mode.
149150
var ReadOnly = &Config{ReadOnly: true}
150151

152+
// nodeHasher is the function to compute the hash of supplied node blob.
153+
type nodeHasher func([]byte) (common.Hash, error)
154+
155+
// merkleNodeHasher computes the hash of the given merkle node.
156+
func merkleNodeHasher(blob []byte) (common.Hash, error) {
157+
if len(blob) == 0 {
158+
return types.EmptyRootHash, nil
159+
}
160+
return crypto.Keccak256Hash(blob), nil
161+
}
162+
163+
// verkleNodeHasher computes the hash of the given verkle node.
164+
func verkleNodeHasher(blob []byte) (common.Hash, error) {
165+
if len(blob) == 0 {
166+
return types.EmptyVerkleHash, nil
167+
}
168+
n, err := verkle.ParseNode(blob, 0)
169+
if err != nil {
170+
return common.Hash{}, err
171+
}
172+
return n.Commit().Bytes(), nil
173+
}
174+
151175
// Database is a multiple-layered structure for maintaining in-memory states
152176
// along with its dirty trie nodes. It consists of one persistent base layer
153177
// backed by a key-value store, on top of which arbitrarily many in-memory diff
@@ -164,9 +188,10 @@ type Database struct {
164188
// readOnly is the flag whether the mutation is allowed to be applied.
165189
// It will be set automatically when the database is journaled during
166190
// the shutdown to reject all following unexpected mutations.
167-
readOnly bool // Flag if database is opened in read only mode
168-
waitSync bool // Flag if database is deactivated due to initial state sync
169-
isVerkle bool // Flag if database is used for verkle tree
191+
readOnly bool // Flag if database is opened in read only mode
192+
waitSync bool // Flag if database is deactivated due to initial state sync
193+
isVerkle bool // Flag if database is used for verkle tree
194+
hasher nodeHasher // Trie node hasher
170195

171196
config *Config // Configuration for database
172197
diskdb ethdb.Database // Persistent storage for matured trie nodes
@@ -184,19 +209,21 @@ func New(diskdb ethdb.Database, config *Config, isVerkle bool) *Database {
184209
}
185210
config = config.sanitize()
186211

212+
db := &Database{
213+
readOnly: config.ReadOnly,
214+
isVerkle: isVerkle,
215+
config: config,
216+
diskdb: diskdb,
217+
hasher: merkleNodeHasher,
218+
}
187219
// Establish a dedicated database namespace tailored for verkle-specific
188220
// data, ensuring the isolation of both verkle and merkle tree data. It's
189221
// important to note that the introduction of a prefix won't lead to
190222
// substantial storage overhead, as the underlying database will efficiently
191223
// compress the shared key prefix.
192224
if isVerkle {
193-
diskdb = rawdb.NewTable(diskdb, string(rawdb.VerklePrefix))
194-
}
195-
db := &Database{
196-
readOnly: config.ReadOnly,
197-
isVerkle: isVerkle,
198-
config: config,
199-
diskdb: diskdb,
225+
db.diskdb = rawdb.NewTable(diskdb, string(rawdb.VerklePrefix))
226+
db.hasher = verkleNodeHasher
200227
}
201228
// Construct the layer tree by resolving the in-disk singleton state
202229
// and in-memory layer journal.
@@ -277,6 +304,8 @@ func (db *Database) repairHistory() error {
277304
//
278305
// The passed in maps(nodes, states) will be retained to avoid copying everything.
279306
// Therefore, these maps must not be changed afterwards.
307+
//
308+
// The supplied parentRoot and root must be a valid trie hash value.
280309
func (db *Database) Update(root common.Hash, parentRoot common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *StateSetWithOrigin) error {
281310
// Hold the lock to prevent concurrent mutations.
282311
db.lock.Lock()
@@ -350,10 +379,9 @@ func (db *Database) Enable(root common.Hash) error {
350379
return errDatabaseReadOnly
351380
}
352381
// Ensure the provided state root matches the stored one.
353-
root = types.TrieRootHash(root)
354-
stored := types.EmptyRootHash
355-
if blob := rawdb.ReadAccountTrieNode(db.diskdb, nil); len(blob) > 0 {
356-
stored = crypto.Keccak256Hash(blob)
382+
stored, err := db.hasher(rawdb.ReadAccountTrieNode(db.diskdb, nil))
383+
if err != nil {
384+
return err
357385
}
358386
if stored != root {
359387
return fmt.Errorf("state root mismatch: stored %x, synced %x", stored, root)
@@ -389,6 +417,8 @@ func (db *Database) Enable(root common.Hash) error {
389417
// Recover rollbacks the database to a specified historical point.
390418
// The state is supported as the rollback destination only if it's
391419
// canonical state and the corresponding trie histories are existent.
420+
//
421+
// The supplied root must be a valid trie hash value.
392422
func (db *Database) Recover(root common.Hash) error {
393423
db.lock.Lock()
394424
defer db.lock.Unlock()
@@ -401,7 +431,6 @@ func (db *Database) Recover(root common.Hash) error {
401431
return errors.New("state rollback is non-supported")
402432
}
403433
// Short circuit if the target state is not recoverable
404-
root = types.TrieRootHash(root)
405434
if !db.Recoverable(root) {
406435
return errStateUnrecoverable
407436
}
@@ -434,9 +463,10 @@ func (db *Database) Recover(root common.Hash) error {
434463
}
435464

436465
// Recoverable returns the indicator if the specified state is recoverable.
466+
//
467+
// The supplied root must be a valid trie hash value.
437468
func (db *Database) Recoverable(root common.Hash) bool {
438469
// Ensure the requested state is a known state.
439-
root = types.TrieRootHash(root)
440470
id := rawdb.ReadStateID(db.diskdb, root)
441471
if id == nil {
442472
return false

0 commit comments

Comments
 (0)