Skip to content

Commit

Permalink
Merge pull request ethereum#37 from OffchainLabs/caller-stack
Browse files Browse the repository at this point in the history
Track Caller Stack
  • Loading branch information
rachel-bousfield authored Jan 14, 2022
2 parents 1b18224 + e7fd4be commit f00de6c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
42 changes: 0 additions & 42 deletions core/vm/arbitrum_evm.go

This file was deleted.

37 changes: 37 additions & 0 deletions core/vm/evm_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,44 @@

package vm

import "github.com/ethereum/go-ethereum/common"

// Depth returns the current depth
func (evm *EVM) Depth() int {
return evm.depth
}

type TxProcessingHook interface {
StartTxHook() bool
GasChargingHook(gasRemaining *uint64) error
EndTxHook(totalGasUsed uint64, success bool)
NonrefundableGas() uint64
PushCaller(addr common.Address)
PopCaller()
}

type DefaultTxProcessor struct{}

func (p DefaultTxProcessor) StartTxHook() bool {
return false
}

func (p DefaultTxProcessor) GasChargingHook(gasRemaining *uint64) error {
return nil
}

func (p DefaultTxProcessor) EndTxHook(totalGasUsed uint64, success bool) {
return
}

func (p DefaultTxProcessor) NonrefundableGas() uint64 {
return 0
}

func (p DefaultTxProcessor) PushCaller(addr common.Address) {
return
}

func (p DefaultTxProcessor) PopCaller() {
return
}
2 changes: 2 additions & 0 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (

// Increment the call depth which is restricted to 1024
in.evm.depth++
in.evm.ProcessingHook.PushCaller(contract.Caller())
defer func() { in.evm.depth-- }()
defer func() { in.evm.ProcessingHook.PopCaller() }()

// Make sure the readOnly is only set if we aren't in readOnly yet.
// This also makes sure that the readOnly flag isn't removed for child calls.
Expand Down

0 comments on commit f00de6c

Please sign in to comment.