From 65ad62ff55b8e6f01140f08885e9bc8f2ffa3b4c Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 6 Mar 2015 16:23:39 +0100 Subject: [PATCH] Fixed gas calculation for CALL. --- libsolidity/ExpressionCompiler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 6b7978872..3d7a25311 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -1052,8 +1052,9 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio if (_functionType.gasSet()) m_context << eth::dupInstruction(m_context.baseToCurrentStackOffset(gasStackPos)); else - // send all gas except for the 41 / 6741 needed to execute "SUB" and "CALL" - m_context << u256(41 + (_functionType.valueSet() ? 6700 : 0)) << eth::Instruction::GAS << eth::Instruction::SUB; + // send all gas except the amount needed to execute "SUB" and "CALL" + // @todo this retains too much gas for now, needs to be fine-tuned. + m_context << u256(50 + (_functionType.valueSet() ? 9000 : 0)) << eth::Instruction::GAS << eth::Instruction::SUB; m_context << eth::Instruction::CALL; auto tag = m_context.appendConditionalJump(); m_context << eth::Instruction::STOP << tag; // STOP if CALL leaves 0.