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

Commit e325253

Browse files
committed
Don't recreate PrecompilesVM on each call
1 parent b088c10 commit e325253

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

libethereum/Executive.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ std::string dumpStorage(ExtVM const& _ext)
4444
o << showbase << hex << i.second.first << ": " << i.second.second << "\n";
4545
return o.str();
4646
};
47+
48+
EVMC& precompilesVM()
49+
{
50+
static EVMC precompilesVM{evmc_create_aleth_precompiles_vm()};
51+
return precompilesVM;
52+
}
53+
4754
} // namespace
4855

4956
Executive::Executive(Block& _s, BlockChain const& _bc, unsigned _level)
@@ -184,15 +191,13 @@ bool Executive::call(CallParameters const& _p, u256 const& _gasPrice, Address co
184191
if (_p.receiveAddress == c_RipemdPrecompiledAddress)
185192
m_s.unrevertableTouch(_p.codeAddress);
186193

187-
auto precompilesVM = make_unique<EVMC>(evmc_create_aleth_precompiles_vm());
188-
189194
try
190195
{
191196
auto gas = _p.gas;
192197
auto const& schedule = m_sealEngine.evmSchedule(m_envInfo.number());
193198
bool const isCreate = false;
194-
m_output = precompilesVM->exec(gas, _p.codeAddress, _p.senderAddress,
195-
_p.apparentValue, _p.data, m_depth, isCreate, _p.staticCall, schedule);
199+
m_output = precompilesVM().exec(gas, _p.codeAddress, _p.senderAddress, _p.apparentValue,
200+
_p.data, m_depth, isCreate, _p.staticCall, schedule);
196201
m_gas = gas;
197202
}
198203
catch (OutOfGas const&)

0 commit comments

Comments
 (0)