Skip to content

Commit d0bac96

Browse files
committed
EEI: charge for memory gas cost in useGas
1 parent 7c21c5b commit d0bac96

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: src/eei.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Literal EthereumInterface::callImport(Import *import, LiteralList& arguments) {
4141
cout << gas << "\n";
4242

4343
takeGas(gas);
44+
// FIXME: this may overflow
45+
takeGas(gas * memory.size() / memory_page_size * memory_cost);
4446

4547
return Literal();
4648
}

Diff for: src/eei.h

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ struct EthereumInterface : ShellExternalInterface {
9898
std::vector<uint8_t> const& code;
9999
struct evm_message const& msg;
100100
ExecutionResult result;
101+
102+
static constexpr unsigned memory_page_size = 65536;
103+
static constexpr unsigned memory_cost = 1;
101104
};
102105

103106
}

0 commit comments

Comments
 (0)