From 4b59cee9778a3c6a0be7ccd6f9f011db554ff560 Mon Sep 17 00:00:00 2001 From: Time Markov Date: Fri, 21 Dec 2018 13:16:36 +0100 Subject: [PATCH 001/153] Set cpp-ethereum module branch to aleth --- .gitmodules | 1 + src/cpp-ethereum | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 7f1303ceb..8286ee5b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "src/cpp-ethereum"] path = src/cpp-ethereum url = https://github.com/qtumproject/cpp-eth-qtum.git + branch = time/aleth diff --git a/src/cpp-ethereum b/src/cpp-ethereum index d6081ecc9..a1c13afbb 160000 --- a/src/cpp-ethereum +++ b/src/cpp-ethereum @@ -1 +1 @@ -Subproject commit d6081ecc98e3c5f4701363672a3e6a8e875d74b2 +Subproject commit a1c13afbbf4c2e5114c31fad9c6604a8862153ae From 81cdd3ec5dfcd2a4f0248f8dfcc3baa0c0e5b93f Mon Sep 17 00:00:00 2001 From: Time Markov Date: Fri, 21 Dec 2018 13:23:02 +0100 Subject: [PATCH 002/153] Update build EVM environment --- src/validation.cpp | 53 ++++++++++++++++++++++++++++++++-------------- src/validation.h | 17 +++++++++++++++ 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index e74c8350a..f9bbd2700 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2232,6 +2232,32 @@ void writeVMlog(const std::vector& res, const CTransaction& tx, c fIsVMlogFile = true; } +LastHashes::LastHashes() +{} + +void LastHashes::set(const CBlockIndex *tip) +{ + clear(); + + m_lastHashes.resize(256); + for(int i=0;i<256;i++){ + if(!tip) + break; + m_lastHashes[i]= uintToh256(*tip->phashBlock); + tip = tip->pprev; + } +} + +dev::h256s LastHashes::precedingHashes(const dev::h256 &) const +{ + return m_lastHashes; +} + +void LastHashes::clear() +{ + m_lastHashes.clear(); +} + bool ByteCodeExec::performByteCode(dev::eth::Permanence type){ for(QtumTransaction& tx : txs){ //validate VM version @@ -2293,27 +2319,22 @@ bool ByteCodeExec::processingResults(ByteCodeExecResult& resultBCE){ } dev::eth::EnvInfo ByteCodeExec::BuildEVMEnvironment(){ - dev::eth::EnvInfo env; CBlockIndex* tip = chainActive.Tip(); - env.setNumber(dev::u256(tip->nHeight + 1)); - env.setTimestamp(dev::u256(block.nTime)); - env.setDifficulty(dev::u256(block.nBits)); + dev::eth::BlockHeader header; + header.setNumber(tip->nHeight + 1); + header.setTimestamp(block.nTime); + header.setDifficulty(dev::u256(block.nBits)); + header.setGasLimit(blockGasLimit); + + lastHashes.set(tip); - dev::eth::LastHashes lh; - lh.resize(256); - for(int i=0;i<256;i++){ - if(!tip) - break; - lh[i]= uintToh256(*tip->phashBlock); - tip = tip->pprev; - } - env.setLastHashes(std::move(lh)); - env.setGasLimit(blockGasLimit); if(block.IsProofOfStake()){ - env.setAuthor(EthAddrFromScript(block.vtx[1]->vout[1].scriptPubKey)); + header.setAuthor(EthAddrFromScript(block.vtx[1]->vout[1].scriptPubKey)); }else { - env.setAuthor(EthAddrFromScript(block.vtx[0]->vout[0].scriptPubKey)); + header.setAuthor(EthAddrFromScript(block.vtx[0]->vout[0].scriptPubKey)); } + dev::u256 gasUsed; + dev::eth::EnvInfo env(header, lastHashes, gasUsed); return env; } diff --git a/src/validation.h b/src/validation.h index 0417ca9a9..4fb0ac9aa 100644 --- a/src/validation.h +++ b/src/validation.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include