Browse Source

Merge pull request #2498 from arkpar/whizz

Whizz branch fixes for Mix, AZ, eth
cl-refactor
Gav Wood 10 years ago
parent
commit
4eab395bc2
  1. 28
      CMakeLists.txt
  2. 55
      alethzero/MainWin.cpp
  3. 4
      alethzero/MiningView.cpp
  4. 4
      alethzero/MiningView.h
  5. 2
      eth/main.cpp
  6. 26
      ethminer/MinerAux.h
  7. 12
      evmjit/libevmjit-cpp/JitVM.cpp
  8. 4
      exp/CMakeLists.txt
  9. 1
      libethcore/BlockInfo.h
  10. 3
      libethcore/Common.h
  11. 3
      libethereum/BlockChain.cpp
  12. 7
      libethereum/BlockChain.h
  13. 2
      libethereum/BlockQueue.cpp
  14. 3
      libethereum/Client.cpp
  15. 6
      libethereum/Client.h
  16. 3
      libtestutils/BlockChainLoader.cpp
  17. 2
      libtestutils/StateLoader.cpp
  18. 2
      libtestutils/StateLoader.h
  19. 8
      libweb3jsonrpc/JsonHelper.cpp
  20. 2
      libweb3jsonrpc/WebThreeStubServer.cpp
  21. 4
      libweb3jsonrpc/WebThreeStubServer.h
  22. 2
      libwebthree/WebThree.cpp
  23. 4
      mix/ClientModel.cpp
  24. 36
      mix/MixClient.cpp
  25. 36
      mix/MixClient.h
  26. 19
      test/TestHelper.cpp
  27. 10
      test/libethcore/dagger.cpp
  28. 18
      test/libethereum/ClientBase.cpp
  29. 3
      test/libethereum/gaspricer.cpp
  30. 6
      test/libethereum/genesis.cpp
  31. 5
      test/libethereum/stateOriginal.cpp
  32. 10
      test/libevm/vm.cpp

28
CMakeLists.txt

@ -400,13 +400,13 @@ if (TOOLS)
endif ()
if (JSONRPC AND GENERAL)
# add_subdirectory(libweb3jsonrpc)
add_subdirectory(libweb3jsonrpc)
endif ()
if (JSCONSOLE)
# add_subdirectory(libjsengine)
# add_subdirectory(libjsconsole)
# add_subdirectory(ethconsole)
add_subdirectory(libjsengine)
add_subdirectory(libjsconsole)
add_subdirectory(ethconsole)
endif ()
if (NOT WIN32)
@ -434,31 +434,31 @@ add_subdirectory(libethcore)
if (GENERAL)
add_subdirectory(libevm)
add_subdirectory(libethereum)
# add_subdirectory(libwebthree)
add_subdirectory(libwebthree)
endif ()
if (MINER OR TOOLS)
# add_subdirectory(ethminer)
add_subdirectory(ethminer)
endif ()
if (ETHKEY OR TOOLS)
# add_subdirectory(ethkey)
add_subdirectory(ethkey)
endif ()
if (TESTS)
# add_subdirectory(libtestutils)
# add_subdirectory(test)
add_subdirectory(libtestutils)
add_subdirectory(test)
if (JSONRPC)
# add_subdirectory(ethrpctest)
add_subdirectory(ethrpctest)
endif ()
endif ()
if (TOOLS)
# add_subdirectory(rlp)
# add_subdirectory(abi)
# add_subdirectory(ethvm)
# add_subdirectory(eth)
add_subdirectory(rlp)
add_subdirectory(abi)
add_subdirectory(ethvm)
add_subdirectory(eth)
if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug")
add_subdirectory(exp)

55
alethzero/MainWin.cpp

@ -189,9 +189,9 @@ Main::Main(QWidget *parent) :
#endif
m_servers.append(QString::fromStdString(Host::pocHost() + ":30303"));
cerr << "State root: " << CanonBlockChain::genesis().stateRoot() << endl;
auto block = CanonBlockChain::createGenesisBlock();
cerr << "Block Hash: " << CanonBlockChain::genesis().hash() << endl;
cerr << "State root: " << CanonBlockChain<Ethash>::genesis().stateRoot() << endl;
auto block = CanonBlockChain<Ethash>::createGenesisBlock();
cerr << "Block Hash: " << CanonBlockChain<Ethash>::genesis().hash() << endl;
cerr << "Block RLP: " << RLP(block) << endl;
cerr << "Block Hex: " << toHex(block) << endl;
cerr << "eth Network protocol version: " << eth::c_protocolVersion << endl;
@ -208,13 +208,14 @@ Main::Main(QWidget *parent) :
statusBar()->addPermanentWidget(ui->chainStatus);
statusBar()->addPermanentWidget(ui->blockCount);
ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ethereum()->sealEngine()->name())).arg(ethereum()->sealEngine()->revision()).arg(dev::Version));
QSettings s("ethereum", "alethzero");
m_networkConfig = s.value("peers").toByteArray();
bytesConstRef network((byte*)m_networkConfig.data(), m_networkConfig.size());
m_webThree.reset(new WebThreeDirect(string("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir(), WithExisting::Trust, {"eth"/*, "shh"*/}, p2p::NetworkPreferences(), network));
ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ethereum()->sealEngine()->name())).arg(ethereum()->sealEngine()->revision()).arg(dev::Version));
m_httpConnector.reset(new jsonrpc::HttpServer(SensibleHttpPort, "", "", dev::SensibleHttpThreads));
auto w3ss = new OurWebThreeStubServer(*m_httpConnector, this);
m_server.reset(w3ss);
@ -1124,7 +1125,7 @@ void Main::refreshMining()
QString t;
if (gp.first != EthashAux::NotGenerating)
t = QString("DAG for #%1-#%2: %3% complete; ").arg(gp.first).arg(gp.first + ETHASH_EPOCH_LENGTH - 1).arg(gp.second);
MiningProgress p = ethereum()->miningProgress();
WorkingProgress p = ethereum()->miningProgress();
ui->mineStatus->setText(t + (ethereum()->isMining() ? p.hashes > 0 ? QString("%1s @ %2kH/s").arg(p.ms / 1000).arg(p.ms ? p.hashes / p.ms : 0) : "Awaiting DAG" : "Not mining"));
if (ethereum()->isMining() && p.hashes > 0)
{
@ -1629,7 +1630,7 @@ void Main::on_transactionQueue_currentItemChanged()
else
s << "<div>Log Bloom: <b><i>Uneventful</i></b></div>";
s << "<div>Gas Used: <b>" << receipt.gasUsed() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot()().abridged() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot().abridged() << "</b></div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";
@ -1699,7 +1700,7 @@ void Main::on_blocks_currentItemChanged()
auto details = ethereum()->blockChain().details(h);
auto blockData = ethereum()->blockChain().block(h);
auto block = RLP(blockData);
BlockInfo info(blockData);
Ethash::BlockHeader info(blockData);
stringstream s;
@ -1709,21 +1710,21 @@ void Main::on_blocks_currentItemChanged()
time_t rawTime = (time_t)(uint64_t)info.timestamp();
strftime(timestamp, 64, "%c", localtime(&rawTime));
s << "<h3>" << h << "</h3>";
s << "<h4>#" << info.number;
s << "<h4>#" << info.number();
s << "&nbsp;&emsp;&nbsp;<b>" << timestamp << "</b></h4>";
s << "<div>D/TD: <b>" << info.difficulty << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty) << "</div>";
s << "<div>D/TD: <b>" << info.difficulty() << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty()) << "/2^" << log2((double)details.totalDifficulty) << "</div>";
s << "&nbsp;&emsp;&nbsp;Children: <b>" << details.children.size() << "</b></div>";
s << "<div>Gas used/limit: <b>" << info.gasUsed << "</b>/<b>" << info.gasLimit << "</b>" << "</div>";
s << "<div>Gas used/limit: <b>" << info.gasUsed() << "</b>/<b>" << info.gasLimit() << "</b>" << "</div>";
s << "<div>Beneficiary: <b>" << htmlEscaped(pretty(info.coinbaseAddress())) << " " << info.coinbaseAddress() << "</b>" << "</div>";
s << "<div>Seed hash: <b>" << info.seedHash() << "</b>" << "</div>";
s << "<div>Mix hash: <b>" << info.mixHash << "</b>" << "</div>";
s << "<div>Nonce: <b>" << info.nonce << "</b>" << "</div>";
s << "<div>Hash w/o nonce: <b>" << info.headerHash(WithoutProof) << "</b>" << "</div>";
s << "<div>Difficulty: <b>" << info.difficulty << "</b>" << "</div>";
if (info.number)
{
auto e = EthashAux::eval(info);
s << "<div>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << "<div>Mix hash: <b>" << info.mixHash() << "</b>" << "</div>";
s << "<div>Nonce: <b>" << info.nonce() << "</b>" << "</div>";
s << "<div>Hash w/o nonce: <b>" << info.hashWithout() << "</b>" << "</div>";
s << "<div>Difficulty: <b>" << info.difficulty() << "</b>" << "</div>";
if (info.number())
{
auto e = EthashAux::eval(info.seedHash(), info.hashWithout(), info.nonce());
s << "<div>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty()) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << "<div>Parent: <b>" << info.parentHash() << "</b>" << "</div>";
}
else
@ -1740,19 +1741,19 @@ void Main::on_blocks_currentItemChanged()
s << "<div>Uncles: <b>" << block[2].itemCount() << "</b> @<b>" << info.sha3Uncles() << "</b>" << "</div>";
for (auto u: block[2])
{
BlockInfo uncle = BlockInfo::fromHeader(u.data());
Ethash::BlockHeader uncle(u.data(), CheckNothing, h256(), HeaderData);
char const* line = "<div><span style=\"margin-left: 2em\">&nbsp;</span>";
s << line << "Hash: <b>" << uncle.hash() << "</b>" << "</div>";
s << line << "Parent: <b>" << uncle.parentHash() << "</b>" << "</div>";
s << line << "Number: <b>" << uncle.number << "</b>" << "</div>";
s << line << "Number: <b>" << uncle.number() << "</b>" << "</div>";
s << line << "Coinbase: <b>" << htmlEscaped(pretty(uncle.coinbaseAddress())) << " " << uncle.coinbaseAddress() << "</b>" << "</div>";
s << line << "Seed hash: <b>" << uncle.seedHash() << "</b>" << "</div>";
s << line << "Mix hash: <b>" << uncle.mixHash << "</b>" << "</div>";
s << line << "Nonce: <b>" << uncle.nonce << "</b>" << "</div>";
s << line << "Mix hash: <b>" << uncle.mixHash() << "</b>" << "</div>";
s << line << "Nonce: <b>" << uncle.nonce() << "</b>" << "</div>";
s << line << "Hash w/o nonce: <b>" << uncle.headerHash(WithoutProof) << "</b>" << "</div>";
s << line << "Difficulty: <b>" << uncle.difficulty << "</b>" << "</div>";
auto e = EthashAux::eval(uncle);
s << line << "Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
s << line << "Difficulty: <b>" << uncle.difficulty() << "</b>" << "</div>";
auto e = EthashAux::eval(uncle.seedHash(), uncle.hashWithout(), uncle.nonce());
s << line << "Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / uncle.difficulty()) << "</b> (mixhash: " << e.mixHash.abridged() << ")" << "</div>";
}
if (info.parentHash())
s << "<div>Pre: <b>" << BlockInfo(ethereum()->blockChain().block(info.parentHash())).stateRoot() << "</b>" << "</div>";
@ -1764,7 +1765,7 @@ void Main::on_blocks_currentItemChanged()
unsigned ii = 0;
for (auto const& i: block[1])
{
s << "<div>" << sha3(i.data()).abridged() << ": <b>" << receipts.receipts[ii].stateRoot()() << "</b> [<b>" << receipts.receipts[ii].gasUsed() << "</b> used]" << "</div>";
s << "<div>" << sha3(i.data()).abridged() << ": <b>" << receipts.receipts[ii].stateRoot() << "</b> [<b>" << receipts.receipts[ii].gasUsed() << "</b> used]" << "</div>";
++ii;
}
s << "<div>Post: <b>" << info.stateRoot() << "</b>" << "</div>";
@ -1807,7 +1808,7 @@ void Main::on_blocks_currentItemChanged()
else
s << "<div>Log Bloom: <b><i>Uneventful</i></b></div>";
s << "<div>Gas Used: <b>" << receipt.gasUsed() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot()().abridged() << "</b></div>";
s << "<div>End State: <b>" << receipt.stateRoot().abridged() << "</b></div>";
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";

4
alethzero/MiningView.cpp

@ -36,7 +36,7 @@ using namespace dev::eth;
// types
using dev::eth::MineInfo;
using dev::eth::MiningProgress;
using dev::eth::WorkingProgress;
// functions
using dev::toString;
@ -50,7 +50,7 @@ MiningView::MiningView(QWidget* _p): QWidget(_p)
{
}
void MiningView::appendStats(list<MineInfo> const& _i, MiningProgress const& _p)
void MiningView::appendStats(list<MineInfo> const& _i, WorkingProgress const& _p)
{
(void)_p;
if (_i.empty())

4
alethzero/MiningView.h

@ -42,14 +42,14 @@ class MiningView: public QWidget
public:
MiningView(QWidget* _p = nullptr);
void appendStats(std::list<dev::eth::MineInfo> const& _l, dev::eth::MiningProgress const& _p);
void appendStats(std::list<dev::eth::MineInfo> const& _l, dev::eth::WorkingProgress const& _p);
void resetStats();
protected:
virtual void paintEvent(QPaintEvent*);
private:
dev::eth::MiningProgress m_progress;
dev::eth::WorkingProgress m_progress;
unsigned m_duration = 300;
std::vector<float> m_values;
std::vector<float> m_bests;

2
eth/main.cpp

@ -1311,7 +1311,7 @@ int main(int argc, char** argv)
{
try
{
CanonBlockChain::setGenesisNonce(Nonce(argv[++i]));
CanonBlockChain<Ethash>::setGenesisNonce(Nonce(argv[++i]));
}
catch (...)
{

26
ethminer/MinerAux.h

@ -397,17 +397,16 @@ public:
private:
void doInitDAG(unsigned _n)
{
BlockInfo bi;
bi.number() = _n;
cout << "Initializing DAG for epoch beginning #" << (bi.number() / 30000 * 30000) << " (seedhash " << bi.proofCache().abridged() << "). This will take a while." << endl;
Ethash::prep(bi);
h256 seedHash = EthashAux::seedHash(_n);
cout << "Initializing DAG for epoch beginning #" << (_n / 30000 * 30000) << " (seedhash " << seedHash.abridged() << "). This will take a while." << endl;
EthashAux::full(seedHash, true);
exit(0);
}
void doBenchmark(MinerType _m, bool _phoneHome, unsigned _warmupDuration = 15, unsigned _trialDuration = 3, unsigned _trials = 5)
{
BlockInfo genesis;
genesis.difficulty = 1 << 18;
Ethash::BlockHeader genesis;
genesis.setDifficulty(1 << 18);
cdebug << genesis.boundary();
GenericFarm<EthashProofOfWork> f;
@ -417,17 +416,16 @@ private:
cout << "Benchmarking on platform: " << platformInfo << endl;
cout << "Preparing DAG..." << endl;
Ethash::prep(genesis);
genesis.prep();
genesis.difficulty = u256(1) << 63;
genesis.noteDirty();
genesis.setDifficulty(u256(1) << 63);
f.setWork(genesis);
if (_m == MinerType::CPU)
f.startCPU();
f.start("cpu");
else if (_m == MinerType::GPU)
f.startGPU();
f.start("opencl");
map<uint64_t, MiningProgress> results;
map<uint64_t, WorkingProgress> results;
uint64_t mean = 0;
uint64_t innerMean = 0;
for (unsigned i = 0; i <= _trials; ++i)
@ -488,9 +486,9 @@ private:
Farm rpc(client);
GenericFarm<EthashProofOfWork> f;
if (_m == MinerType::CPU)
f.startCPU();
f.start("cpu");
else if (_m == MinerType::GPU)
f.startGPU();
f.start("opencl");
EthashProofOfWork::WorkPackage current;
EthashAux::FullType dag;

12
evmjit/libevmjit-cpp/JitVM.cpp

@ -23,8 +23,8 @@ bytesConstRef JitVM::execImpl(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _on
// TODO: Rejecting transactions with gas limit > 2^63 can be used by attacker to take JIT out of scope
rejected |= io_gas > std::numeric_limits<decltype(m_data.gas)>::max(); // Do not accept requests with gas > 2^63 (int64 max)
rejected |= _ext.gasPrice > std::numeric_limits<decltype(m_data.gasPrice)>::max();
rejected |= _ext.currentBlock.number > std::numeric_limits<decltype(m_data.number)>::max();
rejected |= _ext.currentBlock.timestamp() > std::numeric_limits<decltype(m_data.timestamp())>::max();
rejected |= _ext.currentBlock.number() > std::numeric_limits<decltype(m_data.number)>::max();
rejected |= _ext.currentBlock.timestamp() > std::numeric_limits<decltype(m_data.timestamp)>::max();
if (rejected)
{
@ -42,10 +42,10 @@ bytesConstRef JitVM::execImpl(u256& io_gas, ExtVMFace& _ext, OnOpFunc const& _on
m_data.origin = eth2jit(fromAddress(_ext.origin));
m_data.callValue = eth2jit(_ext.value);
m_data.coinBase = eth2jit(fromAddress(_ext.currentBlock.coinbaseAddress()));
m_data.difficulty = eth2jit(_ext.currentBlock.difficulty);
m_data.gasLimit = eth2jit(_ext.currentBlock.gasLimit);
m_data.number = static_cast<decltype(m_data.number)>(_ext.currentBlock.number);
m_data.timestamp() = static_cast<decltype(m_data.timestamp())>(_ext.currentBlock.timestamp());
m_data.difficulty = eth2jit(_ext.currentBlock.difficulty());
m_data.gasLimit = eth2jit(_ext.currentBlock.gasLimit());
m_data.number = static_cast<decltype(m_data.number)>(_ext.currentBlock.number());
m_data.timestamp = static_cast<decltype(m_data.timestamp)>(_ext.currentBlock.timestamp());
m_data.code = _ext.code.data();
m_data.codeSize = _ext.code.size();
m_data.codeHash = eth2jit(_ext.codeHash);

4
exp/CMakeLists.txt

@ -21,10 +21,10 @@ if (READLINE_FOUND)
endif()
if (JSONRPC)
# target_link_libraries(${EXECUTABLE} web3jsonrpc)
target_link_libraries(${EXECUTABLE} web3jsonrpc)
endif()
#target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} webthree)
target_link_libraries(${EXECUTABLE} ethereum)
target_link_libraries(${EXECUTABLE} p2p)
if (ETHASHCL)

1
libethcore/BlockInfo.h

@ -128,6 +128,7 @@ public:
void setGasUsed(u256 const& _v) { m_gasUsed = _v; noteDirty(); }
void setExtraData(bytes const& _v) { m_extraData = _v; noteDirty(); }
void setLogBloom(LogBloom const& _v) { m_logBloom = _v; noteDirty(); }
void setDifficulty(u256 const& _v) { m_difficulty = _v; noteDirty(); }
Address const& coinbaseAddress() const { return m_coinbaseAddress; }
h256 const& stateRoot() const { return m_stateRoot; }

3
libethcore/Common.h

@ -130,9 +130,10 @@ struct ImportRequirements
TransactionBasic = 8, ///< Check the basic structure of the transactions.
UncleSeals = 16, ///< Check the basic structure of the uncles.
TransactionSignatures = 32, ///< Check the basic structure of the transactions.
Parent = 64, ///< Check parent block header
CheckUncles = UncleBasic | UncleSeals, ///< Check uncle seals
CheckTransactions = TransactionBasic | TransactionSignatures, ///< Check transaction signatures
Default = ValidSeal | DontHave | CheckUncles | CheckTransactions,
Everything = ValidSeal | DontHave | CheckUncles | CheckTransactions | Parent,
None = 0
};
};

3
libethereum/BlockChain.cpp

@ -137,7 +137,6 @@ BlockChain::BlockChain(bytes const& _genesisBlock, std::unordered_map<Address, A
// Initialise with the genesis as the last block on the longest chain.
m_genesisBlock = _genesisBlock;
m_genesisHash = sha3(RLP(m_genesisBlock)[0].data());
m_genesisState = _genesisState;
// remove the next line real soon. we don't need to be supporting this forever.
upgradeDatabase(_path, genesisHash());
@ -356,7 +355,7 @@ tuple<ImportRoute, bool, unsigned> BlockChain::sync(BlockQueue& _bq, OverlayDB c
// Nonce & uncle nonces already verified in verification thread at this point.
ImportRoute r;
DEV_TIMED_ABOVE("Block import " + toString(block.verified.info.number()), 500)
r = import(block.verified, _stateDB, ImportRequirements::Default & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles);
r = import(block.verified, _stateDB, ImportRequirements::Everything & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles);
fresh += r.liveBlocks;
dead += r.deadBlocks;
goodTransactions += r.goodTranactions;

7
libethereum/BlockChain.h

@ -118,12 +118,12 @@ public:
/// Attempt to import the given block directly into the CanonBlockChain and sync with the state DB.
/// @returns the block hashes of any blocks that came into/went out of the canonical block chain.
std::pair<ImportResult, ImportRoute> attemptImport(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Default) noexcept;
std::pair<ImportResult, ImportRoute> attemptImport(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Everything) noexcept;
/// Import block into disk-backed DB
/// @returns the block hashes of any blocks that came into/went out of the canonical block chain.
ImportRoute import(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Default);
ImportRoute import(VerifiedBlockRef const& _block, OverlayDB const& _db, ImportRequirements::value _ir = ImportRequirements::Default);
ImportRoute import(bytes const& _block, OverlayDB const& _stateDB, ImportRequirements::value _ir = ImportRequirements::Everything);
ImportRoute import(VerifiedBlockRef const& _block, OverlayDB const& _db, ImportRequirements::value _ir = ImportRequirements::Everything);
/// Returns true if the given block is known (though not necessarily a part of the canon chain).
bool isKnown(h256 const& _hash) const;
@ -391,6 +391,7 @@ public:
{
BlockHeader h(_block, (_ir & ImportRequirements::ValidSeal) ? Strictness::CheckEverything : Strictness::QuickNonce);
h.verifyInternals(_block);
if ((_ir & ImportRequirements::Parent) != 0)
h.verifyParent(header(h.parentHash()));
res.info = static_cast<BlockInfo&>(h);
}

2
libethereum/BlockQueue.cpp

@ -110,7 +110,7 @@ void BlockQueue::verifierBody()
swap(work.block, res.blockData);
try
{
res.verified = m_bc->verifyBlock(&res.blockData, m_onBad, CheckEverything);
res.verified = m_bc->verifyBlock(&res.blockData, m_onBad, ImportRequirements::Everything & ~ImportRequirements::Parent);
}
catch (...)
{

3
libethereum/Client.cpp

@ -84,10 +84,9 @@ void Client::init(p2p::Host* _extNet, std::string const& _dbPath, WithExisting _
// TODO: consider returning the upgrade mechanism here. will delaying the opening of the blockchain database
// until after the construction.
m_stateDB = State::openDB(_dbPath, bc().genesisHash(), _forceAction);
m_preMine = State(m_stateDB);
m_postMine = State(m_stateDB);
// LAZY. TODO: move genesis state construction/commiting to stateDB openning and have this just take the root from the genesis block.
m_preMine = bc().genesisState(m_stateDB);
m_postMine = m_preMine;
m_bq.setChain(bc());

6
libethereum/Client.h

@ -77,7 +77,7 @@ std::ostream& operator<<(std::ostream& _out, ActivityReport const& _r);
* @brief Main API hub for interfacing with Ethereum.
* Not to be used directly - subclass.
*/
class Client: public ClientBase, Worker
class Client: public ClientBase, protected Worker
{
public:
/// New-style Constructor.
@ -342,6 +342,8 @@ public:
init(_host, _dbPath, _forceAction, _networkId);
}
virtual ~SpecialisedClient() { stopWorking(); }
/// Get the object representing the current canonical blockchain.
CanonBlockChain<Sealer> const& blockChain() const { return m_bc; }
@ -365,6 +367,8 @@ public:
u256 _networkId = 0
): SpecialisedClient<Ethash>(_host, _gpForAdoption, _dbPath, _forceAction, _networkId) {}
virtual ~EthashClient() { stopWorking(); }
/// Update to the latest transactions and get hash of the current block to be mined minus the
/// nonce (the 'work hash') and the difficulty to be met.
virtual std::tuple<h256, h256, h256> getEthashWork() override;

3
libtestutils/BlockChainLoader.cpp

@ -19,6 +19,7 @@
* @date 2015
*/
#include <libethereum/CanonBlockChain.h>
#include "BlockChainLoader.h"
#include "StateLoader.h"
#include "Common.h"
@ -35,7 +36,7 @@ BlockChainLoader::BlockChainLoader(Json::Value const& _json)
m_state = sl.state();
// load genesisBlock
m_bc.reset(new BlockChain(fromHex(_json["genesisRLP"].asString()), m_dir.path(), WithExisting::Kill));
m_bc.reset(new FullBlockChain<Ethash>(fromHex(_json["genesisRLP"].asString()), sl.stateDefinition(), m_dir.path(), WithExisting::Kill));
assert(m_state.rootHash() == m_bc->info().stateRoot());
// load blocks

2
libtestutils/StateLoader.cpp

@ -27,7 +27,7 @@ using namespace dev::eth;
using namespace dev::test;
StateLoader::StateLoader(Json::Value const& _json, std::string const& _dbPath):
m_state(State::openDB(_dbPath, WithExisting::Kill), BaseState::Empty)
m_state(State::openDB(_dbPath, h256{}, WithExisting::Kill), BaseState::Empty)
{
for (string const& name: _json.getMemberNames())
{

2
libtestutils/StateLoader.h

@ -24,6 +24,7 @@
#include <json/json.h>
#include <libdevcore/TransientDirectory.h>
#include <libethereum/State.h>
#include <libethereum/BlockChain.h>
namespace dev
{
@ -38,6 +39,7 @@ class StateLoader
public:
StateLoader(Json::Value const& _json, std::string const& _dbPath);
eth::State const& state() const { return m_state; }
eth::StateDefinition const& stateDefinition() const { return m_state.m_cache; }
private:
eth::State m_state;

8
libweb3jsonrpc/JsonHelper.cpp

@ -93,10 +93,10 @@ Json::Value toJson(dev::eth::BlockInfo const& _bi)
res["miner"] = toJS(_bi.coinbaseAddress());
res["stateRoot"] = toJS(_bi.stateRoot());
res["transactionsRoot"] = toJS(_bi.transactionsRoot());
res["difficulty"] = toJS(_bi.difficulty);
res["difficulty"] = toJS(_bi.difficulty());
res["number"] = toJS(_bi.number());
res["gasUsed"] = toJS(_bi.gasUsed);
res["gasLimit"] = toJS(_bi.gasLimit);
res["gasUsed"] = toJS(_bi.gasUsed());
res["gasLimit"] = toJS(_bi.gasLimit());
res["timestamp"] = toJS(_bi.timestamp());
res["extraData"] = toJS(_bi.extraData());
res["logsBloom"] = toJS(_bi.logBloom());
@ -176,7 +176,7 @@ Json::Value toJson(dev::eth::TransactionSkeleton const& _t)
Json::Value toJson(dev::eth::TransactionReceipt const& _t)
{
Json::Value res;
res["stateRoot"] = toJS(_t.stateRoot()());
res["stateRoot"] = toJS(_t.stateRoot());
res["gasUsed"] = toJS(_t.gasUsed());
res["bloom"] = toJS(_t.bloom());
res["log"] = dev::toJson(_t.log());

2
libweb3jsonrpc/WebThreeStubServer.cpp

@ -106,7 +106,7 @@ bool WebThreeStubServer::admin_eth_setBidPrice(std::string const& _wei, std::str
return true;
}
dev::eth::CanonBlockChain const& WebThreeStubServer::bc() const
dev::eth::BlockChain const& WebThreeStubServer::bc() const
{
return m_web3.ethereum()->blockChain();
}

4
libweb3jsonrpc/WebThreeStubServer.h

@ -34,7 +34,7 @@ namespace eth
{
class KeyManager;
class TrivialGasPricer;
class CanonBlockChain;
class BlockChain;
class BlockQueue;
}
@ -89,7 +89,7 @@ private:
private:
h256 blockHash(std::string const& _blockNumberOrHash) const;
dev::eth::CanonBlockChain const& bc() const;
dev::eth::BlockChain const& bc() const;
dev::eth::BlockQueue const& bq() const;
dev::WebThreeDirect& m_web3;

2
libwebthree/WebThree.cpp

@ -52,7 +52,7 @@ WebThreeDirect::WebThreeDirect(
Defaults::setDBPath(_dbPath);
if (_interfaces.count("eth"))
{
m_ethereum.reset(new eth::Client(&m_net, _dbPath, _we, 0));
m_ethereum.reset(new eth::EthashClient(&m_net, shared_ptr<GasPricer>(), _dbPath, _we, 0));
m_ethereum->setExtraData(rlpList(0, _clientVersion, m_net.id()));
}

4
mix/ClientModel.cpp

@ -686,9 +686,9 @@ RecordLogEntry* ClientModel::lastBlock() const
{
eth::BlockInfo blockInfo = m_client->blockInfo();
stringstream strGas;
strGas << blockInfo.gasUsed;
strGas << blockInfo.gasUsed();
stringstream strNumber;
strNumber << blockInfo.number;
strNumber << blockInfo.number();
RecordLogEntry* record = new RecordLogEntry(0, QString::fromStdString(strNumber.str()), tr(" - Block - "), tr("Hash: ") + QString(QString::fromStdString(dev::toHex(blockInfo.hash().ref()))), QString(), QString(), QString(), false, RecordLogEntry::RecordType::Block, QString::fromStdString(strGas.str()), QString(), tr("Block"), QVariantMap(), QVariantMap(), QVariantList());
QQmlEngine::setObjectOwnership(record, QQmlEngine::JavaScriptOwnership);
return record;

36
mix/MixClient.cpp

@ -24,12 +24,13 @@
#include <vector>
#include <utility>
#include <libdevcore/Exceptions.h>
#include <libethcore/Params.h>
#include <libethcore/BasicAuthority.h>
#include <libethereum/CanonBlockChain.h>
#include <libethereum/Transaction.h>
#include <libethereum/Executive.h>
#include <libethereum/ExtVM.h>
#include <libethereum/BlockChain.h>
#include <libethcore/Params.h>
#include <libevm/VM.h>
#include "Exceptions.h"
using namespace std;
@ -45,22 +46,20 @@ u256 const c_mixGenesisDifficulty = 131072; //TODO: make it lower for Mix someho
namespace
{
}
struct MixPow //dummy POW
MixBlockChain::MixBlockChain(std::string const& _path, h256 _stateRoot):
FullBlockChain<NoProof>(createGenesisBlock(_stateRoot), std::unordered_map<Address, Account>(), _path, WithExisting::Kill)
{
typedef int Solution;
static bool verify(BlockInfo const&) { return true; }
};
}
bytes MixBlockChain::createGenesisBlock(h256 _stateRoot)
{
RLPStream block(3);
block.appendList(15)
block.appendList(13)
<< h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie
<< LogBloom() << c_mixGenesisDifficulty << 0 << c_genesisGasLimit << 0 << (unsigned)0
<< std::string() << h256() << h64(u64(42));
<< std::string();
block.appendRaw(RLPEmptyList);
block.appendRaw(RLPEmptyList);
return block.out();
@ -78,7 +77,6 @@ MixClient::~MixClient()
void MixClient::resetState(std::unordered_map<Address, Account> const& _accounts, Secret const& _miner)
{
WriteGuard l(x_state);
Guard fl(x_filtersWatches);
@ -91,12 +89,13 @@ void MixClient::resetState(std::unordered_map<Address, Account> const& _accounts
SecureTrieDB<Address, MemoryDB> accountState(&m_stateDB);
accountState.init();
dev::eth::commit(_accounts, static_cast<MemoryDB&>(m_stateDB), accountState);
dev::eth::commit(_accounts, accountState);
h256 stateRoot = accountState.root();
m_bc.reset();
m_bc.reset(new MixBlockChain(m_dbPath, stateRoot));
m_state = eth::State(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address());
m_state.sync(bc());
State s(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address());
s.sync(bc());
m_state = s;
m_startState = m_state;
WriteGuard lx(x_executions);
m_executions.clear();
@ -275,11 +274,14 @@ void MixClient::mine()
{
WriteGuard l(x_state);
m_state.commitToMine(bc());
m_state.completeMine<MixPow>(0);
bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Default & ~ImportRequirements::ValidNonce);
NoProof::BlockHeader h(m_state.info());
RLPStream header;
h.streamRLP(header);
m_state.sealBlock(header.out());
bc().import(m_state.blockData(), m_state.db(), ImportRequirements::Everything & ~ImportRequirements::ValidSeal);
m_state.sync(bc());
m_startState = m_state;
h256Set changed { dev::eth::PendingChangedFilter, dev::eth::ChainChangedFilter };
}
ExecutionResult MixClient::lastExecution() const
@ -383,9 +385,9 @@ uint64_t MixClient::hashrate() const
return 0;
}
eth::MiningProgress MixClient::miningProgress() const
eth::WorkingProgress MixClient::miningProgress() const
{
return eth::MiningProgress();
return eth::WorkingProgress();
}
}

36
mix/MixClient.h

@ -25,6 +25,7 @@
#include <vector>
#include <string>
#include <libethcore/BasicAuthority.h>
#include <libethereum/ExtVM.h>
#include <libethereum/ClientBase.h>
#include <libethereum/Client.h>
@ -32,13 +33,40 @@
namespace dev
{
namespace mix
{
class MixBlockChain: public dev::eth::BlockChain
class NoProof
{
class BlockHeaderRaw: public dev::eth::BlockInfo
{
public:
static const unsigned SealFields = 0;
protected:
BlockHeaderRaw() = default;
BlockHeaderRaw(BlockInfo const& _bi): BlockInfo(_bi) {}
void populateFromHeader(RLP const& _header, dev::eth::Strictness _s) { (void) _header; (void) _s; }
void populateFromParent(BlockHeaderRaw const& _parent) { (void)_parent; }
void streamRLPFields(RLPStream& _s) const { (void) _s; }
};
public:
static std::string name() { return "NoProof"; }
static unsigned revision() { return 0; }
using BlockHeader = dev::eth::BlockHeaderPolished<BlockHeaderRaw>;
private:
static AddressHash s_authorities;
};
class MixBlockChain: public dev::eth::FullBlockChain<NoProof>
{
public:
MixBlockChain(std::string const& _path, h256 _stateRoot): BlockChain(createGenesisBlock(_stateRoot), _path, WithExisting::Kill) {}
MixBlockChain(std::string const& _path, h256 _stateRoot);
static bytes createGenesisBlock(h256 _stateRoot);
};
@ -67,9 +95,7 @@ public:
void stopMining() override;
bool isMining() const override;
uint64_t hashrate() const override;
eth::MiningProgress miningProgress() const override;
eth::ProofOfWork::WorkPackage getWork() override { return eth::ProofOfWork::WorkPackage(); }
bool submitWork(eth::ProofOfWork::Solution const&) override { return false; }
eth::WorkingProgress miningProgress() const override;
virtual void flushTransactions() override {}
/// @returns the last mined block information

19
test/TestHelper.cpp

@ -23,6 +23,7 @@
#include <thread>
#include <chrono>
#include <libethcore/EthashAux.h>
#include <libethereum/Client.h>
#include <liblll/Compiler.h>
#include <libevm/VMFactory.h>
@ -63,11 +64,17 @@ void connectClients(Client& c1, Client& c2)
void mine(State& s, BlockChain const& _bc)
{
s.commitToMine(_bc);
GenericFarm<ProofOfWork> f;
GenericFarm<EthashProofOfWork> f;
bool completed = false;
f.onSolutionFound([&](ProofOfWork::Solution sol)
{
return completed = s.completeMine<ProofOfWork>(sol);
Ethash::BlockHeader header(s.info);
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
{
header.m_mixHash = sol.mixHash;
header.m_nonce = sol.nonce;
RLPStream ret;
header.streamRLP(ret);
s.sealBlock(ret);
return true;
});
f.setWork(s.info());
f.startCPU();
@ -77,9 +84,9 @@ void mine(State& s, BlockChain const& _bc)
void mine(BlockInfo& _bi)
{
GenericFarm<ProofOfWork> f;
GenericFarm<EthashProofOfWork> f;
bool completed = false;
f.onSolutionFound([&](ProofOfWork::Solution sol)
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
{
_bi.proof = sol;
return completed = true;

10
test/libethcore/dagger.cpp

@ -54,11 +54,11 @@ BOOST_AUTO_TEST_CASE(basic_test)
cnote << i.first;
js::mObject& o = i.second.get_obj();
vector<pair<string, string>> ss;
BlockInfo header = BlockInfo::fromHeader(fromHex(o["header"].get_str()), CheckNothing);
Ethash::BlockHeader header(fromHex(o["header"].get_str()), CheckNothing);
h256 headerHash(o["header_hash"].get_str());
Nonce nonce(o["nonce"].get_str());
BOOST_REQUIRE_EQUAL(headerHash, header.headerHash(WithoutNonce));
BOOST_REQUIRE_EQUAL(nonce, header.nonce);
BOOST_REQUIRE_EQUAL(headerHash, header.hashWithout());
BOOST_REQUIRE_EQUAL(nonce, header.nonce());
unsigned cacheSize(o["cache_size"].get_int());
h256 cacheHash(o["cache_hash"].get_str());
@ -73,9 +73,9 @@ BOOST_AUTO_TEST_CASE(basic_test)
#endif
h256 result(o["result"].get_str());
EthashProofOfWork::Result r = EthashAux::eval(header);
EthashProofOfWork::Result r = EthashAux::eval(header.seedHash(), header.hashWithout(), header.nonce());
BOOST_REQUIRE_EQUAL(r.value, result);
BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash);
BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash());
}
}

18
test/libethereum/ClientBase.cpp

@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(blocks)
ETH_CHECK_EQUAL(expectedHashFromNumber, hashFromNumber);
// blockInfo
auto compareBlockInfos = [](Json::Value const& _b, BlockInfo _blockInfo) -> void
auto compareBlockInfos = [](Json::Value const& _b, Ethash::BlockHeader _blockInfo) -> void
{
LogBloom expectedBlockInfoBloom = LogBloom(fromHex(_b["bloom"].asString()));
Address expectedBlockInfoCoinbase = Address(fromHex(_b["coinbase"].asString()));
@ -119,27 +119,27 @@ BOOST_AUTO_TEST_CASE(blocks)
h256 expectedBlockInfoUncldeHash = h256(fromHex(_b["uncleHash"].asString()));
ETH_CHECK_EQUAL(expectedBlockInfoBloom, _blockInfo.logBloom());
ETH_CHECK_EQUAL(expectedBlockInfoCoinbase, _blockInfo.coinbaseAddress());
ETH_CHECK_EQUAL(expectedBlockInfoDifficulty, _blockInfo.difficulty);
ETH_CHECK_EQUAL(expectedBlockInfoDifficulty, _blockInfo.difficulty());
ETH_CHECK_EQUAL_COLLECTIONS(
expectedBlockInfoExtraData.begin(),
expectedBlockInfoExtraData.end(),
_blockInfo.extraData().begin(),
_blockInfo.extraData().end()
);
ETH_CHECK_EQUAL(expectedBlockInfoGasLimit, _blockInfo.gasLimit);
ETH_CHECK_EQUAL(expectedBlockInfoGasUsed, _blockInfo.gasUsed);
ETH_CHECK_EQUAL(expectedBlockInfoGasLimit, _blockInfo.gasLimit());
ETH_CHECK_EQUAL(expectedBlockInfoGasUsed, _blockInfo.gasUsed());
ETH_CHECK_EQUAL(expectedBlockInfoHash, _blockInfo.hash());
ETH_CHECK_EQUAL(expectedBlockInfoMixHash, _blockInfo.mixHash);
ETH_CHECK_EQUAL(expectedBlockInfoNonce, _blockInfo.nonce);
ETH_CHECK_EQUAL(expectedBlockInfoNumber, _blockInfo.number);
ETH_CHECK_EQUAL(expectedBlockInfoMixHash, _blockInfo.mixHash());
ETH_CHECK_EQUAL(expectedBlockInfoNonce, _blockInfo.nonce());
ETH_CHECK_EQUAL(expectedBlockInfoNumber, _blockInfo.number());
ETH_CHECK_EQUAL(expectedBlockInfoParentHash, _blockInfo.parentHash());
ETH_CHECK_EQUAL(expectedBlockInfoReceiptsRoot, _blockInfo..receiptsRoot());
ETH_CHECK_EQUAL(expectedBlockInfoReceiptsRoot, _blockInfo.receiptsRoot());
ETH_CHECK_EQUAL(expectedBlockInfoTimestamp, _blockInfo.timestamp());
ETH_CHECK_EQUAL(expectedBlockInfoTransactionsRoot, _blockInfo.transactionsRoot());
ETH_CHECK_EQUAL(expectedBlockInfoUncldeHash, _blockInfo.sha3Uncles());
};
BlockInfo blockInfo = _client.blockInfo(blockHash);
Ethash::BlockHeader blockInfo(_client.bc().headerData(blockHash));
compareBlockInfos(blockHeader, blockInfo);
// blockDetails

3
test/libethereum/gaspricer.cpp

@ -20,6 +20,7 @@
*/
#include <libtestutils/BlockChainLoader.h>
#include <libethcore/Ethash.h>
#include <libethereum/BlockChain.h>
#include <libethereum/GasPricer.h>
#include <libethereum/BasicGasPricer.h>
@ -54,7 +55,7 @@ BOOST_AUTO_TEST_CASE(trivialGasPricer)
std::shared_ptr<dev::eth::GasPricer> gp(new TrivialGasPricer);
BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo);
BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo);
gp->update(BlockChain(bytes(), TransientDirectory().path(), WithExisting::Kill));
gp->update(FullBlockChain<Ethash>(bytes(), StateDefinition(), TransientDirectory().path(), WithExisting::Kill));
BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo);
BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo);
}

6
test/libethereum/genesis.cpp

@ -60,9 +60,9 @@ BOOST_AUTO_TEST_CASE(genesis_tests)
js::mObject o = v.get_obj();
BOOST_CHECK_EQUAL(CanonBlockChain::genesis().stateRoot(), h256(o["genesis_state_root"].get_str()));
BOOST_CHECK_EQUAL(toHex(CanonBlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str())));
BOOST_CHECK_EQUAL(BlockInfo::headerHash(CanonBlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str()));
BOOST_CHECK_EQUAL(CanonBlockChain<Ethash>::genesis().stateRoot(), h256(o["genesis_state_root"].get_str()));
BOOST_CHECK_EQUAL(toHex(CanonBlockChain<Ethash>::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str())));
BOOST_CHECK_EQUAL(Ethash::BlockHeader(CanonBlockChain<Ethash>::createGenesisBlock()).hashWithout(), h256(o["genesis_hash"].get_str()));
}
BOOST_AUTO_TEST_SUITE_END()

5
test/libethereum/stateOriginal.cpp

@ -25,6 +25,7 @@
#include <libethereum/CanonBlockChain.h>
#include <libethereum/State.h>
#include <libethcore/Farm.h>
#include <libethcore/BasicAuthority.h>
#include <libethereum/Defaults.h>
#include <test/TestHelper.h>
@ -59,8 +60,8 @@ BOOST_AUTO_TEST_CASE(Complex)
Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count()));
OverlayDB stateDB = State::openDB();
CanonBlockChain bc;
OverlayDB stateDB = State::openDB(h256());
CanonBlockChain<BasicAuthority> bc;
cout << bc;
State s = bc.genesisState(stateDB);

10
test/libevm/vm.cpp

@ -33,7 +33,7 @@ using namespace dev::eth;
using namespace dev::test;
FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix.
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), EmptySHA3, _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {}
ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), EmptySHA3, _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number()), _depth) {}
h160 FakeExtVM::create(u256 _endowment, u256& io_gas, bytesConstRef _init, OnOpFunc const&)
{
@ -84,11 +84,11 @@ mObject FakeExtVM::exportEnv()
{
mObject ret;
ret["previousHash"] = toString(currentBlock.parentHash());
ret["currentDifficulty"] = toCompactHex(currentBlock.difficulty, HexPrefix::Add, 1);
ret["currentDifficulty"] = toCompactHex(currentBlock.difficulty(), HexPrefix::Add, 1);
ret["currentTimestamp"] = toCompactHex(currentBlock.timestamp(), HexPrefix::Add, 1);
ret["currentCoinbase"] = toString(currentBlock.coinbaseAddress());
ret["currentNumber"] = toCompactHex(currentBlock.number, HexPrefix::Add, 1);
ret["currentGasLimit"] = toCompactHex(currentBlock.gasLimit, HexPrefix::Add, 1);
ret["currentNumber"] = toCompactHex(currentBlock.number(), HexPrefix::Add, 1);
ret["currentGasLimit"] = toCompactHex(currentBlock.gasLimit(), HexPrefix::Add, 1);
return ret;
}
@ -107,7 +107,7 @@ void FakeExtVM::importEnv(mObject& _o)
lastHashes = test::lastHashes(currentBlock.number);
currentBlock.gasLimit = toInt(_o["currentGasLimit"]);
currentBlock.difficulty = toInt(_o["currentDifficulty"]);
currentBlock.timestamp() = toInt(_o["currentTimestamp"]);
currentBlock.timestamp = toInt(_o["currentTimestamp"]);
currentBlock.coinbaseAddress() = Address(_o["currentCoinbase"].get_str());
}

Loading…
Cancel
Save