diff --git a/libethereum/Executive.cpp b/libethereum/Executive.cpp index dc2e62824..8fe348e00 100644 --- a/libethereum/Executive.cpp +++ b/libethereum/Executive.cpp @@ -72,7 +72,7 @@ bool Executive::setup(bytesConstRef _rlp) BOOST_THROW_EXCEPTION(OutOfGas() << RequirementError((bigint)gasCost, (bigint)m_t.gas())); } - u256 cost = m_t.value() + m_t.gas() * m_t.gasPrice(); + bigint cost = m_t.value() + (bigint)m_t.gas() * m_t.gasPrice(); // Avoid unaffordable transactions. if (m_s.balance(m_t.sender()) < cost) @@ -82,7 +82,7 @@ bool Executive::setup(bytesConstRef _rlp) } u256 startGasUsed = m_s.gasUsed(); - if (startGasUsed + m_t.gas() > m_s.m_currentBlock.gasLimit) + if (startGasUsed + (bigint)m_t.gas() > m_s.m_currentBlock.gasLimit) { clog(StateDetail) << "Too much gas used in this block: Require <" << (m_s.m_currentBlock.gasLimit - startGasUsed) << " Got" << m_t.gas(); BOOST_THROW_EXCEPTION(BlockGasLimitReached() << RequirementError((bigint)(m_s.m_currentBlock.gasLimit - startGasUsed), (bigint)m_t.gas())); @@ -92,7 +92,7 @@ bool Executive::setup(bytesConstRef _rlp) m_s.noteSending(m_t.sender()); // Pay... - clog(StateDetail) << "Paying" << formatBalance(cost) << "from sender (includes" << m_t.gas() << "gas at" << formatBalance(m_t.gasPrice()) << ")"; + clog(StateDetail) << "Paying" << formatBalance(u256(cost)) << "from sender (includes" << m_t.gas() << "gas at" << formatBalance(m_t.gasPrice()) << ")"; m_s.subBalance(m_t.sender(), cost); if (m_t.isCreation()) diff --git a/test/stSpecialTestFiller.json b/test/stSpecialTestFiller.json index fcb1d74a6..9aaf94f92 100644 --- a/test/stSpecialTestFiller.json +++ b/test/stSpecialTestFiller.json @@ -37,5 +37,38 @@ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "" } + }, + + "OverflowGasMakeMoney" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "(2**256)-1", + "currentGasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "2**200", + "gasLimit" : "115792089237316195423570985008687907853269984665640564039457584007913129639435", + "gasPrice" : "1", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "501" + } } }