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

v1.3.4 #49

Merged
merged 140 commits into from
Aug 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
fa8d398
cmd, core, trie: verkle-capable `geth init` (#28270)
gballet Nov 14, 2023
e803ef0
eth/tracers/js: fix isPush for push0 (#28520)
s1na Nov 14, 2023
24d4622
trie: spelling - fix comments in hasher (#28507)
sysvm Nov 14, 2023
2391fbc
tests/fuzzers: move fuzzers into native packages (#28467)
holiman Nov 14, 2023
c5b7cfa
tests: skip tests on windows 32bit CI (#28521)
holiman Nov 14, 2023
984f826
cmd/geth: more special cases logging tests (#28527)
jwasinger Nov 15, 2023
2814ee0
accounts,cmd,console,les,metrics: refactor some errors checked by (S…
BabyHalimao Nov 15, 2023
b9504e4
miner: run tests in parallel (#28506)
estensen Nov 15, 2023
fcc7ae1
internal/jsre/deps: fix typo in jsdoc (#28511)
aliening Nov 15, 2023
db7895d
accounts/abi: improve readability of method-to-string conversion (#2…
Halimao Nov 15, 2023
a75a2d6
all: replace some cases of strings.SplitN with strings.Cut (#28446)
estensen Nov 15, 2023
5bf8769
ethdb/memorydb, trie: reduced allocations (#28473)
holiman Nov 15, 2023
8b78d6a
Dockerfile: update Go to 1.21 (#28538)
estensen Nov 17, 2023
c8a2202
cmd/evm: validate blockchain tests poststate account storage (#28443)
danceratopz Nov 17, 2023
77cb21d
signer: run tests in parallel (#28536)
estensen Nov 20, 2023
a737482
accounts, cmd: fix typos (#28526)
levisyin Nov 20, 2023
14a1e96
core/txpool/legacypool: respect nolocals-setting (#28435)
jp-imx Nov 20, 2023
460cc16
cmd: run tests in parallel (#28546)
estensen Nov 20, 2023
661bd45
core/state/snapshot: print correct error from trie iterator (#28560)
rjl493456442 Nov 21, 2023
ad16f11
cmd/evm: capitalize evm commands (#28569)
tmelhao Nov 21, 2023
525db7b
accounts/abi: context info on unpack-errors (#28529)
levisyin Nov 21, 2023
146e8d9
core, trie, rpc: speed up tests (#28461)
MariusVanDerWijden Nov 21, 2023
6489a0d
ethdb/pebble: don't double-close iterator inside pebbleIterator (#28566)
magicxyyz Nov 21, 2023
e9f59b5
eth/filters: reuse error msg for invalid block range (#28479)
ucwong Nov 21, 2023
347fecd
core/types: make 'v' optional for DynamicFeeTx and BlobTx (#28564)
marioevz Nov 22, 2023
d6cea48
rpc: improve performance of subscription notification encoding (#28328)
jsvisa Nov 22, 2023
104dbf7
cmd/utils: validate pre-existing genesis in --dev mode (#28468)
jwasinger Nov 22, 2023
3cfcd25
cmd/geth: add support for --dev flag in dumpgenesis (#28463)
jwasinger Nov 22, 2023
5ff929c
les/vflux: run tests in parallel (#28524)
estensen Nov 22, 2023
d468c33
cmd/{geth,utils}: add cmd to export preimages in snap enumeration ord…
gballet Nov 22, 2023
63127f5
cmd/geth: fix build error (#28585)
fjl Nov 22, 2023
eec37e3
cmd/devp2p/internal/ethtest: undo debug-hack (#28588)
holiman Nov 23, 2023
d76efbb
params: update discV5 bootnodes (#28562)
cortze Nov 23, 2023
bdf5e38
cmd, les, tests: remove light client code (#28586)
MariusVanDerWijden Nov 23, 2023
2a20130
eth, internal/ethapi: drop some weird indirection (#28597)
karalabe Nov 24, 2023
333dd95
trie: fix random test generator early terminate (#28590)
weiihann Nov 25, 2023
1e28e0b
eth/gasestimator, internal/ethapi: move gas estimator out of rpc (#28…
karalabe Nov 27, 2023
5b57727
go.mod: update uint256 to v1.2.4 (#28612)
holiman Nov 27, 2023
71817f3
eth/catalyst, eth/downloader: expose more sync information (#28584)
rjl493456442 Nov 28, 2023
58297e3
light: remove package light(#28614)
lightclient Nov 28, 2023
63979bc
cmd/evm, core/state: fix post-exec dump of state (statetests, blockch…
holiman Nov 28, 2023
248dc50
ethereum: remove TODO comment about subscription (#28609)
sbs2001 Nov 28, 2023
bbc5db8
eth/tracers/js: fix type inconsistencies (#28488)
s1na Nov 28, 2023
34dcd74
crypto/secp256k1: fix 32-bit tests when CGO_ENABLED=0 (#28602)
gballet Nov 28, 2023
e0c7ad0
consensus: verify the nonexistence of shanghai- and cancun-specific h…
jakub-freebit Nov 28, 2023
61b844f
eth/gasestimator: allow slight estimation error in favor of less iter…
karalabe Nov 28, 2023
28e7371
all: replace log15 with slog (#28187)
jwasinger Nov 29, 2023
ab0eb46
core/state: make stateobject.create selfcontain (#28459)
rjl493456442 Nov 29, 2023
fa0df76
trie/triedb/hashdb: take lock around access to dirties cache (#28542)
magicxyyz Nov 30, 2023
f2b509d
accounts/abi/bind: fix typo (#28630)
BorkBorked Dec 1, 2023
dd0d0a2
slog: faster and less memory-consumption (#28621)
holiman Dec 1, 2023
5fb8ebc
eth/tracers: tx-level state in debug_traceCall (#28460)
jsvisa Dec 1, 2023
6e488c2
cmd/evm: fix Env struct json tag (#28635)
ddl-hust Dec 4, 2023
f04e5bd
accounts/abi/bind: fixed typos (#28634)
BorkBorked Dec 4, 2023
70fd0b6
eth/fetcher: fix invalid tracking of received at time for block (#28637)
manav2401 Dec 4, 2023
2e13b01
accounts: run tests in parallel (#28544)
estensen Dec 4, 2023
3dc071e
eth/tracers/logger: make structlog/json-log stack hex again (#28628)
holiman Dec 5, 2023
b8d44ed
log: remove lazy, remove unused interfaces, unexport methods (#28622)
holiman Dec 5, 2023
69576df
.github: use github actions to run 32-bit linux tests (#28549)
gballet Dec 5, 2023
55b483d
ethdb/pebble: remove a dependency (#28627)
MariusVanDerWijden Dec 6, 2023
a113497
tests/fuzzers/bls12381: deactivate BLS fuzzer when CGO_ENABLED=0 (#28…
gballet Dec 7, 2023
77c4bbc
build: upgrade -dlgo version to Go 1.21.5 (#28648)
sandakersmann Dec 7, 2023
5a45e7a
rpc: fix ns/µs mismatch in metrics (#28649)
holiman Dec 8, 2023
1048e2d
cmd/evm: fix dump after state-test exec (#28650)
holiman Dec 8, 2023
fff843c
beacon/light: add CommitteeChain (#27766)
zsfelfoldi Dec 8, 2023
d98d70f
cmd/utils, eth: disallow invalid snap sync / snapshot flag combos (#2…
karalabe Dec 8, 2023
e206d3f
trie: remove inconsistent trie nodes during sync in path mode (#28595)
rjl493456442 Dec 8, 2023
a3ca1b2
cmd/utils: fix HTTPHost, WSHost flag priority (#28669)
weiihann Dec 12, 2023
17c2b3c
eth/protocols/eth: fix typos in comments (#28652)
guerrierindien Dec 12, 2023
81fd1b3
core/txpool : small cleanup refactors (#28654)
ucwong Dec 12, 2023
b2ced97
eth/fetcher, eth/gasestimator: fix typos in comments (#28675)
Ursulafe Dec 13, 2023
0f74aad
all: fix typos in comments (#28662)
nnsW3 Dec 13, 2023
f1794ba
miner: eliminate the dead loop possibility for `newWorkLoop` and `mai…
FletcherMan Dec 15, 2023
edc864f
all: fix typos in comments (#28682)
bodhi-crypo Dec 18, 2023
5b22a47
p2p/discover: add liveness check in collectTableNodes (#28686)
fjl Dec 18, 2023
02766d3
internal/flags: add missing flag types for auto-env-var generation (#…
sebastianst Dec 18, 2023
05bbc56
cmd/evm: default to mirror mainnet forks enabled (#28691)
jwasinger Dec 18, 2023
553bafc
cmd/evm, cmd/clef, cmd/bootnode: fix / unify logging (#28696)
holiman Dec 18, 2023
c18c5c3
cmd/evm: t8n support custom tracers (#28557)
jsvisa Dec 18, 2023
a18b845
params: release go-ethereum v1.13.6 stable
fjl Dec 18, 2023
5ba3d57
Merge branch 'release/1.13' into release-1.13.6
fjl Dec 18, 2023
da6cdaf
all: release go-ethereum v1.13.6
fjl Dec 18, 2023
5d77c38
Merge tag 'v1.13.6' into upstream_merge
cffls Mar 28, 2024
3fc3de0
Fix build errors
cffls Mar 29, 2024
98a2f47
Fix test-integration
cffls Mar 29, 2024
2e48bb1
Merge pull request #1205 from cffls/upstream_merge
cffls Apr 9, 2024
7e2be02
Merge upstream_merge branch to develop (#1229)
cffls Apr 29, 2024
3a719a8
eth/tracers: avoid data race when tracing block with bor tx (#1214)
easyfold May 3, 2024
bf6ca34
build(deps): bump golang.org/x/net from 0.22.0 to 0.23.0 (#1225)
dependabot[bot] May 3, 2024
96ef9db
cherry pick to fix lints
holiman Mar 18, 2024
9e07678
Merge branch 'develop' into merge-master
anshalshukla May 6, 2024
f2a892c
fix: lint
anshalshukla May 6, 2024
8fc2a95
Merge pull request #1241 from maticnetwork/merge-master
anshalshukla May 6, 2024
902c1ce
eth: explicitly commented the code were bor could get into snap-sync …
pratikspatil024 May 9, 2024
d95c05b
Enable ancient block pruning (#1216)
manav2401 May 9, 2024
5f6a76b
added error handeling in ethstats.go which prevents node to panic (#1…
pratikspatil024 May 27, 2024
368a1a3
not going into snap sync (#1247)
pratikspatil024 May 27, 2024
4170c27
Merge pull request #1250 from maticnetwork/psp-master
pratikspatil024 May 27, 2024
052405b
Revert "Merge upstream_merge branch to develop (#1229)"
pratikspatil024 May 28, 2024
54c8ddb
some fixed due to recent changes
pratikspatil024 May 28, 2024
5db6fa7
Merge pull request #1253 from maticnetwork/psp-develop
pratikspatil024 May 28, 2024
6a5c552
Merge branch 'develop' of https://github.com/maticnetwork/bor into up…
pratikspatil024 May 28, 2024
e789b4e
eth/internal: add `debug.peerStats` for stats related to all connecte…
manav2401 May 28, 2024
f25b6ef
Merge branch 'develop' of https://github.com/maticnetwork/bor into up…
pratikspatil024 May 28, 2024
3278c79
Merge pull request #1254 from maticnetwork/upstream_merge
pratikspatil024 May 29, 2024
d8374ec
bump version to v1.3.3-beta
manav2401 May 30, 2024
a0acefc
eth: broadcast block to static and trusted peers as well (#1258)
pratikspatil024 Jun 6, 2024
c0d1fbb
Fix panic when fetching block in case of reorg (#1259)
pratikspatil024 Jun 6, 2024
5b0805d
version bump to 1.3.3-beta2
pratikspatil024 Jun 6, 2024
57b77e3
chg: fix percentile validation in fee history (#1235)
marcello33 May 1, 2024
e28c203
remove additional bootnodes (#1255)
anshalshukla Jun 6, 2024
6bc8334
eth/fetcher: modify queue limits for improving sync near chain tip (#…
manav2401 Jun 7, 2024
2aa76a9
eth: change block propagation and announcement logs to debug
manav2401 Jun 10, 2024
e6a4625
bump version to v1.3.3-beta3
manav2401 Jun 10, 2024
1351a54
p2p/discover: improved node revalidation (#29572)
fjl May 23, 2024
706cf1c
p2p/discover: fix crash when revalidated node is removed (#29864)
fjl May 28, 2024
be1e580
p2p/enode: fix endpoint determination for IPv6 (#29801)
fjl May 23, 2024
b2c178d
p2p/enode: fix TCPEndpoint (#29827)
AaronChen0 May 23, 2024
7850a9f
p2p/discover: fix update logic in handleAddNode (#29836)
lightclient May 28, 2024
0e093b2
p2p/discover: refactor node and endpoint representation (#29844)
fjl May 29, 2024
642f552
p2p: fix race in dialScheduler (#29235)
fjl Mar 12, 2024
22670cd
version bump to 1.3.3
pratikspatil024 Jun 12, 2024
625774f
Merge pull request #1265 from maticnetwork/1.3.3-candidate
pratikspatil024 Jun 12, 2024
d0a212b
Merge pull request #1266 from maticnetwork/master
pratikspatil024 Jun 12, 2024
d67620c
core, eth, internal, miner, params: enforce 30gwei for gas related co…
marcello33 Jun 12, 2024
bd5d54e
Merge pull request #1267 from maticnetwork/psp-p2p-upstream
pratikspatil024 Jun 13, 2024
a9e5c95
chg: upgrade deps and solve sec issues (#1261)
marcello33 Jun 10, 2024
9c2d462
internal/cli: check for delete permissions before starting to prune (…
manav2401 Jun 18, 2024
2fd85b3
eth, consensus: refactor whitelisting related logs and improve error …
manav2401 Jun 18, 2024
c551b41
bump version to v1.3.4-beta
manav2401 Jun 19, 2024
0bc2dcb
cmd/utils: use defined filter api instance instead of a new one (#1270)
manav2401 Jun 20, 2024
b228a47
bump version to v1.3.4-beta2
manav2401 Jun 21, 2024
32c9405
core/rawdb: log ancient pruner offset
manav2401 Jun 24, 2024
1a05223
PIP-35 for amoy: enforce gas related configs (#1285)
manav2401 Jul 11, 2024
6715996
miner: log last tx hash before commit interrupt (#1289)
manav2401 Jul 11, 2024
31545e5
bump version to v1.3.4-beta3
manav2401 Jul 11, 2024
dce4253
PIP-35: enforce gas related configs for mainnet (#1290)
manav2401 Jul 23, 2024
29840e2
bump version to v1.3.4
manav2401 Jul 25, 2024
9e274ca
Merge tag 'v1.3.4' into TS_v1.3.4
tyler-smith Jul 30, 2024
ada2bff
Remove BN-added file from now-deleted directory.
tyler-smith Aug 1, 2024
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
Next Next commit
cmd, core, trie: verkle-capable geth init (#28270)
This change allows the creation of a genesis block for verkle testnets. This makes for a chunk of code that is easier to review and still touches many discussion points.
gballet authored Nov 14, 2023
commit fa8d39807dc557d9a32a5c8e311ef1209b809e82
4 changes: 2 additions & 2 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
@@ -211,7 +211,7 @@ func initGenesis(ctx *cli.Context) error {
}
defer chaindb.Close()

triedb := utils.MakeTrieDatabase(ctx, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false)
triedb := utils.MakeTrieDatabase(ctx, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false, genesis.IsVerkle())
defer triedb.Close()

_, hash, err := core.SetupGenesisBlockWithOverride(chaindb, triedb, genesis, &overrides)
@@ -485,7 +485,7 @@ func dump(ctx *cli.Context) error {
if err != nil {
return err
}
triedb := utils.MakeTrieDatabase(ctx, db, true, true) // always enable preimage lookup
triedb := utils.MakeTrieDatabase(ctx, db, true, true, false) // always enable preimage lookup
defer triedb.Close()

state, err := state.New(root, state.NewDatabaseWithNodeDB(db, triedb), nil)
2 changes: 1 addition & 1 deletion cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
@@ -482,7 +482,7 @@ func dbDumpTrie(ctx *cli.Context) error {
db := utils.MakeChainDatabase(ctx, stack, true)
defer db.Close()

triedb := utils.MakeTrieDatabase(ctx, db, false, true)
triedb := utils.MakeTrieDatabase(ctx, db, false, true, false)
defer triedb.Close()

var (
8 changes: 4 additions & 4 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
@@ -205,7 +205,7 @@ func verifyState(ctx *cli.Context) error {
log.Error("Failed to load head block")
return errors.New("no head block")
}
triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true)
triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true, false)
defer triedb.Close()

snapConfig := snapshot.Config{
@@ -260,7 +260,7 @@ func traverseState(ctx *cli.Context) error {
chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close()

triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true)
triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true, false)
defer triedb.Close()

headBlock := rawdb.ReadHeadBlock(chaindb)
@@ -369,7 +369,7 @@ func traverseRawState(ctx *cli.Context) error {
chaindb := utils.MakeChainDatabase(ctx, stack, true)
defer chaindb.Close()

triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true)
triedb := utils.MakeTrieDatabase(ctx, chaindb, false, true, false)
defer triedb.Close()

headBlock := rawdb.ReadHeadBlock(chaindb)
@@ -533,7 +533,7 @@ func dumpState(ctx *cli.Context) error {
if err != nil {
return err
}
triedb := utils.MakeTrieDatabase(ctx, db, false, true)
triedb := utils.MakeTrieDatabase(ctx, db, false, true, false)
defer triedb.Close()

snapConfig := snapshot.Config{
6 changes: 3 additions & 3 deletions cmd/geth/verkle.go
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ func checkChildren(root verkle.VerkleNode, resolver verkle.NodeResolverFn) error
return fmt.Errorf("could not find child %x in db: %w", childC, err)
}
// depth is set to 0, the tree isn't rebuilt so it's not a problem
childN, err := verkle.ParseNode(childS, 0, childC[:])
childN, err := verkle.ParseNode(childS, 0)
if err != nil {
return fmt.Errorf("decode error child %x in db: %w", child.Commitment().Bytes(), err)
}
@@ -145,7 +145,7 @@ func verifyVerkle(ctx *cli.Context) error {
if err != nil {
return err
}
root, err := verkle.ParseNode(serializedRoot, 0, rootC[:])
root, err := verkle.ParseNode(serializedRoot, 0)
if err != nil {
return err
}
@@ -195,7 +195,7 @@ func expandVerkle(ctx *cli.Context) error {
if err != nil {
return err
}
root, err := verkle.ParseNode(serializedRoot, 0, rootC[:])
root, err := verkle.ParseNode(serializedRoot, 0)
if err != nil {
return err
}
3 changes: 2 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
@@ -2212,9 +2212,10 @@ func MakeConsolePreloads(ctx *cli.Context) []string {
}

// MakeTrieDatabase constructs a trie database based on the configured scheme.
func MakeTrieDatabase(ctx *cli.Context, disk ethdb.Database, preimage bool, readOnly bool) *trie.Database {
func MakeTrieDatabase(ctx *cli.Context, disk ethdb.Database, preimage bool, readOnly bool, isVerkle bool) *trie.Database {
config := &trie.Config{
Preimages: preimage,
IsVerkle: isVerkle,
}
scheme, err := rawdb.ParseStateScheme(ctx.String(StateSchemeFlag.Name), disk)
if err != nil {
23 changes: 20 additions & 3 deletions core/genesis.go
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/pathdb"
)

//go:generate go run github.com/fjl/gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go
@@ -121,10 +122,20 @@ func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error {
}

// hash computes the state root according to the genesis specification.
func (ga *GenesisAlloc) hash() (common.Hash, error) {
func (ga *GenesisAlloc) hash(isVerkle bool) (common.Hash, error) {
// If a genesis-time verkle trie is requested, create a trie config
// with the verkle trie enabled so that the tree can be initialized
// as such.
var config *trie.Config
if isVerkle {
config = &trie.Config{
PathDB: pathdb.Defaults,
IsVerkle: true,
}
}
// Create an ephemeral in-memory database for computing hash,
// all the derived states will be discarded to not pollute disk.
db := state.NewDatabase(rawdb.NewMemoryDatabase())
db := state.NewDatabaseWithConfig(rawdb.NewMemoryDatabase(), config)
statedb, err := state.New(types.EmptyRootHash, db, nil)
if err != nil {
return common.Hash{}, err
@@ -410,9 +421,15 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
}
}

// IsVerkle indicates whether the state is already stored in a verkle
// tree at genesis time.
func (g *Genesis) IsVerkle() bool {
return g.Config.IsVerkle(new(big.Int).SetUint64(g.Number), g.Timestamp)
}

// ToBlock returns the genesis block according to genesis specification.
func (g *Genesis) ToBlock() *types.Block {
root, err := g.Alloc.hash()
root, err := g.Alloc.hash(g.IsVerkle())
if err != nil {
panic(err)
}
66 changes: 65 additions & 1 deletion core/genesis_test.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
package core

import (
"bytes"
"encoding/json"
"math/big"
"reflect"
@@ -231,7 +232,7 @@ func TestReadWriteGenesisAlloc(t *testing.T) {
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
{2}: {Balance: big.NewInt(2), Storage: map[common.Hash]common.Hash{{2}: {2}}},
}
hash, _ = alloc.hash()
hash, _ = alloc.hash(false)
)
blob, _ := json.Marshal(alloc)
rawdb.WriteGenesisStateSpec(db, hash, blob)
@@ -261,3 +262,66 @@ func newDbConfig(scheme string) *trie.Config {
}
return &trie.Config{PathDB: pathdb.Defaults}
}

func TestVerkleGenesisCommit(t *testing.T) {
var verkleTime uint64 = 0
verkleConfig := &params.ChainConfig{
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
MergeNetsplitBlock: nil,
ShanghaiTime: &verkleTime,
CancunTime: &verkleTime,
PragueTime: &verkleTime,
VerkleTime: &verkleTime,
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
Ethash: nil,
Clique: nil,
}

genesis := &Genesis{
BaseFee: big.NewInt(params.InitialBaseFee),
Config: verkleConfig,
Timestamp: verkleTime,
Difficulty: big.NewInt(0),
Alloc: GenesisAlloc{
{1}: {Balance: big.NewInt(1), Storage: map[common.Hash]common.Hash{{1}: {1}}},
},
}

expected := common.Hex2Bytes("14398d42be3394ff8d50681816a4b7bf8d8283306f577faba2d5bc57498de23b")
got := genesis.ToBlock().Root().Bytes()
if !bytes.Equal(got, expected) {
t.Fatalf("invalid genesis state root, expected %x, got %x", expected, got)
}

db := rawdb.NewMemoryDatabase()
triedb := trie.NewDatabase(db, &trie.Config{IsVerkle: true, PathDB: pathdb.Defaults})
block := genesis.MustCommit(db, triedb)
if !bytes.Equal(block.Root().Bytes(), expected) {
t.Fatalf("invalid genesis state root, expected %x, got %x", expected, got)
}

// Test that the trie is verkle
if !triedb.IsVerkle() {
t.Fatalf("expected trie to be verkle")
}

if !rawdb.ExistsAccountTrieNode(db, nil) {
t.Fatal("could not find node")
}
}
51 changes: 34 additions & 17 deletions core/state/database.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ import (
"errors"
"fmt"

"github.com/crate-crypto/go-ipa/banderwagon"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/lru"
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -28,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/trienode"
"github.com/ethereum/go-ethereum/trie/utils"
)

const (
@@ -36,6 +38,12 @@ const (

// Cache size granted for caching clean code.
codeCacheSize = 64 * 1024 * 1024

// commitmentSize is the size of commitment stored in cache.
commitmentSize = banderwagon.UncompressedSize

// Cache item granted for caching commitment results.
commitmentCacheItems = 64 * 1024 * 1024 / (commitmentSize + common.AddressLength)
)

// Database wraps access to tries and contract code.
@@ -44,7 +52,7 @@ type Database interface {
OpenTrie(root common.Hash) (Trie, error)

// OpenStorageTrie opens the storage trie of an account.
OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash) (Trie, error)
OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash, trie Trie) (Trie, error)

// CopyTrie returns an independent copy of the given trie.
CopyTrie(Trie) Trie
@@ -70,11 +78,6 @@ type Trie interface {
// TODO(fjl): remove this when StateTrie is removed
GetKey([]byte) []byte

// GetStorage returns the value for key stored in the trie. The value bytes
// must not be modified by the caller. If a node was not found in the database,
// a trie.MissingNodeError is returned.
GetStorage(addr common.Address, key []byte) ([]byte, error)

// GetAccount abstracts an account read from the trie. It retrieves the
// account blob from the trie with provided account address and decodes it
// with associated decoding algorithm. If the specified account is not in
@@ -83,27 +86,32 @@ type Trie interface {
// be returned.
GetAccount(address common.Address) (*types.StateAccount, error)

// UpdateStorage associates key with value in the trie. If value has length zero,
// any existing value is deleted from the trie. The value bytes must not be modified
// by the caller while they are stored in the trie. If a node was not found in the
// database, a trie.MissingNodeError is returned.
UpdateStorage(addr common.Address, key, value []byte) error
// GetStorage returns the value for key stored in the trie. The value bytes
// must not be modified by the caller. If a node was not found in the database,
// a trie.MissingNodeError is returned.
GetStorage(addr common.Address, key []byte) ([]byte, error)

// UpdateAccount abstracts an account write to the trie. It encodes the
// provided account object with associated algorithm and then updates it
// in the trie with provided address.
UpdateAccount(address common.Address, account *types.StateAccount) error

// UpdateContractCode abstracts code write to the trie. It is expected
// to be moved to the stateWriter interface when the latter is ready.
UpdateContractCode(address common.Address, codeHash common.Hash, code []byte) error
// UpdateStorage associates key with value in the trie. If value has length zero,
// any existing value is deleted from the trie. The value bytes must not be modified
// by the caller while they are stored in the trie. If a node was not found in the
// database, a trie.MissingNodeError is returned.
UpdateStorage(addr common.Address, key, value []byte) error

// DeleteAccount abstracts an account deletion from the trie.
DeleteAccount(address common.Address) error

// DeleteStorage removes any existing value for key from the trie. If a node
// was not found in the database, a trie.MissingNodeError is returned.
DeleteStorage(addr common.Address, key []byte) error

// DeleteAccount abstracts an account deletion from the trie.
DeleteAccount(address common.Address) error
// UpdateContractCode abstracts code write to the trie. It is expected
// to be moved to the stateWriter interface when the latter is ready.
UpdateContractCode(address common.Address, codeHash common.Hash, code []byte) error

// Hash returns the root hash of the trie. It does not write to the database and
// can be used even if the trie doesn't have one.
@@ -170,6 +178,9 @@ type cachingDB struct {

// OpenTrie opens the main account trie at a specific root hash.
func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
if db.triedb.IsVerkle() {
return trie.NewVerkleTrie(root, db.triedb, utils.NewPointCache(commitmentCacheItems))
}
tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.triedb)
if err != nil {
return nil, err
@@ -178,7 +189,13 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
}

// OpenStorageTrie opens the storage trie of an account.
func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash) (Trie, error) {
func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Address, root common.Hash, self Trie) (Trie, error) {
// In the verkle case, there is only one tree. But the two-tree structure
// is hardcoded in the codebase. So we need to return the same trie in this
// case.
if db.triedb.IsVerkle() {
return self, nil
}
tr, err := trie.NewStateTrie(trie.StorageTrieID(stateRoot, crypto.Keccak256Hash(address.Bytes()), root), db.triedb)
if err != nil {
return nil, err
2 changes: 1 addition & 1 deletion core/state/iterator.go
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ func (it *nodeIterator) step() error {
address := common.BytesToAddress(preimage)

// Traverse the storage slots belong to the account
dataTrie, err := it.state.db.OpenStorageTrie(it.state.originalRoot, address, account.Root)
dataTrie, err := it.state.db.OpenStorageTrie(it.state.originalRoot, address, account.Root, it.state.trie)
if err != nil {
return err
}
2 changes: 1 addition & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ func (s *stateObject) getTrie() (Trie, error) {
s.trie = s.db.prefetcher.trie(s.addrHash, s.data.Root)
}
if s.trie == nil {
tr, err := s.db.db.OpenStorageTrie(s.db.originalRoot, s.address, s.data.Root)
tr, err := s.db.db.OpenStorageTrie(s.db.originalRoot, s.address, s.data.Root, s.db.trie)
if err != nil {
return nil, err
}
2 changes: 1 addition & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
@@ -998,7 +998,7 @@ func (s *StateDB) fastDeleteStorage(addrHash common.Hash, root common.Hash) (boo
// employed when the associated state snapshot is not available. It iterates the
// storage slots along with all internal trie nodes via trie directly.
func (s *StateDB) slowDeleteStorage(addr common.Address, addrHash common.Hash, root common.Hash) (bool, common.StorageSize, map[common.Hash][]byte, *trienode.NodeSet, error) {
tr, err := s.db.OpenStorageTrie(s.originalRoot, addr, root)
tr, err := s.db.OpenStorageTrie(s.originalRoot, addr, root, s.trie)
if err != nil {
return false, 0, nil, nil, fmt.Errorf("failed to open storage trie, err: %w", err)
}
4 changes: 3 additions & 1 deletion core/state/trie_prefetcher.go
Original file line number Diff line number Diff line change
@@ -305,7 +305,9 @@ func (sf *subfetcher) loop() {
}
sf.trie = trie
} else {
trie, err := sf.db.OpenStorageTrie(sf.state, sf.addr, sf.root)
// The trie argument can be nil as verkle doesn't support prefetching
// yet. TODO FIX IT(rjl493456442), otherwise code will panic here.
trie, err := sf.db.OpenStorageTrie(sf.state, sf.addr, sf.root, nil)
if err != nil {
log.Warn("Trie prefetcher failed opening trie", "root", sf.root, "err", err)
return
Loading