Commit 738d6f29 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #1335 from ethereum-optimism/l2geth/reduce-blockchain-diff

l2geth: remove dead code in `blockchain.go` and `miner/worker.go`
parents 3aa7695b 6dbb9293
---
'@eth-optimism/l2geth': patch
---
Remove dead code in `blockchain.go` and `miner/worker.go`
...@@ -151,8 +151,6 @@ type BlockChain struct { ...@@ -151,8 +151,6 @@ type BlockChain struct {
chainmu sync.RWMutex // blockchain insertion lock chainmu sync.RWMutex // blockchain insertion lock
currentTimestamp atomic.Value // Timestamp to be used when mining the current block.
currentBlock atomic.Value // Current head of the block chain currentBlock atomic.Value // Current head of the block chain
currentFastBlock atomic.Value // Current head of the fast-sync chain (may be above the block chain!) currentFastBlock atomic.Value // Current head of the fast-sync chain (may be above the block chain!)
...@@ -249,13 +247,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par ...@@ -249,13 +247,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
// it in advance. // it in advance.
bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true) bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true)
if currentHeader := bc.CurrentHeader(); currentHeader != nil {
log.Debug("Read timestamp from last block. ", "timestamp", bc.CurrentHeader().Time)
bc.SetCurrentTimestamp(int64(bc.CurrentHeader().Time))
} else {
bc.SetCurrentTimestamp(int64(0))
}
if frozen, err := bc.db.Ancients(); err == nil && frozen > 0 { if frozen, err := bc.db.Ancients(); err == nil && frozen > 0 {
var ( var (
needRewind bool needRewind bool
...@@ -504,17 +495,6 @@ func (bc *BlockChain) GasLimit() uint64 { ...@@ -504,17 +495,6 @@ func (bc *BlockChain) GasLimit() uint64 {
return bc.CurrentBlock().GasLimit() return bc.CurrentBlock().GasLimit()
} }
// SetCurrentTimestamp sets the timestamp for blocks added to the canonical chain.
func (bc *BlockChain) SetCurrentTimestamp(timestamp int64) {
bc.currentTimestamp.Store(&timestamp)
}
// CurrentTimestamp retrieves the timestamp used for blocks added to the canonical chain.
func (bc *BlockChain) CurrentTimestamp() int64 {
// Note: Can never be nil
return *bc.currentTimestamp.Load().(*int64)
}
// CurrentBlock retrieves the current head block of the canonical chain. The // CurrentBlock retrieves the current head block of the canonical chain. The
// block is retrieved from the blockchain's internal cache. // block is retrieved from the blockchain's internal cache.
func (bc *BlockChain) CurrentBlock() *types.Block { func (bc *BlockChain) CurrentBlock() *types.Block {
......
...@@ -320,10 +320,6 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) ...@@ -320,10 +320,6 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
return b.eth.txPool.AddLocal(signedTx) return b.eth.txPool.AddLocal(signedTx)
} }
func (b *EthAPIBackend) SetTimestamp(timestamp int64) {
b.eth.blockchain.SetCurrentTimestamp(timestamp)
}
func (b *EthAPIBackend) GetPoolTransactions() (types.Transactions, error) { func (b *EthAPIBackend) GetPoolTransactions() (types.Transactions, error) {
pending, err := b.eth.txPool.Pending() pending, err := b.eth.txPool.Pending()
if err != nil { if err != nil {
......
...@@ -86,7 +86,6 @@ type Backend interface { ...@@ -86,7 +86,6 @@ type Backend interface {
CurrentBlock() *types.Block CurrentBlock() *types.Block
// Optimism-specific API // Optimism-specific API
SetTimestamp(timestamp int64)
IsVerifier() bool IsVerifier() bool
IsSyncing() bool IsSyncing() bool
GetEthContext() (uint64, uint64) GetEthContext() (uint64, uint64)
......
...@@ -352,7 +352,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) { ...@@ -352,7 +352,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
select { select {
case <-w.startCh: case <-w.startCh:
clearPending(w.chain.CurrentBlock().NumberU64()) clearPending(w.chain.CurrentBlock().NumberU64())
timestamp = w.chain.CurrentTimestamp()
commit(false, commitInterruptNewHead) commit(false, commitInterruptNewHead)
// Remove this code for the OVM implementation. It is responsible for // Remove this code for the OVM implementation. It is responsible for
...@@ -374,7 +373,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) { ...@@ -374,7 +373,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timer.Reset(recommit) timer.Reset(recommit)
continue continue
} }
timestamp = w.chain.CurrentTimestamp()
commit(true, commitInterruptResubmit) commit(true, commitInterruptResubmit)
} }
...@@ -543,7 +541,7 @@ func (w *worker) mainLoop() { ...@@ -543,7 +541,7 @@ func (w *worker) mainLoop() {
// If clique is running in dev mode(period is 0), disable // If clique is running in dev mode(period is 0), disable
// advance sealing here. // advance sealing here.
if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 { if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 {
w.commitNewWork(nil, true, w.chain.CurrentTimestamp()) w.commitNewWork(nil, true, time.Now().Unix())
} }
} }
atomic.AddInt32(&w.newTxs, int32(len(ev.Txs))) atomic.AddInt32(&w.newTxs, int32(len(ev.Txs)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment