aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-22 20:10:07 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-23 18:16:44 +0800
commitd4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch)
tree17c93170551d3eeabe2935de1765f157007f0dc2 /core
parent47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff)
downloadgo-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.bz2
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.lz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.xz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'core')
-rw-r--r--core/block_validator.go4
-rw-r--r--core/blockchain.go104
-rw-r--r--core/database_util.go49
-rw-r--r--core/genesis.go5
-rw-r--r--core/headerchain.go23
-rw-r--r--core/state/state_object.go21
-rw-r--r--core/state/statedb.go13
-rw-r--r--core/state_processor.go6
-rw-r--r--core/state_transition.go6
-rw-r--r--core/tx_pool.go59
-rw-r--r--core/vm/contracts.go8
-rw-r--r--core/vm/interpreter.go17
12 files changed, 154 insertions, 161 deletions
diff --git a/core/block_validator.go b/core/block_validator.go
index ee524b61f..a23a4134b 100644
--- a/core/block_validator.go
+++ b/core/block_validator.go
@@ -24,7 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"gopkg.in/fatih/set.v0"
@@ -169,7 +169,7 @@ func (v *BlockValidator) VerifyUncles(block, parent *types.Block) error {
for h := range ancestors {
branch += fmt.Sprintf(" O - %x\n |\n", h)
}
- glog.Infoln(branch)
+ log.Info(fmt.Sprint(branch))
return UncleError("uncle[%d](%x) is ancestor", i, hash[:4])
}
diff --git a/core/blockchain.go b/core/blockchain.go
index b57eb48e3..e46a76fc1 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -36,8 +36,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
@@ -161,9 +160,9 @@ func NewBlockChain(chainDb ethdb.Database, config *params.ChainConfig, pow pow.P
headerByNumber := bc.GetHeaderByNumber(header.Number.Uint64())
// make sure the headerByNumber (if present) is in our current canonical chain
if headerByNumber != nil && headerByNumber.Hash() == header.Hash() {
- glog.V(logger.Error).Infof("Found bad hash, rewinding chain to block #%d [%x…]", header.Number, header.ParentHash[:4])
+ log.Error(fmt.Sprintf("Found bad hash, rewinding chain to block #%d [%x…]", header.Number, header.ParentHash[:4]))
bc.SetHead(header.Number.Uint64() - 1)
- glog.V(logger.Error).Infoln("Chain rewind was successful, resuming normal operation")
+ log.Error(fmt.Sprint("Chain rewind was successful, resuming normal operation"))
}
}
}
@@ -220,9 +219,9 @@ func (self *BlockChain) loadLastState() error {
blockTd := self.GetTd(self.currentBlock.Hash(), self.currentBlock.NumberU64())
fastTd := self.GetTd(self.currentFastBlock.Hash(), self.currentFastBlock.NumberU64())
- glog.V(logger.Info).Infof("Last header: #%d [%x…] TD=%v", currentHeader.Number, currentHeader.Hash().Bytes()[:4], headerTd)
- glog.V(logger.Info).Infof("Last block: #%d [%x…] TD=%v", self.currentBlock.Number(), self.currentBlock.Hash().Bytes()[:4], blockTd)
- glog.V(logger.Info).Infof("Fast block: #%d [%x…] TD=%v", self.currentFastBlock.Number(), self.currentFastBlock.Hash().Bytes()[:4], fastTd)
+ log.Info(fmt.Sprintf("Last header: #%d [%x…] TD=%v", currentHeader.Number, currentHeader.Hash().Bytes()[:4], headerTd))
+ log.Info(fmt.Sprintf("Last block: #%d [%x…] TD=%v", self.currentBlock.Number(), self.currentBlock.Hash().Bytes()[:4], blockTd))
+ log.Info(fmt.Sprintf("Fast block: #%d [%x…] TD=%v", self.currentFastBlock.Number(), self.currentFastBlock.Hash().Bytes()[:4], fastTd))
return nil
}
@@ -263,10 +262,10 @@ func (bc *BlockChain) SetHead(head uint64) {
}
if err := WriteHeadBlockHash(bc.chainDb, bc.currentBlock.Hash()); err != nil {
- glog.Fatalf("failed to reset head block hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to reset head block hash: %v", err))
}
if err := WriteHeadFastBlockHash(bc.chainDb, bc.currentFastBlock.Hash()); err != nil {
- glog.Fatalf("failed to reset head fast block hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to reset head fast block hash: %v", err))
}
bc.loadLastState()
}
@@ -287,7 +286,7 @@ func (self *BlockChain) FastSyncCommitHead(hash common.Hash) error {
self.currentBlock = block
self.mu.Unlock()
- glog.V(logger.Info).Infof("committed block #%d [%x…] as new head", block.Number(), hash[:4])
+ log.Info(fmt.Sprintf("committed block #%d [%x…] as new head", block.Number(), hash[:4]))
return nil
}
@@ -391,10 +390,10 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) {
// Prepare the genesis block and reinitialise the chain
if err := bc.hc.WriteTd(genesis.Hash(), genesis.NumberU64(), genesis.Difficulty()); err != nil {
- glog.Fatalf("failed to write genesis block TD: %v", err)
+ log.Crit(fmt.Sprintf("failed to write genesis block TD: %v", err))
}
if err := WriteBlock(bc.chainDb, genesis); err != nil {
- glog.Fatalf("failed to write genesis block: %v", err)
+ log.Crit(fmt.Sprintf("failed to write genesis block: %v", err))
}
bc.genesisBlock = genesis
bc.insert(bc.genesisBlock)
@@ -418,7 +417,7 @@ func (self *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error {
return fmt.Errorf("export failed: first (%d) is greater than last (%d)", first, last)
}
- glog.V(logger.Info).Infof("exporting %d blocks...\n", last-first+1)
+ log.Info(fmt.Sprintf("exporting %d blocks...\n", last-first+1))
for nr := first; nr <= last; nr++ {
block := self.GetBlockByNumber(nr)
@@ -446,10 +445,10 @@ func (bc *BlockChain) insert(block *types.Block) {
// Add the block to the canonical chain number scheme and mark as the head
if err := WriteCanonicalHash(bc.chainDb, block.Hash(), block.NumberU64()); err != nil {
- glog.Fatalf("failed to insert block number: %v", err)
+ log.Crit(fmt.Sprintf("failed to insert block number: %v", err))
}
if err := WriteHeadBlockHash(bc.chainDb, block.Hash()); err != nil {
- glog.Fatalf("failed to insert head block hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to insert head block hash: %v", err))
}
bc.currentBlock = block
@@ -458,7 +457,7 @@ func (bc *BlockChain) insert(block *types.Block) {
bc.hc.SetCurrentHeader(block.Header())
if err := WriteHeadFastBlockHash(bc.chainDb, block.Hash()); err != nil {
- glog.Fatalf("failed to insert head fast block hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to insert head fast block hash: %v", err))
}
bc.currentFastBlock = block
}
@@ -590,7 +589,7 @@ func (bc *BlockChain) Stop() {
bc.wg.Wait()
- glog.V(logger.Info).Infoln("Chain manager stopped")
+ log.Info(fmt.Sprint("Chain manager stopped"))
}
func (self *BlockChain) procFutureBlocks() {
@@ -687,7 +686,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
failure := fmt.Errorf("non contiguous insert: item %d is #%d [%x…], item %d is #%d [%x…] (parent [%x…])", i-1, blockChain[i-1].NumberU64(),
blockChain[i-1].Hash().Bytes()[:4], i, blockChain[i].NumberU64(), blockChain[i].Hash().Bytes()[:4], blockChain[i].ParentHash().Bytes()[:4])
- glog.V(logger.Error).Info(failure.Error())
+ log.Error(fmt.Sprint(failure.Error()))
return 0, failure
}
}
@@ -735,31 +734,31 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
if err := WriteBody(self.chainDb, block.Hash(), block.NumberU64(), block.Body()); err != nil {
errs[index] = fmt.Errorf("failed to write block body: %v", err)
atomic.AddInt32(&failed, 1)
- glog.Fatal(errs[index])
+ log.Crit(fmt.Sprint(errs[index]))
return
}
if err := WriteBlockReceipts(self.chainDb, block.Hash(), block.NumberU64(), receipts); err != nil {
errs[index] = fmt.Errorf("failed to write block receipts: %v", err)
atomic.AddInt32(&failed, 1)
- glog.Fatal(errs[index])
+ log.Crit(fmt.Sprint(errs[index]))
return
}
if err := WriteMipmapBloom(self.chainDb, block.NumberU64(), receipts); err != nil {
errs[index] = fmt.Errorf("failed to write log blooms: %v", err)
atomic.AddInt32(&failed, 1)
- glog.Fatal(errs[index])
+ log.Crit(fmt.Sprint(errs[index]))
return
}
if err := WriteTransactions(self.chainDb, block); err != nil {
errs[index] = fmt.Errorf("failed to write individual transactions: %v", err)
atomic.AddInt32(&failed, 1)
- glog.Fatal(errs[index])
+ log.Crit(fmt.Sprint(errs[index]))
return
}
if err := WriteReceipts(self.chainDb, receipts); err != nil {
errs[index] = fmt.Errorf("failed to write individual receipts: %v", err)
atomic.AddInt32(&failed, 1)
- glog.Fatal(errs[index])
+ log.Crit(fmt.Sprint(errs[index]))
return
}
atomic.AddInt32(&stats.processed, 1)
@@ -785,7 +784,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
}
}
if atomic.LoadInt32(&self.procInterrupt) == 1 {
- glog.V(logger.Debug).Infoln("premature abort during receipt chain processing")
+ log.Debug(fmt.Sprint("premature abort during receipt chain processing"))
return 0, nil
}
// Update the head fast sync block if better
@@ -793,7 +792,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
head := blockChain[len(errs)-1]
if self.GetTd(self.currentFastBlock.Hash(), self.currentFastBlock.NumberU64()).Cmp(self.GetTd(head.Hash(), head.NumberU64())) < 0 {
if err := WriteHeadFastBlockHash(self.chainDb, head.Hash()); err != nil {
- glog.Fatalf("failed to update head fast block hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to update head fast block hash: %v", err))
}
self.currentFastBlock = head
}
@@ -806,7 +805,7 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
if stats.ignored > 0 {
ignored = fmt.Sprintf(" (%d ignored)", stats.ignored)
}
- glog.V(logger.Info).Infof("imported %4d receipts in %9v. #%d [%x… / %x…]%s", stats.processed, common.PrettyDuration(time.Since(start)), last.Number(), first.Hash().Bytes()[:4], last.Hash().Bytes()[:4], ignored)
+ log.Info(fmt.Sprintf("imported %4d receipts in %9v. #%d [%x… / %x…]%s", stats.processed, common.PrettyDuration(time.Since(start)), last.Number(), first.Hash().Bytes()[:4], last.Hash().Bytes()[:4], ignored))
return 0, nil
}
@@ -830,10 +829,10 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err
// Irrelevant of the canonical status, write the block itself to the database
if err := self.hc.WriteTd(block.Hash(), block.NumberU64(), externTd); err != nil {
- glog.Fatalf("failed to write block total difficulty: %v", err)
+ log.Crit(fmt.Sprintf("failed to write block total difficulty: %v", err))
}
if err := WriteBlock(self.chainDb, block); err != nil {
- glog.Fatalf("failed to write block contents: %v", err)
+ log.Crit(fmt.Sprintf("failed to write block contents: %v", err))
}
// If the total difficulty is higher than our known, add it to the canonical chain
@@ -867,7 +866,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
failure := fmt.Errorf("non contiguous insert: item %d is #%d [%x…], item %d is #%d [%x…] (parent [%x…])",
i-1, chain[i-1].NumberU64(), chain[i-1].Hash().Bytes()[:4], i, chain[i].NumberU64(), chain[i].Hash().Bytes()[:4], chain[i].ParentHash().Bytes()[:4])
- glog.V(logger.Error).Info(failure.Error())
+ log.Error(fmt.Sprint(failure.Error()))
return 0, failure
}
}
@@ -894,7 +893,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
for i, block := range chain {
if atomic.LoadInt32(&self.procInterrupt) == 1 {
- glog.V(logger.Debug).Infoln("Premature abort during block chain processing")
+ log.Debug(fmt.Sprint("Premature abort during block chain processing"))
break
}
bstart := time.Now()
@@ -991,9 +990,9 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
switch status {
case CanonStatTy:
- if glog.V(logger.Debug) {
- glog.Infof("inserted block #%d [%x…] in %9v: %3d txs %7v gas %d uncles.", block.Number(), block.Hash().Bytes()[0:4], common.PrettyDuration(time.Since(bstart)), len(block.Transactions()), block.GasUsed(), len(block.Uncles()))
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("inserted block #%d [%x…] in %9v: %3d txs %7v gas %d uncles.", block.Number(), block.Hash().Bytes()[0:4], common.PrettyDuration(time.Since(bstart)), len(block.Transactions()), block.GasUsed(), len(block.Uncles()))
+ }})
blockInsertTimer.UpdateSince(bstart)
events = append(events, ChainEvent{block, block.Hash(), logs})
@@ -1014,9 +1013,9 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
return i, err
}
case SideStatTy:
- if glog.V(logger.Detail) {
- glog.Infof("inserted forked block #%d [%x…] (TD=%v) in %9v: %3d txs %d uncles.", block.Number(), block.Hash().Bytes()[0:4], block.Difficulty(), common.PrettyDuration(time.Since(bstart)), len(block.Transactions()), len(block.Uncles()))
- }
+ log.Trace("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("inserted forked block #%d [%x…] (TD=%v) in %9v: %3d txs %d uncles.", block.Number(), block.Hash().Bytes()[0:4], block.Difficulty(), common.PrettyDuration(time.Since(bstart)), len(block.Transactions()), len(block.Uncles()))
+ }})
blockInsertTimer.UpdateSince(bstart)
events = append(events, ChainSideEvent{block})
@@ -1025,10 +1024,8 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
}
stats.processed++
- if glog.V(logger.Info) {
- stats.usedGas += usedGas.Uint64()
- stats.report(chain, i)
- }
+ stats.usedGas += usedGas.Uint64()
+ stats.report(chain, i)
}
go self.postChainEvents(events, coalescedLogs)
@@ -1070,7 +1067,7 @@ func (st *insertStats) report(chain []*types.Block, index int) {
} else {
hashes = fmt.Sprintf("%x…", end.Hash().Bytes()[:4])
}
- glog.Infof("imported %4d blocks, %5d txs (%7.3f Mg) in %9v (%6.3f Mg/s). #%v [%s]%s", st.processed, txcount, float64(st.usedGas)/1000000, common.PrettyDuration(elapsed), float64(st.usedGas)*1000/float64(elapsed), end.Number(), hashes, extra)
+ log.Info(fmt.Sprintf("imported %4d blocks, %5d txs (%7.3f Mg) in %9v (%6.3f Mg/s). #%v [%s]%s", st.processed, txcount, float64(st.usedGas)/1000000, common.PrettyDuration(elapsed), float64(st.usedGas)*1000/float64(elapsed), end.Number(), hashes, extra))
*st = insertStats{startTime: now, lastIndex: index}
}
@@ -1150,21 +1147,24 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
return fmt.Errorf("Invalid new chain")
}
}
+ // Ensure the user sees large reorgs
+ logFn := log.Debug
+ if len(oldChain) > 63 {
+ logFn = log.Warn
+ }
+ logFn("", "msg", log.Lazy{Fn: func() string {
+ oldLen, newLen := len(oldChain), len(newChain)
+ newLast, newFirst := newChain[0], newChain[newLen-1]
+ oldLast, oldFirst := oldChain[0], oldChain[oldLen-1]
- if oldLen := len(oldChain); oldLen > 63 || glog.V(logger.Debug) {
- newLen := len(newChain)
- newLast := newChain[0]
- newFirst := newChain[newLen-1]
- oldLast := oldChain[0]
- oldFirst := oldChain[oldLen-1]
- glog.Infof("Chain split detected after #%v [%x…]. Reorganising chain (-%v +%v blocks), rejecting #%v-#%v [%x…/%x…] in favour of #%v-#%v [%x…/%x…]",
+ return fmt.Sprintf("Chain split detected after #%v [%x…]. Reorganising chain (-%v +%v blocks), rejecting #%v-#%v [%x…/%x…] in favour of #%v-#%v [%x…/%x…]",
commonBlock.Number(), commonBlock.Hash().Bytes()[:4],
oldLen, newLen,
oldFirst.Number(), oldLast.Number(),
oldFirst.Hash().Bytes()[:4], oldLast.Hash().Bytes()[:4],
newFirst.Number(), newLast.Number(),
newFirst.Hash().Bytes()[:4], newLast.Hash().Bytes()[:4])
- }
+ }})
var addedTxs types.Transactions
// insert blocks. Order does not matter. Last block will be written in ImportChain itself which creates the new head properly
@@ -1271,12 +1271,12 @@ func (bc *BlockChain) addBadBlock(block *types.Block) {
// reportBlock logs a bad block error.
func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, err error) {
bc.addBadBlock(block)
- if glog.V(logger.Error) {
+ log.Error("", "msg", log.Lazy{Fn: func() string {
var receiptString string
for _, receipt := range receipts {
receiptString += fmt.Sprintf("\t%v\n", receipt)
}
- glog.Errorf(`
+ return fmt.Sprintf(`
########## BAD BLOCK #########
Chain config: %v
@@ -1287,7 +1287,7 @@ Hash: 0x%x
Error: %v
##############################
`, bc.config, block.Number(), block.Hash(), receiptString, err)
- }
+ }})
}
// InsertHeaderChain attempts to insert the given header chain in to the local
diff --git a/core/database_util.go b/core/database_util.go
index e83d5d5e7..23240b35e 100644
--- a/core/database_util.go
+++ b/core/database_util.go
@@ -28,8 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
@@ -107,7 +106,7 @@ func GetBlockNumber(db ethdb.Database, hash common.Hash) uint64 {
}
header := new(types.Header)
if err := rlp.Decode(bytes.NewReader(data), header); err != nil {
- glog.Fatalf("failed to decode block header: %v", err)
+ log.Crit(fmt.Sprintf("failed to decode block header: %v", err))
}
return header.Number.Uint64()
}
@@ -167,7 +166,7 @@ func GetHeader(db ethdb.Database, hash common.Hash, number uint64) *types.Header
}
header := new(types.Header)
if err := rlp.Decode(bytes.NewReader(data), header); err != nil {
- glog.V(logger.Error).Infof("invalid block header RLP for hash %x: %v", hash, err)
+ log.Error(fmt.Sprintf("invalid block header RLP for hash %x: %v", hash, err))
return nil
}
return header
@@ -191,7 +190,7 @@ func GetBody(db ethdb.Database, hash common.Hash, number uint64) *types.Body {
}
body := new(types.Body)
if err := rlp.Decode(bytes.NewReader(data), body); err != nil {
- glog.V(logger.Error).Infof("invalid block body RLP for hash %x: %v", hash, err)
+ log.Error(fmt.Sprintf("invalid block body RLP for hash %x: %v", hash, err))
return nil
}
return body
@@ -209,7 +208,7 @@ func GetTd(db ethdb.Database, hash common.Hash, number uint64) *big.Int {
}
td := new(big.Int)
if err := rlp.Decode(bytes.NewReader(data), td); err != nil {
- glog.V(logger.Error).Infof("invalid block total difficulty RLP for hash %x: %v", hash, err)
+ log.Error(fmt.Sprintf("invalid block total difficulty RLP for hash %x: %v", hash, err))
return nil
}
return td
@@ -247,7 +246,7 @@ func GetBlockReceipts(db ethdb.Database, hash common.Hash, number uint64) types.
}
storageReceipts := []*types.ReceiptForStorage{}
if err := rlp.DecodeBytes(data, &storageReceipts); err != nil {
- glog.V(logger.Error).Infof("invalid receipt array RLP for hash %x: %v", hash, err)
+ log.Error(fmt.Sprintf("invalid receipt array RLP for hash %x: %v", hash, err))
return nil
}
receipts := make(types.Receipts, len(storageReceipts))
@@ -294,7 +293,7 @@ func GetReceipt(db ethdb.Database, txHash common.Hash) *types.Receipt {
var receipt types.ReceiptForStorage
err := rlp.DecodeBytes(data, &receipt)
if err != nil {
- glog.V(logger.Debug).Infoln("GetReceipt err:", err)
+ log.Debug(fmt.Sprint("GetReceipt err:", err))
}
return (*types.Receipt)(&receipt)
}
@@ -303,7 +302,7 @@ func GetReceipt(db ethdb.Database, txHash common.Hash) *types.Receipt {
func WriteCanonicalHash(db ethdb.Database, hash common.Hash, number uint64) error {
key := append(append(headerPrefix, encodeBlockNumber(number)...), numSuffix...)
if err := db.Put(key, hash.Bytes()); err != nil {
- glog.Fatalf("failed to store number to hash mapping into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store number to hash mapping into database: %v", err))
}
return nil
}
@@ -311,7 +310,7 @@ func WriteCanonicalHash(db ethdb.Database, hash common.Hash, number uint64) erro
// WriteHeadHeaderHash stores the head header's hash.
func WriteHeadHeaderHash(db ethdb.Database, hash common.Hash) error {
if err := db.Put(headHeaderKey, hash.Bytes()); err != nil {
- glog.Fatalf("failed to store last header's hash into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store last header's hash into database: %v", err))
}
return nil
}
@@ -319,7 +318,7 @@ func WriteHeadHeaderHash(db ethdb.Database, hash common.Hash) error {
// WriteHeadBlockHash stores the head block's hash.
func WriteHeadBlockHash(db ethdb.Database, hash common.Hash) error {
if err := db.Put(headBlockKey, hash.Bytes()); err != nil {
- glog.Fatalf("failed to store last block's hash into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store last block's hash into database: %v", err))
}
return nil
}
@@ -327,7 +326,7 @@ func WriteHeadBlockHash(db ethdb.Database, hash common.Hash) error {
// WriteHeadFastBlockHash stores the fast head block's hash.
func WriteHeadFastBlockHash(db ethdb.Database, hash common.Hash) error {
if err := db.Put(headFastKey, hash.Bytes()); err != nil {
- glog.Fatalf("failed to store last fast block's hash into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store last fast block's hash into database: %v", err))
}
return nil
}
@@ -343,13 +342,13 @@ func WriteHeader(db ethdb.Database, header *types.Header) error {
encNum := encodeBlockNumber(num)
key := append(blockHashPrefix, hash...)
if err := db.Put(key, encNum); err != nil {
- glog.Fatalf("failed to store hash to number mapping into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store hash to number mapping into database: %v", err))
}
key = append(append(headerPrefix, encNum...), hash...)
if err := db.Put(key, data); err != nil {
- glog.Fatalf("failed to store header into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store header into database: %v", err))
}
- glog.V(logger.Debug).Infof("stored header #%v [%x…]", header.Number, hash[:4])
+ log.Debug(fmt.Sprintf("stored header #%v [%x…]", header.Number, hash[:4]))
return nil
}
@@ -366,9 +365,9 @@ func WriteBody(db ethdb.Database, hash common.Hash, number uint64, body *types.B
func WriteBodyRLP(db ethdb.Database, hash common.Hash, number uint64, rlp rlp.RawValue) error {
key := append(append(bodyPrefix, encodeBlockNumber(number)...), hash.Bytes()...)
if err := db.Put(key, rlp); err != nil {
- glog.Fatalf("failed to store block body into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store block body into database: %v", err))
}
- glog.V(logger.Debug).Infof("stored block body [%x…]", hash.Bytes()[:4])
+ log.Debug(fmt.Sprintf("stored block body [%x…]", hash.Bytes()[:4]))
return nil
}
@@ -380,9 +379,9 @@ func WriteTd(db ethdb.Database, hash common.Hash, number uint64, td *big.Int) er
}
key := append(append(append(headerPrefix, encodeBlockNumber(number)...), hash.Bytes()...), tdSuffix...)
if err := db.Put(key, data); err != nil {
- glog.Fatalf("failed to store block total difficulty into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store block total difficulty into database: %v", err))
}
- glog.V(logger.Debug).Infof("stored block total difficulty [%x…]: %v", hash.Bytes()[:4], td)
+ log.Debug(fmt.Sprintf("stored block total difficulty [%x…]: %v", hash.Bytes()[:4], td))
return nil
}
@@ -415,9 +414,9 @@ func WriteBlockReceipts(db ethdb.Database, hash common.Hash, number uint64, rece
// Store the flattened receipt slice
key := append(append(blockReceiptsPrefix, encodeBlockNumber(number)...), hash.Bytes()...)
if err := db.Put(key, bytes); err != nil {
- glog.Fatalf("failed to store block receipts into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store block receipts into database: %v", err))
}
- glog.V(logger.Debug).Infof("stored block receipts [%x…]", hash.Bytes()[:4])
+ log.Debug(fmt.Sprintf("stored block receipts [%x…]", hash.Bytes()[:4]))
return nil
}
@@ -458,7 +457,7 @@ func WriteTransactions(db ethdb.Database, block *types.Block) error {
}
// Write the scheduled data into the database
if err := batch.Write(); err != nil {
- glog.Fatalf("failed to store transactions into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store transactions into database: %v", err))
}
return nil
}
@@ -490,7 +489,7 @@ func WriteReceipts(db ethdb.Database, receipts types.Receipts) error {
}
// Write the scheduled data into the database
if err := batch.Write(); err != nil {
- glog.Fatalf("failed to store receipts into database: %v", err)
+ log.Crit(fmt.Sprintf("failed to store receipts into database: %v", err))
}
return nil
}
@@ -552,7 +551,7 @@ func GetBlockByHashOld(db ethdb.Database, hash common.Hash) *types.Block {
}
var block types.StorageBlock
if err := rlp.Decode(bytes.NewReader(data), &block); err != nil {
- glog.V(logger.Error).Infof("invalid block RLP for hash %x: %v", hash, err)
+ log.Error(fmt.Sprintf("invalid block RLP for hash %x: %v", hash, err))
return nil
}
return (*types.Block)(&block)
@@ -623,7 +622,7 @@ func WritePreimages(db ethdb.Database, number uint64, preimages map[common.Hash]
if err := batch.Write(); err != nil {
return fmt.Errorf("preimage write fail for block %d: %v", number, err)
}
- glog.V(logger.Debug).Infof("%d preimages in block %d, including %d new", len(preimages), number, hitCount)
+ log.Debug(fmt.Sprintf("%d preimages in block %d, including %d new", len(preimages), number, hitCount))
}
return nil
}
diff --git a/core/genesis.go b/core/genesis.go
index b94b5af76..a015f04c1 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -31,8 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
@@ -92,7 +91,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
}, nil, nil, nil)
if block := GetBlock(chainDb, block.Hash(), block.NumberU64()); block != nil {
- glog.V(logger.Info).Infoln("Genesis block already in chain. Writing canonical number")
+ log.Info(fmt.Sprint("Genesis block already in chain. Writing canonical number"))
err := WriteCanonicalHash(chainDb, block.Hash(), block.NumberU64())
if err != nil {
return nil, err
diff --git a/core/headerchain.go b/core/headerchain.go
index 1dc189323..a0550a428 100644
--- a/core/headerchain.go
+++ b/core/headerchain.go
@@ -30,8 +30,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"github.com/hashicorp/golang-lru"
@@ -102,7 +101,7 @@ func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, getValid
if err != nil {
return nil, err
}
- glog.V(logger.Info).Infoln("WARNING: Wrote default ethereum genesis block")
+ log.Info(fmt.Sprint("WARNING: Wrote default ethereum genesis block"))
hc.genesisHeader = genesisBlock.Header()
}
@@ -155,10 +154,10 @@ func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, er
// Irrelevant of the canonical status, write the td and header to the database
if err := hc.WriteTd(hash, number, externTd); err != nil {
- glog.Fatalf("failed to write header total difficulty: %v", err)
+ log.Crit(fmt.Sprintf("failed to write header total difficulty: %v", err))
}
if err := WriteHeader(hc.chainDb, header); err != nil {
- glog.Fatalf("failed to write header contents: %v", err)
+ log.Crit(fmt.Sprintf("failed to write header contents: %v", err))
}
// If the total difficulty is higher than our known, add it to the canonical chain
@@ -189,10 +188,10 @@ func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, er
// Extend the canonical chain with the new header
if err := WriteCanonicalHash(hc.chainDb, hash, number); err != nil {
- glog.Fatalf("failed to insert header number: %v", err)
+ log.Crit(fmt.Sprintf("failed to insert header number: %v", err))
}
if err := WriteHeadHeaderHash(hc.chainDb, hash); err != nil {
- glog.Fatalf("failed to insert head header hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to insert head header hash: %v", err))
}
hc.currentHeaderHash, hc.currentHeader = hash, types.CopyHeader(header)
@@ -231,7 +230,7 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, checkFreq int, w
failure := fmt.Errorf("non contiguous insert: item %d is #%d [%x…], item %d is #%d [%x…] (parent [%x…])",
i-1, chain[i-1].Number.Uint64(), chain[i-1].Hash().Bytes()[:4], i, chain[i].Number.Uint64(), chain[i].Hash().Bytes()[:4], chain[i].ParentHash.Bytes()[:4])
- glog.V(logger.Error).Info(failure.Error())
+ log.Error(fmt.Sprint(failure.Error()))
return 0, failure
}
}
@@ -317,7 +316,7 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, checkFreq int, w
for i, header := range chain {
// Short circuit insertion if shutting down
if hc.procInterrupt() {
- glog.V(logger.Debug).Infoln("premature abort during header chain processing")
+ log.Debug(fmt.Sprint("premature abort during header chain processing"))
break
}
hash := header.Hash()
@@ -339,7 +338,7 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, checkFreq int, w
if stats.ignored > 0 {
ignored = fmt.Sprintf(" (%d ignored)", stats.ignored)
}
- glog.V(logger.Info).Infof("imported %4d headers%s in %9v. #%v [%x… / %x…]", stats.processed, ignored, common.PrettyDuration(time.Since(start)), last.Number, first.Hash().Bytes()[:4], last.Hash().Bytes()[:4])
+ log.Info(fmt.Sprintf("imported %4d headers%s in %9v. #%v [%x… / %x…]", stats.processed, ignored, common.PrettyDuration(time.Since(start)), last.Number, first.Hash().Bytes()[:4], last.Hash().Bytes()[:4]))
return 0, nil
}
@@ -446,7 +445,7 @@ func (hc *HeaderChain) CurrentHeader() *types.Header {
// SetCurrentHeader sets the current head header of the canonical chain.
func (hc *HeaderChain) SetCurrentHeader(head *types.Header) {
if err := WriteHeadHeaderHash(hc.chainDb, head.Hash()); err != nil {
- glog.Fatalf("failed to insert head header hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to insert head header hash: %v", err))
}
hc.currentHeader = head
hc.currentHeaderHash = head.Hash()
@@ -489,7 +488,7 @@ func (hc *HeaderChain) SetHead(head uint64, delFn DeleteCallback) {
hc.currentHeaderHash = hc.currentHeader.Hash()
if err := WriteHeadHeaderHash(hc.chainDb, hc.currentHeaderHash); err != nil {
- glog.Fatalf("failed to reset head header hash: %v", err)
+ log.Crit(fmt.Sprintf("failed to reset head header hash: %v", err))
}
}
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 4fb69b646..ebb103806 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -24,8 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
@@ -135,9 +134,9 @@ func (self *stateObject) markSuicided() {
self.onDirty(self.Address())
self.onDirty = nil
}
- if glog.V(logger.Debug) {
- glog.Infof("%x: #%d %v X\n", self.Address(), self.Nonce(), self.Balance())
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("%x: #%d %v X\n", self.Address(), self.Nonce(), self.Balance())
+ }})
}
func (c *stateObject) touch() {
@@ -253,9 +252,9 @@ func (c *stateObject) AddBalance(amount *big.Int) {
}
c.SetBalance(new(big.Int).Add(c.Balance(), amount))
- if glog.V(logger.Debug) {
- glog.Infof("%x: #%d %v (+ %v)\n", c.Address(), c.Nonce(), c.Balance(), amount)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("%x: #%d %v (+ %v)\n", c.Address(), c.Nonce(), c.Balance(), amount)
+ }})
}
// SubBalance removes amount from c's balance.
@@ -266,9 +265,9 @@ func (c *stateObject) SubBalance(amount *big.Int) {
}
c.SetBalance(new(big.Int).Sub(c.Balance(), amount))
- if glog.V(logger.Debug) {
- glog.Infof("%x: #%d %v (- %v)\n", c.Address(), c.Nonce(), c.Balance(), amount)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("%x: #%d %v (- %v)\n", c.Address(), c.Nonce(), c.Balance(), amount)
+ }})
}
func (self *stateObject) SetBalance(amount *big.Int) {
diff --git a/core/state/statedb.go b/core/state/statedb.go
index cae2dc4b2..a87607a25 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -27,8 +27,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
lru "github.com/hashicorp/golang-lru"
@@ -411,7 +410,7 @@ func (self *StateDB) getStateObject(addr common.Address) (stateObject *stateObje
}
var data Account
if err := rlp.DecodeBytes(enc, &data); err != nil {
- glog.Errorf("can't decode object at %x: %v", addr[:], err)
+ log.Error(fmt.Sprintf("can't decode object at %x: %v", addr[:], err))
return nil
}
// Insert into the live set.
@@ -446,9 +445,9 @@ func (self *StateDB) createObject(addr common.Address) (newobj, prev *stateObjec
newobj = newObject(self, addr, Account{}, self.MarkStateObjectDirty)
newobj.setNonce(0) // sets the object to dirty
if prev == nil {
- if glog.V(logger.Debug) {
- glog.Infof("(+) %x\n", addr)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("(+) %x\n", addr)
+ }})
self.journal = append(self.journal, createObjectChange{account: &addr})
} else {
self.journal = append(self.journal, resetObjectChange{prev: prev})
@@ -617,7 +616,7 @@ func (s *StateDB) CommitBatch(deleteEmptyObjects bool) (root common.Hash, batch
batch = s.db.NewBatch()
root, _ = s.commit(batch, deleteEmptyObjects)
- glog.V(logger.Debug).Infof("Trie cache stats: %d misses, %d unloads", trie.CacheMisses(), trie.CacheUnloads())
+ log.Debug(fmt.Sprintf("Trie cache stats: %d misses, %d unloads", trie.CacheMisses(), trie.CacheUnloads()))
return root, batch
}
diff --git a/core/state_processor.go b/core/state_processor.go
index 6485e9abd..72c6e6c37 100644
--- a/core/state_processor.go
+++ b/core/state_processor.go
@@ -17,14 +17,14 @@
package core
import (
+ "fmt"
"math/big"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
@@ -122,7 +122,7 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, s
receipt.Logs = statedb.GetLogs(tx.Hash())
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
- glog.V(logger.Debug).Infoln(receipt)
+ log.Debug(fmt.Sprint(receipt))
return receipt, gas, err
}
diff --git a/core/state_transition.go b/core/state_transition.go
index 6acc78479..8e7891b96 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -18,12 +18,12 @@ package core
import (
"errors"
+ "fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
@@ -255,7 +255,7 @@ func (self *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *b
ret, self.gas, vmerr = evm.Call(sender, self.to().Address(), self.data, self.gas, self.value)
}
if vmerr != nil {
- glog.V(logger.Debug).Infoln("vm returned with error:", err)
+ log.Debug(fmt.Sprint("vm returned with error:", err))
// The only possible consensus-error would be if there wasn't
// sufficient balance to make the transfer happen. The first
// balance transfer may never fail.
diff --git a/core/tx_pool.go b/core/tx_pool.go
index 987b43d4a..b0a8eea0f 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -28,8 +28,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/karalabe/cookiejar.v2/collections/prque"
@@ -163,12 +162,12 @@ func (pool *TxPool) eventLoop() {
func (pool *TxPool) resetState() {
currentState, err := pool.currentState()
if err != nil {
- glog.V(logger.Error).Infof("Failed to get current state: %v", err)
+ log.Error(fmt.Sprintf("Failed to get current state: %v", err))
return
}
managedState := state.ManageState(currentState)
if err != nil {
- glog.V(logger.Error).Infof("Failed to get managed state: %v", err)
+ log.Error(fmt.Sprintf("Failed to get managed state: %v", err))
return
}
pool.pendingState = managedState
@@ -193,7 +192,7 @@ func (pool *TxPool) Stop() {
pool.events.Unsubscribe()
close(pool.quit)
pool.wg.Wait()
- glog.V(logger.Info).Infoln("Transaction pool stopped")
+ log.Info(fmt.Sprint("Transaction pool stopped"))
}
func (pool *TxPool) State() *state.ManagedState {
@@ -334,14 +333,14 @@ func (pool *TxPool) add(tx *types.Transaction) error {
pool.enqueueTx(hash, tx)
// Print a log message if low enough level is set
- if glog.V(logger.Debug) {
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
rcpt := "[NEW_CONTRACT]"
if to := tx.To(); to != nil {
rcpt = common.Bytes2Hex(to[:4])
}
from, _ := types.Sender(pool.signer, tx) // from already verified during tx validation
- glog.Infof("(t) 0x%x => %s (%v) %x\n", from[:4], rcpt, tx.Value, hash)
- }
+ return fmt.Sprintf("(t) 0x%x => %s (%v) %x\n", from[:4], rcpt, tx.Value(), hash)
+ }})
return nil
}
@@ -423,7 +422,7 @@ func (pool *TxPool) AddBatch(txs []*types.Transaction) error {
for _, tx := range txs {
if err := pool.add(tx); err != nil {
- glog.V(logger.Debug).Infoln("tx error:", err)
+ log.Debug(fmt.Sprint("tx error:", err))
}
}
@@ -514,32 +513,32 @@ func (pool *TxPool) promoteExecutables(state *state.StateDB) {
for addr, list := range pool.queue {
// Drop all transactions that are deemed too old (low nonce)
for _, tx := range list.Forward(state.GetNonce(addr)) {
- if glog.V(logger.Debug) {
- glog.Infof("Removed old queued transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Removed old queued transaction: %v", tx)
+ }})
delete(pool.all, tx.Hash())
}
// Drop all transactions that are too costly (low balance)
drops, _ := list.Filter(state.GetBalance(addr))
for _, tx := range drops {
- if glog.V(logger.Debug) {
- glog.Infof("Removed unpayable queued transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Removed unpayable queued transaction: %v", tx)
+ }})
delete(pool.all, tx.Hash())
queuedNofundsCounter.Inc(1)
}
// Gather all executable transactions and promote them
for _, tx := range list.Ready(pool.pendingState.GetNonce(addr)) {
- if glog.V(logger.Debug) {
- glog.Infof("Promoting queued transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Promoting queued transaction: %v", tx)
+ }})
pool.promoteTx(addr, tx.Hash(), tx)
}
// Drop all transactions over the allowed limit
for _, tx := range list.Cap(int(maxQueuedPerAccount)) {
- if glog.V(logger.Debug) {
- glog.Infof("Removed cap-exceeding queued transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Removed cap-exceeding queued transaction: %v", tx)
+ }})
delete(pool.all, tx.Hash())
queuedRLCounter.Inc(1)
}
@@ -651,24 +650,24 @@ func (pool *TxPool) demoteUnexecutables(state *state.StateDB) {
// Drop all transactions that are deemed too old (low nonce)
for _, tx := range list.Forward(nonce) {
- if glog.V(logger.Debug) {
- glog.Infof("Removed old pending transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Removed old pending transaction: %v", tx)
+ }})
delete(pool.all, tx.Hash())
}
// Drop all transactions that are too costly (low balance), and queue any invalids back for later
drops, invalids := list.Filter(state.GetBalance(addr))
for _, tx := range drops {
- if glog.V(logger.Debug) {
- glog.Infof("Removed unpayable pending transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Removed unpayable pending transaction: %v", tx)
+ }})
delete(pool.all, tx.Hash())
pendingNofundsCounter.Inc(1)
}
for _, tx := range invalids {
- if glog.V(logger.Debug) {
- glog.Infof("Demoting pending transaction: %v", tx)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("Demoting pending transaction: %v", tx)
+ }})
pool.enqueueTx(tx.Hash(), tx)
}
// Delete the entire queue entry if it became empty.
diff --git a/core/vm/contracts.go b/core/vm/contracts.go
index 1447c2cad..2793d2aa7 100644
--- a/core/vm/contracts.go
+++ b/core/vm/contracts.go
@@ -18,11 +18,11 @@ package vm
import (
"crypto/sha256"
+ "fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"golang.org/x/crypto/ripemd160"
)
@@ -75,14 +75,14 @@ func (c *ecrecover) Run(in []byte) []byte {
// tighter sig s values in homestead only apply to tx sigs
if common.Bytes2Big(in[32:63]).BitLen() > 0 || !crypto.ValidateSignatureValues(v, r, s, false) {
- glog.V(logger.Detail).Infof("ECRECOVER error: v, r or s value invalid")
+ log.Trace(fmt.Sprintf("ECRECOVER error: v, r or s value invalid"))
return nil
}
// v needs to be at the end for libsecp256k1
pubKey, err := crypto.Ecrecover(in[:32], append(in[64:128], v))
// make sure the public key is a valid one
if err != nil {
- glog.V(logger.Detail).Infoln("ECRECOVER error: ", err)
+ log.Trace(fmt.Sprint("ECRECOVER error: ", err))
return nil
}
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index 46c6befef..41f6a53f8 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -25,8 +25,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
@@ -124,13 +123,13 @@ func (evm *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err e
}
}()
- if glog.V(logger.Debug) {
- glog.Infof("evm running: %x\n", codehash[:4])
- tstart := time.Now()
- defer func() {
- glog.Infof("evm done: %x. time: %v\n", codehash[:4], time.Since(tstart))
- }()
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("evm running: %x\n", codehash[:4])
+ }})
+ tstart := time.Now()
+ defer log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprintf("evm done: %x. time: %v\n", codehash[:4], time.Since(tstart))
+ }})
// The Interpreter main run loop (contextual). This loop runs until either an
// explicit STOP, RETURN or SELFDESTRUCT is executed, an error occurred during