Skip to content

Commit cbb74bb

Browse files
committed
EEI: charge for memory gas cost in useGas
1 parent f4a85d9 commit cbb74bb

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/eei.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ string toHex(evmc_uint256be const& value) {
203203
HERA_DEBUG << "useGas " << gas << "\n";
204204

205205
takeGas(gas);
206+
// FIXME: this may overflow
207+
takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage);
206208

207209
return Literal();
208210
}

src/eei.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ struct EthereumInterface : ShellExternalInterface {
9999
evmc_message const& msg;
100100
std::vector<uint8_t> lastReturnData;
101101
ExecutionResult & result;
102+
102103
};
103104

104105
struct GasSchedule {
106+
static constexpr unsigned memoryPageSize = 65536;
107+
static constexpr unsigned memoryCostPerPage = 1;
108+
105109
static constexpr unsigned storageLoad = 200;
106110
static constexpr unsigned storageStoreCreate = 20000;
107111
static constexpr unsigned storageStoreChange = 5000;

0 commit comments

Comments
 (0)