Skip to content

Commit

Permalink
make scopecontext stack accurate towards delegate and static calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Jul 15, 2024
1 parent a42a7a1 commit 256d27e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
22 changes: 12 additions & 10 deletions arbos/programs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,19 @@ func newApiClosures(

// Tracing: emit the call (value transfer is done later in evm.Call)
if tracingInfo != nil {
var args []uint256.Int
args = append(args, *uint256.NewInt(gas)) // gas
args = append(args, *uint256.NewInt(0).SetBytes(contract.Bytes())) // to address
if opcode == vm.CALL {
args = append(args, *uint256.NewInt(0).SetBytes(value.Bytes())) // call value
}
args = append(args, *uint256.NewInt(0)) // memory offset
args = append(args, *uint256.NewInt(uint64(len(input)))) // memory length
args = append(args, *uint256.NewInt(0)) // return offset
args = append(args, *uint256.NewInt(0)) // return size
s := &vm.ScopeContext{
Memory: vm.NewMemory(),
Stack: util.TracingStackFromArgs(
*uint256.NewInt(gas), // gas
*uint256.NewInt(0).SetBytes(contract.Bytes()), // to address
*uint256.NewInt(0).SetBytes(value.Bytes()), // call value
*uint256.NewInt(0), // memory offset
*uint256.NewInt(uint64(len(input))), // memory length
*uint256.NewInt(0), // return offset
*uint256.NewInt(0), // return size
),
Memory: util.TracingMemoryFromBytes(input),
Stack: util.TracingStackFromArgs(args...),
Contract: scope.Contract,
}
tracingInfo.Tracer.CaptureState(0, opcode, startGas, baseCost+gas, s, []byte{}, depth, nil)
Expand Down
5 changes: 1 addition & 4 deletions arbos/util/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ func (info *TracingInfo) RecordEmitLog(topics []common.Hash, data []byte) {
for _, topic := range topics {
args = append(args, HashToUint256(topic)) // topic: 32-byte value. Max topics count is 4
}
memory := vm.NewMemory()
memory.Resize(size)
memory.Set(0, size, data)
scope := &vm.ScopeContext{
Memory: memory,
Memory: TracingMemoryFromBytes(data),
Stack: TracingStackFromArgs(args...),
Contract: info.Contract,
}
Expand Down

0 comments on commit 256d27e

Please sign in to comment.