Skip to content

Commit

Permalink
Merge pull request #6 from light-scale/perf/disable-preimages-by-default
Browse files Browse the repository at this point in the history
perf: disable preimages by default
  • Loading branch information
lightscale-luke authored Jan 27, 2023
2 parents 4f145df + a6832ed commit 1090f26
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
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

0 comments on commit 1090f26

Please sign in to comment.