Skip to content

Commit b9d8b07

Browse files
committed
EEI: charge for memory gas cost in useGas
1 parent ddc43df commit b9d8b07

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/eei.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ namespace HeraVM {
146146
HERA_DEBUG << "useGas " << gas << "\n";
147147

148148
takeGas(gas);
149+
// FIXME: this may overflow
150+
takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage);
149151

150152
return Literal();
151153
}

src/eei.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ struct EthereumInterface : ShellExternalInterface {
113113
evm_message const& msg;
114114
std::vector<uint8_t> lastReturnData;
115115
ExecutionResult & result;
116+
116117
};
117118

118119
struct GasSchedule {
120+
static constexpr unsigned memoryPageSize = 65536;
121+
static constexpr unsigned memoryCostPerPage = 1;
122+
119123
static constexpr unsigned storageLoad = 200;
120124
static constexpr unsigned storageStoreCreate = 20000;
121125
static constexpr unsigned storageStoreChange = 5000;

0 commit comments

Comments
 (0)