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

Commit 8da9bc0

Browse files
committed
Don't recreate PrecompilesVM on each call
1 parent 97200a7 commit 8da9bc0

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)
@@ -185,15 +192,13 @@ bool Executive::call(CallParameters const& _p, u256 const& _gasPrice, Address co
185192
if (_p.receiveAddress == c_RipemdPrecompiledAddress)
186193
m_s.unrevertableTouch(_p.codeAddress);
187194

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

0 commit comments

Comments
 (0)