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

Commit

Permalink
Don't recreate PrecompilesVM on each call
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Dec 23, 2019
1 parent 97200a7 commit 8da9bc0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions libethereum/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ std::string dumpStorage(ExtVM const& _ext)
o << showbase << hex << i.second.first << ": " << i.second.second << "\n";
return o.str();
};

EVMC& precompilesVM()
{
static EVMC precompilesVM{evmc_create_aleth_precompiles_vm(), {}};
return precompilesVM;
}

} // namespace

Executive::Executive(Block& _s, BlockChain const& _bc, unsigned _level)
Expand Down Expand Up @@ -185,15 +192,13 @@ bool Executive::call(CallParameters const& _p, u256 const& _gasPrice, Address co
if (_p.receiveAddress == c_RipemdPrecompiledAddress)
m_s.unrevertableTouch(_p.codeAddress);

auto precompilesVM = make_unique<EVMC>(evmc_create_aleth_precompiles_vm());

try
{
auto gas = _p.gas;
auto const& schedule = m_sealEngine.evmSchedule(m_envInfo.number());
bool const isCreate = false;
m_output = precompilesVM->exec(gas, _p.codeAddress, _p.senderAddress,
_p.apparentValue, _p.data, m_depth, isCreate, _p.staticCall, schedule);
m_output = precompilesVM().exec(gas, _p.codeAddress, _p.senderAddress, _p.apparentValue,
_p.data, m_depth, isCreate, _p.staticCall, schedule);
m_gas = gas;
}
catch (OutOfGas const&)
Expand Down

0 comments on commit 8da9bc0

Please sign in to comment.