Skip to content

Commit 558ca3b

Browse files
committed
EEI: charge for memory gas cost in useGas
1 parent 30d0354 commit 558ca3b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/eei.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ namespace hera {
132132
ensureCondition(gas >= 0, ArgumentOutOfRange, "Negative gas supplied.");
133133

134134
takeGas(gas);
135+
// FIXME: this may overflow
136+
takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage);
135137
}
136138

137139
int64_t EthereumInterface::eeiGetGasLeft()

src/eei.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ class EthereumInterface {
163163
};
164164

165165
struct GasSchedule {
166+
static constexpr unsigned memoryPageSize = 65536;
167+
static constexpr unsigned memoryCostPerPage = 1;
168+
166169
static constexpr unsigned storageLoad = 200;
167170
static constexpr unsigned storageStoreCreate = 20000;
168171
static constexpr unsigned storageStoreChange = 5000;

0 commit comments

Comments
 (0)