Skip to content

Commit

Permalink
EEI: charge for memory gas cost in useGas
Browse files Browse the repository at this point in the history
  • Loading branch information
axic authored and jakelang committed Apr 28, 2018
1 parent a6c07f9 commit 9c939fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/eei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ string toHex(evmc_uint256be const& value) {
HERA_DEBUG << "useGas " << gas << "\n";

takeGas(gas);
// FIXME: this may overflow
takeGas(gas * memory.size() / GasSchedule::memoryPageSize * GasSchedule::memoryCostPerPage);

return Literal();
}
Expand Down
4 changes: 4 additions & 0 deletions src/eei.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ struct EthereumInterface : ShellExternalInterface {
evmc_message const& msg;
std::vector<uint8_t> lastReturnData;
ExecutionResult & result;

};

struct GasSchedule {
static constexpr unsigned memoryPageSize = 65536;
static constexpr unsigned memoryCostPerPage = 1;

static constexpr unsigned storageLoad = 200;
static constexpr unsigned storageStoreCreate = 20000;
static constexpr unsigned storageStoreChange = 5000;
Expand Down

0 comments on commit 9c939fa

Please sign in to comment.