mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 23:56:43 +00:00
Fixed wrong split of trx and call
This commit is contained in:
parent
da14392fc6
commit
8f17c19c63
3 changed files with 32 additions and 27 deletions
|
|
@ -184,9 +184,9 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
|||
} else {
|
||||
// Handle tracer events for entering and exiting a call frame
|
||||
evm.Config.Tracer.CaptureEnter(CALL, caller.Address(), addr, input, gas, value)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeTxInitialBalance)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeCallInitialBalance)
|
||||
defer func(startGas uint64) {
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeTxBuyBack)
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeCallLeftOverRefunded)
|
||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||
}(gas)
|
||||
}
|
||||
|
|
@ -259,9 +259,9 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
|
|||
// Invoke tracer hooks that signal entering/exiting a call frame
|
||||
if evm.Config.Tracer != nil {
|
||||
evm.Config.Tracer.CaptureEnter(CALLCODE, caller.Address(), addr, input, gas, value)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeTxInitialBalance)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeCallInitialBalance)
|
||||
defer func(startGas uint64) {
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeTxBuyBack)
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeCallLeftOverRefunded)
|
||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||
}(gas)
|
||||
}
|
||||
|
|
@ -316,9 +316,9 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
|
|||
parent := caller.(*Contract)
|
||||
// DELEGATECALL inherits value from parent call
|
||||
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, parent.value)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeTxInitialBalance)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeCallInitialBalance)
|
||||
defer func(startGas uint64) {
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeTxBuyBack)
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeCallLeftOverRefunded)
|
||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||
}(gas)
|
||||
}
|
||||
|
|
@ -360,9 +360,9 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
|
|||
// Invoke tracer hooks that signal entering/exiting a call frame
|
||||
if evm.Config.Tracer != nil {
|
||||
evm.Config.Tracer.CaptureEnter(STATICCALL, caller.Address(), addr, input, gas, nil)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeTxInitialBalance)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeCallInitialBalance)
|
||||
defer func(startGas uint64) {
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeTxBuyBack)
|
||||
evm.Config.Tracer.OnGasChange(leftOverGas, 0, GasChangeCallLeftOverRefunded)
|
||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||
}(gas)
|
||||
}
|
||||
|
|
@ -435,9 +435,9 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
|||
}()
|
||||
} else {
|
||||
evm.Config.Tracer.CaptureEnter(typ, caller.Address(), address, codeAndHash.code, gas, value)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeTxInitialBalance)
|
||||
evm.Config.Tracer.OnGasChange(0, gas, GasChangeCallInitialBalance)
|
||||
defer func() {
|
||||
evm.Config.Tracer.OnGasChange(leftoverGas, 0, GasChangeTxBuyBack)
|
||||
evm.Config.Tracer.OnGasChange(leftoverGas, 0, GasChangeCallLeftOverRefunded)
|
||||
evm.Config.Tracer.CaptureExit(ret, gas-leftoverGas, err)
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
|||
scope.Stack.push(&stackvalue)
|
||||
|
||||
if interpreter.evm.Config.Tracer != nil {
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded)
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverReturned)
|
||||
}
|
||||
|
||||
scope.Contract.Gas += returnGas
|
||||
|
|
@ -659,7 +659,7 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]
|
|||
scope.Stack.push(&stackvalue)
|
||||
|
||||
if interpreter.evm.Config.Tracer != nil {
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded)
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverReturned)
|
||||
}
|
||||
|
||||
scope.Contract.Gas += returnGas
|
||||
|
|
@ -709,7 +709,7 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
|
|||
}
|
||||
|
||||
if interpreter.evm.Config.Tracer != nil {
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded)
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverReturned)
|
||||
}
|
||||
|
||||
scope.Contract.Gas += returnGas
|
||||
|
|
@ -749,7 +749,7 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
|
|||
}
|
||||
|
||||
if interpreter.evm.Config.Tracer != nil {
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded)
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverReturned)
|
||||
}
|
||||
|
||||
scope.Contract.Gas += returnGas
|
||||
|
|
@ -782,7 +782,7 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
|||
}
|
||||
|
||||
if interpreter.evm.Config.Tracer != nil {
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded)
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverReturned)
|
||||
}
|
||||
|
||||
scope.Contract.Gas += returnGas
|
||||
|
|
@ -815,7 +815,7 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
|
|||
}
|
||||
|
||||
if interpreter.evm.Config.Tracer != nil {
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverRefunded)
|
||||
interpreter.evm.Config.Tracer.OnGasChange(scope.Contract.Gas, scope.Contract.Gas+returnGas, GasChangeCallLeftOverReturned)
|
||||
}
|
||||
|
||||
scope.Contract.Gas += returnGas
|
||||
|
|
|
|||
|
|
@ -72,23 +72,28 @@ const (
|
|||
// end of the transaction's execution. There is only one such gas change per transaction.
|
||||
GasChangeTxBuyBack
|
||||
|
||||
// GasChangeCallContractCreation is the amount of gas that will be burned for a CREATE, today controlled by EIP150 rules
|
||||
// GasChangeCallInitialBalance is the initial balance for the call which will be equal to the gasLimit of the call. There is only
|
||||
// one such gas change per call.
|
||||
GasChangeCallInitialBalance
|
||||
// GasChangeCallLeftOverReturned is the amount of gas left over that will be returned to the caller, this change will always
|
||||
// be a negative change as we "drain" left over gas towards 0.
|
||||
GasChangeCallLeftOverReturned
|
||||
// GasChangeCallLeftOverRefunded is the amount of gas that will be refunded to the call after the child call execution it
|
||||
// executed completed. This value is always positive as we are giving gas back to the you, the left over gas of the child.
|
||||
GasChangeCallLeftOverRefunded
|
||||
// GasChangeCallContractCreation is the amount of gas that will be burned for a CREATE, today controlled by EIP150 rules.
|
||||
GasChangeCallContractCreation
|
||||
// GasChangeContractCreation is the amount of gas that will be burned for a CREATE2, today controlled by EIP150 rules
|
||||
// GasChangeContractCreation is the amount of gas that will be burned for a CREATE2, today controlled by EIP150 rules.
|
||||
GasChangeCallContractCreation2
|
||||
// GasChangeCallCodeStorage is the amount of gas that will be charged for code storage
|
||||
// GasChangeCallCodeStorage is the amount of gas that will be charged for code storage.
|
||||
GasChangeCallCodeStorage
|
||||
// GasChangeCallOpCode is the amount of gas that will be charged for an opcode executed by the EVM, exact opcode that was
|
||||
// performed can be check by `CaptureState` handling
|
||||
// performed can be check by `CaptureState` handling.
|
||||
GasChangeCallOpCode
|
||||
// GasChangeCallPrecompiledContract is the amount of gas that will be charged for a precompiled contract execution
|
||||
// GasChangeCallPrecompiledContract is the amount of gas that will be charged for a precompiled contract execution.
|
||||
GasChangeCallPrecompiledContract
|
||||
// GasChangeCallStorageColdAccess is the amount of gas that will be charged for a cold storage access as controlled by EIP2929 rules
|
||||
// GasChangeCallStorageColdAccess is the amount of gas that will be charged for a cold storage access as controlled by EIP2929 rules.
|
||||
GasChangeCallStorageColdAccess
|
||||
// GasChangeCallLeftOverRefunded is the amount of gas that will be refunded to the caller after the execution of the call, if
|
||||
// there is left over at the end of call's execution. This can change can happen multiple times within a single transaction as
|
||||
// each call is independent of each other.
|
||||
GasChangeCallLeftOverRefunded
|
||||
// GasChangeCallFailedExecution is the burning of the remaining gas when the execution failed without a revert
|
||||
// GasChangeCallFailedExecution is the burning of the remaining gas when the execution failed without a revert.
|
||||
GasChangeCallFailedExecution
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue