Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Implement EIP1380 (call-to-self) in aleth-interpreter #5753

Merged
merged 4 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- Added: [#5755](https://github.com/ethereum/aleth/pull/5755) testeth now runs `stChainId`, `stSLoadTest`, `stSelfBalance` tests for Istanbul.
- Added: [#5758](https://github.com/ethereum/aleth/pull/5758) Istanbul support: activation in Ropsten config.
- Added: [#5762](https://github.com/ethereum/aleth/pull/5762) aleth-vm supports `--network Istanbul` option.
- Added: [#5753](https://github.com/ethereum/aleth/pull/5753) Implement EIP1380 (lower gas costs for call-to-self) in aleth-interpreter.
- Changed: [#5532](https://github.com/ethereum/aleth/pull/5532) The leveldb is upgraded to 1.22. This is breaking change on Windows and the old databases are not compatible.
- Changed: [#5559](https://github.com/ethereum/aleth/pull/5559) Update peer validation error messages.
- Changed: [#5568](https://github.com/ethereum/aleth/pull/5568) Improve rlpx handshake log messages and create new rlpx log channel.
Expand Down
1 change: 1 addition & 0 deletions libaleth-interpreter/VM.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct VMSchedule
static constexpr int64_t valueTransferGas = 9000;
static constexpr int64_t callStipend = 2300;
static constexpr int64_t callNewAccount = 25000;
static constexpr int64_t callSelfGas = 40;
};

class VM
Expand Down
10 changes: 7 additions & 3 deletions libaleth-interpreter/VMCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ void VM::caseCall()

bool VM::caseCallSetup(evmc_message& o_msg, bytesRef& o_output)
{
m_runGas = m_rev >= EVMC_TANGERINE_WHISTLE ? 700 : 40;
auto const destination = intx::be::trunc<evmc::address>(m_SP[1]);

// Check for call-to-self (eip1380) and adjust gas accordingly
if (m_rev >= EVMC_BERLIN && m_message->destination == destination)
m_runGas = VMSchedule::callSelfGas;
else
m_runGas = evmc_get_instruction_metrics_table(m_rev)[static_cast<size_t>(m_OP)].gas_cost;

switch (m_OP)
{
Expand All @@ -214,8 +220,6 @@ bool VM::caseCallSetup(evmc_message& o_msg, bytesRef& o_output)

bool const haveValueArg = m_OP == Instruction::CALL || m_OP == Instruction::CALLCODE;

auto const destination = intx::be::trunc<evmc::address>(m_SP[1]);

if (m_OP == Instruction::CALL && (m_SP[2] > 0 || m_rev < EVMC_SPURIOUS_DRAGON) &&
!m_context->host->account_exists(m_context, &destination))
{
Expand Down