From 9c939fab6328d50942fb6cefa15db73e2795e46c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 11 Jan 2018 17:41:36 +0000 Subject: [PATCH] EEI: charge for memory gas cost in useGas --- src/eei.cpp | 2 ++ src/eei.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/eei.cpp b/src/eei.cpp index 8b7eb730c..1e4346fa3 100644 --- a/src/eei.cpp +++ b/src/eei.cpp @@ -198,6 +198,8 @@ string toHex(evmc_uint256be const& value) { HERA_DEBUG << "useGas " << gas << "\n"; takeGas(gas); + // FIXME: this may overflow + takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage); return Literal(); } diff --git a/src/eei.h b/src/eei.h index 5982eb977..f3cfff99c 100644 --- a/src/eei.h +++ b/src/eei.h @@ -99,9 +99,13 @@ struct EthereumInterface : ShellExternalInterface { evmc_message const& msg; std::vector lastReturnData; ExecutionResult & result; + }; struct GasSchedule { + static constexpr unsigned memoryPageSize = 65536; + static constexpr unsigned memoryCostPerPage = 1; + static constexpr unsigned storageLoad = 200; static constexpr unsigned storageStoreCreate = 20000; static constexpr unsigned storageStoreChange = 5000;