Skip to content

Commit

Permalink
Merge pull request #1010 from qtumproject/time/evmone0.10
Browse files Browse the repository at this point in the history
Update EVM to Evmone 0.10
  • Loading branch information
qtum-neil authored Aug 22, 2023
2 parents 83fcd84 + 6a06d73 commit 0d7f3ca
Show file tree
Hide file tree
Showing 35 changed files with 1,768 additions and 1,357 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2022)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_HOLDERS,[The %s Developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Qtum Core]])
AC_INIT([Qtum Core],m4_join([.], _CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MINOR, _CLIENT_VERSION_BUILD)m4_if(_CLIENT_VERSION_RC, [0], [], [rc]_CLIENT_VERSION_RC),[https://github.com/qtumproject/qtum/issues],[qtum],[https://qtum.org/])
Expand Down
23 changes: 15 additions & 8 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -706,24 +706,32 @@ libbitcoin_common_a_SOURCES = \
evmone/evmc/lib/instructions/instruction_names.c \
evmone/evmc/include/evmc/evmc.h \
evmone/evmc/include/evmc/evmc.hpp \
evmone/evmc/include/evmc/filter_iterator.hpp \
evmone/evmc/include/evmc/helpers.h \
evmone/evmc/include/evmc/hex.hpp \
evmone/evmc/include/evmc/instructions.h \
evmone/evmc/include/evmc/loader.h \
evmone/evmc/include/evmc/mocked_host.hpp \
evmone/evmc/include/evmc/tooling.hpp \
evmone/evmc/include/evmc/utils.h \
evmone/lib/evmone/analysis.cpp \
evmone/lib/evmone/analysis.hpp \
evmone/lib/evmone/advanced_analysis.cpp \
evmone/lib/evmone/advanced_analysis.hpp \
evmone/lib/evmone/advanced_execution.cpp \
evmone/lib/evmone/advanced_execution.hpp \
evmone/lib/evmone/advanced_instructions.cpp \
evmone/lib/evmone/baseline.cpp \
evmone/lib/evmone/baseline.hpp \
evmone/lib/evmone/baseline_instruction_table.cpp \
evmone/lib/evmone/baseline_instruction_table.hpp \
evmone/lib/evmone/execution.cpp \
evmone/lib/evmone/execution.hpp \
evmone/lib/evmone/eof.cpp \
evmone/lib/evmone/eof.hpp \
evmone/lib/evmone/execution_state.hpp \
evmone/lib/evmone/instructions_calls.cpp \
evmone/lib/evmone/instructions.cpp \
evmone/lib/evmone/instructions.hpp \
evmone/lib/evmone/instruction_traits.hpp \
evmone/lib/evmone/limits.hpp \
evmone/lib/evmone/instructions_opcodes.hpp \
evmone/lib/evmone/instructions_storage.cpp \
evmone/lib/evmone/instructions_traits.hpp \
evmone/lib/evmone/instructions_xmacro.hpp \
evmone/lib/evmone/opcodes_helpers.h \
evmone/lib/evmone/tracing.cpp \
evmone/lib/evmone/tracing.hpp \
Expand Down Expand Up @@ -850,7 +858,6 @@ libbitcoin_common_a_SOURCES = \
eth_client/utils/ethash/lib/ethash/primes.h \
eth_client/utils/ethash/lib/ethash/progpow.cpp \
eth_client/utils/ethash/lib/ethash/support/attributes.h \
eth_client/utils/intx/int128.hpp \
eth_client/utils/intx/intx.hpp \
eth_client/utils/json_spirit/JsonSpiritHeaders.h \
eth_client/utils/json_spirit/json_spirit.h \
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ BITCOIN_TESTS =\
test/qtumtests/delegations_tests.cpp \
test/qtumtests/istanbulfork_tests.cpp \
test/qtumtests/londonfork_tests.cpp \
test/qtumtests/evmone_tests.cpp
test/qtumtests/evmone_tests.cpp \
test/qtumtests/shanghaifork_tests.cpp


if ENABLE_WALLET
Expand Down
15 changes: 15 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class CMainParams : public CChainParams {
consensus.nReduceBlocktimeHeight = 845000;
consensus.nMuirGlacierHeight = 845000;
consensus.nLondonHeight = 2080512;
consensus.nShanghaiHeight = 0x7fffffff;
consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.posLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.QIP9PosLimit = uint256S("0000000000001fffffffffffffffffffffffffffffffffffffffffffffffffff"); // The new POS-limit activated after QIP9
Expand Down Expand Up @@ -248,6 +249,7 @@ class CTestNetParams : public CChainParams {
consensus.nReduceBlocktimeHeight = 806600;
consensus.nMuirGlacierHeight = 806600;
consensus.nLondonHeight = 1967616;
consensus.nShanghaiHeight = 0x7fffffff;
consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.posLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.QIP9PosLimit = uint256S("0000000000001fffffffffffffffffffffffffffffffffffffffffffffffffff"); // The new POS-limit activated after QIP9
Expand Down Expand Up @@ -428,6 +430,7 @@ class SigNetParams : public CChainParams {
consensus.nReduceBlocktimeHeight = 0;
consensus.nMuirGlacierHeight = 0;
consensus.nLondonHeight = 0;
consensus.nShanghaiHeight = 0;
consensus.powLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.posLimit = uint256S("0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.QIP9PosLimit = uint256S("0000000000001fffffffffffffffffffffffffffffffffffffffffffffffffff"); // The new POS-limit activated after QIP9
Expand Down Expand Up @@ -531,6 +534,7 @@ class CRegTestParams : public CChainParams {
consensus.nReduceBlocktimeHeight = 0;
consensus.nMuirGlacierHeight = 0;
consensus.nLondonHeight = 0;
consensus.nShanghaiHeight = 0;
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.posLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.QIP9PosLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // The new POS-limit activated after QIP9
Expand Down Expand Up @@ -793,6 +797,7 @@ std::string CChainParams::EVMGenesisInfo() const
evmConsensus.QIP7Height = consensus.QIP7Height;
evmConsensus.nMuirGlacierHeight = consensus.nMuirGlacierHeight;
evmConsensus.nLondonHeight = consensus.nLondonHeight;
evmConsensus.nShanghaiHeight = consensus.nShanghaiHeight;
return dev::eth::genesisInfoQtum(GetEVMNetwork(), evmConsensus);
}

Expand Down Expand Up @@ -975,3 +980,13 @@ void UpdateTaprootHeight(int nHeight)
{
const_cast<CChainParams*>(globalChainParams.get())->UpdateTaprootHeight(nHeight);
}

void CChainParams::UpdateShanghaiHeight(int nHeight)
{
consensus.nShanghaiHeight = nHeight;
}

void UpdateShanghaiHeight(int nHeight)
{
const_cast<CChainParams*>(globalChainParams.get())->UpdateShanghaiHeight(nHeight);
}
6 changes: 6 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class CChainParams
bool HasHardwareWalletSupport() const { return fHasHardwareWalletSupport; }
void UpdateLondonHeight(int nHeight);
void UpdateTaprootHeight(int nHeight);
void UpdateShanghaiHeight(int nHeight);

//! Get allowed assumeutxo configuration.
//! @see ChainstateManager
Expand Down Expand Up @@ -260,4 +261,9 @@ void UpdateLondonHeight(int nHeight);
*/
void UpdateTaprootHeight(int nHeight);

/**
* Allows modifying the shanghai block height regtest parameter.
*/
void UpdateShanghaiHeight(int nHeight);

#endif // BITCOIN_CHAINPARAMS_H
2 changes: 2 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ struct Params {
int nMuirGlacierHeight;
/** Block height at which EVM London fork becomes active */
int nLondonHeight;
/** Block height at which EVM Shanghai fork becomes active */
int nShanghaiHeight;
/**
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.
Expand Down
1 change: 1 addition & 0 deletions src/eth_client/libethashseal/GenesisInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ std::string dev::eth::genesisInfoQtum(Network _n, EVMConsensus _consensus)
ReplaceInt(_consensus.QIP7Height, "QIP7_STARTING_BLOCK", _genesisInfo);
ReplaceInt(_consensus.nMuirGlacierHeight, "MUIR_STARTING_BLOCK", _genesisInfo);
ReplaceInt(_consensus.nLondonHeight, "LONDON_STARTING_BLOCK", _genesisInfo);
ReplaceInt(_consensus.nShanghaiHeight, "SHANGHAI_STARTING_BLOCK", _genesisInfo);
return _genesisInfo;
}
4 changes: 3 additions & 1 deletion src/eth_client/libethashseal/GenesisInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ struct EVMConsensus
QIP6Height(nHeight),
QIP7Height(nHeight),
nMuirGlacierHeight(nHeight),
nLondonHeight(nHeight)
nLondonHeight(nHeight),
nShanghaiHeight(nHeight)
{}

int QIP6Height = 0x7fffffff;
int QIP7Height = 0x7fffffff;
int nMuirGlacierHeight = 0x7fffffff;
int nLondonHeight = 0x7fffffff;
int nShanghaiHeight = 0x7fffffff;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/eth_client/libethashseal/genesis/qtumNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ R"E(
"qip6ForkBlock": "QIP6_STARTING_BLOCK",
"berlinForkBlock": "LONDON_STARTING_BLOCK",
"londonForkBlock": "LONDON_STARTING_BLOCK",
"shanghaiForkBlock": "SHANGHAI_STARTING_BLOCK",
"networkID" : "0x51",
"chainID": "0x51",
"maximumExtraDataSize": "0x20",
Expand Down
2 changes: 2 additions & 0 deletions src/eth_client/libethcore/ChainOperationParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ EVMSchedule const& ChainOperationParams::forkScheduleForBlockNumber(u256 const&
{
if (_blockNumber >= experimentalForkBlock)
return ExperimentalSchedule;
else if (_blockNumber >= shanghaiForkBlock)
return ShanghaiSchedule;
else if (_blockNumber >= londonForkBlock)
return LondonSchedule;
else if (_blockNumber >= berlinForkBlock)
Expand Down
1 change: 1 addition & 0 deletions src/eth_client/libethcore/ChainOperationParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct ChainOperationParams
u256 londonForkBlock = c_infiniteBlockNumber;
u256 lastForkBlock = c_infiniteBlockNumber;
u256 qip6ForkBlock = c_infiniteBlockNumber;
u256 shanghaiForkBlock = c_infiniteBlockNumber;
AdditionalEIPs lastForkAdditionalEIPs;
int chainID = 0; // Distinguishes different chains (mainnet, Ropsten, etc).
int networkID = 0; // Distinguishes different sub protocols.
Expand Down
13 changes: 11 additions & 2 deletions src/eth_client/libethcore/EVMSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct EVMSchedule
bool eip2200Mode = false;
bool eip2929Mode = false;
bool eip1559Mode = false;
bool eip6049Mode = false;
bool haveBitwiseShifting = false;
bool haveRevert = false;
bool haveReturnData = false;
Expand Down Expand Up @@ -197,8 +198,16 @@ static const EVMSchedule LondonSchedule = [] {
return schedule;
}();

static const EVMSchedule ExperimentalSchedule = [] {
static const EVMSchedule ShanghaiSchedule = [] {
EVMSchedule schedule = LondonSchedule;
// Shanghai revision
schedule.eip6049Mode = true;

return schedule;
}();

static const EVMSchedule ExperimentalSchedule = [] {
EVMSchedule schedule = ShanghaiSchedule;
schedule.accountVersion = 1;
schedule.blockhashGas = 800;
return schedule;
Expand All @@ -207,7 +216,7 @@ static const EVMSchedule ExperimentalSchedule = [] {
inline EVMSchedule const& latestScheduleForAccountVersion(u256 const& _version)
{
if (_version == 0)
return LondonSchedule;
return ShanghaiSchedule;
else if (_version == ExperimentalSchedule.accountVersion)
return ExperimentalSchedule;
else
Expand Down
1 change: 1 addition & 0 deletions src/eth_client/libethereum/ChainParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ void ChainParams::loadConfig(
setOptionalU256Parameter(londonForkBlock, c_londonForkBlock);
setOptionalU256Parameter(experimentalForkBlock, c_experimentalForkBlock);
setOptionalU256Parameter(qip6ForkBlock, c_qip6ForkBlock);
setOptionalU256Parameter(shanghaiForkBlock, c_shanghaiForkBlock);

lastForkBlock = findMaxForkBlockNumber(params);
lastForkWithAdditionalEIPsSchedule = forkScheduleForBlockNumber(lastForkBlock);
Expand Down
2 changes: 1 addition & 1 deletion src/eth_client/libethereum/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ bool Executive::finalize()
// Selfdestructs...
if (m_ext)
for (auto a: m_ext->sub.selfdestructs)
m_s.kill(a);
m_s.kill(a.first);

// Logs...
if (m_ext)
Expand Down
4 changes: 2 additions & 2 deletions src/eth_client/libethereum/ExtVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ CreateResult ExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _code, I
return {transactionExceptionToEvmcStatusCode(e.getException()), e.takeOutput(), e.newAddress()};
}

void ExtVM::selfdestruct(Address _a)
bool ExtVM::selfdestruct(Address _a)
{
// Why transfer is not used here? That caused a consensus issue before (see Quirk #2 in
// http://martin.swende.se/blog/Ethereum_quirks_and_vulns.html). There is one test case
Expand All @@ -165,7 +165,7 @@ void ExtVM::selfdestruct(Address _a)
m_sealEngine.deleteAddresses.insert(_a);
}
m_s.transferBalance(myAddress, _a, m_s.balance(myAddress));
ExtVMFace::selfdestruct(_a);
return ExtVMFace::selfdestruct(_a);
}

h256 ExtVM::blockHash(u256 _number)
Expand Down
2 changes: 1 addition & 1 deletion src/eth_client/libethereum/ExtVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ExtVM : public ExtVMFace
}

/// Selfdestruct the associated contract to the given address.
void selfdestruct(Address _a) final;
bool selfdestruct(Address _a) final;

/// Return the EVM gas-price schedule for this execution context.
EVMSchedule const& evmSchedule() const final { return m_evmSchedule; }
Expand Down
1 change: 1 addition & 0 deletions src/eth_client/libethereum/ValidationSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ string const c_chainID = "chainID";
string const c_networkID = "networkID";
string const c_allowFutureBlocks = "allowFutureBlocks";
string const c_qip6ForkBlock = "qip6ForkBlock";
string const c_shanghaiForkBlock = "shanghaiForkBlock";

void validateConfigJson(js::mObject const& _obj)
{
Expand Down
1 change: 1 addition & 0 deletions src/eth_client/libethereum/ValidationSchemes.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ extern std::string const c_chainID;
extern std::string const c_networkID;
extern std::string const c_allowFutureBlocks;
extern std::string const c_qip6ForkBlock;
extern std::string const c_shanghaiForkBlock;

// Validate config.json that contains chain params and genesis state
void validateConfigJson(json_spirit::mObject const& _obj);
Expand Down
4 changes: 3 additions & 1 deletion src/eth_client/libevm/EVMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace
{
evmc_revision toRevision(EVMSchedule const& _schedule) noexcept
{
if (_schedule.eip6049Mode)
return EVMC_SHANGHAI;
if (_schedule.eip1559Mode)
return EVMC_LONDON;
if (_schedule.eip2929Mode)
Expand Down Expand Up @@ -84,7 +86,7 @@ owning_bytes_ref EVMC::exec(u256& io_gas, ExtVMFace& _ext, const OnOpFunc& _onOp
assert(flags != EVMC_STATIC || kind == EVMC_CALL); // STATIC implies a CALL.
evmc_message msg = {kind, flags, static_cast<int32_t>(_ext.depth), gas, toEvmC(_ext.myAddress),
toEvmC(_ext.caller), _ext.data.data(), _ext.data.size(), toEvmC(_ext.value),
toEvmC(0x0_cppui256)};
toEvmC(0x0_cppui256), toEvmC(_ext.myAddress)};
EvmCHost host{_ext};
auto r = execute(host, mode, msg, _ext.code.data(), _ext.code.size());
// FIXME: Copy the output for now, but copyless version possible.
Expand Down
Loading

0 comments on commit 0d7f3ca

Please sign in to comment.