mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-31 09:03:46 +00:00
Continued our work on new Firehose tracer
This commit is contained in:
parent
7cc206e494
commit
e93892267f
4 changed files with 13 additions and 25 deletions
|
|
@ -160,7 +160,7 @@ type BlockchainLogger interface {
|
|||
state.StateLogger
|
||||
OnBlockStart(*types.Block)
|
||||
OnBlockEnd(td *big.Int, err error)
|
||||
OnGenesisBlock(*types.Block)
|
||||
OnGenesisBlock(*types.Block, GenesisAlloc)
|
||||
}
|
||||
|
||||
// BlockChain represents the canonical chain given a database with a genesis
|
||||
|
|
@ -1834,6 +1834,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
|||
}
|
||||
return it.index, err
|
||||
}
|
||||
|
||||
// Update the metrics touched during block commit
|
||||
accountCommitTimer.Update(statedb.AccountCommits) // Account commits are complete, we can mark them
|
||||
storageCommitTimer.Update(statedb.StorageCommits) // Storage commits are complete, we can mark them
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database, bcLogger Bloc
|
|||
return nil, errors.New("can't start clique chain without signers")
|
||||
}
|
||||
if bcLogger != nil {
|
||||
bcLogger.OnGenesisBlock(block)
|
||||
bcLogger.OnGenesisBlock(block, g.Alloc)
|
||||
}
|
||||
// All the checks has passed, flush the states derived from the genesis
|
||||
// specification as well as the specification itself into the provided
|
||||
|
|
|
|||
|
|
@ -252,33 +252,19 @@ func (f *Firehose) OnBlockStart(b *types.Block) {
|
|||
}
|
||||
|
||||
func (f *Firehose) OnBlockEnd(td *big.Int, err error) {
|
||||
// OnBlockEnd can be called while a transaction/call is still in progress, so must only assert that we are in a block
|
||||
f.ensureInBlock()
|
||||
|
||||
if err == nil {
|
||||
// No reset, next step is either OnBlockValidationError (skip and reset) or OnBlockWritten (flush and reset)
|
||||
f.ensureInBlockAndNotInTrx()
|
||||
|
||||
f.block.Header.TotalDifficulty = pbeth.BigIntFromNative(td)
|
||||
f.printBlockToFirehose(f.block)
|
||||
} else {
|
||||
// OnBlockEnd with error means that we could have been in any state
|
||||
f.resetBlock()
|
||||
f.resetTransaction()
|
||||
f.resetCall()
|
||||
// An error occurred, could have happen in transaction/call context, we must not check if in trx, only check in block
|
||||
f.ensureInBlock()
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Firehose) OnBlockValidationError(block *types.Block, err error) {
|
||||
f.ensureInBlockAndNotInTrx()
|
||||
|
||||
fmt.Fprintf(os.Stderr, "OnBlockValidationError: b=%v, err=%v\n", block.NumberU64(), err)
|
||||
f.resetBlock()
|
||||
}
|
||||
|
||||
func (f *Firehose) OnBlockWritten() {
|
||||
f.ensureInBlockAndNotInTrx()
|
||||
|
||||
f.printBlockToFirehose(f.block)
|
||||
|
||||
f.resetBlock()
|
||||
f.resetTransaction()
|
||||
f.resetCall()
|
||||
}
|
||||
|
||||
func (f *Firehose) OnGenesisBlock(b *types.Block, alloc core.GenesisAlloc) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
|
@ -29,7 +30,7 @@ func (p *Printer) CaptureEnd(output []byte, gasUsed uint64, err error) {
|
|||
|
||||
// CaptureState implements the EVMLogger interface to trace a single step of VM execution.
|
||||
func (p *Printer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
|
||||
//fmt.Printf("CaptureState: pc=%v, op=%v, gas=%v, cost=%v, scope=%v, rData=%v, depth=%v, err=%v\n", pc, op, gas, cost, scope, rData, depth, err)
|
||||
//fmt.Printf("CaptureState: pc=%v, op=%v, gas=%v, cost=%v, scope=%v, rData=%s, depth=%v, err=%v\n", pc, op, gas, cost, scope, hexutil.Bytes(rData), depth, err)
|
||||
}
|
||||
|
||||
// CaptureFault implements the EVMLogger interface to trace an execution fault.
|
||||
|
|
@ -78,7 +79,7 @@ func (p *Printer) OnBlockEnd(td *big.Int, err error) {
|
|||
fmt.Printf("OnBlockEnd: td=%v, err=%v\n", td, err)
|
||||
}
|
||||
|
||||
func (p *Printer) OnGenesisBlock(b *types.Block) {
|
||||
func (p *Printer) OnGenesisBlock(b *types.Block, _ core.GenesisAlloc) {
|
||||
fmt.Printf("OnGenesisBlock: b=%v\n", b.NumberU64())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue