diff --git a/core/vm/evm.go b/core/vm/evm.go index f2ae81cd775..da1734e3f4f 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -221,6 +221,12 @@ func (evm *EVM) call(typ OpCode, caller ContractRef, addr libcommon.Address, inp v := value if typ == STATICCALL { v = nil + } else if typ == DELEGATECALL { + // 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 + v = parent.value } if depth == 0 { evm.config.Tracer.CaptureStart(evm, caller.Address(), addr, isPrecompile, false /* create */, input, gas, v, code) diff --git a/eth/tracers/internal/tracetest/testdata/call_tracer/delegatecall.json b/eth/tracers/internal/tracetest/testdata/call_tracer/delegatecall.json index 9ba67a9bf46..eb7539d4613 100644 --- a/eth/tracers/internal/tracetest/testdata/call_tracer/delegatecall.json +++ b/eth/tracers/internal/tracetest/testdata/call_tracer/delegatecall.json @@ -70,7 +70,8 @@ "input": "0x7d65837a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a529806c67cc6486d4d62024471772f47f6fd672", "output": "0x0000000000000000000000000000000000000000000000000000000000000001", "to": "0x42b02b5deeb78f34cd5ac896473b63e6c99a71a2", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" } ], "from": "0x269296dddce321a6bcbaa2f0181127593d732cba", diff --git a/eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json b/eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json index bc13bc25068..e9ad6df6ab8 100644 --- a/eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json +++ b/eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json @@ -163,7 +163,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x24d4e90a0000000000000000000000000000000000000000000000020000000000000000", "output": "0x000000000000000000000000000000000000000000000000b17217f7d1cf79ab", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" }, { "from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0", @@ -172,7 +173,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x872fb2b5000000000000000000000000000000000000000000000000c330b3f7006420b8", "output": "0x00000000000000000000000000000000000000000000000224bf7df2c80f0878", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" }, { "from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0", @@ -181,7 +183,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x872fb2b50000000000000000000000000000000000000000000000000000000000000000", "output": "0x00000000000000000000000000000000000000000000000100000016aee6e8ef", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" }, { "from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0", @@ -190,7 +193,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x24d4e90a00000000000000000000000000000000000000000000000324bf7e0976f5f167", "output": "0x0000000000000000000000000000000000000000000000012535c5e5f87ee0d2", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" }, { "from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0", @@ -199,7 +203,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x872fb2b5000000000000000000000000000000000000000000000000c330b3f7006420b8", "output": "0x00000000000000000000000000000000000000000000000224bf7df2c80f0878", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" }, { "from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0", @@ -208,7 +213,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x872fb2b500000000000000000000000000000000000000000000000237d37fe5d297a500", "output": "0x0000000000000000000000000000000000000000000000093088c407fcbbce38", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" }, { "from": "0x8695e5e79dab06fbbb05f445316fa4edb0da30f0", @@ -217,7 +223,8 @@ "to": "0xef3487d24a0702703e04a26cef479e313c8fc7ae", "input": "0x24d4e90a00000000000000000000000000000000000000000000000b554841fac4cad6b0", "output": "0x0000000000000000000000000000000000000000000000026d7fc130d6a74cbe", - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value":"0x0" } ], "value": "0x0", @@ -390,7 +397,8 @@ "data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000" } ], - "type": "DELEGATECALL" + "type": "DELEGATECALL", + "value": "0x0" } ], "value": "0x0",