Skip to content

Commit

Permalink
fix gas calculation (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Jun 20, 2023
1 parent 5dc3575 commit d5f30e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eth/tracers/sentio/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (t *sentioTracer) CaptureEnd(output []byte, usedGas uint64, err error) {
currentGas := uint64(t.callstack[stackSize-1].Gas) - usedGas
for j := stackSize - 1; j > 0; j-- {
t.callstack[j].Output = common.CopyBytes(output)
t.callstack[j].GasUsed = math.HexOrDecimal64(uint64(t.callstack[j].Gas) - currentGas + t.callstack[j].gasCost)
t.callstack[j].GasUsed = math.HexOrDecimal64(uint64(t.callstack[j].Gas) - currentGas)
t.callstack[j-1].Traces = append(t.callstack[j-1].Traces, t.callstack[j])
}
t.callstack = t.callstack[:1]
Expand Down Expand Up @@ -199,10 +199,10 @@ func (t *sentioTracer) CaptureExit(output []byte, usedGas uint64, err error) {

call := t.callstack[i]
call.GasUsed = math.HexOrDecimal64(usedGas)
currentGas := uint64(call.Gas) - usedGas + call.gasCost
currentGas := uint64(call.Gas) - usedGas
for j := stackSize - 1; j >= i; j-- {
t.callstack[j].Output = common.CopyBytes(output)
t.callstack[j].GasUsed = math.HexOrDecimal64(uint64(t.callstack[j].Gas) - currentGas + t.callstack[j].gasCost)
t.callstack[j].GasUsed = math.HexOrDecimal64(uint64(t.callstack[j].Gas) - currentGas)
t.callstack[j-1].Traces = append(t.callstack[j-1].Traces, t.callstack[j])
}
call.GasUsed = math.HexOrDecimal64(usedGas)
Expand Down Expand Up @@ -324,7 +324,7 @@ func (t *sentioTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, s

// TODO maybe don't need return all
for j := stackSize - 1; j >= i; j-- {
t.callstack[j].GasUsed = math.HexOrDecimal64(uint64(t.callstack[j].Gas) - gas + t.callstack[j].gasCost)
t.callstack[j].GasUsed = math.HexOrDecimal64(uint64(t.callstack[j].Gas) - gas)
t.callstack[j].OutputStack = copyStack(t.callstack[j].function.OutputSize)
if functionInfo.OutputMemory {
t.callstack[j].OutputMemory = formatMemory()
Expand Down

0 comments on commit d5f30e3

Please sign in to comment.