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

Commit

Permalink
Merge pull request #5753 from ethereum/eip1380-callself-interpreter
Browse files Browse the repository at this point in the history
Implement EIP1380 (call-to-self) in aleth-interpreter
  • Loading branch information
halfalicious authored Oct 4, 2019
2 parents 06dad45 + be4d2b7 commit 515bbc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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

0 comments on commit 515bbc7

Please sign in to comment.