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 Jan 18, 2018
1 parent f305443 commit 5c3b5d7
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -146,6 +146,8 @@ namespace HeraVM {
HERA_DEBUG << "useGas " << gas << "\n";

takeGas(gas);
// FIXME: this may overflow
takeGas(gas * memory.size() / memory_page_size * memory_cost);

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

static constexpr unsigned memory_page_size = 65536;
static constexpr unsigned memory_cost = 1;
};

struct GasSchedule {
Expand Down

0 comments on commit 5c3b5d7

Please sign in to comment.