Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
more

more
  • Loading branch information
HAOYUatHZ committed Apr 6, 2023
1 parent 1529f33 commit 6ad4822
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
9 changes: 5 additions & 4 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
txLookupCache, _ := lru.New(txLookupCacheLimit)
futureBlocks, _ := lru.New(maxFutureBlocks)
// override snapshot setting
if chainConfig.Zktrie && cacheConfig.SnapshotLimit > 0 {
if chainConfig.Scroll != nil && chainConfig.Scroll.UseZktrie && cacheConfig.SnapshotLimit > 0 {
log.Warn("Snapshot has been disabled by zktrie")
cacheConfig.SnapshotLimit = 0
}

if chainConfig.FeeVaultAddress != nil {
log.Warn("Using fee vault address", "FeeVaultAddress", *chainConfig.FeeVaultAddress)
if chainConfig.Scroll != nil && chainConfig.Scroll.FeeVaultAddress != nil {
log.Warn("Using fee vault address", "FeeVaultAddress", *chainConfig.Scroll.FeeVaultAddress)
}

bc := &BlockChain{
Expand All @@ -249,7 +249,8 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
Cache: cacheConfig.TrieCleanLimit,
Journal: cacheConfig.TrieCleanJournal,
Preimages: cacheConfig.Preimages,
Zktrie: chainConfig.Zktrie,
// TODO:
// Zktrie: chainConfig.Zktrie,
}),
quit: make(chan struct{}),
chainmu: syncx.NewClosableMutex(),
Expand Down
14 changes: 7 additions & 7 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
storedcfg := rawdb.ReadChainConfig(db, stored)
if storedcfg == nil {
log.Warn("Found genesis block without chain config")
} else {
trieCfg = &trie.Config{Zktrie: storedcfg.Zktrie}
} else if storedcfg.Scroll != nil {
trieCfg = &trie.Config{Zktrie: storedcfg.Scroll.UseZktrie}
}
} else {
trieCfg = &trie.Config{Zktrie: genesis.Config.Zktrie}
} else if genesis.Config.Scroll != nil {
trieCfg = &trie.Config{Zktrie: genesis.Config.Scroll.UseZktrie}
}

if _, err := state.New(header.Root, state.NewDatabaseWithConfig(db, trieCfg), nil); err != nil {
Expand Down Expand Up @@ -276,8 +276,8 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
db = rawdb.NewMemoryDatabase()
}
var trieCfg *trie.Config
if g.Config != nil {
trieCfg = &trie.Config{Zktrie: g.Config.Zktrie}
if g.Config != nil && g.Config.Scroll != nil {
trieCfg = &trie.Config{Zktrie: g.Config.Scroll.UseZktrie}
}
statedb, err := state.New(common.Hash{}, state.NewDatabaseWithConfig(db, trieCfg), nil)
if err != nil {
Expand Down Expand Up @@ -315,7 +315,7 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
if g.Config != nil && g.Config.IsLondon(common.Big0) {
if g.BaseFee != nil {
head.BaseFee = g.BaseFee
} else if g.Config.EnableEIP2718 && g.Config.EnableEIP1559 {
} else if g.Config.Scroll != nil && g.Config.Scroll.EnableEIP2718 && g.Config.Scroll.EnableEIP1559 {
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
} else {
head.BaseFee = nil
Expand Down
10 changes: 8 additions & 2 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,14 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
// Update all fork indicator by next pending block number.
next := new(big.Int).Add(newHead.Number, big.NewInt(1))
pool.istanbul = pool.chainconfig.IsIstanbul(next)
pool.eip2718 = pool.chainconfig.EnableEIP2718 && pool.chainconfig.IsBerlin(next)
pool.eip1559 = pool.chainconfig.EnableEIP1559 && pool.chainconfig.IsLondon(next)

if pool.chainconfig.Scroll != nil {
pool.eip2718 = pool.chainconfig.Scroll.EnableEIP2718 && pool.chainconfig.IsBerlin(next)
pool.eip1559 = pool.chainconfig.Scroll.EnableEIP1559 && pool.chainconfig.IsLondon(next)
} else {
pool.eip2718 = pool.chainconfig.IsBerlin(next)
pool.eip1559 = pool.chainconfig.IsLondon(next)
}
}

// promoteExecutables moves transactions that have become processable from the
Expand Down

0 comments on commit 6ad4822

Please sign in to comment.