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 all 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## [1.8.0] - Unreleased

- Added: [#5699](https://github.com/ethereum/aleth/pull/5699) EIP 2046: Reduced gas cost for static calls made to precompiles.
- Added: [#5752](https://github.com/ethereum/aleth/pull/5752) Implement EIP1380 (reduced gas costs for call-to-self) in LegacyVM.
- Added: [#5752](https://github.com/ethereum/aleth/pull/5752) [#5753](https://github.com/ethereum/aleth/pull/5753) Implement EIP1380 (reduced gas costs for call-to-self).
- Removed: [#5760](https://github.com/ethereum/aleth/pull/5760) Official support for Visual Studio 2015 has been dropped. Compilation with this compiler is expected to stop working after migration to C++14.

## [1.7.0] - Unreleased
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
8 changes: 5 additions & 3 deletions libaleth-interpreter/VMCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ 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;

switch (m_OP)
{
Expand All @@ -214,8 +218,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