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

aleth-precompiles library #5855

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Don't recreate PrecompilesVM on each call
gumb0 committed Dec 23, 2019
commit ba28bf729afcf0558c555bf272f28f9eb6de2401
13 changes: 9 additions & 4 deletions libethereum/Executive.cpp
Original file line number Diff line number Diff line change
@@ -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)
@@ -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&)