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 committed Mar 12, 2018
1 parent d383a9a commit c4ba6a1
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 @@ -188,6 +188,8 @@ string toHex(evm_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 @@ -113,9 +113,13 @@ struct EthereumInterface : ShellExternalInterface {
evm_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 c4ba6a1

Please sign in to comment.