Skip to content

Commit b0cd8c4

Browse files
ziogaschrs1na
andauthored
core/vm: set tracer-observable value of a delegatecall to match parent 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]>
1 parent 77380b9 commit b0cd8c4

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

core/vm/evm.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
315315

316316
// Invoke tracer hooks that signal entering/exiting a call frame
317317
if evm.Config.Debug {
318-
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, nil)
318+
// NOTE: caller must, at all times be a contract. It should never happen
319+
// that caller is something other than a Contract.
320+
parent := caller.(*Contract)
321+
// DELEGATECALL inherits value from parent call
322+
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, parent.value)
319323
defer func(startGas uint64) {
320324
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
321325
}(gas)

eth/tracers/internal/tracetest/testdata/call_tracer/delegatecall.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"input": "0x7d65837a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a529806c67cc6486d4d62024471772f47f6fd672",
7373
"output": "0x0000000000000000000000000000000000000000000000000000000000000001",
7474
"to": "0x42b02b5deeb78f34cd5ac896473b63e6c99a71a2",
75-
"type": "DELEGATECALL"
75+
"type": "DELEGATECALL",
76+
"value": "0x0"
7677
}
7778
],
7879
"from": "0x269296dddce321a6bcbaa2f0181127593d732cba",

eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@
165165
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
166166
"input": "0x24d4e90a0000000000000000000000000000000000000000000000020000000000000000",
167167
"output": "0x000000000000000000000000000000000000000000000000b17217f7d1cf79ab",
168-
"type": "DELEGATECALL"
168+
"type": "DELEGATECALL",
169+
"value": "0x0"
169170
},
170171
{
171172
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
@@ -174,7 +175,8 @@
174175
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
175176
"input": "0x872fb2b5000000000000000000000000000000000000000000000000c330b3f7006420b8",
176177
"output": "0x00000000000000000000000000000000000000000000000224bf7df2c80f0878",
177-
"type": "DELEGATECALL"
178+
"type": "DELEGATECALL",
179+
"value": "0x0"
178180
},
179181
{
180182
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
@@ -183,7 +185,8 @@
183185
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
184186
"input": "0x872fb2b50000000000000000000000000000000000000000000000000000000000000000",
185187
"output": "0x00000000000000000000000000000000000000000000000100000016aee6e8ef",
186-
"type": "DELEGATECALL"
188+
"type": "DELEGATECALL",
189+
"value": "0x0"
187190
},
188191
{
189192
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
@@ -192,7 +195,8 @@
192195
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
193196
"input": "0x24d4e90a00000000000000000000000000000000000000000000000324bf7e0976f5f167",
194197
"output": "0x0000000000000000000000000000000000000000000000012535c5e5f87ee0d2",
195-
"type": "DELEGATECALL"
198+
"type": "DELEGATECALL",
199+
"value": "0x0"
196200
},
197201
{
198202
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
@@ -201,7 +205,8 @@
201205
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
202206
"input": "0x872fb2b5000000000000000000000000000000000000000000000000c330b3f7006420b8",
203207
"output": "0x00000000000000000000000000000000000000000000000224bf7df2c80f0878",
204-
"type": "DELEGATECALL"
208+
"type": "DELEGATECALL",
209+
"value": "0x0"
205210
},
206211
{
207212
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
@@ -210,7 +215,8 @@
210215
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
211216
"input": "0x872fb2b500000000000000000000000000000000000000000000000237d37fe5d297a500",
212217
"output": "0x0000000000000000000000000000000000000000000000093088c407fcbbce38",
213-
"type": "DELEGATECALL"
218+
"type": "DELEGATECALL",
219+
"value": "0x0"
214220
},
215221
{
216222
"from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0",
@@ -219,7 +225,8 @@
219225
"to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae",
220226
"input": "0x24d4e90a00000000000000000000000000000000000000000000000b554841fac4cad6b0",
221227
"output": "0x0000000000000000000000000000000000000000000000026d7fc130d6a74cbe",
222-
"type": "DELEGATECALL"
228+
"type": "DELEGATECALL",
229+
"value": "0x0"
223230
}
224231
],
225232
"value": "0x0",
@@ -387,7 +394,8 @@
387394
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000"
388395
}
389396
],
390-
"type": "DELEGATECALL"
397+
"type": "DELEGATECALL",
398+
"value": "0x0"
391399
}
392400
],
393401
"value": "0x0",

0 commit comments

Comments
 (0)