GasMeter can now account for gas of Keccak-256

This commit is contained in:
hrkrshnn 2021-04-12 12:24:42 +02:00
parent 1f5b874eaf
commit dd6300a53e
2 changed files with 5 additions and 0 deletions

View File

@ -117,6 +117,9 @@ void GasMeterVisitor::instructionCostsInternal(evmasm::Instruction _instruction)
{
if (_instruction == evmasm::Instruction::EXP)
m_runGas += evmasm::GasCosts::expGas + evmasm::GasCosts::expByteGas(m_dialect.evmVersion());
else if (_instruction == evmasm::Instruction::KECCAK256)
// Assumes that Keccak-256 is computed on a single word (rounded up).
m_runGas += evmasm::GasCosts::keccak256Gas + evmasm::GasCosts::keccak256WordGas;
else
m_runGas += evmasm::GasMeter::runGas(_instruction);
m_dataGas += singleByteDataGas();

View File

@ -36,6 +36,8 @@ struct EVMDialect;
*
* Assumes that EXP is not used with exponents larger than a single byte.
* Is not particularly exact for anything apart from arithmetic.
*
* Assumes that Keccak-256 is computed on a single word (rounded up).
*/
class GasMeter
{