mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-07 12:33:48 +00:00
Fixed a few linting errors
This commit is contained in:
parent
ad7fdb83cc
commit
2108b9d42a
1 changed files with 42 additions and 22 deletions
|
|
@ -36,14 +36,25 @@ import (
|
|||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
const (
|
||||
firehoseTraceLevel = "trace"
|
||||
firehoseDebugLevel = "debug"
|
||||
firehoseInfoLevel = "info"
|
||||
)
|
||||
|
||||
const (
|
||||
callSourceRoot = "root"
|
||||
callSourceChild = "child"
|
||||
)
|
||||
|
||||
// Here what you can expect from the debugging levels:
|
||||
// - Info == block start/end + trx start/end
|
||||
// - Debug == Info + call start/end + error
|
||||
// - Trace == Debug + state db changes, log, balance, nonce, code, storage, gas
|
||||
var firehoseTracerLogLevel = strings.ToLower(os.Getenv("FIREHOSE_ETHEREUM_TRACER_LOG_LEVEL"))
|
||||
var isFirehoseInfoEnabled = firehoseTracerLogLevel == "info" || firehoseTracerLogLevel == "debug" || firehoseTracerLogLevel == "trace"
|
||||
var isFirehoseDebugEnabled = firehoseTracerLogLevel == "debug" || firehoseTracerLogLevel == "trace"
|
||||
var isFirehoseTracerEnabled = firehoseTracerLogLevel == "trace"
|
||||
var isFirehoseInfoEnabled = firehoseTracerLogLevel == firehoseInfoLevel || firehoseTracerLogLevel == firehoseDebugLevel || firehoseTracerLogLevel == firehoseTraceLevel
|
||||
var isFirehoseDebugEnabled = firehoseTracerLogLevel == firehoseDebugLevel || firehoseTracerLogLevel == firehoseTraceLevel
|
||||
var isFirehoseTracerEnabled = firehoseTracerLogLevel == firehoseTraceLevel
|
||||
|
||||
var emptyCommonAddress = common.Address{}
|
||||
var emptyCommonHash = common.Hash{}
|
||||
|
|
@ -547,7 +558,9 @@ func (f *Firehose) completeTransaction(receipt *types.Receipt) *pbeth.Transactio
|
|||
rootCall := f.transaction.Calls[0]
|
||||
|
||||
if !f.deferredCallState.IsEmpty() {
|
||||
f.deferredCallState.MaybePopulateCallAndReset("root", rootCall)
|
||||
if err := f.deferredCallState.MaybePopulateCallAndReset(callSourceRoot, rootCall); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Receipt can be nil if an error occurred during the transaction execution, right now we don't have it
|
||||
|
|
@ -710,7 +723,7 @@ func (f *Firehose) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracing.
|
|||
|
||||
if activeCall := f.callStack.Peek(); activeCall != nil {
|
||||
opCode := vm.OpCode(op)
|
||||
f.captureInterpreterStep(activeCall, pc, opCode, gas, cost, scope, rData, depth, err)
|
||||
f.captureInterpreterStep(activeCall)
|
||||
|
||||
// The rest of the logic expects that a call succeeded, nothing to do more here if the interpreter failed on this OpCode
|
||||
if err != nil {
|
||||
|
|
@ -751,7 +764,9 @@ func (f *Firehose) onOpcodeKeccak256(call *pbeth.Call, stack []uint256.Int, memo
|
|||
// We should have exclusive access to the hasher, we can safely reset it.
|
||||
f.hasher.Reset()
|
||||
f.hasher.Write(preImage)
|
||||
f.hasher.Read(f.hasherBuf[:])
|
||||
if _, err := f.hasher.Read(f.hasherBuf[:]); err != nil {
|
||||
panic(fmt.Errorf("failed to read keccak256 hash: %w", err))
|
||||
}
|
||||
|
||||
encodedData := hex.EncodeToString(preImage)
|
||||
|
||||
|
|
@ -794,13 +809,11 @@ var opCodeToGasChangeReasonMap = map[vm.OpCode]pbeth.GasChange_Reason{
|
|||
// OnOpcodeFault implements the EVMLogger interface to trace an execution fault.
|
||||
func (f *Firehose) OnOpcodeFault(pc uint64, op byte, gas, cost uint64, scope tracing.OpContext, depth int, err error) {
|
||||
if activeCall := f.callStack.Peek(); activeCall != nil {
|
||||
f.captureInterpreterStep(activeCall, pc, vm.OpCode(op), gas, cost, scope, nil, depth, err)
|
||||
f.captureInterpreterStep(activeCall)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Firehose) captureInterpreterStep(activeCall *pbeth.Call, pc uint64, op vm.OpCode, gas, cost uint64, _ tracing.OpContext, rData []byte, depth int, err error) {
|
||||
_, _, _, _, _, _, _ = pc, op, gas, cost, rData, depth, err
|
||||
|
||||
func (f *Firehose) captureInterpreterStep(activeCall *pbeth.Call) {
|
||||
if *f.applyBackwardCompatibility {
|
||||
// for call, we need to process the executed code here
|
||||
// since in old firehose executed code calculation depends if the code exist
|
||||
|
|
@ -862,7 +875,7 @@ func (f *Firehose) callStart(source string, callType pbeth.CallType, from common
|
|||
// be assigned back to 0 because of a bug in the console reader. remove on new chain.
|
||||
//
|
||||
// New chain integration should remove this `if` statement
|
||||
if source == "root" {
|
||||
if source == callSourceRoot {
|
||||
call.BeginOrdinal = 0
|
||||
}
|
||||
}
|
||||
|
|
@ -922,7 +935,7 @@ func (f *Firehose) callEnd(source string, output []byte, gasUsed uint64, err err
|
|||
firehoseDebug("call end (source=%s index=%d output=%s gasUsed=%d err=%s reverted=%t)", source, f.callStack.ActiveIndex(), outputView(output), gasUsed, errorView(err), reverted)
|
||||
|
||||
if f.latestCallEnterSuicided {
|
||||
if source != "child" {
|
||||
if source != callSourceChild {
|
||||
panic(fmt.Errorf("unexpected source for suicided call end, expected child but got %s, suicide are always produced on a 'child' source", source))
|
||||
}
|
||||
|
||||
|
|
@ -978,10 +991,10 @@ func (f *Firehose) callEnd(source string, output []byte, gasUsed uint64, err err
|
|||
|
||||
func computeCallSource(depth int) string {
|
||||
if depth == 0 {
|
||||
return "root"
|
||||
return callSourceRoot
|
||||
}
|
||||
|
||||
return "child"
|
||||
return callSourceChild
|
||||
}
|
||||
|
||||
func (f *Firehose) OnGenesisBlock(b *types.Block, alloc types.GenesisAlloc) {
|
||||
|
|
@ -1446,7 +1459,10 @@ func flushToFirehose(in []byte, writer io.Writer) {
|
|||
}
|
||||
|
||||
errstr := fmt.Sprintf("\nFIREHOSE FAILED WRITING %dx: %s\n", loops, err)
|
||||
os.WriteFile("/tmp/firehose_writer_failed_print.log", []byte(errstr), 0644)
|
||||
if err := os.WriteFile("./firehose_writer_failed_print.log", []byte(errstr), 0600); err != nil {
|
||||
fmt.Println(errstr)
|
||||
}
|
||||
|
||||
fmt.Fprint(writer, errstr)
|
||||
}
|
||||
|
||||
|
|
@ -1724,28 +1740,32 @@ func gasPrice(tx *types.Transaction, baseFee *big.Int) *pbeth.BigInt {
|
|||
panic(errUnhandledTransactionType("gasPrice", tx.Type()))
|
||||
}
|
||||
|
||||
func FirehoseDebug(msg string, args ...interface{}) {
|
||||
func FirehoseDebug(msg string, args ...any) {
|
||||
firehoseDebug(msg, args...)
|
||||
}
|
||||
|
||||
func firehoseInfo(msg string, args ...interface{}) {
|
||||
func firehoseInfo(msg string, args ...any) {
|
||||
if isFirehoseInfoEnabled {
|
||||
fmt.Fprintf(os.Stderr, "[Firehose] "+msg+"\n", args...)
|
||||
firehoseLog(msg, args)
|
||||
}
|
||||
}
|
||||
|
||||
func firehoseDebug(msg string, args ...interface{}) {
|
||||
func firehoseDebug(msg string, args ...any) {
|
||||
if isFirehoseDebugEnabled {
|
||||
fmt.Fprintf(os.Stderr, "[Firehose] "+msg+"\n", args...)
|
||||
firehoseLog(msg, args)
|
||||
}
|
||||
}
|
||||
|
||||
func firehoseTrace(msg string, args ...interface{}) {
|
||||
func firehoseTrace(msg string, args ...any) {
|
||||
if isFirehoseTracerEnabled {
|
||||
fmt.Fprintf(os.Stderr, "[Firehose] "+msg+"\n", args...)
|
||||
firehoseLog(msg, args)
|
||||
}
|
||||
}
|
||||
|
||||
func firehoseLog(msg string, args []any) {
|
||||
fmt.Fprintf(os.Stderr, "[Firehose] "+msg+"\n", args...)
|
||||
}
|
||||
|
||||
// Ignore unused, we keep it around for debugging purposes
|
||||
var _ = firehoseDebugPrintStack
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue