Skip to content

Commit c4ba6a1

Browse files
committed
EEI: charge for memory gas cost in useGas
1 parent d383a9a commit c4ba6a1

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
@@ -188,6 +188,8 @@ string toHex(evm_uint256be const& value) {
188188
HERA_DEBUG << "useGas " << gas << "\n";
189189

190190
takeGas(gas);
191+
// FIXME: this may overflow
192+
takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage);
191193

192194
return Literal();
193195
}

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)