Skip to content

Commit

Permalink
core/vm: set tracer-observable value of a delegatecall to match par…
Browse files Browse the repository at this point in the history
…ent `value` (#26632)

This is a breaking change in the tracing hooks API as well as semantics of the callTracer:

- CaptureEnter hook provided a nil value argument in case of DELEGATECALL. However to stay consistent with how delegate calls behave in EVM this hook is changed to pass in the value of the parent call.
- callTracer will return parent call's value for DELEGATECALL frames.

---------

Co-authored-by: Sina Mahmoodi <[email protected]>
  • Loading branch information
ziogaschr and s1na authored Feb 10, 2023
1 parent 77380b9 commit b0cd8c4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
6 changes: 5 additions & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by

// Invoke tracer hooks that signal entering/exiting a call frame
if evm.Config.Debug {
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, nil)
// NOTE: caller must, at all times be a contract. It should never happen
// that caller is something other than a Contract.
parent := caller.(*Contract)
// DELEGATECALL inherits value from parent call
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, parent.value)
defer func(startGas uint64) {
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
}(gas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"input": "0x7d65837a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a529806c67cc6486d4d62024471772f47f6fd672",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
"to": "0x42b02b5deeb78f34cd5ac896473b63e6c99a71a2",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
}
],
"from": "0x269296dddce321a6bcbaa2f0181127593d732cba",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x24d4e90a0000000000000000000000000000000000000000000000020000000000000000",
"output": "0x000000000000000000000000000000000000000000000000b17217f7d1cf79ab",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
},
{
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
Expand All @@ -174,7 +175,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x872fb2b5000000000000000000000000000000000000000000000000c330b3f7006420b8",
"output": "0x00000000000000000000000000000000000000000000000224bf7df2c80f0878",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
},
{
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
Expand All @@ -183,7 +185,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x872fb2b50000000000000000000000000000000000000000000000000000000000000000",
"output": "0x00000000000000000000000000000000000000000000000100000016aee6e8ef",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
},
{
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
Expand All @@ -192,7 +195,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x24d4e90a00000000000000000000000000000000000000000000000324bf7e0976f5f167",
"output": "0x0000000000000000000000000000000000000000000000012535c5e5f87ee0d2",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
},
{
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
Expand All @@ -201,7 +205,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x872fb2b5000000000000000000000000000000000000000000000000c330b3f7006420b8",
"output": "0x00000000000000000000000000000000000000000000000224bf7df2c80f0878",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
},
{
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
Expand All @@ -210,7 +215,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x872fb2b500000000000000000000000000000000000000000000000237d37fe5d297a500",
"output": "0x0000000000000000000000000000000000000000000000093088c407fcbbce38",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
},
{
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
Expand All @@ -219,7 +225,8 @@
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
"input": "0x24d4e90a00000000000000000000000000000000000000000000000b554841fac4cad6b0",
"output": "0x0000000000000000000000000000000000000000000000026d7fc130d6a74cbe",
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
}
],
"value": "0x0",
Expand Down Expand Up @@ -387,7 +394,8 @@
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000"
}
],
"type": "DELEGATECALL"
"type": "DELEGATECALL",
"value": "0x0"
}
],
"value": "0x0",
Expand Down

0 comments on commit b0cd8c4

Please sign in to comment.