mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-13 15:33:47 +00:00
Added back OnSystemCallStart/End that were lost in update to latest Geth version
This commit is contained in:
parent
a4e3ab8818
commit
bb041978a7
3 changed files with 49 additions and 3 deletions
|
|
@ -186,6 +186,13 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
|
||||||
// ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root
|
// ProcessBeaconBlockRoot applies the EIP-4788 system call to the beacon block root
|
||||||
// contract. This method is exported to be used in tests.
|
// contract. This method is exported to be used in tests.
|
||||||
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) {
|
func ProcessBeaconBlockRoot(beaconRoot common.Hash, vmenv *vm.EVM, statedb *state.StateDB) {
|
||||||
|
if vmenv.Config.Tracer != nil && vmenv.Config.Tracer.OnSystemCallStart != nil {
|
||||||
|
vmenv.Config.Tracer.OnSystemCallStart()
|
||||||
|
}
|
||||||
|
if vmenv.Config.Tracer != nil && vmenv.Config.Tracer.OnSystemCallEnd != nil {
|
||||||
|
defer vmenv.Config.Tracer.OnSystemCallEnd()
|
||||||
|
}
|
||||||
|
|
||||||
// If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with
|
// If EIP-4788 is enabled, we need to invoke the beaconroot storage contract with
|
||||||
// the new root
|
// the new root
|
||||||
msg := &Message{
|
msg := &Message{
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,11 @@ type Hooks struct {
|
||||||
OnStorageChange StorageChangeHook
|
OnStorageChange StorageChangeHook
|
||||||
OnLog LogHook
|
OnLog LogHook
|
||||||
|
|
||||||
|
// This is being discussed in PR https://github.com/ethereum/go-ethereum/pull/29355
|
||||||
|
// but Firehose needs them so we add handling for them in our patch
|
||||||
|
OnSystemCallStart func()
|
||||||
|
OnSystemCallEnd func()
|
||||||
|
|
||||||
// Firehose backward compatibility
|
// Firehose backward compatibility
|
||||||
// This hook exist because some current Firehose supported chains requires it
|
// This hook exist because some current Firehose supported chains requires it
|
||||||
// but this field is going to be deprecated and newer chains will not produced
|
// but this field is going to be deprecated and newer chains will not produced
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,11 @@ func newTracingHooksFromFirehose(tracer *Firehose) *tracing.Hooks {
|
||||||
OnGasChange: tracer.OnGasChange,
|
OnGasChange: tracer.OnGasChange,
|
||||||
OnLog: tracer.OnLog,
|
OnLog: tracer.OnLog,
|
||||||
|
|
||||||
|
// This is being discussed in PR https://github.com/ethereum/go-ethereum/pull/29355
|
||||||
|
// but Firehose needs them so we add handling for them in our patch.
|
||||||
|
OnSystemCallStart: tracer.OnSystemCallStart,
|
||||||
|
OnSystemCallEnd: tracer.OnSystemCallEnd,
|
||||||
|
|
||||||
// This should actually be conditional but it's not possible to do it in the hooks
|
// This should actually be conditional but it's not possible to do it in the hooks
|
||||||
// directly because the chain ID will be known only after the `OnBlockchainInit` call.
|
// directly because the chain ID will be known only after the `OnBlockchainInit` call.
|
||||||
// So we register it unconditionally and the actual `OnNewAccount` hook will decide
|
// So we register it unconditionally and the actual `OnNewAccount` hook will decide
|
||||||
|
|
@ -442,15 +447,15 @@ func (f *Firehose) reorderCallOrdinals(call *pbeth.Call, ordinalBase uint64) (or
|
||||||
return call.EndOrdinal
|
return call.EndOrdinal
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firehose) OnBeaconBlockRootStart(root common.Hash) {
|
func (f *Firehose) OnSystemCallStart() {
|
||||||
firehoseInfo("system call start (for=%s)", "beacon_block_root")
|
firehoseInfo("system call start (for=%s)", callerView(3))
|
||||||
f.ensureInBlockAndNotInTrx()
|
f.ensureInBlockAndNotInTrx()
|
||||||
|
|
||||||
f.inSystemCall = true
|
f.inSystemCall = true
|
||||||
f.transaction = &pbeth.TransactionTrace{}
|
f.transaction = &pbeth.TransactionTrace{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Firehose) OnBeaconBlockRootEnd() {
|
func (f *Firehose) OnSystemCallEnd() {
|
||||||
f.ensureInBlockAndInTrx()
|
f.ensureInBlockAndInTrx()
|
||||||
f.ensureInSystemCall()
|
f.ensureInSystemCall()
|
||||||
|
|
||||||
|
|
@ -1963,6 +1968,35 @@ func (r *receiptView) String() string {
|
||||||
return fmt.Sprintf("[status=%s, gasUsed=%d, logs=%d]", status, r.GasUsed, len(r.Logs))
|
return fmt.Sprintf("[status=%s, gasUsed=%d, logs=%d]", status, r.GasUsed, len(r.Logs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type callerViewer struct {
|
||||||
|
skipFrame int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v callerViewer) String() string {
|
||||||
|
_, file, line, found := runtime.Caller(v.skipFrame)
|
||||||
|
if !found {
|
||||||
|
return "<unknown>"
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s:%d", file, line)
|
||||||
|
}
|
||||||
|
|
||||||
|
// callerView returns a fmt.Stringer that will print the caller of the function. You need
|
||||||
|
// to specify how many frames to skip from the callstack. The minimum is 1 and usually 2.
|
||||||
|
//
|
||||||
|
// Imagine you have the call stack
|
||||||
|
// - callerView(3)
|
||||||
|
// - firehoseDebug(..., callerView(3))
|
||||||
|
// - OnOpcode(...)
|
||||||
|
// - ProcessCall(...)
|
||||||
|
// - ...<rest of Geth calls>
|
||||||
|
//
|
||||||
|
// In this example, with `callerView(2)` which means skip 3 call frames, you would get
|
||||||
|
// you to ProcessCall frame and `callerView` would print that.
|
||||||
|
func callerView(skipFrame int) fmt.Stringer {
|
||||||
|
return callerViewer{skipFrame}
|
||||||
|
}
|
||||||
|
|
||||||
func emptyBytesToNil(in []byte) []byte {
|
func emptyBytesToNil(in []byte) []byte {
|
||||||
if len(in) == 0 {
|
if len(in) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue