Skip to content

Commit 9c939fa

Browse files
axicjakelang
authored andcommitted
EEI: charge for memory gas cost in useGas
1 parent a6c07f9 commit 9c939fa

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Diff for: src/eei.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ string toHex(evmc_uint256be const& value) {
198198
HERA_DEBUG << "useGas " << gas << "\n";
199199

200200
takeGas(gas);
201+
// FIXME: this may overflow
202+
takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage);
201203

202204
return Literal();
203205
}

Diff for: src/eei.h

+4
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)