From eab9585ea15f61fdf3076ed8da867c740bde51c7 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 4 Aug 2015 14:05:20 +0200 Subject: [PATCH] Fix clone with regards to value transfer. --- Compiler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Compiler.cpp b/Compiler.cpp index eadfc204a..f0d1b38ea 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -712,11 +712,13 @@ eth::Assembly Compiler::getCloneRuntime() a << u256(0) << eth::Instruction::DUP1 << eth::Instruction::CALLDATACOPY; //@todo adjust for larger return values, make this dynamic. a << u256(0x20) << u256(0) << eth::Instruction::CALLDATASIZE; - a << u256(0) << eth::Instruction::DUP1; + // unfortunately, we have to send the value again, so that CALLVALUE returns the correct value + // in the callcoded contract. + a << u256(0) << eth::Instruction::CALLVALUE; // this is the address which has to be substituted by the linker. //@todo implement as special "marker" AssemblyItem. a << u256("0xcafecafecafecafecafecafecafecafecafecafe"); - a << u256(eth::c_callGas + 10) << eth::Instruction::GAS << eth::Instruction::SUB; + a << u256(eth::c_callGas + eth::c_callValueTransferGas + 10) << eth::Instruction::GAS << eth::Instruction::SUB; a << eth::Instruction::CALLCODE; //@todo adjust for larger return values, make this dynamic. a << u256(0x20) << u256(0) << eth::Instruction::RETURN;