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

perf: disable preimages by default #6

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 1 addition & 10 deletions light/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ type TxPool struct {

istanbul bool // Fork indicator whether we are in the istanbul stage.
eip2718 bool // Fork indicator whether we are in the eip2718 stage.

// [Scroll: START]
// NOTE(chokobole): This part is different from scroll
zktrie bool
// [Scroll: END]
}

// TxRelayBackend provides an interface to the mechanism that forwards transactions to the
Expand Down Expand Up @@ -109,10 +104,6 @@ func NewTxPool(config *params.ChainConfig, chain *LightChain, relay TxRelayBacke
chainDb: chain.Odr().Database(),
head: chain.CurrentHeader().Hash(),
clearIdx: chain.CurrentHeader().Number.Uint64(),
// [Scroll: START]
// NOTE(chokobole): This part is different from scroll
zktrie: config.Zktrie,
// [Scroll: END]
}
// Subscribe events from blockchain
pool.chainHeadSub = pool.chain.SubscribeChainHeadEvent(pool.chainHeadCh)
Expand All @@ -125,7 +116,7 @@ func NewTxPool(config *params.ChainConfig, chain *LightChain, relay TxRelayBacke
func (pool *TxPool) currentState(ctx context.Context) *state.StateDB {
// [Scroll: START]
// NOTE(chokobole): This part is different from scroll
return NewState(ctx, pool.chain.CurrentHeader(), pool.odr, pool.zktrie)
return NewState(ctx, pool.chain.CurrentHeader(), pool.odr, pool.config.Zktrie)
// [Scroll: END]
}

Expand Down
3 changes: 1 addition & 2 deletions trie/zk_trie_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ type ZktrieDatabase struct {

func NewZktrieDatabase(diskdb ethdb.KeyValueStore) *ZktrieDatabase {
// NOTE(chokobole): This part is different from scroll
// TODO(chokobole): We need to know Preimages is required. If we don't set here, some tests are failed.
return &ZktrieDatabase{db: NewDatabaseWithConfig(diskdb, &Config{Preimages: true, Zktrie: true}), prefix: []byte{}}
return &ZktrieDatabase{db: NewDatabaseWithConfig(diskdb, &Config{Zktrie: true}), prefix: []byte{}}
}

// adhoc wrapper...
Expand Down
3 changes: 2 additions & 1 deletion trie/zk_trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import (
)

func newEmptyZkTrie() *ZkTrie {
trie, _ := NewZkTrie(common.Hash{}, NewZktrieDatabase(memorydb.New()))
triedb := NewZktrieDatabaseFromTriedb(NewDatabaseWithConfig(memorydb.New(), &Config{Preimages: true}))
trie, _ := NewZkTrie(common.Hash{}, triedb)
return trie
}

Expand Down