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

feat: bring ZkTrie in #1076

Merged
merged 43 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
024ac05
fix: trie tests
omerfirmak Oct 1, 2024
8cbdb7f
bring zktrie files in
omerfirmak Sep 24, 2024
a06856e
rename Database to MemDatabase
omerfirmak Sep 24, 2024
b791ce1
remove unused
omerfirmak Sep 24, 2024
77588d1
fold proof file into the main one
omerfirmak Sep 24, 2024
2a63b42
remove unused
omerfirmak Sep 24, 2024
2df0567
fold zktrie in zktrieimpl
omerfirmak Sep 25, 2024
5246aa2
rename and move ZktrieDatabase
omerfirmak Sep 25, 2024
a3af265
bring in zktrie tests from trie package
omerfirmak Sep 26, 2024
39c7874
conform to geth Trie interface
omerfirmak Sep 26, 2024
961496f
bring in proof tracer and tests
omerfirmak Sep 26, 2024
bede8dc
remove raw db access
omerfirmak Sep 30, 2024
46584ff
drop Impl from type
omerfirmak Sep 30, 2024
4fa2477
move ZkTrie to trie package
omerfirmak Oct 1, 2024
fc20b1b
remove dependency on scroll-tech/zktrie
omerfirmak Oct 1, 2024
4649905
rename ZkChildResolver
omerfirmak Oct 3, 2024
c3a78e0
fix leaves and add Must* functions
omerfirmak Oct 3, 2024
08158ae
remove raw db stuff
omerfirmak Oct 3, 2024
5015090
make triedb zk only
omerfirmak Oct 3, 2024
22e00d9
alias StateTrie to ZkTrie
omerfirmak Oct 3, 2024
88a8d89
remove InitHasScheme
omerfirmak Oct 4, 2024
adc38df
make zktrie error if interacted after being committed
omerfirmak Oct 5, 2024
d93bcde
remove unused
omerfirmak Oct 5, 2024
ef0b018
fix/skip state tests
omerfirmak Oct 7, 2024
61c8c0f
remove IsDebug()
omerfirmak Oct 7, 2024
7524d8c
fix/skip blockchain_test.go tests
omerfirmak Oct 7, 2024
c26f5df
skip set_head tests on PathScheme
omerfirmak Oct 7, 2024
d848c2c
fix/skip core package tests
omerfirmak Oct 7, 2024
4aba38b
make TryDelete not return an error on non-existing key
omerfirmak Oct 8, 2024
083d32a
make snap compile
omerfirmak Oct 8, 2024
6d03c0c
allow pruning
omerfirmak Oct 8, 2024
9793f0c
recursive commit to calculate a path
omerfirmak Oct 9, 2024
9899b22
cheaper childresolver
omerfirmak Oct 9, 2024
15e03a6
fix leaf parent
omerfirmak Oct 9, 2024
a0e3c25
Revert "make snap compile"
omerfirmak Oct 18, 2024
a6d9ce0
stub functions needed by snap
omerfirmak Oct 18, 2024
41e2866
implement GetKey
omerfirmak Oct 18, 2024
3c5fede
fix TestStateProcessorErrors
omerfirmak Oct 18, 2024
d42eb5e
fix filters compilation
omerfirmak Oct 18, 2024
d729b07
fix: TestTransaction_RoundTripRpcJSON
omerfirmak Oct 24, 2024
aba78f9
Merge branch 'syncUpstream/active' into omerfirmak/bring-in-zktrie
colinlyguo Oct 28, 2024
d024a3e
Merge branch 'syncUpstream/active' into omerfirmak/bring-in-zktrie
colinlyguo Oct 31, 2024
a2092c2
fix go.sum
colinlyguo Oct 31, 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
2 changes: 0 additions & 2 deletions cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ func runCmd(ctx *cli.Context) error {
triedb := trie.NewDatabase(db, &trie.Config{
Preimages: preimages,
HashDB: hashdb.Defaults,
// scroll related
IsUsingZktrie: genesisConfig.Config.Scroll.ZktrieEnabled(),
})
defer triedb.Close()
genesis := genesisConfig.MustCommit(db, triedb)
Expand Down
14 changes: 1 addition & 13 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ var (
GCModeFlag = &cli.StringFlag{
Name: "gcmode",
Usage: `Blockchain garbage collection mode, only relevant in state.scheme=hash ("full", "archive")`,
Value: GCModeArchive,
Value: GCModeFull,
Category: flags.StateCategory,
}
StateSchemeFlag = &cli.StringFlag{
Expand Down Expand Up @@ -2056,12 +2056,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
stack.Config().L1Confirmations = rpc.FinalizedBlockNumber
log.Info("Setting flag", "--l1.sync.startblock", "4038000")
stack.Config().L1DeploymentBlock = 4038000
// disable pruning
if ctx.String(GCModeFlag.Name) != GCModeArchive {
log.Crit("Must use --gcmode=archive")
}
log.Info("Pruning disabled")
cfg.NoPruning = true
case ctx.Bool(ScrollFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 534352
Expand All @@ -2072,12 +2066,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
stack.Config().L1Confirmations = rpc.FinalizedBlockNumber
log.Info("Setting flag", "--l1.sync.startblock", "18306000")
stack.Config().L1DeploymentBlock = 18306000
// disable pruning
if ctx.String(GCModeFlag.Name) != GCModeArchive {
log.Crit("Must use --gcmode=archive")
}
log.Info("Pruning disabled")
cfg.NoPruning = true
case ctx.Bool(DeveloperFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1337
Expand Down
14 changes: 5 additions & 9 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ type CacheConfig struct {
}

// triedbConfig derives the configures for trie database.
func (c *CacheConfig) triedbConfig(isUsingZktrie bool) *trie.Config {
config := &trie.Config{Preimages: c.Preimages, IsUsingZktrie: isUsingZktrie}
func (c *CacheConfig) triedbConfig() *trie.Config {
config := &trie.Config{Preimages: c.Preimages}
if c.StateScheme == rawdb.HashScheme {
config.HashDB = &hashdb.Config{
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
Expand All @@ -176,8 +176,8 @@ var defaultCacheConfig = &CacheConfig{
TrieCleanLimit: 256,
TrieDirtyLimit: 256,
TrieTimeLimit: 5 * time.Minute,
SnapshotLimit: 256,
SnapshotWait: true,
SnapshotLimit: 0, // Snapshots don't support zkTrie yet
SnapshotWait: false,
StateScheme: rawdb.HashScheme,
}

Expand Down Expand Up @@ -272,11 +272,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
cacheConfig = defaultCacheConfig
}
// Open trie database with provided config
triedbConfig := cacheConfig.triedbConfig(false)
if genesis != nil && genesis.Config != nil && genesis.Config.Scroll.ZktrieEnabled() {
cacheConfig.triedbConfig(true)
}
triedb := trie.NewDatabase(db, triedbConfig)
triedb := trie.NewDatabase(db, cacheConfig.triedbConfig())

// Setup the genesis block, commit the provided genesis specification
// to database if the genesis block is not present yet, or load the
Expand Down
3 changes: 2 additions & 1 deletion core/blockchain_repair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ func testLongReorgedSnapSyncingDeepRepair(t *testing.T, snapshots bool) {
}

func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
for _, scheme := range []string{rawdb.HashScheme /*, rawdb.PathScheme*/} {
omerfirmak marked this conversation as resolved.
Show resolved Hide resolved
testRepairWithScheme(t, tt, snapshots, scheme)
}
}
Expand Down Expand Up @@ -1898,6 +1898,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
// In this case the snapshot layer of B3 is not created because of existent
// state.
func TestIssue23496(t *testing.T) {
t.Skip("snapshot doesn't support zktrie")
testIssue23496(t, rawdb.HashScheme)
testIssue23496(t, rawdb.PathScheme)
omerfirmak marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_sethead_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ func testLongReorgedSnapSyncingDeepSetHead(t *testing.T, snapshots bool) {
}

func testSetHead(t *testing.T, tt *rewindTest, snapshots bool) {
for _, scheme := range []string{rawdb.HashScheme, rawdb.PathScheme} {
for _, scheme := range []string{rawdb.HashScheme /*, rawdb.PathScheme*/} {
testSetHeadWithScheme(t, tt, snapshots, scheme)
}
}
Expand Down
3 changes: 3 additions & 0 deletions core/blockchain_snapshot_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build all_tests
// +build all_tests

// Copyright 2020 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
Expand Down
Loading
Loading