From a10292205e73d26b7d5298bf2faa924cae66cbc5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 16 Feb 2015 11:47:06 +0100 Subject: [PATCH 001/313] Move to Chromium. --- alethzero/CMakeLists.txt | 5 +++ alethzero/Main.ui | 15 ++++--- alethzero/MainWin.cpp | 87 +++++++++++++++++++--------------------- alethzero/MainWin.h | 2 - 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt index 9e41260fe..83fe797fe 100644 --- a/alethzero/CMakeLists.txt +++ b/alethzero/CMakeLists.txt @@ -14,6 +14,9 @@ include_directories(..) include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) +find_package (Qt5WebEngine QUIET) +find_package (Qt5WebEngineWidgets QUIET) + qt5_wrap_ui(ui_Main.h Main.ui) qt5_wrap_ui(ui_Debugger.h Debugger.ui) qt5_wrap_ui(ui_Transact.h Transact.ui) @@ -39,6 +42,8 @@ target_link_libraries(${EXECUTABLE} Qt5::Core) target_link_libraries(${EXECUTABLE} Qt5::Widgets) target_link_libraries(${EXECUTABLE} Qt5::WebKit) target_link_libraries(${EXECUTABLE} Qt5::WebKitWidgets) +target_link_libraries(${EXECUTABLE} Qt5::WebEngine) +target_link_libraries(${EXECUTABLE} Qt5::WebEngineWidgets) target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} ethereum) target_link_libraries(${EXECUTABLE} evm) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index b7c4f6c96..05f5b17bd 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -95,13 +95,7 @@ - - - - about:blank - - - + @@ -1672,6 +1666,12 @@ font-size: 14pt
DownloadView.h
1 + + QWebEngineView + QWidget +
QtWebEngineWidgets/QWebEngineView
+ 1 +
shhTo @@ -1686,7 +1686,6 @@ font-size: 14pt jsConsole tabWidget urlEdit - webView idealPeers forceAddress port diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 00fb29e2d..68078a95d 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -19,13 +19,15 @@ * @date 2014 */ +#define QWEBENGINEINSPECTOR 1 #include #include #include #include #include -#include -#include +#include +#include +#include #include #include #include @@ -154,31 +156,24 @@ Main::Main(QWidget *parent) : m_server->setIdentities(keysAsVector(owned())); m_server->StartListening(); - connect(ui->webView, &QWebView::loadStarted, [this]() + connect(ui->webView, &QWebEngineView::loadFinished, [this]() { - QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); - QWebFrame* f = ui->webView->page()->mainFrame(); - f->disconnect(SIGNAL(javaScriptWindowObjectCleared())); - - connect(f, &QWebFrame::javaScriptWindowObjectCleared, [f, this]() - { - f->disconnect(); - f->addToJavaScriptWindowObject("env", this, QWebFrame::QtOwnership); - f->evaluateJavaScript(contentsOfQResource(":/js/bignumber.min.js")); - f->evaluateJavaScript(contentsOfQResource(":/js/webthree.js")); - f->evaluateJavaScript(contentsOfQResource(":/js/setup.js")); - }); +// f->disconnect(); +// f->addToJavaScriptWindowObject("env", this, QWebFrame::QtOwnership); + auto f = ui->webView->page(); + f->runJavaScript(contentsOfQResource(":/js/bignumber.min.js")); + f->runJavaScript(contentsOfQResource(":/js/webthree.js")); + f->runJavaScript(contentsOfQResource(":/js/setup.js")); }); - connect(ui->webView, &QWebView::loadFinished, [=]() - { - }); - - connect(ui->webView, &QWebView::titleChanged, [=]() + connect(ui->webView, &QWebEngineView::titleChanged, [=]() { ui->tabWidget->setTabText(0, ui->webView->title()); }); + ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); +// QWebEngineInspector* inspector = new QWebEngineInspector(); +// inspector->setPage(page); readSettings(); installWatches(); startTimer(100); @@ -361,7 +356,7 @@ QString Main::contents(QString _s) void Main::load(QString _s) { QString contents = QString::fromStdString(dev::asString(dev::contents(_s.toStdString()))); - ui->webView->page()->currentFrame()->evaluateJavaScript(contents); + ui->webView->page()->runJavaScript(contents); /* QFile fin(_s); if (!fin.open(QFile::ReadOnly)) @@ -420,35 +415,35 @@ void Main::on_jsInput_returnPressed() ui->jsInput->setText(""); } -QVariant Main::evalRaw(QString const& _js) -{ - return ui->webView->page()->currentFrame()->evaluateJavaScript(_js); -} - void Main::eval(QString const& _js) { if (_js.trimmed().isEmpty()) return; - QVariant ev = ui->webView->page()->currentFrame()->evaluateJavaScript((_js.startsWith("{") || _js.startsWith("if ") || _js.startsWith("if(")) ? _js : ("___RET=(" + _js + ")")); - QVariant jsonEv = ui->webView->page()->currentFrame()->evaluateJavaScript("JSON.stringify(___RET)"); - QString s; - if (ev.isNull()) - s = "null"; - else if (ev.type() == QVariant::String) - s = "\"" + ev.toString().toHtmlEscaped() + "\""; - else if (ev.type() == QVariant::Int || ev.type() == QVariant::Double) - s = "" + ev.toString().toHtmlEscaped() + ""; - else if (jsonEv.type() == QVariant::String) - s = "" + jsonEv.toString().toHtmlEscaped() + ""; - else - s = "unknown type"; - m_consoleHistory.push_back(qMakePair(_js, s)); - s = "" Div(Mono "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%"); - for (auto const& i: m_consoleHistory) - s += "
>" + i.first.toHtmlEscaped() + "
" - "
 " + i.second + "
"; - s += ""; - ui->jsConsole->setHtml(s); + auto f = [=](QVariant ev) { + auto f2 = [=](QVariant jsonEv) { + QString s; + if (ev.isNull()) + s = "null"; + else if (ev.type() == QVariant::String) + s = "\"" + ev.toString().toHtmlEscaped() + "\""; + else if (ev.type() == QVariant::Int || ev.type() == QVariant::Double) + s = "" + ev.toString().toHtmlEscaped() + ""; + else if (jsonEv.type() == QVariant::String) + s = "" + jsonEv.toString().toHtmlEscaped() + ""; + else + s = "unknown type"; + m_consoleHistory.push_back(qMakePair(_js, s)); + s = "" Div(Mono "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%"); + for (auto const& i: m_consoleHistory) + s += "
>" + i.first.toHtmlEscaped() + "
" + "
 " + i.second + "
"; + s += ""; + ui->jsConsole->setHtml(s); + }; + ui->webView->page()->runJavaScript("JSON.stringify(___RET)", f2); + }; + auto c = (_js.startsWith("{") || _js.startsWith("if ") || _js.startsWith("if(")) ? _js : ("___RET=(" + _js + ")"); + ui->webView->page()->runJavaScript(c, f); } static Public stringToPublic(QString const& _a) diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 6c4a97301..5cb7aa964 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -74,8 +74,6 @@ public: NatSpecFace* natSpec() { return &m_natSpecDB; } - QVariant evalRaw(QString const& _js); - QString pretty(dev::Address _a) const override; QString prettyU256(dev::u256 _n) const override; QString render(dev::Address _a) const override; From 27a81649199f31fa26bd1952fb73d66e38eaed00 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 16 Feb 2015 14:33:15 +0100 Subject: [PATCH 002/313] added QtWebEngine::initialize() --- alethzero/MainWin.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 68078a95d..3bbb643a7 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -112,6 +112,7 @@ Main::Main(QWidget *parent) : { setWindowFlags(Qt::Window); ui->setupUi(this); + QtWebEngine::initialize(); g_logPost = [=](string const& s, char const* c) { simpleDebugOut(s, c); @@ -171,7 +172,7 @@ Main::Main(QWidget *parent) : ui->tabWidget->setTabText(0, ui->webView->title()); }); - ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); +// ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); // QWebEngineInspector* inspector = new QWebEngineInspector(); // inspector->setPage(page); readSettings(); From b8461cb8b9031266cd709c056b02760bb6a05f7d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 17 Feb 2015 14:45:06 +0100 Subject: [PATCH 003/313] Tentative registry included in Genesis. --- alethzero/MainWin.cpp | 4 +++- libethereum/CanonBlockChain.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 68078a95d..648733556 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,7 @@ Main::Main(QWidget *parent) : ui(new Ui::Main), m_transact(this, this) { + QtWebEngine::initialize(); setWindowFlags(Qt::Window); ui->setupUi(this); g_logPost = [=](string const& s, char const* c) @@ -171,7 +173,7 @@ Main::Main(QWidget *parent) : ui->tabWidget->setTabText(0, ui->webView->title()); }); - ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); +// ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); // QWebEngineInspector* inspector = new QWebEngineInspector(); // inspector->setPage(page); readSettings(); diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index fc7107154..3ce69d724 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -29,17 +29,20 @@ #include #include #include +#include #include "State.h" #include "Defaults.h" using namespace std; using namespace dev; using namespace dev::eth; +using namespace dev::solidity; #define ETH_CATCH 1 std::map const& dev::eth::genesisState() { static std::map s_ret; + if (s_ret.empty()) { // Initialise. @@ -54,10 +57,14 @@ std::map const& dev::eth::genesisState() "e4157b34ea9615cfbde6b4fda419828124b70c78" })) s_ret[Address(fromHex(i))] = Account(u256(1) << 200, Account::NormalCreation); + s_ret[Address(1)] = Account(0, Account::ContractConception); + s_ret[Address(2600)].setCode(fromHex("60e060020a60003504806301984892146100ba5780631c83171b146100cf578063449c2090146100e05780635d574e32146100fe5780635fd4b08a14610112578063618242da146101275780636be16bed1461013c5780636c4489b41461014d5780637d2e3ce914610180578063994d29cc146101935780639e71f357146101a8578063b8202c18146101bc578063c284bc2a146101d0578063e50f599a146101e1578063e5811b35146101f8578063ec7b92001461021657005b6100c5600435610652565b8060005260206000f35b6100da600435610446565b60006000f35b6100eb600435610426565b80600160a060020a031660005260206000f35b61010c600435602435610324565b60006000f35b61011d600435610375565b8060005260206000f35b610132600435610612565b8060005260206000f35b6101476004356105f2565b60006000f35b61015860043561037c565b84600160a060020a031660005283600160a060020a0316602052816040528060605260806000f35b61018d60043560006102d3565b60006000f35b61019e600435610632565b8060005260206000f35b6101b6600435602435610234565b60006000f35b6101ca600435602435610282565b60006000f35b6101db600435610513565b60006000f35b6101f2600435602435604435610495565b60006000f35b61020360043561048e565b80600160a060020a031660005260206000f35b610221600435610409565b80600160a060020a031660005260206000f35b33600160a060020a03166001600084815260200190815260200160002054600160a060020a0316146102655761027e565b8060016000848152602001908152602001600020819055505b5050565b33600160a060020a03166001600084815260200190815260200160002054600160a060020a0316146102b3576102cf565b8060016000848152602001908152602001600020600401819055505b5050565b33600160a060020a03166001600084815260200190815260200160002054600160a060020a03161461030457610320565b8060016000848152602001908152602001600020600201819055505b5050565b33600160a060020a03166001600084815260200190815260200160002054600160a060020a03161461035557610371565b8060016000848152602001908152602001600020600301819055505b5050565b6000919050565b60006000600060006000600160008781526020019081526020016000205494506001600087815260200190815260200160002060010154935060016000878152602001908152602001600020600201549250600160008781526020019081526020016000206003015491506001600087815260200190815260200160002060040154905091939590929450565b600060016000838152602001908152602001600020549050919050565b600060016000838152602001908152602001600020600101549050919050565b6001600082815260200190815260200160002054600160a060020a031660001461046f5761048b565b3360016000838152602001908152602001600020600101819055505b50565b6000919050565b33600160a060020a03166001600085815260200190815260200160002054600160a060020a0316146104c65761050e565b816001600085815260200190815260200160002060010181905550806104eb5761050d565b826000600084600160a060020a03168152602001908152602001600020819055505b5b505050565b33600160a060020a03166001600083815260200190815260200160002054600160a060020a031614610544576105ef565b80600060006001600085815260200190815260200160002060010154600160a060020a031681526020019081526020016000205414610582576105bb565b6000600060006001600085815260200190815260200160002060010154600160a060020a03168152602001908152602001600020819055505b6001600082815260200190815260200160002060008155600101600081556001016000815560010160008155600101600090555b50565b600060016000838152602001908152602001600020600201549050919050565b600060016000838152602001908152602001600020600301549050919050565b600060016000838152602001908152602001600020600401549050919050565b60006000600083600160a060020a0316815260200190815260200160002054905091905056")); } return s_ret; } +// TODO: place Registry in here. + std::unique_ptr CanonBlockChain::s_genesis; boost::shared_mutex CanonBlockChain::x_genesis; From fe4d638ad5351a820bf91d7902899f46224e46da Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 18 Feb 2015 13:48:28 +0100 Subject: [PATCH 004/313] Debuggy stuff and revert canonblockchain. --- libethereum/CanonBlockChain.cpp | 2 -- libjsqrc/ethereumjs/dist/ethereum.js | 8 ++++++++ libjsqrc/ethereumjs/dist/ethereum.js.map | 4 ++-- libjsqrc/ethereumjs/dist/ethereum.min.js | 2 +- libjsqrc/ethereumjs/lib/web3.js | 8 ++++++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index 3ce69d724..b4ca86916 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -57,8 +57,6 @@ std::map const& dev::eth::genesisState() "e4157b34ea9615cfbde6b4fda419828124b70c78" })) s_ret[Address(fromHex(i))] = Account(u256(1) << 200, Account::NormalCreation); - s_ret[Address(1)] = Account(0, Account::ContractConception); - s_ret[Address(2600)].setCode(fromHex("60e060020a60003504806301984892146100ba5780631c83171b146100cf578063449c2090146100e05780635d574e32146100fe5780635fd4b08a14610112578063618242da146101275780636be16bed1461013c5780636c4489b41461014d5780637d2e3ce914610180578063994d29cc146101935780639e71f357146101a8578063b8202c18146101bc578063c284bc2a146101d0578063e50f599a146101e1578063e5811b35146101f8578063ec7b92001461021657005b6100c5600435610652565b8060005260206000f35b6100da600435610446565b60006000f35b6100eb600435610426565b80600160a060020a031660005260206000f35b61010c600435602435610324565b60006000f35b61011d600435610375565b8060005260206000f35b610132600435610612565b8060005260206000f35b6101476004356105f2565b60006000f35b61015860043561037c565b84600160a060020a031660005283600160a060020a0316602052816040528060605260806000f35b61018d60043560006102d3565b60006000f35b61019e600435610632565b8060005260206000f35b6101b6600435602435610234565b60006000f35b6101ca600435602435610282565b60006000f35b6101db600435610513565b60006000f35b6101f2600435602435604435610495565b60006000f35b61020360043561048e565b80600160a060020a031660005260206000f35b610221600435610409565b80600160a060020a031660005260206000f35b33600160a060020a03166001600084815260200190815260200160002054600160a060020a0316146102655761027e565b8060016000848152602001908152602001600020819055505b5050565b33600160a060020a03166001600084815260200190815260200160002054600160a060020a0316146102b3576102cf565b8060016000848152602001908152602001600020600401819055505b5050565b33600160a060020a03166001600084815260200190815260200160002054600160a060020a03161461030457610320565b8060016000848152602001908152602001600020600201819055505b5050565b33600160a060020a03166001600084815260200190815260200160002054600160a060020a03161461035557610371565b8060016000848152602001908152602001600020600301819055505b5050565b6000919050565b60006000600060006000600160008781526020019081526020016000205494506001600087815260200190815260200160002060010154935060016000878152602001908152602001600020600201549250600160008781526020019081526020016000206003015491506001600087815260200190815260200160002060040154905091939590929450565b600060016000838152602001908152602001600020549050919050565b600060016000838152602001908152602001600020600101549050919050565b6001600082815260200190815260200160002054600160a060020a031660001461046f5761048b565b3360016000838152602001908152602001600020600101819055505b50565b6000919050565b33600160a060020a03166001600085815260200190815260200160002054600160a060020a0316146104c65761050e565b816001600085815260200190815260200160002060010181905550806104eb5761050d565b826000600084600160a060020a03168152602001908152602001600020819055505b5b505050565b33600160a060020a03166001600083815260200190815260200160002054600160a060020a031614610544576105ef565b80600060006001600085815260200190815260200160002060010154600160a060020a031681526020019081526020016000205414610582576105bb565b6000600060006001600085815260200190815260200160002060010154600160a060020a03168152602001908152602001600020819055505b6001600082815260200190815260200160002060008155600101600081556001016000815560010160008155600101600090555b50565b600060016000838152602001908152602001600020600201549050919050565b600060016000838152602001908152602001600020600301549050919050565b600060016000838152602001908152602001600020600401549050919050565b60006000600083600160a060020a0316815260200190815260200160002054905091905056")); } return s_ret; } diff --git a/libjsqrc/ethereumjs/dist/ethereum.js b/libjsqrc/ethereumjs/dist/ethereum.js index 4c36a7c71..0979b6260 100644 --- a/libjsqrc/ethereumjs/dist/ethereum.js +++ b/libjsqrc/ethereumjs/dist/ethereum.js @@ -1570,6 +1570,14 @@ var web3 = { }; }, + canary: function (abi) { + return function(addr) { + // Default to address of Config. TODO: rremove prior to genesis. + addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b'; + return addr; + }; + }, + /// @param filter may be a string, object or event /// @param indexed is optional, this is an object with optional event indexed params /// @param options is optional, this is an object with optional event options ('max'...) diff --git a/libjsqrc/ethereumjs/dist/ethereum.js.map b/libjsqrc/ethereumjs/dist/ethereum.js.map index e441da86c..16bcfd010 100644 --- a/libjsqrc/ethereumjs/dist/ethereum.js.map +++ b/libjsqrc/ethereumjs/dist/ethereum.js.map @@ -18,7 +18,7 @@ "index.js" ], "names": [], - "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", + "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AClNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACrGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC1JA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACtGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC/EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9IA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACxQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", "file": "generated.js", "sourceRoot": "", "sourcesContent": [ @@ -35,7 +35,7 @@ "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see .\n*/\n/** @file qtsync.js\n * @authors:\n * Marek Kotewicz \n * Marian Oancea \n * @date 2014\n */\n\nvar QtSyncProvider = function () {\n};\n\nQtSyncProvider.prototype.send = function (payload) {\n var result = navigator.qt.callMethod(JSON.stringify(payload));\n return JSON.parse(result);\n};\n\nmodule.exports = QtSyncProvider;\n\n", "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see .\n*/\n/** @file types.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar f = require('./formatters');\n\n/// @param expected type prefix (string)\n/// @returns function which checks if type has matching prefix. if yes, returns true, otherwise false\nvar prefixedType = function (prefix) {\n return function (type) {\n return type.indexOf(prefix) === 0;\n };\n};\n\n/// @param expected type name (string)\n/// @returns function which checks if type is matching expected one. if yes, returns true, otherwise false\nvar namedType = function (name) {\n return function (type) {\n return name === type;\n };\n};\n\n/// Setups input formatters for solidity types\n/// @returns an array of input formatters \nvar inputTypes = function () {\n \n return [\n { type: prefixedType('uint'), format: f.formatInputInt },\n { type: prefixedType('int'), format: f.formatInputInt },\n { type: prefixedType('hash'), format: f.formatInputInt },\n { type: prefixedType('string'), format: f.formatInputString }, \n { type: prefixedType('real'), format: f.formatInputReal },\n { type: prefixedType('ureal'), format: f.formatInputReal },\n { type: namedType('address'), format: f.formatInputInt },\n { type: namedType('bool'), format: f.formatInputBool }\n ];\n};\n\n/// Setups output formaters for solidity types\n/// @returns an array of output formatters\nvar outputTypes = function () {\n\n return [\n { type: prefixedType('uint'), format: f.formatOutputUInt },\n { type: prefixedType('int'), format: f.formatOutputInt },\n { type: prefixedType('hash'), format: f.formatOutputHash },\n { type: prefixedType('string'), format: f.formatOutputString },\n { type: prefixedType('real'), format: f.formatOutputReal },\n { type: prefixedType('ureal'), format: f.formatOutputUReal },\n { type: namedType('address'), format: f.formatOutputAddress },\n { type: namedType('bool'), format: f.formatOutputBool }\n ];\n};\n\nmodule.exports = {\n prefixedType: prefixedType,\n namedType: namedType,\n inputTypes: inputTypes,\n outputTypes: outputTypes\n};\n\n", "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see .\n*/\n/** @file utils.js\n * @authors:\n * Marek Kotewicz \n * @date 2015\n */\n\nvar c = require('./const');\n\n/// Finds first index of array element matching pattern\n/// @param array\n/// @param callback pattern\n/// @returns index of element\nvar findIndex = function (array, callback) {\n var end = false;\n var i = 0;\n for (; i < array.length && !end; i++) {\n end = callback(array[i]);\n }\n return end ? i - 1 : -1;\n};\n\n/// @returns ascii string representation of hex value prefixed with 0x\nvar toAscii = function(hex) {\n// Find termination\n var str = \"\";\n var i = 0, l = hex.length;\n if (hex.substring(0, 2) === '0x') {\n i = 2;\n }\n for (; i < l; i+=2) {\n var code = parseInt(hex.substr(i, 2), 16);\n if (code === 0) {\n break;\n }\n\n str += String.fromCharCode(code);\n }\n\n return str;\n};\n \nvar toHex = function(str) {\n var hex = \"\";\n for(var i = 0; i < str.length; i++) {\n var n = str.charCodeAt(i).toString(16);\n hex += n.length < 2 ? '0' + n : n;\n }\n\n return hex;\n};\n\n/// @returns hex representation (prefixed by 0x) of ascii string\nvar fromAscii = function(str, pad) {\n pad = pad === undefined ? 0 : pad;\n var hex = toHex(str);\n while (hex.length < pad*2)\n hex += \"00\";\n return \"0x\" + hex;\n};\n\n/// @returns display name for function/event eg. multiply(uint256) -> multiply\nvar extractDisplayName = function (name) {\n var length = name.indexOf('('); \n return length !== -1 ? name.substr(0, length) : name;\n};\n\n/// @returns overloaded part of function/event name\nvar extractTypeName = function (name) {\n /// TODO: make it invulnerable\n var length = name.indexOf('(');\n return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : \"\";\n};\n\n/// Filters all function from input abi\n/// @returns abi array with filtered objects of type 'function'\nvar filterFunctions = function (json) {\n return json.filter(function (current) {\n return current.type === 'function'; \n }); \n};\n\n/// Filters all events form input abi\n/// @returns abi array with filtered objects of type 'event'\nvar filterEvents = function (json) {\n return json.filter(function (current) {\n return current.type === 'event';\n });\n};\n\n/// used to transform value/string to eth string\n/// TODO: use BigNumber.js to parse int\n/// TODO: add tests for it!\nvar toEth = function (str) {\n var val = typeof str === \"string\" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;\n var unit = 0;\n var units = c.ETH_UNITS;\n while (val > 3000 && unit < units.length - 1)\n {\n val /= 1000;\n unit++;\n }\n var s = val.toString().length < val.toFixed(2).length ? val.toString() : val.toFixed(2);\n var replaceFunction = function($0, $1, $2) {\n return $1 + ',' + $2;\n };\n\n while (true) {\n var o = s;\n s = s.replace(/(\\d)(\\d\\d\\d[\\.\\,])/, replaceFunction);\n if (o === s)\n break;\n }\n return s + ' ' + units[unit];\n};\n\nmodule.exports = {\n findIndex: findIndex,\n toAscii: toAscii,\n fromAscii: fromAscii,\n extractDisplayName: extractDisplayName,\n extractTypeName: extractTypeName,\n filterFunctions: filterFunctions,\n filterEvents: filterEvents,\n toEth: toEth\n};\n\n", - "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see .\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Gav Wood \n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js');\n*/}\n\nvar utils = require('./utils');\n\n/// @returns an array of objects describing web3 api methods\nvar web3Methods = function () {\n return [\n { name: 'sha3', call: 'web3_sha3' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth api methods\nvar ethMethods = function () {\n var blockCall = function (args) {\n return typeof args[0] === \"string\" ? \"eth_blockByHash\" : \"eth_blockByNumber\";\n };\n\n var transactionCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_transactionByHash' : 'eth_transactionByNumber';\n };\n\n var uncleCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_uncleByHash' : 'eth_uncleByNumber';\n };\n\n var methods = [\n { name: 'balanceAt', call: 'eth_balanceAt' },\n { name: 'stateAt', call: 'eth_stateAt' },\n { name: 'storageAt', call: 'eth_storageAt' },\n { name: 'countAt', call: 'eth_countAt'},\n { name: 'codeAt', call: 'eth_codeAt' },\n { name: 'transact', call: 'eth_transact' },\n { name: 'call', call: 'eth_call' },\n { name: 'block', call: blockCall },\n { name: 'transaction', call: transactionCall },\n { name: 'uncle', call: uncleCall },\n { name: 'compilers', call: 'eth_compilers' },\n { name: 'flush', call: 'eth_flush' },\n { name: 'lll', call: 'eth_lll' },\n { name: 'solidity', call: 'eth_solidity' },\n { name: 'serpent', call: 'eth_serpent' },\n { name: 'logs', call: 'eth_logs' }\n ];\n return methods;\n};\n\n/// @returns an array of objects describing web3.eth api properties\nvar ethProperties = function () {\n return [\n { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },\n { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },\n { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },\n { name: 'gasPrice', getter: 'eth_gasPrice' },\n { name: 'accounts', getter: 'eth_accounts' },\n { name: 'peerCount', getter: 'eth_peerCount' },\n { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },\n { name: 'number', getter: 'eth_number'}\n ];\n};\n\n/// @returns an array of objects describing web3.db api methods\nvar dbMethods = function () {\n return [\n { name: 'put', call: 'db_put' },\n { name: 'get', call: 'db_get' },\n { name: 'putString', call: 'db_putString' },\n { name: 'getString', call: 'db_getString' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh api methods\nvar shhMethods = function () {\n return [\n { name: 'post', call: 'shh_post' },\n { name: 'newIdentity', call: 'shh_newIdentity' },\n { name: 'haveIdentity', call: 'shh_haveIdentity' },\n { name: 'newGroup', call: 'shh_newGroup' },\n { name: 'addToGroup', call: 'shh_addToGroup' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth.watch api methods\nvar ethWatchMethods = function () {\n var newFilter = function (args) {\n return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';\n };\n\n return [\n { name: 'newFilter', call: newFilter },\n { name: 'uninstallFilter', call: 'eth_uninstallFilter' },\n { name: 'getMessages', call: 'eth_filterLogs' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shhWatchMethods = function () {\n return [\n { name: 'newFilter', call: 'shh_newFilter' },\n { name: 'uninstallFilter', call: 'shh_uninstallFilter' },\n { name: 'getMessages', call: 'shh_getMessages' }\n ];\n};\n\n/// creates methods in a given object based on method description on input\n/// setups api calls for these methods\nvar setupMethods = function (obj, methods) {\n methods.forEach(function (method) {\n obj[method.name] = function () {\n var args = Array.prototype.slice.call(arguments);\n var call = typeof method.call === 'function' ? method.call(args) : method.call;\n return web3.provider.send({\n method: call,\n params: args\n });\n };\n });\n};\n\n/// creates properties in a given object based on properties description on input\n/// setups api calls for these properties\nvar setupProperties = function (obj, properties) {\n properties.forEach(function (property) {\n var proto = {};\n proto.get = function () {\n return web3.provider.send({\n method: property.getter\n });\n };\n\n if (property.setter) {\n proto.set = function (val) {\n return web3.provider.send({\n method: property.setter,\n params: [val]\n });\n };\n }\n Object.defineProperty(obj, property.name, proto);\n });\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {\n _callbacks: {},\n _events: {},\n providers: {},\n\n /// @returns ascii string representation of hex value prefixed with 0x\n toAscii: utils.toAscii,\n\n /// @returns hex representation (prefixed by 0x) of ascii string\n fromAscii: utils.fromAscii,\n\n /// @returns decimal representaton of hex value prefixed by 0x\n toDecimal: function (val) {\n // remove 0x and place 0, if it's required\n val = val.length > 2 ? val.substring(2) : \"0\";\n return (new BigNumber(val, 16).toString(10));\n },\n\n /// @returns hex representation (prefixed by 0x) of decimal value\n fromDecimal: function (val) {\n return \"0x\" + (new BigNumber(val).toString(16));\n },\n\n /// used to transform value/string to eth string\n toEth: utils.toEth,\n\n /// eth object prototype\n eth: {\n contractFromAbi: function (abi) {\n return function(addr) {\n // Default to address of Config. TODO: rremove prior to genesis.\n addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';\n var ret = web3.eth.contract(addr, abi);\n ret.address = addr;\n return ret;\n };\n },\n\n /// @param filter may be a string, object or event\n /// @param indexed is optional, this is an object with optional event indexed params\n /// @param options is optional, this is an object with optional event options ('max'...)\n watch: function (filter, indexed, options) {\n if (filter._isEvent) {\n return filter(indexed, options);\n }\n return new web3.filter(filter, ethWatch);\n }\n },\n\n /// db object prototype\n db: {},\n\n /// shh object prototype\n shh: {\n \n /// @param filter may be a string, object or event\n watch: function (filter, indexed) {\n return new web3.filter(filter, shhWatch);\n }\n },\n};\n\n/// setups all api methods\nsetupMethods(web3, web3Methods());\nsetupMethods(web3.eth, ethMethods());\nsetupProperties(web3.eth, ethProperties());\nsetupMethods(web3.db, dbMethods());\nsetupMethods(web3.shh, shhMethods());\n\nvar ethWatch = {\n changed: 'eth_changed'\n};\n\nsetupMethods(ethWatch, ethWatchMethods());\n\nvar shhWatch = {\n changed: 'shh_changed'\n};\n\nsetupMethods(shhWatch, shhWatchMethods());\n\nweb3.setProvider = function(provider) {\n web3.provider.set(provider);\n};\n\nmodule.exports = web3;\n\n", + "/*\n This file is part of ethereum.js.\n\n ethereum.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n ethereum.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with ethereum.js. If not, see .\n*/\n/** @file web3.js\n * @authors:\n * Jeffrey Wilcke \n * Marek Kotewicz \n * Marian Oancea \n * Gav Wood \n * @date 2014\n */\n\nif (\"build\" !== 'build') {/*\n var BigNumber = require('bignumber.js');\n*/}\n\nvar utils = require('./utils');\n\n/// @returns an array of objects describing web3 api methods\nvar web3Methods = function () {\n return [\n { name: 'sha3', call: 'web3_sha3' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth api methods\nvar ethMethods = function () {\n var blockCall = function (args) {\n return typeof args[0] === \"string\" ? \"eth_blockByHash\" : \"eth_blockByNumber\";\n };\n\n var transactionCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_transactionByHash' : 'eth_transactionByNumber';\n };\n\n var uncleCall = function (args) {\n return typeof args[0] === \"string\" ? 'eth_uncleByHash' : 'eth_uncleByNumber';\n };\n\n var methods = [\n { name: 'balanceAt', call: 'eth_balanceAt' },\n { name: 'stateAt', call: 'eth_stateAt' },\n { name: 'storageAt', call: 'eth_storageAt' },\n { name: 'countAt', call: 'eth_countAt'},\n { name: 'codeAt', call: 'eth_codeAt' },\n { name: 'transact', call: 'eth_transact' },\n { name: 'call', call: 'eth_call' },\n { name: 'block', call: blockCall },\n { name: 'transaction', call: transactionCall },\n { name: 'uncle', call: uncleCall },\n { name: 'compilers', call: 'eth_compilers' },\n { name: 'flush', call: 'eth_flush' },\n { name: 'lll', call: 'eth_lll' },\n { name: 'solidity', call: 'eth_solidity' },\n { name: 'serpent', call: 'eth_serpent' },\n { name: 'logs', call: 'eth_logs' }\n ];\n return methods;\n};\n\n/// @returns an array of objects describing web3.eth api properties\nvar ethProperties = function () {\n return [\n { name: 'coinbase', getter: 'eth_coinbase', setter: 'eth_setCoinbase' },\n { name: 'listening', getter: 'eth_listening', setter: 'eth_setListening' },\n { name: 'mining', getter: 'eth_mining', setter: 'eth_setMining' },\n { name: 'gasPrice', getter: 'eth_gasPrice' },\n { name: 'accounts', getter: 'eth_accounts' },\n { name: 'peerCount', getter: 'eth_peerCount' },\n { name: 'defaultBlock', getter: 'eth_defaultBlock', setter: 'eth_setDefaultBlock' },\n { name: 'number', getter: 'eth_number'}\n ];\n};\n\n/// @returns an array of objects describing web3.db api methods\nvar dbMethods = function () {\n return [\n { name: 'put', call: 'db_put' },\n { name: 'get', call: 'db_get' },\n { name: 'putString', call: 'db_putString' },\n { name: 'getString', call: 'db_getString' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh api methods\nvar shhMethods = function () {\n return [\n { name: 'post', call: 'shh_post' },\n { name: 'newIdentity', call: 'shh_newIdentity' },\n { name: 'haveIdentity', call: 'shh_haveIdentity' },\n { name: 'newGroup', call: 'shh_newGroup' },\n { name: 'addToGroup', call: 'shh_addToGroup' }\n ];\n};\n\n/// @returns an array of objects describing web3.eth.watch api methods\nvar ethWatchMethods = function () {\n var newFilter = function (args) {\n return typeof args[0] === 'string' ? 'eth_newFilterString' : 'eth_newFilter';\n };\n\n return [\n { name: 'newFilter', call: newFilter },\n { name: 'uninstallFilter', call: 'eth_uninstallFilter' },\n { name: 'getMessages', call: 'eth_filterLogs' }\n ];\n};\n\n/// @returns an array of objects describing web3.shh.watch api methods\nvar shhWatchMethods = function () {\n return [\n { name: 'newFilter', call: 'shh_newFilter' },\n { name: 'uninstallFilter', call: 'shh_uninstallFilter' },\n { name: 'getMessages', call: 'shh_getMessages' }\n ];\n};\n\n/// creates methods in a given object based on method description on input\n/// setups api calls for these methods\nvar setupMethods = function (obj, methods) {\n methods.forEach(function (method) {\n obj[method.name] = function () {\n var args = Array.prototype.slice.call(arguments);\n var call = typeof method.call === 'function' ? method.call(args) : method.call;\n return web3.provider.send({\n method: call,\n params: args\n });\n };\n });\n};\n\n/// creates properties in a given object based on properties description on input\n/// setups api calls for these properties\nvar setupProperties = function (obj, properties) {\n properties.forEach(function (property) {\n var proto = {};\n proto.get = function () {\n return web3.provider.send({\n method: property.getter\n });\n };\n\n if (property.setter) {\n proto.set = function (val) {\n return web3.provider.send({\n method: property.setter,\n params: [val]\n });\n };\n }\n Object.defineProperty(obj, property.name, proto);\n });\n};\n\n/// setups web3 object, and it's in-browser executed methods\nvar web3 = {\n _callbacks: {},\n _events: {},\n providers: {},\n\n /// @returns ascii string representation of hex value prefixed with 0x\n toAscii: utils.toAscii,\n\n /// @returns hex representation (prefixed by 0x) of ascii string\n fromAscii: utils.fromAscii,\n\n /// @returns decimal representaton of hex value prefixed by 0x\n toDecimal: function (val) {\n // remove 0x and place 0, if it's required\n val = val.length > 2 ? val.substring(2) : \"0\";\n return (new BigNumber(val, 16).toString(10));\n },\n\n /// @returns hex representation (prefixed by 0x) of decimal value\n fromDecimal: function (val) {\n return \"0x\" + (new BigNumber(val).toString(16));\n },\n\n /// used to transform value/string to eth string\n toEth: utils.toEth,\n\n /// eth object prototype\n eth: {\n contractFromAbi: function (abi) {\n return function(addr) {\n // Default to address of Config. TODO: rremove prior to genesis.\n addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';\n var ret = web3.eth.contract(addr, abi);\n ret.address = addr;\n return ret;\n };\n },\n\n canary: function (abi) {\n return function(addr) {\n // Default to address of Config. TODO: rremove prior to genesis.\n addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b';\n return addr;\n };\n },\n\n /// @param filter may be a string, object or event\n /// @param indexed is optional, this is an object with optional event indexed params\n /// @param options is optional, this is an object with optional event options ('max'...)\n watch: function (filter, indexed, options) {\n if (filter._isEvent) {\n return filter(indexed, options);\n }\n return new web3.filter(filter, ethWatch);\n }\n },\n\n /// db object prototype\n db: {},\n\n /// shh object prototype\n shh: {\n \n /// @param filter may be a string, object or event\n watch: function (filter, indexed) {\n return new web3.filter(filter, shhWatch);\n }\n },\n};\n\n/// setups all api methods\nsetupMethods(web3, web3Methods());\nsetupMethods(web3.eth, ethMethods());\nsetupProperties(web3.eth, ethProperties());\nsetupMethods(web3.db, dbMethods());\nsetupMethods(web3.shh, shhMethods());\n\nvar ethWatch = {\n changed: 'eth_changed'\n};\n\nsetupMethods(ethWatch, ethWatchMethods());\n\nvar shhWatch = {\n changed: 'shh_changed'\n};\n\nsetupMethods(shhWatch, shhWatchMethods());\n\nweb3.setProvider = function(provider) {\n web3.provider.set(provider);\n};\n\nmodule.exports = web3;\n\n", "var web3 = require('./lib/web3');\nvar ProviderManager = require('./lib/providermanager');\nweb3.provider = new ProviderManager();\nweb3.filter = require('./lib/filter');\nweb3.providers.HttpSyncProvider = require('./lib/httpsync');\nweb3.providers.QtSyncProvider = require('./lib/qtsync');\nweb3.eth.contract = require('./lib/contract');\nweb3.abi = require('./lib/abi');\n\n\nmodule.exports = web3;\n" ] } \ No newline at end of file diff --git a/libjsqrc/ethereumjs/dist/ethereum.min.js b/libjsqrc/ethereumjs/dist/ethereum.min.js index df408d3e4..8f0ddb5a1 100644 --- a/libjsqrc/ethereumjs/dist/ethereum.min.js +++ b/libjsqrc/ethereumjs/dist/ethereum.min.js @@ -1 +1 @@ -require=function t(e,n,r){function i(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;av;v++)g.push(h(e.slice(0,r))),e=e.slice(r);n.push(g)}else i.prefixedType("string")(t[f].type)?(c=c.slice(r),n.push(h(e.slice(0,r))),e=e.slice(r)):(n.push(h(e.slice(0,r))),e=e.slice(r))}),n},d=function(t){var e={};return t.forEach(function(t){var n=r.extractDisplayName(t.name),i=r.extractTypeName(t.name),o=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[n]&&(e[n]=o),e[n][i]=o}),e},g=function(t){var e={};return t.forEach(function(t){var n=r.extractDisplayName(t.name),i=r.extractTypeName(t.name),o=function(e){return h(t.outputs,e)};void 0===e[n]&&(e[n]=o),e[n][i]=o}),e},v=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*o.ETH_SIGNATURE_LENGTH)},y=function(t){return n.sha3(n.fromAscii(t))};e.exports={inputParser:d,outputParser:g,formatInput:l,formatOutput:h,signatureFromAscii:v,eventSignatureFromAscii:y}},{"./const":2,"./formatters":6,"./types":11,"./utils":12,"./web3":13}],2:[function(t,e){var n=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:n,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN}}},{}],3:[function(t,e){var n=t("./web3"),r=t("./abi"),i=t("./utils"),o=t("./event"),a=function(t){n._currentContractAbi=t.abi,n._currentContractAddress=t.address,n._currentContractMethodName=t.method,n._currentContractMethodParams=t.params},u=function(t){t.call=function(e){return t._isTransact=!1,t._options=e,t},t.transact=function(e){return t._isTransact=!0,t._options=e,t},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},s=function(t,e,o){var u=r.inputParser(e),s=r.outputParser(e);i.filterFunctions(e).forEach(function(f){var c=i.extractDisplayName(f.name),l=i.extractTypeName(f.name),p=function(){var i=Array.prototype.slice.call(arguments),p=r.signatureFromAscii(f.name),m=u[c][l].apply(null,i),h=t._options||{};h.to=o,h.data=p+m;var d=t._isTransact===!0||t._isTransact!==!1&&!f.constant,g=h.collapse!==!1;if(t._options={},t._isTransact=null,d)return a({abi:e,address:o,method:f.name,params:i}),void n.eth.transact(h);var v=n.eth.call(h),y=s[c][l](v);return g&&(1===y.length?y=y[0]:0===y.length&&(y=null)),y};void 0===t[c]&&(t[c]=p),t[c][l]=p})},f=function(t,e,n){t.address=n,t._onWatchEventResult=function(t){var n=event.getMatchingEvent(i.filterEvents(e)),r=o.outputParser(n);return r(t)},Object.defineProperty(t,"topic",{get:function(){return i.filterEvents(e).map(function(t){return r.eventSignatureFromAscii(t.name)})}})},c=function(t,e,a){i.filterEvents(e).forEach(function(e){var u=function(){var t=Array.prototype.slice.call(arguments),i=r.eventSignatureFromAscii(e.name),u=o.inputParser(a,i,e),s=u.apply(null,t);return s._onWatchEventResult=function(t){var n=o.outputParser(e);return n(t)},n.eth.watch(s)};u._isEvent=!0;var s=i.extractDisplayName(e.name),f=i.extractTypeName(e.name);void 0===t[s]&&(t[s]=u),t[s][f]=u})},l=function(t,e){e.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var n={};return u(n),s(n,e,t),f(n,e,t),c(n,e,t),n};e.exports=l},{"./abi":1,"./event":4,"./utils":12,"./web3":13}],4:[function(t,e){var n=t("./abi"),r=t("./utils"),i=function(t,e){return t.filter(function(t){return t.indexed===e})},o=function(t,e){var n=r.findIndex(t,function(t){return t.name===e});return-1===n?void console.error("indexed param with name "+e+" not found"):t[n]},a=function(t,e){return Object.keys(e).map(function(r){var a=[o(i(t.inputs,!0),r)],u=e[r];return u instanceof Array?u.map(function(t){return n.formatInput(a,[t])}):n.formatInput(a,[u])})},u=function(t,e,n){return function(r,i){var o=i||{};return o.address=t,o.topic=[],o.topic.push(e),r&&(o.topic=o.topic.concat(a(n,r))),o}},s=function(t,e,n){e.slice(),n.slice();return t.reduce(function(t,r){var i;return i=r.indexed?e.splice(0,1)[0]:n.splice(0,1)[0],t[r.name]=i,t},{})},f=function(t){return function(e){var o={event:r.extractDisplayName(t.name),number:e.number,args:{}};if(!e.topic)return o;var a=i(t.inputs,!0),u="0x"+e.topic.slice(1,e.topic.length).map(function(t){return t.slice(2)}).join(""),f=n.formatOutput(a,u),c=i(t.inputs,!1),l=n.formatOutput(c,e.data);return o.args=s(t.inputs,f,l),o}},c=function(t,e){for(var r=0;rn;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},o=function(t){for(var e="",n=0;n3e3&&r2?t.substring(2):"0",new BigNumber(t,16).toString(10)},fromDecimal:function(t){return"0x"+new BigNumber(t).toString(16)},toEth:n.toEth,eth:{contractFromAbi:function(t){return function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=p.eth.contract(e,t);return n.address=e,n}},watch:function(t,e,n){return t._isEvent?t(e,n):new p.filter(t,m)}},db:{},shh:{watch:function(t){return new p.filter(t,h)}}};c(p,r()),c(p.eth,i()),l(p.eth,o()),c(p.db,a()),c(p.shh,u());var m={changed:"eth_changed"};c(m,s());var h={changed:"shh_changed"};c(h,f()),p.setProvider=function(t){p.provider.set(t)},e.exports=p},{"./utils":12}],web3:[function(t,e){var n=t("./lib/web3"),r=t("./lib/providermanager");n.provider=new r,n.filter=t("./lib/filter"),n.providers.HttpSyncProvider=t("./lib/httpsync"),n.providers.QtSyncProvider=t("./lib/qtsync"),n.eth.contract=t("./lib/contract"),n.abi=t("./lib/abi"),e.exports=n},{"./lib/abi":1,"./lib/contract":3,"./lib/filter":5,"./lib/httpsync":7,"./lib/providermanager":9,"./lib/qtsync":10,"./lib/web3":13}]},{},["web3"]); \ No newline at end of file +require=function t(e,n,r){function i(a,u){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;av;v++)g.push(h(e.slice(0,r))),e=e.slice(r);n.push(g)}else i.prefixedType("string")(t[f].type)?(c=c.slice(r),n.push(h(e.slice(0,r))),e=e.slice(r)):(n.push(h(e.slice(0,r))),e=e.slice(r))}),n},d=function(t){var e={};return t.forEach(function(t){var n=r.extractDisplayName(t.name),i=r.extractTypeName(t.name),o=function(){var e=Array.prototype.slice.call(arguments);return l(t.inputs,e)};void 0===e[n]&&(e[n]=o),e[n][i]=o}),e},g=function(t){var e={};return t.forEach(function(t){var n=r.extractDisplayName(t.name),i=r.extractTypeName(t.name),o=function(e){return h(t.outputs,e)};void 0===e[n]&&(e[n]=o),e[n][i]=o}),e},v=function(t){return n.sha3(n.fromAscii(t)).slice(0,2+2*o.ETH_SIGNATURE_LENGTH)},y=function(t){return n.sha3(n.fromAscii(t))};e.exports={inputParser:d,outputParser:g,formatInput:l,formatOutput:h,signatureFromAscii:v,eventSignatureFromAscii:y}},{"./const":2,"./formatters":6,"./types":11,"./utils":12,"./web3":13}],2:[function(t,e){var n=["wei","Kwei","Mwei","Gwei","szabo","finney","ether","grand","Mether","Gether","Tether","Pether","Eether","Zether","Yether","Nether","Dether","Vether","Uether"];e.exports={ETH_PADDING:32,ETH_SIGNATURE_LENGTH:4,ETH_UNITS:n,ETH_BIGNUMBER_ROUNDING_MODE:{ROUNDING_MODE:BigNumber.ROUND_DOWN}}},{}],3:[function(t,e){var n=t("./web3"),r=t("./abi"),i=t("./utils"),o=t("./event"),a=function(t){n._currentContractAbi=t.abi,n._currentContractAddress=t.address,n._currentContractMethodName=t.method,n._currentContractMethodParams=t.params},u=function(t){t.call=function(e){return t._isTransact=!1,t._options=e,t},t.transact=function(e){return t._isTransact=!0,t._options=e,t},t._options={},["gas","gasPrice","value","from"].forEach(function(e){t[e]=function(n){return t._options[e]=n,t}})},s=function(t,e,o){var u=r.inputParser(e),s=r.outputParser(e);i.filterFunctions(e).forEach(function(f){var c=i.extractDisplayName(f.name),l=i.extractTypeName(f.name),p=function(){var i=Array.prototype.slice.call(arguments),p=r.signatureFromAscii(f.name),m=u[c][l].apply(null,i),h=t._options||{};h.to=o,h.data=p+m;var d=t._isTransact===!0||t._isTransact!==!1&&!f.constant,g=h.collapse!==!1;if(t._options={},t._isTransact=null,d)return a({abi:e,address:o,method:f.name,params:i}),void n.eth.transact(h);var v=n.eth.call(h),y=s[c][l](v);return g&&(1===y.length?y=y[0]:0===y.length&&(y=null)),y};void 0===t[c]&&(t[c]=p),t[c][l]=p})},f=function(t,e,n){t.address=n,t._onWatchEventResult=function(t){var n=event.getMatchingEvent(i.filterEvents(e)),r=o.outputParser(n);return r(t)},Object.defineProperty(t,"topic",{get:function(){return i.filterEvents(e).map(function(t){return r.eventSignatureFromAscii(t.name)})}})},c=function(t,e,a){i.filterEvents(e).forEach(function(e){var u=function(){var t=Array.prototype.slice.call(arguments),i=r.eventSignatureFromAscii(e.name),u=o.inputParser(a,i,e),s=u.apply(null,t);return s._onWatchEventResult=function(t){var n=o.outputParser(e);return n(t)},n.eth.watch(s)};u._isEvent=!0;var s=i.extractDisplayName(e.name),f=i.extractTypeName(e.name);void 0===t[s]&&(t[s]=u),t[s][f]=u})},l=function(t,e){e.forEach(function(t){if(-1===t.name.indexOf("(")){var e=t.name,n=t.inputs.map(function(t){return t.type}).join();t.name=e+"("+n+")"}});var n={};return u(n),s(n,e,t),f(n,e,t),c(n,e,t),n};e.exports=l},{"./abi":1,"./event":4,"./utils":12,"./web3":13}],4:[function(t,e){var n=t("./abi"),r=t("./utils"),i=function(t,e){return t.filter(function(t){return t.indexed===e})},o=function(t,e){var n=r.findIndex(t,function(t){return t.name===e});return-1===n?void console.error("indexed param with name "+e+" not found"):t[n]},a=function(t,e){return Object.keys(e).map(function(r){var a=[o(i(t.inputs,!0),r)],u=e[r];return u instanceof Array?u.map(function(t){return n.formatInput(a,[t])}):n.formatInput(a,[u])})},u=function(t,e,n){return function(r,i){var o=i||{};return o.address=t,o.topic=[],o.topic.push(e),r&&(o.topic=o.topic.concat(a(n,r))),o}},s=function(t,e,n){e.slice(),n.slice();return t.reduce(function(t,r){var i;return i=r.indexed?e.splice(0,1)[0]:n.splice(0,1)[0],t[r.name]=i,t},{})},f=function(t){return function(e){var o={event:r.extractDisplayName(t.name),number:e.number,args:{}};if(!e.topic)return o;var a=i(t.inputs,!0),u="0x"+e.topic.slice(1,e.topic.length).map(function(t){return t.slice(2)}).join(""),f=n.formatOutput(a,u),c=i(t.inputs,!1),l=n.formatOutput(c,e.data);return o.args=s(t.inputs,f,l),o}},c=function(t,e){for(var r=0;rn;n+=2){var i=parseInt(t.substr(n,2),16);if(0===i)break;e+=String.fromCharCode(i)}return e},o=function(t){for(var e="",n=0;n3e3&&r2?t.substring(2):"0",new BigNumber(t,16).toString(10)},fromDecimal:function(t){return"0x"+new BigNumber(t).toString(16)},toEth:n.toEth,eth:{contractFromAbi:function(t){return function(e){e=e||"0xc6d9d2cd449a754c494264e1809c50e34d64562b";var n=p.eth.contract(e,t);return n.address=e,n}},canary:function(){return function(t){return t=t||"0xc6d9d2cd449a754c494264e1809c50e34d64562b"}},watch:function(t,e,n){return t._isEvent?t(e,n):new p.filter(t,m)}},db:{},shh:{watch:function(t){return new p.filter(t,h)}}};c(p,r()),c(p.eth,i()),l(p.eth,o()),c(p.db,a()),c(p.shh,u());var m={changed:"eth_changed"};c(m,s());var h={changed:"shh_changed"};c(h,f()),p.setProvider=function(t){p.provider.set(t)},e.exports=p},{"./utils":12}],web3:[function(t,e){var n=t("./lib/web3"),r=t("./lib/providermanager");n.provider=new r,n.filter=t("./lib/filter"),n.providers.HttpSyncProvider=t("./lib/httpsync"),n.providers.QtSyncProvider=t("./lib/qtsync"),n.eth.contract=t("./lib/contract"),n.abi=t("./lib/abi"),e.exports=n},{"./lib/abi":1,"./lib/contract":3,"./lib/filter":5,"./lib/httpsync":7,"./lib/providermanager":9,"./lib/qtsync":10,"./lib/web3":13}]},{},["web3"]); \ No newline at end of file diff --git a/libjsqrc/ethereumjs/lib/web3.js b/libjsqrc/ethereumjs/lib/web3.js index 41df75051..9c7eb6824 100644 --- a/libjsqrc/ethereumjs/lib/web3.js +++ b/libjsqrc/ethereumjs/lib/web3.js @@ -205,6 +205,14 @@ var web3 = { }; }, + canary: function (abi) { + return function(addr) { + // Default to address of Config. TODO: rremove prior to genesis. + addr = addr || '0xc6d9d2cd449a754c494264e1809c50e34d64562b'; + return addr; + }; + }, + /// @param filter may be a string, object or event /// @param indexed is optional, this is an object with optional event indexed params /// @param options is optional, this is an object with optional event options ('max'...) From a22208b03424a1e24b332596096c49ff3729ef8d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 005/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 48 +++++++++++++++++++++++ libethcore/CommonEth.cpp | 2 +- libethereum/CachedAddressState.cpp | 6 +-- libethereum/CachedAddressState.h | 3 ++ libethereum/CanonBlockChain.cpp | 2 +- libethereum/State.cpp | 63 +++++++++++++----------------- libethereum/State.h | 9 ++--- mix/MixClient.cpp | 2 +- 8 files changed, 88 insertions(+), 47 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f5b7ff9c9..c08199e06 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -325,6 +325,54 @@ std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) return _out; } +template +class SecureGenericTrieDB: private TrieDB +{ + using Super = TrieDB; + +public: + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + using Super::open; + using Super::init; + using Super::setRoot; + using Super::haveRoot; + + /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). + using Super::isNull; + /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). + using Super::isEmpty; + + using Super::root; + + using Super::leftOvers; + using Super::check; + + std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } + void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } +}; + +template +class SecureTrieDB: public SecureGenericTrieDB +{ + using Super = SecureGenericTrieDB; + +public: + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + std::string operator[](KeyType _k) const { return at(_k); } + + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } +}; + } // Template implementations... diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 2264e6ec9..8facdf0f1 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 54; +const unsigned c_protocolVersion = 55; const unsigned c_databaseVersion = 5; vector> const& units() diff --git a/libethereum/CachedAddressState.cpp b/libethereum/CachedAddressState.cpp index 5f9be6944..e2fadc8b5 100644 --- a/libethereum/CachedAddressState.cpp +++ b/libethereum/CachedAddressState.cpp @@ -56,9 +56,9 @@ std::map CachedAddressState::storage() const std::map ret; if (m_r) { - TrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - ret[j.first] = RLP(j.second).toInt(); + SecureTrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) +// for (auto const& j: memdb) +// ret[j.first] = RLP(j.second).toInt(); } if (m_s) for (auto const& j: m_s->storageOverlay()) diff --git a/libethereum/CachedAddressState.h b/libethereum/CachedAddressState.h index 301f54338..8a3c3a607 100644 --- a/libethereum/CachedAddressState.h +++ b/libethereum/CachedAddressState.h @@ -45,7 +45,10 @@ public: u256 balance() const; u256 nonce() const; bytes code() const; + + // TODO: DEPRECATE. std::map storage() const; + AccountDiff diff(CachedAddressState const& _c); private: diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index b0fe90a78..29fdc9acc 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -76,7 +76,7 @@ bytes CanonBlockChain::createGenesisBlock() h256 stateRoot; { MemoryDB db; - TrieDB state(&db); + SecureTrieDB state(&db); state.init(); dev::eth::commit(genesisState(), db, state); stateRoot = state.root(); diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 76ad1f269..917239351 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -168,18 +168,6 @@ State::~State() { } -Address State::nextActiveAddress(Address _a) const -{ - auto it = m_state.lower_bound(_a); - if ((*it).first == _a) - ++it; - if (it == m_state.end()) - // exchange comments if we want to wraparound -// it = m_state.begin(); - return Address(); - return (*it).first; -} - StateDiff State::diff(State const& _c) const { StateDiff ret; @@ -188,13 +176,14 @@ StateDiff State::diff(State const& _c) const std::set
trieAds; std::set
trieAdsD; - auto trie = TrieDB(const_cast(&m_db), rootHash()); - auto trieD = TrieDB(const_cast(&_c.m_db), _c.rootHash()); + auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); + auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -356,9 +345,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -591,9 +581,10 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) { cwarn << "Bad state root!"; cnote << "Given to be:" << m_currentBlock.stateRoot; - cnote << TrieDB(&m_db, m_currentBlock.stateRoot); + // TODO: Fix +// cnote << SecureTrieDB(&m_db, m_currentBlock.stateRoot); cnote << "Calculated to be:" << rootHash(); - cnote << m_state; +// cnote << m_state; cnote << *this; // Rollback the trie. m_db.rollback(); @@ -932,7 +923,7 @@ u256 State::storage(Address _id, u256 _memory) const return mit->second; // Not in the storage cache - go to the DB. - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) string payload = memdb.at(_memory); u256 ret = payload.size() ? RLP(payload).toInt() : 0; it->second.setStorage(_memory, ret); @@ -950,9 +941,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1003,24 +995,24 @@ bool State::isTrieGood(bool _enforceRefs, bool _requireNoLeftOvers) const cwarn << "LEFTOVERS" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << "Left:" << lo; cnote << "Keys:" << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } // TODO: Enable once fixed. - for (auto const& i: m_state) +/* for (auto const& i: m_state) { RLP r(i.second); - TrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. + SecureTrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. for (auto const& j: storageDB) { (void)j; } if (!e && r[3].toHash() != EmptySHA3 && m_db.lookup(r[3].toHash()).empty()) return false; - } + }*/ } catch (InvalidTrie const&) { cwarn << "BAD TRIE" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } return true; @@ -1187,9 +1179,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) std::set cached; if (r) { - TrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index 813141d17..37af0cf0e 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -94,9 +94,6 @@ public: /// @returns the set containing all addresses currently in use in Ethereum. std::map addresses() const; - /// @returns the address b such that b > @a _a . - Address nextActiveAddress(Address _a) const; - /// Get the header information on the present block. BlockInfo const& info() const { return m_currentBlock; } @@ -299,7 +296,7 @@ private: void paranoia(std::string const& _when, bool _enforceRefs = false) const; OverlayDB m_db; ///< Our overlay for the state tree. - TrieDB m_state; ///< Our state tree, as an OverlayDB DB. + SecureTrieDB m_state; ///< Our state tree, as an OverlayDB DB. Transactions m_transactions; ///< The current list of transactions that we've included in the state. TransactionReceipts m_receipts; ///< The corresponding list of transaction receipts. std::set m_transactionSet; ///< The set of transaction hashes that we've included in the state. @@ -328,7 +325,7 @@ private: std::ostream& operator<<(std::ostream& _out, State const& _s); template -void commit(std::map const& _cache, DB& _db, TrieDB& _state) +void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) if (!i.second.isAlive()) @@ -345,7 +342,7 @@ void commit(std::map const& _cache, DB& _db, TrieDB storageDB(&_db, i.second.baseRoot()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); for (auto const& j: i.second.storageOverlay()) if (j.second) storageDB.insert(j.first, rlp(j.second)); diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index a78bc017d..f9ef19ff9 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -79,7 +79,7 @@ void MixClient::resetState(u256 _balance) m_watches.clear(); m_stateDB = OverlayDB(); - TrieDB accountState(&m_stateDB); + SecureTrieDB accountState(&m_stateDB); accountState.init(); std::map genesisState = { std::make_pair(KeyPair(c_userAccountSecret).address(), Account(_balance, Account::NormalCreation)) }; dev::eth::commit(genesisState, static_cast(m_stateDB), accountState); From e9e310822b65e82e8ad66389493c52832478092e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 006/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 6 +- libdevcrypto/MemoryDB.cpp | 2 +- libdevcrypto/MemoryDB.h | 4 ++ libdevcrypto/TrieDB.h | 123 +++++++++++++++++++++++++------------- test/trie.cpp | 44 +++++++++++++- 5 files changed, 130 insertions(+), 49 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 2b4e6bc08..24fac9c0a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -53,7 +53,7 @@ public: enum ConstructFromStringType { FromHex, FromBinary }; /// Method to convert from a string. - enum ConstructFromHashType { AlignLeft, AlignRight }; + enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent }; /// Construct an empty hash. FixedHash() { m_data.fill(0); } @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.cpp b/libdevcrypto/MemoryDB.cpp index 4fc4ed9ad..56b77ddee 100644 --- a/libdevcrypto/MemoryDB.cpp +++ b/libdevcrypto/MemoryDB.cpp @@ -107,7 +107,7 @@ set MemoryDB::keys() const { set ret; for (auto const& i: m_refCount) - if (i.second) + if (i.second && h128(i.first.ref().cropped(0, 16))) ret.insert(i.first); return ret; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 4b8d3b3a2..816e393a3 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -26,6 +26,7 @@ #include #include #include +#include "SHA3.h" namespace dev { @@ -50,6 +51,9 @@ public: bool kill(h256 _h); void purge(); + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + std::set keys() const; protected: diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index c08199e06..676193112 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -62,17 +62,21 @@ extern const h256 EmptyTrie; * assert(t.isEmpty()); * @endcode */ -template +template class GenericTrieDB { public: + using DB = _DB; + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} + void open(DB* _db) { m_db = _db; } void open(DB* _db, h256 _root) { m_db = _db; setRoot(_root); } - void init(); + void init() { setRoot(insertNode(&RLPNull)); assert(node(m_root).size()); } + void setRoot(h256 _root) { m_root = _root; @@ -83,7 +87,6 @@ public: if (!node(m_root).size()) BOOST_THROW_EXCEPTION(RootNotFound()); } - bool haveRoot(h256 _root, bool _enforceRefs = true) { return _root == c_shaNull ? true : m_db->lookup(_root, _enforceRefs).size(); } /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). bool isNull() const { return !node(m_root).size(); } @@ -211,6 +214,9 @@ public: iterator lower_bound(bytesConstRef _key) const { return iterator(this, _key); } +protected: + DB* db() const { return m_db; } + private: RLPStream& streamNode(RLPStream& _s, bytes const& _b); @@ -281,30 +287,33 @@ std::ostream& operator<<(std::ostream& _out, GenericTrieDB const& _db) return _out; } -template -class TrieDB: public GenericTrieDB +template +class SpecificTrieDB: public Generic { public: - TrieDB(DB* _db): GenericTrieDB(_db) {} - TrieDB(DB* _db, h256 _root): GenericTrieDB(_db, _root) {} + using DB = typename Generic::DB; + using KeyType = _KeyType; + + SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } - bool contains(KeyType _k) const { return GenericTrieDB::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return GenericTrieDB::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { GenericTrieDB::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + bool contains(KeyType _k) const { return Generic::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Generic::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Generic::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { GenericTrieDB::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void remove(KeyType _k) { Generic::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - class iterator: public GenericTrieDB::iterator + class iterator: public Generic::iterator { public: - using Super = typename GenericTrieDB::iterator; + using Super = typename Generic::iterator; using value_type = std::pair; iterator() {} - iterator(TrieDB const* _db): Super(_db) {} - iterator(TrieDB const* _db, bytesConstRef _k): Super(_db, _k) {} + iterator(Generic const* _db): Super(_db) {} + iterator(Generic const* _db, bytesConstRef _k): Super(_db, _k) {} value_type operator*() const { return at(); } value_type operator->() const { return at(); } @@ -317,27 +326,28 @@ public: iterator lower_bound(KeyType _k) const { return iterator(this, bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template -std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) +template +std::ostream& operator<<(std::ostream& _out, SpecificTrieDB const& _db) { for (auto const& i: _db) _out << i.first << ": " << escaped(i.second.toString(), false) << std::endl; return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -350,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... @@ -641,7 +685,7 @@ template void GenericTrieDB::iterator::next() } } -template typename TrieDB::iterator::value_type TrieDB::iterator::at() const +template typename SpecificTrieDB::iterator::value_type SpecificTrieDB::iterator::at() const { auto p = Super::at(); value_type ret; @@ -651,13 +695,6 @@ template typename TrieDB::iterator::value return ret; } -template void GenericTrieDB::init() -{ - m_root = insertNode(&RLPNull); -// std::cout << "Initialised root to " << m_root << std::endl; - assert(node(m_root).size()); -} - template void GenericTrieDB::insert(bytesConstRef _key, bytesConstRef _value) { #if ETH_PARANOIA diff --git a/test/trie.cpp b/test/trie.cpp index 39a3a59a5..4b676fb9a 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -48,6 +48,8 @@ static unsigned fac(unsigned _i) } } +using dev::operator <<; + BOOST_AUTO_TEST_SUITE(TrieTests) BOOST_AUTO_TEST_CASE(trie_test_anyorder) @@ -79,15 +81,35 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) next_permutation(ss.begin(), ss.end()); MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); for (auto const& k: ss) { t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } } } @@ -139,15 +161,33 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) { if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); + t.remove(k.first), ht.remove(k.first), ft.remove(k.first); else - t.insert(k.first, k.second); + t.insert(k.first, k.second), ht.insert(k.first, k.second), ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); From f661289cf35586b67b0146195d246e9fb7adbca2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 007/313] FatDB integrated. --- CMakeLists.txt | 7 ++++++- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/CommonEth.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cd7a80c4..156d0e5c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ function(createDefaultCacheConfig) set(PARANOIA OFF CACHE BOOL "Additional run-time checks") set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") + set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") endfunction() @@ -44,6 +45,10 @@ function(configureProject) add_definitions(-DETH_EVMJIT) endif() + if (FATDB) + add_definitions(-DETH_FATDB) + endif() + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() @@ -110,7 +115,7 @@ cmake_policy(SET CMP0015 NEW) createDefaultCacheConfig() configureProject() message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") -message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}") +message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}; FATDB: ${FATDB}") # Default TARGET_PLATFORM to "linux". diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 676193112..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 8facdf0f1..eba10e321 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 917239351..6aedc4c24 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -179,11 +179,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,10 +344,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -941,10 +939,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1180,9 +1177,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From bae383f617baefc5e1e9c3dd0f8b0b66337e2736 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 008/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 47 ++++++++++++++++------------ libdevcore/FixedHash.h | 6 ++-- libdevcore/vector_ref.h | 2 +- libdevcrypto/MemoryDB.h | 8 +++-- libdevcrypto/OverlayDB.cpp | 13 ++++++++ libdevcrypto/OverlayDB.h | 2 ++ libdevcrypto/TrieDB.h | 2 +- libethcore/CommonEth.cpp | 2 +- libethereum/Account.h | 36 ++++++++++++++++------ libethereum/BlockChain.cpp | 15 ++++++--- libethereum/State.cpp | 8 ++--- libethereum/State.h | 63 ++++++++++++++++++++------------------ test/CMakeLists.txt | 2 +- test/stateOriginal.cpp | 36 ++++++++++++++++------ test/trie.cpp | 20 ++++++++++++ 15 files changed, 177 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 156d0e5c5..ba25e74ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() @@ -153,8 +154,11 @@ if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) endif () add_subdirectory(libsolidity) -add_subdirectory(lllc) -add_subdirectory(solc) + +if (NOT JUSTTESTS) + add_subdirectory(lllc) + add_subdirectory(solc) +endif() if (JSONRPC) add_subdirectory(libweb3jsonrpc) @@ -171,25 +175,30 @@ add_subdirectory(libethereum) add_subdirectory(libwebthree) add_subdirectory(test) -add_subdirectory(eth) -if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") - add_subdirectory(exp) -endif () +if (NOT JUSTTESTS) -# TODO check msvc -if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) - add_subdirectory(neth) -endif () + add_subdirectory(eth) + + if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") + add_subdirectory(exp) + endif () + + # TODO check msvc + if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) + add_subdirectory(neth) + endif () + + if (NOT HEADLESS) + + add_subdirectory(libnatspec) + add_subdirectory(libjsqrc) + add_subdirectory(alethzero) + add_subdirectory(third) + add_subdirectory(mix) + + endif() -if (NOT HEADLESS) - - add_subdirectory(libnatspec) - add_subdirectory(libjsqrc) - add_subdirectory(alethzero) - add_subdirectory(third) - add_subdirectory(mix) - endif() enable_testing() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 24fac9c0a..3113b5427 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,16 +65,16 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } /// Explicitly construct, copying from a string. - explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s)) {} + explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s), _ht) {} /// Convert to arithmetic type. operator Arith() const { return fromBigEndian(m_data); } diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index 42633f6f1..2c5f07e51 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -23,7 +23,7 @@ public: vector_ref(typename std::conditional::value, std::vector::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} vector_ref(typename std::conditional::value, std::string const&, std::string&>::type _data): m_data((_T*)_data.data()), m_count(_data.size() / sizeof(_T)) {} #ifdef STORAGE_LEVELDB_INCLUDE_DB_H_ - vector_ref(leveldb::Slice const& _s): m_data(_s.data()), m_count(_s.size() / sizeof(_T)) {} + vector_ref(leveldb::Slice const& _s): m_data(reinterpret_cast<_T*>(_s.data())), m_count(_s.size() / sizeof(_T)) {} #endif explicit operator bool() const { return m_data && m_count; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 816e393a3..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,14 +51,18 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; protected: + static h256 aux(h256 _k) { return h256(sha3(_k).ref().cropped(0, 24), h256::AlignLeft); } + std::map m_over; std::map m_refCount; + h256 m_auxKey; + std::map m_aux; mutable bool m_enforceRefs = false; }; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 9e110bb84..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -19,6 +19,7 @@ * @date 2014 */ +#include #include #include "OverlayDB.h" using namespace std; @@ -51,11 +52,23 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } } +bytes OverlayDB::lookupAux(h256 _h) const +{ + bytes ret = MemoryDB::lookupAux(_h); + if (!ret.empty()) + return ret; + std::string v; + m_db->Get(m_readOptions, _h.ref(), &v); + return asBytes(v); +} + void OverlayDB::rollback() { m_over.clear(); diff --git a/libdevcrypto/OverlayDB.h b/libdevcrypto/OverlayDB.h index e9bd53343..d027afbd4 100644 --- a/libdevcrypto/OverlayDB.h +++ b/libdevcrypto/OverlayDB.h @@ -51,6 +51,8 @@ public: bool exists(h256 _h) const; void kill(h256 _h); + bytes lookupAux(h256 _h) const; + private: using MemoryDB::clear; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..348cab59e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index eba10e321..ad41780e9 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/Account.h b/libethereum/Account.h index 3f3a5d548..2cc962baa 100644 --- a/libethereum/Account.h +++ b/libethereum/Account.h @@ -76,28 +76,40 @@ public: ContractConception }; + /// Changedness of account to create. + enum Changedness + { + /// Account starts as though it has been changed. + Changed, + /// Account starts as though it has not been changed. + Unchanged + }; + /// Construct a dead Account. Account() {} /// Construct an alive Account, with given endowment, for either a normal (non-contract) account or for a /// contract account in the /// conception phase, where the code is not yet known. - Account(u256 _balance, NewAccountType _t): m_isAlive(true), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} + Account(u256 _balance, NewAccountType _t, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} /// Explicit constructor for wierd cases of construction of a normal account. - Account(u256 _nonce, u256 _balance): m_isAlive(true), m_nonce(_nonce), m_balance(_balance) {} + Account(u256 _nonce, u256 _balance, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance) {} /// Explicit constructor for wierd cases of construction or a contract account. - Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash): m_isAlive(true), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } + Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash, Changedness _c): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } /// Kill this account. Useful for the suicide opcode. Following this call, isAlive() returns false. - void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; } + void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; changed(); } /// @returns true iff this object represents an account in the state. Returns false if this object /// represents an account that should no longer exist in the trie (an account that never existed or was /// suicided). bool isAlive() const { return m_isAlive; } + /// @returns true if the account is unchanged from creation. + bool isDirty() const { return !m_isUnchanged; } + /// @returns the balance of this account. Can be altered in place. u256& balance() { return m_balance; } @@ -106,7 +118,7 @@ public: u256 const& balance() const { return m_balance; } /// Increments the balance of this account by the given amount. It's a bigint, so can be negative. - void addBalance(bigint _i) { m_balance = (u256)((bigint)m_balance + _i); } + void addBalance(bigint _i) { if (!_i) return; m_balance = (u256)((bigint)m_balance + _i); changed(); } /// @returns the nonce of the account. Can be altered in place. u256& nonce() { return m_nonce; } @@ -115,7 +127,7 @@ public: u256 const& nonce() const { return m_nonce; } /// Increment the nonce of the account by one. - void incNonce() { m_nonce++; } + void incNonce() { m_nonce++; changed(); } /// @returns the root of the trie (whose nodes are stored in the state db externally to this class) @@ -127,7 +139,7 @@ public: /// Set a key/value pair in the account's storage. This actually goes into the overlay, for committing /// to the trie later. - void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; } + void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; changed(); } /// @returns true if we are in the contract-conception state and setCode is valid to call. bool isFreshCode() const { return m_codeHash == c_contractConceptionCodeHash; } @@ -140,8 +152,8 @@ public: h256 codeHash() const { assert(!isFreshCode()); return m_codeHash; } /// Sets the code of the account. Must only be called when isFreshCode() returns true. - void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; } - void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; } + void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } + void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } /// @returns true if the account's code is available through code(). bool codeCacheValid() const { return m_codeHash == EmptySHA3 || m_codeHash == c_contractConceptionCodeHash || m_codeCache.size(); } @@ -154,9 +166,15 @@ public: bytes const& code() const { assert(codeCacheValid()); return m_codeCache; } private: + /// Note that we've altered the account. + void changed() { m_isUnchanged = false; } + /// Is this account existant? If not, it represents a deleted account. bool m_isAlive = false; + /// True if we've not made any alteration to the account having been given it's properties directly. + bool m_isUnchanged = false; + /// Account's nonce. u256 m_nonce = 0; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 29095076f..f3a204fea 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -19,6 +19,8 @@ * @date 2014 */ +#include + #include "BlockChain.h" #include @@ -43,14 +45,17 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_extrasDB->NewIterator(_bc.m_readOptions); + auto it = _bc.m_db->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { - string rlpString = it->value().ToString(); - RLP r(rlpString); - BlockDetails d(r); - _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parent << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + try { + BlockInfo d(bytesConstRef(it->value())); + _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parentHash << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + } + catch (...) { + cwarn << "Invalid DB entry:" << toHex(it->key().ToString()) << " -> " << toHex(bytesConstRef(it->value())); + } } delete it; return _out; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 6aedc4c24..014d0f91e 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -224,7 +224,7 @@ void State::ensureCached(std::map& _cache, Address _a, bool _r if (state.isNull()) s = Account(0, Account::NormalCreation); else - s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash()); + s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash(), Account::Unchanged); bool ok; tie(it, ok) = _cache.insert(make_pair(_a, s)); } @@ -625,7 +625,7 @@ void State::uncommitToMine() if (!m_transactions.size()) m_state.setRoot(m_previousBlock.stateRoot); else - m_state.setRoot(m_receipts[m_receipts.size() - 1].stateRoot()); + m_state.setRoot(m_receipts.back().stateRoot()); m_db = m_lastTx; paranoia("Uncommited to mine", true); m_currentBlock.sha3Uncles = h256(); @@ -890,7 +890,7 @@ Address State::newContract(u256 _balance, bytes const& _code) auto it = m_cache.find(ret); if (it == m_cache.end()) { - m_cache[ret] = Account(0, _balance, EmptyTrie, h); + m_cache[ret] = Account(0, _balance, EmptyTrie, h, Account::Changed); return ret; } } @@ -1144,7 +1144,7 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) _out << "--- " << _s.rootHash() << std::endl; std::set
d; std::set
dtr; - auto trie = TrieDB(const_cast(&_s.m_db), _s.rootHash()); + auto trie = SecureTrieDB(const_cast(&_s.m_db), _s.rootHash()); for (auto i: trie) d.insert(i.first), dtr.insert(i.first); for (auto i: _s.m_cache) diff --git a/libethereum/State.h b/libethereum/State.h index 37af0cf0e..a496a4a03 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -328,40 +328,43 @@ template void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) - if (!i.second.isAlive()) - _state.remove(i.first); - else + if (i.second.isDirty()) { - RLPStream s(4); - s << i.second.nonce() << i.second.balance(); - - if (i.second.storageOverlay().empty()) - { - assert(i.second.baseRoot()); - s.append(i.second.baseRoot()); - } + if (!i.second.isAlive()) + _state.remove(i.first); else { - SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7ddfdb40d..292f62a03 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) target_link_libraries(testeth solidity) -if (NOT HEADLESS) +if (NOT HEADLESS AND NOT JUSTTESTS) target_link_libraries(testeth webthree) target_link_libraries(testeth natspec) endif() diff --git a/test/stateOriginal.cpp b/test/stateOriginal.cpp index 65ff5084f..5b7b0415e 100644 --- a/test/stateOriginal.cpp +++ b/test/stateOriginal.cpp @@ -20,6 +20,7 @@ * State test functions. */ +#include #include #include #include @@ -29,7 +30,21 @@ using namespace std; using namespace dev; using namespace dev::eth; -int stateTest() +namespace dev +{ +namespace test +{ + +int stateTest(); + +BOOST_AUTO_TEST_SUITE(StateIntegration) + +BOOST_AUTO_TEST_CASE(Basic) +{ + State s; +} + +BOOST_AUTO_TEST_CASE(Complex) { cnote << "Testing State..."; @@ -37,14 +52,15 @@ int stateTest() KeyPair myMiner = sha3("Gav's Miner"); // KeyPair you = sha3("123"); - Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); + Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count())); OverlayDB stateDB = State::openDB(); CanonBlockChain bc; - State s(myMiner.address(), stateDB); - cout << bc; + State s(myMiner.address(), stateDB); + cout << s; + // Sync up - this won't do much until we use the last state. s.sync(bc); @@ -52,7 +68,7 @@ int stateTest() // Mine to get some ether! s.commitToMine(bc); - while (!s.mine(100).completed) {} + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -65,7 +81,7 @@ int stateTest() // Inject a transaction to transfer funds from miner to me. bytes tx; { - Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); + Transaction t(1000, 10000, 10000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); assert(t.sender() == myMiner.address()); tx = t.rlp(); } @@ -76,7 +92,7 @@ int stateTest() // Mine to get some ether and set in stone. s.commitToMine(bc); s.commitToMine(bc); - while (!s.mine(50).completed) { s.commitToMine(bc); } + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -85,7 +101,9 @@ int stateTest() s.sync(bc); cout << s; - - return 0; } +BOOST_AUTO_TEST_SUITE_END() + +} +} diff --git a/test/trie.cpp b/test/trie.cpp index 4b676fb9a..aa453925d 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -52,6 +52,26 @@ using dev::operator <<; BOOST_AUTO_TEST_SUITE(TrieTests) +BOOST_AUTO_TEST_CASE(fat_trie) +{ + h256 r; + MemoryDB fm; + { + FatGenericTrieDB ft(&fm); + ft.init(); + ft.insert(h256("69", h256::FromHex, h256::AlignRight).ref(), h256("414243", h256::FromHex, h256::AlignRight).ref()); + for (auto i: ft) + cnote << i.first << i.second; + r = ft.root(); + } + { + FatGenericTrieDB ft(&fm); + ft.setRoot(r); + for (auto i: ft) + cnote << i.first << i.second; + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 3e471f89046661a0c25e5f39bbfa35acf5bf1148 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 009/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 348cab59e..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From e3219c6563e22adff380eca1c780327995dca576 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 010/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 3 + libevm/ExtVMFace.h | 3 + libevm/FeeStructure.cpp | 59 +++++--- libevm/FeeStructure.h | 50 ++++--- libevm/VM.cpp | 197 ++++++--------------------- libevmcore/Instruction.cpp | 267 ++++++++++++++++++------------------- libevmcore/Instruction.h | 14 ++ 7 files changed, 259 insertions(+), 334 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 30cbf1a5a..40ff62175 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -69,6 +69,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } + /// Does the account exist? + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final { diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 13e8712b8..1bca3e2b2 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -142,6 +142,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address) { return 0; } + /// Does the account exist? + virtual bool exists(Address) { return false; } + /// Suicide the associated contract and give proceeds to the given address. virtual void suicide(Address) { sub.suicides.insert(myAddress); } diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 94eb956af..1c1bf8a9e 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -25,24 +25,41 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 const dev::eth::c_stepGas = 1; -u256 const dev::eth::c_balanceGas = 20; -u256 const dev::eth::c_sha3Gas = 10; -u256 const dev::eth::c_sha3WordGas = 10; -u256 const dev::eth::c_sloadGas = 20; -u256 const dev::eth::c_sstoreSetGas = 300; -u256 const dev::eth::c_sstoreResetGas = 100; -u256 const dev::eth::c_sstoreRefundGas = 100; -u256 const dev::eth::c_createGas = 100; -u256 const dev::eth::c_createDataGas = 5; -u256 const dev::eth::c_callGas = 20; -u256 const dev::eth::c_expGas = 1; -u256 const dev::eth::c_expByteGas = 1; -u256 const dev::eth::c_memoryGas = 1; -u256 const dev::eth::c_txDataZeroGas = 1; -u256 const dev::eth::c_txDataNonZeroGas = 5; -u256 const dev::eth::c_txGas = 500; -u256 const dev::eth::c_logGas = 32; -u256 const dev::eth::c_logDataGas = 1; -u256 const dev::eth::c_logTopicGas = 32; -u256 const dev::eth::c_copyGas = 1; +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + + diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 8ef384265..1b58c80e9 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,27 +28,37 @@ namespace dev namespace eth { -extern u256 const c_stepGas; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. -extern u256 const c_balanceGas; ///< Once per BALANCE operation. -extern u256 const c_sha3Gas; ///< Once per SHA3 operation. -extern u256 const c_sha3WordGas; -extern u256 const c_sloadGas; ///< Once per SLOAD operation. -extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. -extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. -extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. -extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. +extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. +extern u256 const c_expGas; ///< Once per EXP instuction. +extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + +extern u256 const c_sha3Gas; ///< Once per SHA3 operation. +extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + +extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + +extern u256 const c_sloadGas; ///< Once per SLOAD operation. +extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. +extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. +extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + +extern u256 const c_logGas; ///< Per LOG* operation. +extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. +extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. +extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; -extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_expGas; ///< Once per EXP instuction. -extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. -extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. -extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. -extern u256 const c_logGas; ///< Per LOG* operation. -extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. -extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. -extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. +extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. +extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. +extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + +extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. +extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. +extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2ba18eda6..a52b0ec3e 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -21,7 +21,7 @@ #include "VM.h" #include - +using namespace std; using namespace dev; using namespace dev::eth; @@ -32,13 +32,33 @@ void VM::reset(u256 _gas) noexcept m_jumpDests.clear(); } +struct InstructionMetric +{ + int gasPriceTier; + int args; +}; + +static array metrics() +{ + array s_ret; + for (unsigned i = 0; i < 256; ++i) + { + InstructionInfo inst = instructionInfo((Instruction)i); + s_ret[i].gasPriceTier = inst.gasPriceTier; + s_ret[i].args = inst.args; + } + return s_ret; +} + bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { + static const array c_metrics = metrics(); + auto memNeed = [](u256 _offset, dev::u256 _size) { return _size ? (bigint)_offset + _size : (bigint)0; }; auto gasForMem = [](bigint _size) -> bigint { bigint s = _size / 32; - return (bigint)c_memoryGas * (s + s * s / 1024); + return (bigint)c_memoryGas * s + s * s / c_quadCoeffDiv; }; if (m_jumpDests.empty()) @@ -57,36 +77,35 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) Instruction inst = (Instruction)_ext.getCode(m_curPC); // FEES... - bigint runGas = c_stepGas; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; + // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. + //m_onFail = std::function(onOperation); + + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; + require(metric.args); + auto onOperation = [&]() { if (_onOp) _onOp(osteps - _steps - 1, inst, newTempSize > m_temp.size() ? (newTempSize - m_temp.size()) / 32 : bigint(0), runGas, this, &_ext); }; - // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. - //m_onFail = std::function(onOperation); switch (inst) { - case Instruction::STOP: - runGas = 0; - break; - - case Instruction::SUICIDE: - require(1); - runGas = 0; - break; - case Instruction::SSTORE: - require(2); if (!_ext.store(m_stack.back()) && m_stack[m_stack.size() - 2]) runGas = c_sstoreSetGas; else if (_ext.store(m_stack.back()) && !m_stack[m_stack.size() - 2]) { - runGas = 0; + runGas = c_sstoreClearGas; _ext.sub.refunds += c_sstoreRefundGas; } else @@ -94,52 +113,39 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::SLOAD: - require(1); runGas = c_sloadGas; break; // These all operate on memory and therefore potentially expand it: case Instruction::MSTORE: - require(2); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::MSTORE8: - require(2); newTempSize = (bigint)m_stack.back() + 1; break; case Instruction::MLOAD: - require(1); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::RETURN: - require(2); newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::SHA3: - require(2); runGas = c_sha3Gas + (m_stack[m_stack.size() - 2] + 31) / 32 * c_sha3WordGas; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::CALLDATACOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::CODECOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::EXTCODECOPY: - require(4); copySize = m_stack[m_stack.size() - 4]; newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::BALANCE: - require(1); - runGas = c_balanceGas; - break; case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -147,7 +153,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::LOG4: { unsigned n = (unsigned)inst - (unsigned)Instruction::LOG0; - require(n + 2); runGas = c_logGas + c_logTopicGas * n + (bigint)c_logDataGas * m_stack[m_stack.size() - 2]; newTempSize = memNeed(m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]); break; @@ -155,149 +160,27 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: - require(7); runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + runGas += c_callNewAccountGas; + if (m_stack[m_stack.size() - 3] > 0) + runGas += c_callValueTransferGas; newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); break; case Instruction::CREATE: { - require(3); newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]); runGas = c_createGas; break; } case Instruction::EXP: { - require(2); auto expon = m_stack[m_stack.size() - 2]; runGas = c_expGas + c_expByteGas * (32 - (h256(expon).firstBitSet() / 8)); break; } - - case Instruction::BLOCKHASH: - require(1); - break; - - case Instruction::PC: - case Instruction::MSIZE: - case Instruction::GAS: - case Instruction::JUMPDEST: - case Instruction::ADDRESS: - case Instruction::ORIGIN: - case Instruction::CALLER: - case Instruction::CALLVALUE: - case Instruction::CALLDATASIZE: - case Instruction::CODESIZE: - case Instruction::GASPRICE: - case Instruction::COINBASE: - case Instruction::TIMESTAMP: - case Instruction::NUMBER: - case Instruction::DIFFICULTY: - case Instruction::GASLIMIT: - case Instruction::PUSH1: - case Instruction::PUSH2: - case Instruction::PUSH3: - case Instruction::PUSH4: - case Instruction::PUSH5: - case Instruction::PUSH6: - case Instruction::PUSH7: - case Instruction::PUSH8: - case Instruction::PUSH9: - case Instruction::PUSH10: - case Instruction::PUSH11: - case Instruction::PUSH12: - case Instruction::PUSH13: - case Instruction::PUSH14: - case Instruction::PUSH15: - case Instruction::PUSH16: - case Instruction::PUSH17: - case Instruction::PUSH18: - case Instruction::PUSH19: - case Instruction::PUSH20: - case Instruction::PUSH21: - case Instruction::PUSH22: - case Instruction::PUSH23: - case Instruction::PUSH24: - case Instruction::PUSH25: - case Instruction::PUSH26: - case Instruction::PUSH27: - case Instruction::PUSH28: - case Instruction::PUSH29: - case Instruction::PUSH30: - case Instruction::PUSH31: - case Instruction::PUSH32: - break; - case Instruction::NOT: - case Instruction::ISZERO: - case Instruction::CALLDATALOAD: - case Instruction::EXTCODESIZE: - case Instruction::POP: - case Instruction::JUMP: - require(1); - break; - case Instruction::ADD: - case Instruction::MUL: - case Instruction::SUB: - case Instruction::DIV: - case Instruction::SDIV: - case Instruction::MOD: - case Instruction::SMOD: - case Instruction::LT: - case Instruction::GT: - case Instruction::SLT: - case Instruction::SGT: - case Instruction::EQ: - case Instruction::AND: - case Instruction::OR: - case Instruction::XOR: - case Instruction::BYTE: - case Instruction::JUMPI: - case Instruction::SIGNEXTEND: - require(2); - break; - case Instruction::ADDMOD: - case Instruction::MULMOD: - require(3); - break; - case Instruction::DUP1: - case Instruction::DUP2: - case Instruction::DUP3: - case Instruction::DUP4: - case Instruction::DUP5: - case Instruction::DUP6: - case Instruction::DUP7: - case Instruction::DUP8: - case Instruction::DUP9: - case Instruction::DUP10: - case Instruction::DUP11: - case Instruction::DUP12: - case Instruction::DUP13: - case Instruction::DUP14: - case Instruction::DUP15: - case Instruction::DUP16: - require(1 + (int)inst - (int)Instruction::DUP1); - break; - case Instruction::SWAP1: - case Instruction::SWAP2: - case Instruction::SWAP3: - case Instruction::SWAP4: - case Instruction::SWAP5: - case Instruction::SWAP6: - case Instruction::SWAP7: - case Instruction::SWAP8: - case Instruction::SWAP9: - case Instruction::SWAP10: - case Instruction::SWAP11: - case Instruction::SWAP12: - case Instruction::SWAP13: - case Instruction::SWAP14: - case Instruction::SWAP15: - case Instruction::SWAP16: - require((int)inst - (int)Instruction::SWAP1 + 2); - break; - default: - BOOST_THROW_EXCEPTION(BadInstruction()); + default:; } newTempSize = (newTempSize + 31) / 32 * 32; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index bba3d7745..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -162,136 +162,136 @@ const std::map dev::eth::c_instructions = }; static const std::map c_instructionInfo = -{ // Add, Args, Ret, SideEffects - { Instruction::STOP, { "STOP", 0, 0, 0, true } }, - { Instruction::ADD, { "ADD", 0, 2, 1, false } }, - { Instruction::SUB, { "SUB", 0, 2, 1, false } }, - { Instruction::MUL, { "MUL", 0, 2, 1, false } }, - { Instruction::DIV, { "DIV", 0, 2, 1, false } }, - { Instruction::SDIV, { "SDIV", 0, 2, 1, false } }, - { Instruction::MOD, { "MOD", 0, 2, 1, false } }, - { Instruction::SMOD, { "SMOD", 0, 2, 1, false } }, - { Instruction::EXP, { "EXP", 0, 2, 1, false } }, - { Instruction::NOT, { "NOT", 0, 1, 1, false } }, - { Instruction::LT, { "LT", 0, 2, 1, false } }, - { Instruction::GT, { "GT", 0, 2, 1, false } }, - { Instruction::SLT, { "SLT", 0, 2, 1, false } }, - { Instruction::SGT, { "SGT", 0, 2, 1, false } }, - { Instruction::EQ, { "EQ", 0, 2, 1, false } }, - { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false } }, - { Instruction::AND, { "AND", 0, 2, 1, false } }, - { Instruction::OR, { "OR", 0, 2, 1, false } }, - { Instruction::XOR, { "XOR", 0, 2, 1, false } }, - { Instruction::BYTE, { "BYTE", 0, 2, 1, false } }, - { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false } }, - { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false } }, - { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false } }, - { Instruction::SHA3, { "SHA3", 0, 2, 1, false } }, - { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false } }, - { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false } }, - { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false } }, - { Instruction::CALLER, { "CALLER", 0, 0, 1, false } }, - { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false } }, - { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false } }, - { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false } }, - { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true } }, - { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false } }, - { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true } }, - { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } }, - { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } }, - { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true } }, - { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false } }, - { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false } }, - { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } }, - { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } }, - { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false } }, - { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false } }, - { Instruction::POP, { "POP", 0, 1, 0, false } }, - { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false } }, - { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true } }, - { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true } }, - { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false } }, - { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true } }, - { Instruction::JUMP, { "JUMP", 0, 1, 0, true } }, - { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true } }, - { Instruction::PC, { "PC", 0, 0, 1, false } }, - { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false } }, - { Instruction::GAS, { "GAS", 0, 0, 1, false } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true } }, - { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false } }, - { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false } }, - { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false } }, - { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false } }, - { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false } }, - { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false } }, - { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false } }, - { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false } }, - { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false } }, - { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false } }, - { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false } }, - { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false } }, - { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false } }, - { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false } }, - { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false } }, - { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false } }, - { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false } }, - { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false } }, - { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false } }, - { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false } }, - { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false } }, - { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false } }, - { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false } }, - { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false } }, - { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false } }, - { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false } }, - { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false } }, - { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false } }, - { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false } }, - { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false } }, - { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false } }, - { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false } }, - { Instruction::DUP1, { "DUP1", 0, 1, 2, false } }, - { Instruction::DUP2, { "DUP2", 0, 2, 3, false } }, - { Instruction::DUP3, { "DUP3", 0, 3, 4, false } }, - { Instruction::DUP4, { "DUP4", 0, 4, 5, false } }, - { Instruction::DUP5, { "DUP5", 0, 5, 6, false } }, - { Instruction::DUP6, { "DUP6", 0, 6, 7, false } }, - { Instruction::DUP7, { "DUP7", 0, 7, 8, false } }, - { Instruction::DUP8, { "DUP8", 0, 8, 9, false } }, - { Instruction::DUP9, { "DUP9", 0, 9, 10, false } }, - { Instruction::DUP10, { "DUP10", 0, 10, 11, false } }, - { Instruction::DUP11, { "DUP11", 0, 11, 12, false } }, - { Instruction::DUP12, { "DUP12", 0, 12, 13, false } }, - { Instruction::DUP13, { "DUP13", 0, 13, 14, false } }, - { Instruction::DUP14, { "DUP14", 0, 14, 15, false } }, - { Instruction::DUP15, { "DUP15", 0, 15, 16, false } }, - { Instruction::DUP16, { "DUP16", 0, 16, 17, false } }, - { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false } }, - { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false } }, - { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false } }, - { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false } }, - { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false } }, - { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false } }, - { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false } }, - { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false } }, - { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false } }, - { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false } }, - { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false } }, - { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false } }, - { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false } }, - { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false } }, - { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false } }, - { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false } }, - { Instruction::LOG0, { "LOG0", 0, 2, 0, true } }, - { Instruction::LOG1, { "LOG1", 0, 3, 0, true } }, - { Instruction::LOG2, { "LOG2", 0, 4, 0, true } }, - { Instruction::LOG3, { "LOG3", 0, 5, 0, true } }, - { Instruction::LOG4, { "LOG4", 0, 6, 0, true } }, - { Instruction::CREATE, { "CREATE", 0, 3, 1, true } }, - { Instruction::CALL, { "CALL", 0, 7, 1, true } }, - { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true } }, - { Instruction::RETURN, { "RETURN", 0, 2, 0, true } }, - { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true } } +{ // Add, Args, Ret, SideEffects, GasPriceTier + { Instruction::STOP, { "STOP", 0, 0, 0, true, ZeroTier } }, + { Instruction::ADD, { "ADD", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SUB, { "SUB", 0, 2, 1, false, VeryLowTier } }, + { Instruction::MUL, { "MUL", 0, 2, 1, false, LowTier } }, + { Instruction::DIV, { "DIV", 0, 2, 1, false, LowTier } }, + { Instruction::SDIV, { "SDIV", 0, 2, 1, false, LowTier } }, + { Instruction::MOD, { "MOD", 0, 2, 1, false, LowTier } }, + { Instruction::SMOD, { "SMOD", 0, 2, 1, false, LowTier } }, + { Instruction::EXP, { "EXP", 0, 2, 1, false, SpecialTier } }, + { Instruction::NOT, { "NOT", 0, 1, 1, false, VeryLowTier } }, + { Instruction::LT, { "LT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::GT, { "GT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SLT, { "SLT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SGT, { "SGT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::EQ, { "EQ", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false, VeryLowTier } }, + { Instruction::AND, { "AND", 0, 2, 1, false, VeryLowTier } }, + { Instruction::OR, { "OR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::XOR, { "XOR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::BYTE, { "BYTE", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, MidTier } }, + { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, MidTier } }, + { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, LowTier } }, + { Instruction::SHA3, { "SHA3", 0, 2, 1, false, SpecialTier } }, + { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, BaseTier } }, + { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, ExtTier } }, + { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLER, { "CALLER", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false, BaseTier } }, + { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false, ExtTier } }, + { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, ExtTier } }, + { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, ExtTier } }, + { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, BaseTier } }, + { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, BaseTier } }, + { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false, BaseTier } }, + { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false, BaseTier } }, + { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false, BaseTier } }, + { Instruction::POP, { "POP", 0, 1, 0, false, BaseTier } }, + { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true, VeryLowTier } }, + { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true, VeryLowTier } }, + { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false, SpecialTier } }, + { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true, SpecialTier } }, + { Instruction::JUMP, { "JUMP", 0, 1, 0, true, MidTier } }, + { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, HighTier } }, + { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, + { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false, VeryLowTier } }, + { Instruction::DUP1, { "DUP1", 0, 1, 2, false, VeryLowTier } }, + { Instruction::DUP2, { "DUP2", 0, 2, 3, false, VeryLowTier } }, + { Instruction::DUP3, { "DUP3", 0, 3, 4, false, VeryLowTier } }, + { Instruction::DUP4, { "DUP4", 0, 4, 5, false, VeryLowTier } }, + { Instruction::DUP5, { "DUP5", 0, 5, 6, false, VeryLowTier } }, + { Instruction::DUP6, { "DUP6", 0, 6, 7, false, VeryLowTier } }, + { Instruction::DUP7, { "DUP7", 0, 7, 8, false, VeryLowTier } }, + { Instruction::DUP8, { "DUP8", 0, 8, 9, false, VeryLowTier } }, + { Instruction::DUP9, { "DUP9", 0, 9, 10, false, VeryLowTier } }, + { Instruction::DUP10, { "DUP10", 0, 10, 11, false, VeryLowTier } }, + { Instruction::DUP11, { "DUP11", 0, 11, 12, false, VeryLowTier } }, + { Instruction::DUP12, { "DUP12", 0, 12, 13, false, VeryLowTier } }, + { Instruction::DUP13, { "DUP13", 0, 13, 14, false, VeryLowTier } }, + { Instruction::DUP14, { "DUP14", 0, 14, 15, false, VeryLowTier } }, + { Instruction::DUP15, { "DUP15", 0, 15, 16, false, VeryLowTier } }, + { Instruction::DUP16, { "DUP16", 0, 16, 17, false, VeryLowTier } }, + { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false, VeryLowTier } }, + { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false, VeryLowTier } }, + { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false, VeryLowTier } }, + { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false, VeryLowTier } }, + { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false, VeryLowTier } }, + { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false, VeryLowTier } }, + { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false, VeryLowTier } }, + { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false, VeryLowTier } }, + { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false, VeryLowTier } }, + { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false, VeryLowTier } }, + { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false, VeryLowTier } }, + { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false, VeryLowTier } }, + { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false, VeryLowTier } }, + { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false, VeryLowTier } }, + { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false, VeryLowTier } }, + { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false, VeryLowTier } }, + { Instruction::LOG0, { "LOG0", 0, 2, 0, true, SpecialTier } }, + { Instruction::LOG1, { "LOG1", 0, 3, 0, true, SpecialTier } }, + { Instruction::LOG2, { "LOG2", 0, 4, 0, true, SpecialTier } }, + { Instruction::LOG3, { "LOG3", 0, 5, 0, true, SpecialTier } }, + { Instruction::LOG4, { "LOG4", 0, 6, 0, true, SpecialTier } }, + { Instruction::CREATE, { "CREATE", 0, 3, 1, true, SpecialTier } }, + { Instruction::CALL, { "CALL", 0, 7, 1, true, SpecialTier } }, + { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, SpecialTier } }, + { Instruction::RETURN, { "RETURN", 0, 2, 0, true, ZeroTier } }, + { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true, ZeroTier } } }; string dev::eth::disassemble(bytes const& _mem) @@ -326,12 +326,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } catch (...) { -#ifndef BOOST_NO_EXCEPTIONS - cwarn << "\n" << boost::current_exception_diagnostic_information(); -#else - cwarn << "\n"; -#endif - return InstructionInfo({"", 0, 0, 0, false}); + return InstructionInfo({"", 0, 0, 0, false, InvalidTier}); } } diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h index 5cf002c4c..9eab92713 100644 --- a/libevmcore/Instruction.h +++ b/libevmcore/Instruction.h @@ -223,6 +223,19 @@ inline Instruction logInstruction(unsigned _number) return Instruction(unsigned(Instruction::LOG0) + _number); } +enum Tier +{ + ZeroTier = 0, // 0, Zero + BaseTier, // 2, Quick + VeryLowTier, // 3, Fastest + LowTier, // 5, Fast + MidTier, // 8, Mid + HighTier, // 10, Slow + ExtTier, // 20, Ext + SpecialTier, // multiparam or otherwise special + InvalidTier // Invalid. +}; + /// Information structure for a particular instruction. struct InstructionInfo { @@ -231,6 +244,7 @@ struct InstructionInfo int args; ///< Number of items required on the stack for this instruction (and, for the purposes of ret, the number taken from the stack). int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed. bool sideEffects; ///< false if the only effect on the execution environment (apart from gas usage) is a change to a topmost segment of the stack + int gasPriceTier; ///< Tier for gas pricing. }; /// Information on all the instructions. From f0e1be6abf5b52080f15e3849183971aac7ebac6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 011/313] Gas fixes. Trie fixes. --- libdevcore/Exceptions.h | 1 + libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 8 ++++++-- libethereum/Client.cpp | 4 ++-- libevm/VM.cpp | 15 +++++++-------- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index f3f9b1bf0..3861c69fe 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -40,6 +40,7 @@ struct BadRLP: virtual RLPException {}; struct NoNetworking: virtual Exception {}; struct NoUPnPDevice: virtual Exception {}; struct RootNotFound: virtual Exception {}; +struct BadRoot: virtual Exception {}; struct FileError: virtual Exception {}; struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): m_f("Interface " + _f + " not supported.") {} virtual const char* what() const noexcept { return m_f.c_str(); } private: std::string m_f; }; diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -93,7 +93,7 @@ public: /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). bool isEmpty() const { return m_root == c_shaNull && node(m_root).size(); } - h256 root() const { assert(node(m_root).size()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. + h256 root() const { if (!node(m_root).size()) BOOST_THROW_EXCEPTION(BadRoot()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. void debugPrint() {} @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 11b9557df..4ad7122e4 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -273,9 +273,9 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { - cdebug << "checkWatch" << _watchId; +// cdebug << "checkWatch" << _watchId; auto& w = m_watches.at(_watchId); - cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); +// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index a52b0ec3e..6a6937f89 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -75,21 +75,20 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { // INSTRUCTION... Instruction inst = (Instruction)_ext.getCode(m_curPC); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -186,7 +185,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = (newTempSize + 31) / 32 * 32; if (newTempSize > m_temp.size()) runGas += gasForMem(newTempSize) - gasForMem(m_temp.size()); - runGas += c_copyGas * (copySize + 31) / 32; + runGas += c_copyGas * ((copySize + 31) / 32); onOperation(); // if (_onOp) From bfb922352860d413b2876463e4c724c0532d4abf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:10:32 +0100 Subject: [PATCH 012/313] Solidity STOPs in case of failed call. --- libsolidity/ExpressionCompiler.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 430e46b06..63aa8a3c2 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -984,9 +984,10 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio m_context << eth::dupInstruction(m_context.baseToCurrentStackOffset(gasStackPos)); else // send all gas except for the 21 needed to execute "SUB" and "CALL" - m_context << u256(21) << eth::Instruction::GAS << eth::Instruction::SUB; - m_context << eth::Instruction::CALL - << eth::Instruction::POP; // @todo do not ignore failure indicator + m_context << u256(_functionType.valueSet() ? 6741 : 41) << eth::Instruction::GAS << eth::Instruction::SUB; + m_context << eth::Instruction::CALL; + auto tag = m_context.appendConditionalJump(); + m_context << eth::Instruction::STOP << tag; // STOP if CALL leaves 0. if (_functionType.valueSet()) m_context << eth::Instruction::POP; if (_functionType.gasSet()) @@ -999,10 +1000,12 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio CompilerUtils(m_context).loadFromMemory(0, *firstType, false, true); } -void ExpressionCompiler::appendArgumentsCopyToMemory(vector> const& _arguments, - TypePointers const& _types, - bool _padToWordBoundaries, - bool _padExceptionIfFourBytes) +void ExpressionCompiler::appendArgumentsCopyToMemory( + vector> const& _arguments, + TypePointers const& _types, + bool _padToWordBoundaries, + bool _padExceptionIfFourBytes +) { solAssert(_types.empty() || _types.size() == _arguments.size(), ""); for (size_t i = 0; i < _arguments.size(); ++i) From a1bb249d45ba17042a1b4103a357b30703680c89 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 013/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 6a6937f89..2243da2e7 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From 8f70101cecf7c8e50caad6c00859d66aed4a5d2c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 014/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- test/vm.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 40ff62175..2ff270de5 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/test/vm.h b/test/vm.h index 0a5b5fb45..c13a97276 100644 --- a/test/vm.h +++ b/test/vm.h @@ -50,6 +50,7 @@ public: virtual u256 store(u256 _n) override { return std::get<2>(addresses[myAddress])[_n]; } virtual void setStore(u256 _n, u256 _v) override { std::get<2>(addresses[myAddress])[_n] = _v; } + virtual bool exists(Address _a) override { return !!addresses.count(_a); } virtual u256 balance(Address _a) override { return std::get<0>(addresses[_a]); } virtual void subBalance(u256 _a) override { std::get<0>(addresses[myAddress]) -= _a; } virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); } From e2fdaa6ac2433ce4669ba1da3697dbb5f2a60c7d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 015/313] only check rootHash of state if FATDB is off --- test/state.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/state.cpp b/test/state.cpp index 03f01d0fb..1cbbe454a 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -71,7 +71,13 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } if (_fillin) + { +#if ETH_FATDB importer.exportTest(output, theState); +#else + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off")); +#endif + } else { BOOST_REQUIRE(o.count("post") > 0); @@ -84,6 +90,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); // check addresses +#if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -102,6 +110,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } } checkAddresses >(expectedAddrs, resultAddrs); +#endif + BOOST_CHECK_MESSAGE(theState.rootHash() == h256(o["postStateRoot"].get_str()), "wrong post state root"); } } } From 845b4e7d9836d7be19751898e9260c62d6d54058 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 016/313] add memory tests --- test/TestHelper.cpp | 2 + test/stMemoryStressTestFiller.json | 69 + test/stMemoryTestFiller.json | 1463 +++++++++++++++++++++ test/stQuadraticComplexityTestFiller.json | 682 ++++++++++ test/state.cpp | 47 +- 5 files changed, 2260 insertions(+), 3 deletions(-) create mode 100644 test/stMemoryStressTestFiller.json create mode 100644 test/stMemoryTestFiller.json create mode 100644 test/stQuadraticComplexityTestFiller.json diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 71d381030..3d3330b83 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -195,6 +195,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost) } m_TestObject["post"] = json_spirit::mValue(postState); + m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes()); + // export pre state json_spirit::mObject preState; diff --git a/test/stMemoryStressTestFiller.json b/test/stMemoryStressTestFiller.json new file mode 100644 index 000000000..420f7c3db --- /dev/null +++ b/test/stMemoryStressTestFiller.json @@ -0,0 +1,69 @@ +{ + "mload32bitBound": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "17592320524892", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ [[ 1 ]] (MLOAD 4294967296) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "175923205248920", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "17592320524892", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mload32bitBound2": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "37791080412587", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ [[ 1 ]] (MLOAD 6294967296) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "377910804219850", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "37791080412587", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + } +} diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json new file mode 100644 index 000000000..eac2d5875 --- /dev/null +++ b/test/stMemoryTestFiller.json @@ -0,0 +1,1463 @@ +{ + "mload8bitBound": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ [[ 1 ]] (MLOAD 256) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1000", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mload16bitBound": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "17592320524892", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ [[ 1 ]] (MLOAD 65536) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "175923205248920", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "17592320524892", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31968 42) [[ 1 ]] (MLOAD 31968) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb-1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31967 42) [[ 1 ]] (MLOAD 31967) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb-31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31937 42) [[ 1 ]] (MLOAD 31937) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb-32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31936 42) [[ 1 ]] (MLOAD 31936) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb-33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31935 42) [[ 1 ]] (MLOAD 31935) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb+1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31969 42) [[ 1 ]] (MLOAD 31969) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb+31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 31999 42) [[ 1 ]] (MLOAD 31999) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb+32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 32000 42) [[ 1 ]] (MLOAD 32000) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb+33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 32001 42) [[ 1 ]] (MLOAD 32001) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 31999 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte-1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 31998 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte-31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 31968 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte-32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 31967 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte-33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 31966 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte+1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 32000 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte+31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 32030 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte+32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 32031 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32kb_singleByte+33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 32032 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63968 42) [[ 1 ]] (MLOAD 63968) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183640", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb-1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63967 42) [[ 1 ]] (MLOAD 63967) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183640", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb-31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63937 42) [[ 1 ]] (MLOAD 63937) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183640", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb-32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63936 42) [[ 1 ]] (MLOAD 63936) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183640", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb-33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63935 42) [[ 1 ]] (MLOAD 63935) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb+1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63969 42) [[ 1 ]] (MLOAD 63969) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb+31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 63999 42) [[ 1 ]] (MLOAD 63999) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb+32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 64000 42) [[ 1 ]] (MLOAD 64000) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb+33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE 64001 42) [[ 1 ]] (MLOAD 64001) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 63999 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte-1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 63998 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte-31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 63968 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte-32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 63967 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte-33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 63966 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte+1": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 64000 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte+31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 64030 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte+32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 64031 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem64kb_singleByte+33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 64032 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem0b_singleByte": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 0 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem31b_singleByte": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 30 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem32b_singleByte": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 31 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "mem33b_singleByte": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (MSTORE8 32 42) [[ 0 ]] (MSIZE) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "" + } + }, + + "memReturn": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "42949672960", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "code" : "{ (CALLDATACOPY 0 0 (CALLDATASIZE)) (RETURN 0 (MSIZE)) } ", + "storage": {} + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "429496729600", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "transaction" : { + "nonce" : "0", + "gasPrice" : "1", + "gasLimit" : "1342183320", + "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "value" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "data" : "0xff55883355001144bbccddffeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + } +} diff --git a/test/stQuadraticComplexityTestFiller.json b/test/stQuadraticComplexityTestFiller.json new file mode 100644 index 000000000..d58a04ae4 --- /dev/null +++ b/test/stQuadraticComplexityTestFiller.json @@ -0,0 +1,682 @@ +{ + + "QuadraticComplexitySolidity_CallDataCopy" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "350000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "500000000", + "//" : "contract caller ", + "//" : "{ ", + "//" : " int value; ", + "//" : " function run(int count) ", + "//" : " { ", + "//" : " value = count; ", + "//" : " address a = 0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", + "//" : " while(count > 0) ", + "//" : " { ", + "//" : " a.call('just', 'call'); ", + "//" : " count = count - 1; ", + "//" : " } ", + "//" : " } ", + "//" : "} ", + "code" : "0x60003560e060020a9004806361a4770614601557005b601e6004356024565b60006000f35b60008160008190555073b94f5374fce5edbc8e2a8697c15331677e6ebf0b90505b600082131560bf5780600160a060020a03166000600060007f6a7573740000000000000000000000000000000000000000000000000000000081526004017f63616c6c000000000000000000000000000000000000000000000000000000008152602001600060008560155a03f150506001820391506045565b505056", + "nonce" : "0", + "storage" : { + } + }, + + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "5000000", + "code" : "{ (CALLDATACOPY 0 0 50000) }", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "//" : "run(int256)", + "data" : "0x61a47706000000000000000000000000000000000000000000000000000000000000c350", + "gasLimit" : "904+68*x+e", + "gasLimit" : "350000000", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "1" + } + }, + + "Call50000" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "86000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "aaaf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "7000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 1600 0xaaaf5374fce5edbc8e2a8697c15331677e6ebf0b 1 0 50000 0 0) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "85000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Callcode50000" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "86000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "aaaf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "7000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALLCODE 1600 0xaaaf5374fce5edbc8e2a8697c15331677e6ebf0b 1 0 50000 0 0) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "85000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Create1000" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "86000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 1000) [i](+ @i 1) [[ 0 ]] (CREATE 1 0 50000) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "85000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000_ecrec" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "95000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 500 1 1 0 50000 0 0) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "94500000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000_sha256" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "3925000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 78200 2 1 0 50000 0 0) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "3925000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000_rip160" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "3925000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 78200 3 1 0 50000 0 0) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "3925000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000_identity" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "88250000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 1564 4 1 0 50000 0 0) ) [[ 1 ]] @i}", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "88250000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000_identity2" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "88250000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ [ 1 ] 42 (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 1564 4 1 0 50000 1 50000) ) [[ 1 ]] @i [[ 2 ]] @1 }", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "88250000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + "Return50000" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "88250000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 1564 0xaaaf5374fce5edbc8e2a8697c15331677e6ebf0b 0 0 50000 0 0) ) [[ 1 ]] @i }", + "nonce" : "0", + "storage" : { + } + }, + + "aaaf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (RETURN (CALLDATALOAD 49999) 1) }", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "88250000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Return50000_2" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "88250000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALL 1564 0xaaaf5374fce5edbc8e2a8697c15331677e6ebf0b 0 0 50000 0 0) ) [[ 1 ]] @i }", + "nonce" : "0", + "storage" : { + } + }, + + "aaaf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ [ 0 ] (CALLDATALOAD 49999) (RETURN @0 1) }", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "88250000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + + + "Call50000bytesContract50_1" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "882500000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50) [i](+ @i 1) [[ 0 ]] (CALL 88250000000 0xaaa50000fce5edbc8e2a8697c15331677e6ebf0b 0 0 0 0 0) ) [[ 1 ]] @i }", + "nonce" : "0", + "storage" : { + } + }, + + "aaa50000fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "0x6001600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600101600055", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "882500000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000bytesContract50_2" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "882500000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50) [i](+ @i 1) [[ 0 ]] (CALL 88250000000 0xaaa50000fce5edbc8e2a8697c15331677e6ebf0b 0 0 0 0 0) ) [[ 1 ]] @i }", + "nonce" : "0", + "storage" : { + } + }, + + "aaa50000fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "0x60015b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b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5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b600101600055", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "882500000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call50000bytesContract50_3" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "882500000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ (for {} (< @i 50) [i](+ @i 1) [[ 0 ]] (CALL 88250000000 0xaaa50000fce5edbc8e2a8697c15331677e6ebf0b 0 0 0 0 0) ) [[ 1 ]] @i }", + "nonce" : "0", + "storage" : { + } + }, + + "aaa50000fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "0x600161da8e565b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b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5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b600101600055", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "882500000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + + "Call1MB1024Calldepth" : { + "env" : { + "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "882500000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xffffffffffffffffffffffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "{ [[ 0 ]] (+ @@0 1) (if (LT @@0 1024) [[ 1 ]] (CALL (- (GAS) 1005000) 0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b 0 0 1000000 0 0) [[ 2 ]] 1 ) }", + "nonce" : "0", + "storage" : { + } + }, + + "aaa50000fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0xfffffffffffff", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "data" : "", + "gasLimit" : "882500000000", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "bbbf5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + } +} diff --git a/test/state.cpp b/test/state.cpp index 1cbbe454a..85bc75300 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -91,7 +91,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -169,11 +168,53 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stSolidityTest) +BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) { - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } +BOOST_AUTO_TEST_CASE(stMemoryStressTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} + + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } + +BOOST_AUTO_TEST_CASE(stMemoryTest) +{ + dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); +} + + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From a90afc3d5ebbfbaec31ddce8c0004c8042b05776 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 017/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From cd45664a6313b35bdb83cb6158fafe50c0ce3760 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:18:00 +0100 Subject: [PATCH 018/313] Avoid invalid paranoia tests. --- libethereum/State.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 014d0f91e..6b594e7a5 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -133,7 +133,7 @@ State::State(State const& _s): void State::paranoia(std::string const& _when, bool _enforceRefs) const { -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB // TODO: variable on context; just need to work out when there should be no leftovers // [in general this is hard since contract alteration will result in nodes in the DB that are no directly part of the state DB]. if (!isTrieGood(_enforceRefs, false)) @@ -1084,7 +1084,7 @@ u256 State::execute(LastHashes const& _lh, bytesConstRef _rlp, bytes* o_output, commit(); -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB ctrace << "Executed; now" << rootHash(); ctrace << old.diff(*this); From 6dc6d10b0281dbffd3806789f60a7244ddf34eca Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 019/313] update gas costs --- libevm/FeeStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..58d756bae 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From 5a538bf3144b8253af91054b981e7cb56b4c9365 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 020/313] Log/bloom alterations. --- libdevcore/FixedHash.h | 2 ++ libethcore/BlockInfo.cpp | 2 +- libethcore/CommonEth.h | 7 +++++-- libethereum/BlockDetails.h | 4 ++-- libevm/FeeStructure.cpp | 7 ++++--- libevm/FeeStructure.h | 1 + libevm/VM.cpp | 17 ++--------------- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 3113b5427..eec988d76 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -240,6 +240,8 @@ inline std::ostream& operator<<(std::ostream& _out, FixedHash const& _h) } // Common types of FixedHash. +using h2048 = FixedHash<256>; +using h1024 = FixedHash<128>; using h520 = FixedHash<65>; using h512 = FixedHash<64>; using h256 = FixedHash<32>; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index fec010c2d..89f4c49da 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -101,7 +101,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) stateRoot = _header[field = 3].toHash(); transactionsRoot = _header[field = 4].toHash(); receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + logBloom = _header[field = 6].toHash(); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 79525082f..89ca0aa06 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -44,8 +44,11 @@ std::string formatBalance(bigint const& _b); /// Get information concerning the currency denominations. std::vector> const& units(); -/// The log bloom's size (512 bit). -using LogBloom = h512; +/// The log bloom's size (2048-bit). +using LogBloom = h2048; + +/// Many log blooms. +using LogBlooms = std::vector; template inline u256 exp10() { diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 61b9667c4..9a3ac9ff1 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -55,10 +55,10 @@ struct BlockDetails struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } bytes rlp() const { RLPStream s; s << blooms; return s.out(); } - h512s blooms; + LogBlooms blooms; }; struct BlockReceipts diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..05526117c 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 1b58c80e9..120034b0e 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2243da2e7..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -563,21 +563,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::JUMPDEST: break; -/* case Instruction::LOG0: - _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); - break; - case Instruction::LOG1: - _ext.log({m_stack[m_stack.size() - 1]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 2], (unsigned)m_stack[m_stack.size() - 3])); - break; - case Instruction::LOG2: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 3], (unsigned)m_stack[m_stack.size() - 4])); - break; - case Instruction::LOG3: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 4], (unsigned)m_stack[m_stack.size() - 5])); - break; - case Instruction::LOG4: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3], m_stack[m_stack.size() - 4]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 5], (unsigned)m_stack[m_stack.size() - 6])); - break;*/ case Instruction::LOG0: _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); m_stack.pop_back(); @@ -635,6 +620,8 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALLCODE: { u256 gas = m_stack.back(); + if (m_stack[m_stack.size() - 3] > 0) + gas += c_callStipend; m_stack.pop_back(); Address receiveAddress = asAddress(m_stack.back()); m_stack.pop_back(); From 6e9884ca43ba804a734a49af7ede06f6a306c9d2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 021/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba25e74ce..43ee58eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 732782d3f..97e9a220b 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -82,10 +82,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)500; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)1 + (i.size() + 31) / 32 * 1; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index aa453925d..bdb188651 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -72,6 +72,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From f8c06e92f7ea5d30074274580119d72ac35af5ee Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 022/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 38 +++++++++++++++++++++++++++++++++++++ libethereum/GenesisInfo.cpp | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 feeStructure.json diff --git a/feeStructure.json b/feeStructure.json new file mode 100644 index 000000000..f09464a5a --- /dev/null +++ b/feeStructure.json @@ -0,0 +1,38 @@ +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, + + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index b9b45d4b4..d7224b7cc 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -24,6 +24,10 @@ std::string const dev::eth::c_genesisInfo = R"ETHEREUM( { + "0000000000000000000000000000000000000001": { "wei": "1" }, + "0000000000000000000000000000000000000002": { "wei": "1" }, + "0000000000000000000000000000000000000003": { "wei": "1" }, + "0000000000000000000000000000000000000004": { "wei": "1" }, "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e6716f9544a56c530d868e4bfbacb172315bdead": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "b9c015918bdaba24b4ff057a92a3873d6eb201be": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, From ee0df7beae02eaab1122bf1b6f64fb493721f638 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 023/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethereum/GenesisInfo.cpp | 4 -- libethereum/Precompiled.cpp | 9 ++-- libevm/FeeStructure.cpp | 85 ++++++++++++++++++----------------- libevm/FeeStructure.h | 8 ++++ 5 files changed, 109 insertions(+), 85 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index d7224b7cc..4e6a48284 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -36,9 +36,5 @@ R"ETHEREUM( "cd2a3d9f938e13cd947ec05abc7fe734df8dd826": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "6c386a4b26f73c802f34673f7248bb118f97424a": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e4157b34ea9615cfbde6b4fda419828124b70c78": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, - "b0afc46d9ce366d06ab4952ca27db1d9557ae9fd": { "finney": "154162184" }, - "f6b1e9dc460d4d62cc22ec5f987d726929c0f9f0": { "finney": "102774789" }, - "cc45122d8b7fa0b1eaa6b29e0fb561422a9239d0": { "finney": "51387394" }, - "b7576e9d314df41ec5506494293afb1bd5d3f65d": { "finney": "69423399" }, } )ETHEREUM"; diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 97e9a220b..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace std; using namespace dev; using namespace dev::eth; @@ -82,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 03dd14850..78c6ebfb2 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,45 +22,48 @@ #include "FeeStructure.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 120034b0e..9d60ac1bd 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } From 5ada7247f8eee446b5c1ce3ff0b6ddebf30a5a68 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 024/313] VM CALLCODE fix. --- libevm/FeeStructure.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9d60ac1bd..9109347dc 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From 813d5d91723ba767bace0ae6b56b7e969b883ddb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:03:47 +0100 Subject: [PATCH 025/313] Lenient gas limit. Two uncles only. Min 2048 difficulty & assoc adjustment. --- libethcore/BlockInfo.cpp | 9 ++++++--- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 3 ++- libethereum/State.cpp | 21 +++++++++++---------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 89f4c49da..7789d6b32 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -191,16 +191,19 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(1024, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty >> 10) : (_parent.difficulty + (_parent.difficulty >> 10))); + return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } +template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } + void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (gasLimit != calculateGasLimit(_parent)) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent))); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + // Check timestamp is after previous timestamp. if (parentHash) diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index 9b07743c5..c4628f4aa 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " valid:" + toString(valid) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 3fd62afbd..4679c1961 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -47,6 +47,7 @@ struct InvalidSignature: virtual dev::Exception {}; class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual const char* what() const noexcept; }; struct InvalidUnclesHash: virtual dev::Exception {}; struct InvalidUncle: virtual dev::Exception {}; +struct TooManyUncles: virtual dev::Exception {}; struct UncleTooOld: virtual dev::Exception {}; class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual const char* what() const noexcept; }; struct DuplicateUncleNonce: virtual dev::Exception {}; @@ -55,7 +56,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 6b594e7a5..a9837d118 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -486,10 +486,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) receiptsTrie.init(); LastHashes lh = getLastHashes(_bc, (unsigned)m_previousBlock.number); + RLP rlp(_block); // All ok with the block generally. Play back the transactions now... unsigned i = 0; - for (auto const& tr: RLP(_block)[1]) + for (auto const& tr: rlp[1]) { RLPStream k; k << i; @@ -503,17 +504,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) ++i; } - if (transactionsTrie.root() != m_currentBlock.transactionsRoot) - { - cwarn << "Bad transactions state root!"; - BOOST_THROW_EXCEPTION(InvalidTransactionsStateRoot()); - } - if (receiptsTrie.root() != m_currentBlock.receiptsRoot) { cwarn << "Bad receipts state root."; cwarn << "Block:" << toHex(_block); - cwarn << "Block RLP:" << RLP(_block); + cwarn << "Block RLP:" << rlp; cwarn << "Calculated: " << receiptsTrie.root(); for (unsigned j = 0; j < i; ++j) { @@ -548,10 +543,14 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) u256 tdIncrease = m_currentBlock.difficulty; // Check uncles & apply their rewards to state. + if (rlp[2].itemCount() > 2) + BOOST_THROW_EXCEPTION(TooManyUncles()); + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); - for (auto const& i: RLP(_block)[2]) + + for (auto const& i: rlp[2]) { if (knownUncles.count(sha3(i.data()))) BOOST_THROW_EXCEPTION(UncleInChain(knownUncles, sha3(i.data()) )); @@ -699,7 +698,7 @@ void State::commitToMine(BlockChain const& _bc) // cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); auto p = m_previousBlock.parentHash; - for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash(); ++gen, p = _bc.details(p).parent) + for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash() && unclesCount < 2; ++gen, p = _bc.details(p).parent) { auto us = _bc.details(p).children; assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent! @@ -710,6 +709,8 @@ void State::commitToMine(BlockChain const& _bc) ubi.streamRLP(unclesData, WithNonce); ++unclesCount; uncleAddresses.push_back(ubi.coinbaseAddress); + if (unclesCount == 2) + break; } } } From 92bfa4a7cf78c1a32cc73fbaadd8a793170262aa Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 026/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 48 +++++++++++++++++++++++ libethcore/CommonEth.cpp | 2 +- libethereum/CachedAddressState.cpp | 6 +-- libethereum/CachedAddressState.h | 3 ++ libethereum/CanonBlockChain.cpp | 2 +- libethereum/State.cpp | 63 +++++++++++++----------------- libethereum/State.h | 9 ++--- mix/MixClient.cpp | 2 +- 8 files changed, 88 insertions(+), 47 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f5b7ff9c9..c08199e06 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -325,6 +325,54 @@ std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) return _out; } +template +class SecureGenericTrieDB: private TrieDB +{ + using Super = TrieDB; + +public: + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + using Super::open; + using Super::init; + using Super::setRoot; + using Super::haveRoot; + + /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). + using Super::isNull; + /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). + using Super::isEmpty; + + using Super::root; + + using Super::leftOvers; + using Super::check; + + std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } + void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } +}; + +template +class SecureTrieDB: public SecureGenericTrieDB +{ + using Super = SecureGenericTrieDB; + +public: + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + std::string operator[](KeyType _k) const { return at(_k); } + + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } +}; + } // Template implementations... diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 2264e6ec9..8facdf0f1 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 54; +const unsigned c_protocolVersion = 55; const unsigned c_databaseVersion = 5; vector> const& units() diff --git a/libethereum/CachedAddressState.cpp b/libethereum/CachedAddressState.cpp index 5f9be6944..e2fadc8b5 100644 --- a/libethereum/CachedAddressState.cpp +++ b/libethereum/CachedAddressState.cpp @@ -56,9 +56,9 @@ std::map CachedAddressState::storage() const std::map ret; if (m_r) { - TrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - ret[j.first] = RLP(j.second).toInt(); + SecureTrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) +// for (auto const& j: memdb) +// ret[j.first] = RLP(j.second).toInt(); } if (m_s) for (auto const& j: m_s->storageOverlay()) diff --git a/libethereum/CachedAddressState.h b/libethereum/CachedAddressState.h index 301f54338..8a3c3a607 100644 --- a/libethereum/CachedAddressState.h +++ b/libethereum/CachedAddressState.h @@ -45,7 +45,10 @@ public: u256 balance() const; u256 nonce() const; bytes code() const; + + // TODO: DEPRECATE. std::map storage() const; + AccountDiff diff(CachedAddressState const& _c); private: diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index b0fe90a78..29fdc9acc 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -76,7 +76,7 @@ bytes CanonBlockChain::createGenesisBlock() h256 stateRoot; { MemoryDB db; - TrieDB state(&db); + SecureTrieDB state(&db); state.init(); dev::eth::commit(genesisState(), db, state); stateRoot = state.root(); diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 76ad1f269..917239351 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -168,18 +168,6 @@ State::~State() { } -Address State::nextActiveAddress(Address _a) const -{ - auto it = m_state.lower_bound(_a); - if ((*it).first == _a) - ++it; - if (it == m_state.end()) - // exchange comments if we want to wraparound -// it = m_state.begin(); - return Address(); - return (*it).first; -} - StateDiff State::diff(State const& _c) const { StateDiff ret; @@ -188,13 +176,14 @@ StateDiff State::diff(State const& _c) const std::set
trieAds; std::set
trieAdsD; - auto trie = TrieDB(const_cast(&m_db), rootHash()); - auto trieD = TrieDB(const_cast(&_c.m_db), _c.rootHash()); + auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); + auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -356,9 +345,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -591,9 +581,10 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) { cwarn << "Bad state root!"; cnote << "Given to be:" << m_currentBlock.stateRoot; - cnote << TrieDB(&m_db, m_currentBlock.stateRoot); + // TODO: Fix +// cnote << SecureTrieDB(&m_db, m_currentBlock.stateRoot); cnote << "Calculated to be:" << rootHash(); - cnote << m_state; +// cnote << m_state; cnote << *this; // Rollback the trie. m_db.rollback(); @@ -932,7 +923,7 @@ u256 State::storage(Address _id, u256 _memory) const return mit->second; // Not in the storage cache - go to the DB. - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) string payload = memdb.at(_memory); u256 ret = payload.size() ? RLP(payload).toInt() : 0; it->second.setStorage(_memory, ret); @@ -950,9 +941,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1003,24 +995,24 @@ bool State::isTrieGood(bool _enforceRefs, bool _requireNoLeftOvers) const cwarn << "LEFTOVERS" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << "Left:" << lo; cnote << "Keys:" << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } // TODO: Enable once fixed. - for (auto const& i: m_state) +/* for (auto const& i: m_state) { RLP r(i.second); - TrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. + SecureTrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. for (auto const& j: storageDB) { (void)j; } if (!e && r[3].toHash() != EmptySHA3 && m_db.lookup(r[3].toHash()).empty()) return false; - } + }*/ } catch (InvalidTrie const&) { cwarn << "BAD TRIE" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } return true; @@ -1187,9 +1179,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) std::set cached; if (r) { - TrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index 813141d17..37af0cf0e 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -94,9 +94,6 @@ public: /// @returns the set containing all addresses currently in use in Ethereum. std::map addresses() const; - /// @returns the address b such that b > @a _a . - Address nextActiveAddress(Address _a) const; - /// Get the header information on the present block. BlockInfo const& info() const { return m_currentBlock; } @@ -299,7 +296,7 @@ private: void paranoia(std::string const& _when, bool _enforceRefs = false) const; OverlayDB m_db; ///< Our overlay for the state tree. - TrieDB m_state; ///< Our state tree, as an OverlayDB DB. + SecureTrieDB m_state; ///< Our state tree, as an OverlayDB DB. Transactions m_transactions; ///< The current list of transactions that we've included in the state. TransactionReceipts m_receipts; ///< The corresponding list of transaction receipts. std::set m_transactionSet; ///< The set of transaction hashes that we've included in the state. @@ -328,7 +325,7 @@ private: std::ostream& operator<<(std::ostream& _out, State const& _s); template -void commit(std::map const& _cache, DB& _db, TrieDB& _state) +void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) if (!i.second.isAlive()) @@ -345,7 +342,7 @@ void commit(std::map const& _cache, DB& _db, TrieDB storageDB(&_db, i.second.baseRoot()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); for (auto const& j: i.second.storageOverlay()) if (j.second) storageDB.insert(j.first, rlp(j.second)); diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index e45443d35..04cec6344 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -79,7 +79,7 @@ void MixClient::resetState(u256 _balance) m_watches.clear(); m_stateDB = OverlayDB(); - TrieDB accountState(&m_stateDB); + SecureTrieDB accountState(&m_stateDB); accountState.init(); std::map genesisState = { std::make_pair(KeyPair(c_userAccountSecret).address(), Account(_balance, Account::NormalCreation)) }; dev::eth::commit(genesisState, static_cast(m_stateDB), accountState); From 0f01f4799f71f47b1b4e55257a7ac636379e6c98 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 027/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 6 +- libdevcrypto/MemoryDB.cpp | 2 +- libdevcrypto/MemoryDB.h | 4 ++ libdevcrypto/TrieDB.h | 123 +++++++++++++++++++++++++------------- test/trie.cpp | 44 +++++++++++++- 5 files changed, 130 insertions(+), 49 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 2b4e6bc08..24fac9c0a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -53,7 +53,7 @@ public: enum ConstructFromStringType { FromHex, FromBinary }; /// Method to convert from a string. - enum ConstructFromHashType { AlignLeft, AlignRight }; + enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent }; /// Construct an empty hash. FixedHash() { m_data.fill(0); } @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.cpp b/libdevcrypto/MemoryDB.cpp index 4fc4ed9ad..56b77ddee 100644 --- a/libdevcrypto/MemoryDB.cpp +++ b/libdevcrypto/MemoryDB.cpp @@ -107,7 +107,7 @@ set MemoryDB::keys() const { set ret; for (auto const& i: m_refCount) - if (i.second) + if (i.second && h128(i.first.ref().cropped(0, 16))) ret.insert(i.first); return ret; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 4b8d3b3a2..816e393a3 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -26,6 +26,7 @@ #include #include #include +#include "SHA3.h" namespace dev { @@ -50,6 +51,9 @@ public: bool kill(h256 _h); void purge(); + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + std::set keys() const; protected: diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index c08199e06..676193112 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -62,17 +62,21 @@ extern const h256 EmptyTrie; * assert(t.isEmpty()); * @endcode */ -template +template class GenericTrieDB { public: + using DB = _DB; + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} + void open(DB* _db) { m_db = _db; } void open(DB* _db, h256 _root) { m_db = _db; setRoot(_root); } - void init(); + void init() { setRoot(insertNode(&RLPNull)); assert(node(m_root).size()); } + void setRoot(h256 _root) { m_root = _root; @@ -83,7 +87,6 @@ public: if (!node(m_root).size()) BOOST_THROW_EXCEPTION(RootNotFound()); } - bool haveRoot(h256 _root, bool _enforceRefs = true) { return _root == c_shaNull ? true : m_db->lookup(_root, _enforceRefs).size(); } /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). bool isNull() const { return !node(m_root).size(); } @@ -211,6 +214,9 @@ public: iterator lower_bound(bytesConstRef _key) const { return iterator(this, _key); } +protected: + DB* db() const { return m_db; } + private: RLPStream& streamNode(RLPStream& _s, bytes const& _b); @@ -281,30 +287,33 @@ std::ostream& operator<<(std::ostream& _out, GenericTrieDB const& _db) return _out; } -template -class TrieDB: public GenericTrieDB +template +class SpecificTrieDB: public Generic { public: - TrieDB(DB* _db): GenericTrieDB(_db) {} - TrieDB(DB* _db, h256 _root): GenericTrieDB(_db, _root) {} + using DB = typename Generic::DB; + using KeyType = _KeyType; + + SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } - bool contains(KeyType _k) const { return GenericTrieDB::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return GenericTrieDB::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { GenericTrieDB::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + bool contains(KeyType _k) const { return Generic::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Generic::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Generic::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { GenericTrieDB::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void remove(KeyType _k) { Generic::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - class iterator: public GenericTrieDB::iterator + class iterator: public Generic::iterator { public: - using Super = typename GenericTrieDB::iterator; + using Super = typename Generic::iterator; using value_type = std::pair; iterator() {} - iterator(TrieDB const* _db): Super(_db) {} - iterator(TrieDB const* _db, bytesConstRef _k): Super(_db, _k) {} + iterator(Generic const* _db): Super(_db) {} + iterator(Generic const* _db, bytesConstRef _k): Super(_db, _k) {} value_type operator*() const { return at(); } value_type operator->() const { return at(); } @@ -317,27 +326,28 @@ public: iterator lower_bound(KeyType _k) const { return iterator(this, bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template -std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) +template +std::ostream& operator<<(std::ostream& _out, SpecificTrieDB const& _db) { for (auto const& i: _db) _out << i.first << ": " << escaped(i.second.toString(), false) << std::endl; return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -350,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... @@ -641,7 +685,7 @@ template void GenericTrieDB::iterator::next() } } -template typename TrieDB::iterator::value_type TrieDB::iterator::at() const +template typename SpecificTrieDB::iterator::value_type SpecificTrieDB::iterator::at() const { auto p = Super::at(); value_type ret; @@ -651,13 +695,6 @@ template typename TrieDB::iterator::value return ret; } -template void GenericTrieDB::init() -{ - m_root = insertNode(&RLPNull); -// std::cout << "Initialised root to " << m_root << std::endl; - assert(node(m_root).size()); -} - template void GenericTrieDB::insert(bytesConstRef _key, bytesConstRef _value) { #if ETH_PARANOIA diff --git a/test/trie.cpp b/test/trie.cpp index 39a3a59a5..4b676fb9a 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -48,6 +48,8 @@ static unsigned fac(unsigned _i) } } +using dev::operator <<; + BOOST_AUTO_TEST_SUITE(TrieTests) BOOST_AUTO_TEST_CASE(trie_test_anyorder) @@ -79,15 +81,35 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) next_permutation(ss.begin(), ss.end()); MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); for (auto const& k: ss) { t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } } } @@ -139,15 +161,33 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) { if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); + t.remove(k.first), ht.remove(k.first), ft.remove(k.first); else - t.insert(k.first, k.second); + t.insert(k.first, k.second), ht.insert(k.first, k.second), ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); From 13c082690dea862de2c132d172d3e984c45f4437 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 028/313] FatDB integrated. --- CMakeLists.txt | 7 ++++++- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/CommonEth.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cd7a80c4..156d0e5c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ function(createDefaultCacheConfig) set(PARANOIA OFF CACHE BOOL "Additional run-time checks") set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") + set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") endfunction() @@ -44,6 +45,10 @@ function(configureProject) add_definitions(-DETH_EVMJIT) endif() + if (FATDB) + add_definitions(-DETH_FATDB) + endif() + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() @@ -110,7 +115,7 @@ cmake_policy(SET CMP0015 NEW) createDefaultCacheConfig() configureProject() message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") -message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}") +message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}; FATDB: ${FATDB}") # Default TARGET_PLATFORM to "linux". diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 676193112..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 8facdf0f1..eba10e321 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 917239351..6aedc4c24 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -179,11 +179,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,10 +344,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -941,10 +939,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1180,9 +1177,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From 814349a8405533756a9929d3cb5cecb580c862e9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 029/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 47 ++++++++++++++++------------ libdevcore/FixedHash.h | 6 ++-- libdevcore/vector_ref.h | 2 +- libdevcrypto/MemoryDB.h | 8 +++-- libdevcrypto/OverlayDB.cpp | 13 ++++++++ libdevcrypto/OverlayDB.h | 2 ++ libdevcrypto/TrieDB.h | 2 +- libethcore/CommonEth.cpp | 2 +- libethereum/Account.h | 36 ++++++++++++++++------ libethereum/BlockChain.cpp | 15 ++++++--- libethereum/State.cpp | 8 ++--- libethereum/State.h | 63 ++++++++++++++++++++------------------ test/CMakeLists.txt | 2 +- test/stateOriginal.cpp | 36 ++++++++++++++++------ test/trie.cpp | 20 ++++++++++++ 15 files changed, 177 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 156d0e5c5..ba25e74ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() @@ -153,8 +154,11 @@ if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) endif () add_subdirectory(libsolidity) -add_subdirectory(lllc) -add_subdirectory(solc) + +if (NOT JUSTTESTS) + add_subdirectory(lllc) + add_subdirectory(solc) +endif() if (JSONRPC) add_subdirectory(libweb3jsonrpc) @@ -171,25 +175,30 @@ add_subdirectory(libethereum) add_subdirectory(libwebthree) add_subdirectory(test) -add_subdirectory(eth) -if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") - add_subdirectory(exp) -endif () +if (NOT JUSTTESTS) -# TODO check msvc -if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) - add_subdirectory(neth) -endif () + add_subdirectory(eth) + + if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") + add_subdirectory(exp) + endif () + + # TODO check msvc + if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) + add_subdirectory(neth) + endif () + + if (NOT HEADLESS) + + add_subdirectory(libnatspec) + add_subdirectory(libjsqrc) + add_subdirectory(alethzero) + add_subdirectory(third) + add_subdirectory(mix) + + endif() -if (NOT HEADLESS) - - add_subdirectory(libnatspec) - add_subdirectory(libjsqrc) - add_subdirectory(alethzero) - add_subdirectory(third) - add_subdirectory(mix) - endif() enable_testing() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 24fac9c0a..3113b5427 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,16 +65,16 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } /// Explicitly construct, copying from a string. - explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s)) {} + explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s), _ht) {} /// Convert to arithmetic type. operator Arith() const { return fromBigEndian(m_data); } diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index 42633f6f1..2c5f07e51 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -23,7 +23,7 @@ public: vector_ref(typename std::conditional::value, std::vector::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} vector_ref(typename std::conditional::value, std::string const&, std::string&>::type _data): m_data((_T*)_data.data()), m_count(_data.size() / sizeof(_T)) {} #ifdef STORAGE_LEVELDB_INCLUDE_DB_H_ - vector_ref(leveldb::Slice const& _s): m_data(_s.data()), m_count(_s.size() / sizeof(_T)) {} + vector_ref(leveldb::Slice const& _s): m_data(reinterpret_cast<_T*>(_s.data())), m_count(_s.size() / sizeof(_T)) {} #endif explicit operator bool() const { return m_data && m_count; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 816e393a3..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,14 +51,18 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; protected: + static h256 aux(h256 _k) { return h256(sha3(_k).ref().cropped(0, 24), h256::AlignLeft); } + std::map m_over; std::map m_refCount; + h256 m_auxKey; + std::map m_aux; mutable bool m_enforceRefs = false; }; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 9e110bb84..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -19,6 +19,7 @@ * @date 2014 */ +#include #include #include "OverlayDB.h" using namespace std; @@ -51,11 +52,23 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } } +bytes OverlayDB::lookupAux(h256 _h) const +{ + bytes ret = MemoryDB::lookupAux(_h); + if (!ret.empty()) + return ret; + std::string v; + m_db->Get(m_readOptions, _h.ref(), &v); + return asBytes(v); +} + void OverlayDB::rollback() { m_over.clear(); diff --git a/libdevcrypto/OverlayDB.h b/libdevcrypto/OverlayDB.h index e9bd53343..d027afbd4 100644 --- a/libdevcrypto/OverlayDB.h +++ b/libdevcrypto/OverlayDB.h @@ -51,6 +51,8 @@ public: bool exists(h256 _h) const; void kill(h256 _h); + bytes lookupAux(h256 _h) const; + private: using MemoryDB::clear; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..348cab59e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index eba10e321..ad41780e9 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/Account.h b/libethereum/Account.h index 3f3a5d548..2cc962baa 100644 --- a/libethereum/Account.h +++ b/libethereum/Account.h @@ -76,28 +76,40 @@ public: ContractConception }; + /// Changedness of account to create. + enum Changedness + { + /// Account starts as though it has been changed. + Changed, + /// Account starts as though it has not been changed. + Unchanged + }; + /// Construct a dead Account. Account() {} /// Construct an alive Account, with given endowment, for either a normal (non-contract) account or for a /// contract account in the /// conception phase, where the code is not yet known. - Account(u256 _balance, NewAccountType _t): m_isAlive(true), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} + Account(u256 _balance, NewAccountType _t, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} /// Explicit constructor for wierd cases of construction of a normal account. - Account(u256 _nonce, u256 _balance): m_isAlive(true), m_nonce(_nonce), m_balance(_balance) {} + Account(u256 _nonce, u256 _balance, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance) {} /// Explicit constructor for wierd cases of construction or a contract account. - Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash): m_isAlive(true), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } + Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash, Changedness _c): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } /// Kill this account. Useful for the suicide opcode. Following this call, isAlive() returns false. - void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; } + void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; changed(); } /// @returns true iff this object represents an account in the state. Returns false if this object /// represents an account that should no longer exist in the trie (an account that never existed or was /// suicided). bool isAlive() const { return m_isAlive; } + /// @returns true if the account is unchanged from creation. + bool isDirty() const { return !m_isUnchanged; } + /// @returns the balance of this account. Can be altered in place. u256& balance() { return m_balance; } @@ -106,7 +118,7 @@ public: u256 const& balance() const { return m_balance; } /// Increments the balance of this account by the given amount. It's a bigint, so can be negative. - void addBalance(bigint _i) { m_balance = (u256)((bigint)m_balance + _i); } + void addBalance(bigint _i) { if (!_i) return; m_balance = (u256)((bigint)m_balance + _i); changed(); } /// @returns the nonce of the account. Can be altered in place. u256& nonce() { return m_nonce; } @@ -115,7 +127,7 @@ public: u256 const& nonce() const { return m_nonce; } /// Increment the nonce of the account by one. - void incNonce() { m_nonce++; } + void incNonce() { m_nonce++; changed(); } /// @returns the root of the trie (whose nodes are stored in the state db externally to this class) @@ -127,7 +139,7 @@ public: /// Set a key/value pair in the account's storage. This actually goes into the overlay, for committing /// to the trie later. - void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; } + void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; changed(); } /// @returns true if we are in the contract-conception state and setCode is valid to call. bool isFreshCode() const { return m_codeHash == c_contractConceptionCodeHash; } @@ -140,8 +152,8 @@ public: h256 codeHash() const { assert(!isFreshCode()); return m_codeHash; } /// Sets the code of the account. Must only be called when isFreshCode() returns true. - void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; } - void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; } + void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } + void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } /// @returns true if the account's code is available through code(). bool codeCacheValid() const { return m_codeHash == EmptySHA3 || m_codeHash == c_contractConceptionCodeHash || m_codeCache.size(); } @@ -154,9 +166,15 @@ public: bytes const& code() const { assert(codeCacheValid()); return m_codeCache; } private: + /// Note that we've altered the account. + void changed() { m_isUnchanged = false; } + /// Is this account existant? If not, it represents a deleted account. bool m_isAlive = false; + /// True if we've not made any alteration to the account having been given it's properties directly. + bool m_isUnchanged = false; + /// Account's nonce. u256 m_nonce = 0; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index c7c55758b..d5c5e710c 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -19,6 +19,8 @@ * @date 2014 */ +#include + #include "BlockChain.h" #include @@ -43,14 +45,17 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_extrasDB->NewIterator(_bc.m_readOptions); + auto it = _bc.m_db->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { - string rlpString = it->value().ToString(); - RLP r(rlpString); - BlockDetails d(r); - _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parent << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + try { + BlockInfo d(bytesConstRef(it->value())); + _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parentHash << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + } + catch (...) { + cwarn << "Invalid DB entry:" << toHex(it->key().ToString()) << " -> " << toHex(bytesConstRef(it->value())); + } } delete it; return _out; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 6aedc4c24..014d0f91e 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -224,7 +224,7 @@ void State::ensureCached(std::map& _cache, Address _a, bool _r if (state.isNull()) s = Account(0, Account::NormalCreation); else - s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash()); + s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash(), Account::Unchanged); bool ok; tie(it, ok) = _cache.insert(make_pair(_a, s)); } @@ -625,7 +625,7 @@ void State::uncommitToMine() if (!m_transactions.size()) m_state.setRoot(m_previousBlock.stateRoot); else - m_state.setRoot(m_receipts[m_receipts.size() - 1].stateRoot()); + m_state.setRoot(m_receipts.back().stateRoot()); m_db = m_lastTx; paranoia("Uncommited to mine", true); m_currentBlock.sha3Uncles = h256(); @@ -890,7 +890,7 @@ Address State::newContract(u256 _balance, bytes const& _code) auto it = m_cache.find(ret); if (it == m_cache.end()) { - m_cache[ret] = Account(0, _balance, EmptyTrie, h); + m_cache[ret] = Account(0, _balance, EmptyTrie, h, Account::Changed); return ret; } } @@ -1144,7 +1144,7 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) _out << "--- " << _s.rootHash() << std::endl; std::set
d; std::set
dtr; - auto trie = TrieDB(const_cast(&_s.m_db), _s.rootHash()); + auto trie = SecureTrieDB(const_cast(&_s.m_db), _s.rootHash()); for (auto i: trie) d.insert(i.first), dtr.insert(i.first); for (auto i: _s.m_cache) diff --git a/libethereum/State.h b/libethereum/State.h index 37af0cf0e..a496a4a03 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -328,40 +328,43 @@ template void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) - if (!i.second.isAlive()) - _state.remove(i.first); - else + if (i.second.isDirty()) { - RLPStream s(4); - s << i.second.nonce() << i.second.balance(); - - if (i.second.storageOverlay().empty()) - { - assert(i.second.baseRoot()); - s.append(i.second.baseRoot()); - } + if (!i.second.isAlive()) + _state.remove(i.first); else { - SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7ddfdb40d..292f62a03 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) target_link_libraries(testeth solidity) -if (NOT HEADLESS) +if (NOT HEADLESS AND NOT JUSTTESTS) target_link_libraries(testeth webthree) target_link_libraries(testeth natspec) endif() diff --git a/test/stateOriginal.cpp b/test/stateOriginal.cpp index 65ff5084f..5b7b0415e 100644 --- a/test/stateOriginal.cpp +++ b/test/stateOriginal.cpp @@ -20,6 +20,7 @@ * State test functions. */ +#include #include #include #include @@ -29,7 +30,21 @@ using namespace std; using namespace dev; using namespace dev::eth; -int stateTest() +namespace dev +{ +namespace test +{ + +int stateTest(); + +BOOST_AUTO_TEST_SUITE(StateIntegration) + +BOOST_AUTO_TEST_CASE(Basic) +{ + State s; +} + +BOOST_AUTO_TEST_CASE(Complex) { cnote << "Testing State..."; @@ -37,14 +52,15 @@ int stateTest() KeyPair myMiner = sha3("Gav's Miner"); // KeyPair you = sha3("123"); - Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); + Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count())); OverlayDB stateDB = State::openDB(); CanonBlockChain bc; - State s(myMiner.address(), stateDB); - cout << bc; + State s(myMiner.address(), stateDB); + cout << s; + // Sync up - this won't do much until we use the last state. s.sync(bc); @@ -52,7 +68,7 @@ int stateTest() // Mine to get some ether! s.commitToMine(bc); - while (!s.mine(100).completed) {} + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -65,7 +81,7 @@ int stateTest() // Inject a transaction to transfer funds from miner to me. bytes tx; { - Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); + Transaction t(1000, 10000, 10000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); assert(t.sender() == myMiner.address()); tx = t.rlp(); } @@ -76,7 +92,7 @@ int stateTest() // Mine to get some ether and set in stone. s.commitToMine(bc); s.commitToMine(bc); - while (!s.mine(50).completed) { s.commitToMine(bc); } + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -85,7 +101,9 @@ int stateTest() s.sync(bc); cout << s; - - return 0; } +BOOST_AUTO_TEST_SUITE_END() + +} +} diff --git a/test/trie.cpp b/test/trie.cpp index 4b676fb9a..aa453925d 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -52,6 +52,26 @@ using dev::operator <<; BOOST_AUTO_TEST_SUITE(TrieTests) +BOOST_AUTO_TEST_CASE(fat_trie) +{ + h256 r; + MemoryDB fm; + { + FatGenericTrieDB ft(&fm); + ft.init(); + ft.insert(h256("69", h256::FromHex, h256::AlignRight).ref(), h256("414243", h256::FromHex, h256::AlignRight).ref()); + for (auto i: ft) + cnote << i.first << i.second; + r = ft.root(); + } + { + FatGenericTrieDB ft(&fm); + ft.setRoot(r); + for (auto i: ft) + cnote << i.first << i.second; + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From aae57a0382d229c2ced2647e43220cc809599d66 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 030/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 348cab59e..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From 53550684cb2ebdde9de1f9de3f063b06989b9ae9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 031/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 3 + libevm/ExtVMFace.h | 3 + libevm/FeeStructure.cpp | 59 +++++--- libevm/FeeStructure.h | 50 ++++--- libevm/VM.cpp | 197 ++++++--------------------- libevmcore/Instruction.cpp | 267 ++++++++++++++++++------------------- libevmcore/Instruction.h | 14 ++ 7 files changed, 259 insertions(+), 334 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 30cbf1a5a..40ff62175 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -69,6 +69,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } + /// Does the account exist? + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final { diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 13e8712b8..1bca3e2b2 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -142,6 +142,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address) { return 0; } + /// Does the account exist? + virtual bool exists(Address) { return false; } + /// Suicide the associated contract and give proceeds to the given address. virtual void suicide(Address) { sub.suicides.insert(myAddress); } diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 94eb956af..1c1bf8a9e 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -25,24 +25,41 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 const dev::eth::c_stepGas = 1; -u256 const dev::eth::c_balanceGas = 20; -u256 const dev::eth::c_sha3Gas = 10; -u256 const dev::eth::c_sha3WordGas = 10; -u256 const dev::eth::c_sloadGas = 20; -u256 const dev::eth::c_sstoreSetGas = 300; -u256 const dev::eth::c_sstoreResetGas = 100; -u256 const dev::eth::c_sstoreRefundGas = 100; -u256 const dev::eth::c_createGas = 100; -u256 const dev::eth::c_createDataGas = 5; -u256 const dev::eth::c_callGas = 20; -u256 const dev::eth::c_expGas = 1; -u256 const dev::eth::c_expByteGas = 1; -u256 const dev::eth::c_memoryGas = 1; -u256 const dev::eth::c_txDataZeroGas = 1; -u256 const dev::eth::c_txDataNonZeroGas = 5; -u256 const dev::eth::c_txGas = 500; -u256 const dev::eth::c_logGas = 32; -u256 const dev::eth::c_logDataGas = 1; -u256 const dev::eth::c_logTopicGas = 32; -u256 const dev::eth::c_copyGas = 1; +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + + diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 8ef384265..1b58c80e9 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,27 +28,37 @@ namespace dev namespace eth { -extern u256 const c_stepGas; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. -extern u256 const c_balanceGas; ///< Once per BALANCE operation. -extern u256 const c_sha3Gas; ///< Once per SHA3 operation. -extern u256 const c_sha3WordGas; -extern u256 const c_sloadGas; ///< Once per SLOAD operation. -extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. -extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. -extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. -extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. +extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. +extern u256 const c_expGas; ///< Once per EXP instuction. +extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + +extern u256 const c_sha3Gas; ///< Once per SHA3 operation. +extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + +extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + +extern u256 const c_sloadGas; ///< Once per SLOAD operation. +extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. +extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. +extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + +extern u256 const c_logGas; ///< Per LOG* operation. +extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. +extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. +extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; -extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_expGas; ///< Once per EXP instuction. -extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. -extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. -extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. -extern u256 const c_logGas; ///< Per LOG* operation. -extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. -extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. -extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. +extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. +extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. +extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + +extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. +extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. +extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2ba18eda6..a52b0ec3e 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -21,7 +21,7 @@ #include "VM.h" #include - +using namespace std; using namespace dev; using namespace dev::eth; @@ -32,13 +32,33 @@ void VM::reset(u256 _gas) noexcept m_jumpDests.clear(); } +struct InstructionMetric +{ + int gasPriceTier; + int args; +}; + +static array metrics() +{ + array s_ret; + for (unsigned i = 0; i < 256; ++i) + { + InstructionInfo inst = instructionInfo((Instruction)i); + s_ret[i].gasPriceTier = inst.gasPriceTier; + s_ret[i].args = inst.args; + } + return s_ret; +} + bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { + static const array c_metrics = metrics(); + auto memNeed = [](u256 _offset, dev::u256 _size) { return _size ? (bigint)_offset + _size : (bigint)0; }; auto gasForMem = [](bigint _size) -> bigint { bigint s = _size / 32; - return (bigint)c_memoryGas * (s + s * s / 1024); + return (bigint)c_memoryGas * s + s * s / c_quadCoeffDiv; }; if (m_jumpDests.empty()) @@ -57,36 +77,35 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) Instruction inst = (Instruction)_ext.getCode(m_curPC); // FEES... - bigint runGas = c_stepGas; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; + // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. + //m_onFail = std::function(onOperation); + + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; + require(metric.args); + auto onOperation = [&]() { if (_onOp) _onOp(osteps - _steps - 1, inst, newTempSize > m_temp.size() ? (newTempSize - m_temp.size()) / 32 : bigint(0), runGas, this, &_ext); }; - // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. - //m_onFail = std::function(onOperation); switch (inst) { - case Instruction::STOP: - runGas = 0; - break; - - case Instruction::SUICIDE: - require(1); - runGas = 0; - break; - case Instruction::SSTORE: - require(2); if (!_ext.store(m_stack.back()) && m_stack[m_stack.size() - 2]) runGas = c_sstoreSetGas; else if (_ext.store(m_stack.back()) && !m_stack[m_stack.size() - 2]) { - runGas = 0; + runGas = c_sstoreClearGas; _ext.sub.refunds += c_sstoreRefundGas; } else @@ -94,52 +113,39 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::SLOAD: - require(1); runGas = c_sloadGas; break; // These all operate on memory and therefore potentially expand it: case Instruction::MSTORE: - require(2); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::MSTORE8: - require(2); newTempSize = (bigint)m_stack.back() + 1; break; case Instruction::MLOAD: - require(1); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::RETURN: - require(2); newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::SHA3: - require(2); runGas = c_sha3Gas + (m_stack[m_stack.size() - 2] + 31) / 32 * c_sha3WordGas; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::CALLDATACOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::CODECOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::EXTCODECOPY: - require(4); copySize = m_stack[m_stack.size() - 4]; newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::BALANCE: - require(1); - runGas = c_balanceGas; - break; case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -147,7 +153,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::LOG4: { unsigned n = (unsigned)inst - (unsigned)Instruction::LOG0; - require(n + 2); runGas = c_logGas + c_logTopicGas * n + (bigint)c_logDataGas * m_stack[m_stack.size() - 2]; newTempSize = memNeed(m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]); break; @@ -155,149 +160,27 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: - require(7); runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + runGas += c_callNewAccountGas; + if (m_stack[m_stack.size() - 3] > 0) + runGas += c_callValueTransferGas; newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); break; case Instruction::CREATE: { - require(3); newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]); runGas = c_createGas; break; } case Instruction::EXP: { - require(2); auto expon = m_stack[m_stack.size() - 2]; runGas = c_expGas + c_expByteGas * (32 - (h256(expon).firstBitSet() / 8)); break; } - - case Instruction::BLOCKHASH: - require(1); - break; - - case Instruction::PC: - case Instruction::MSIZE: - case Instruction::GAS: - case Instruction::JUMPDEST: - case Instruction::ADDRESS: - case Instruction::ORIGIN: - case Instruction::CALLER: - case Instruction::CALLVALUE: - case Instruction::CALLDATASIZE: - case Instruction::CODESIZE: - case Instruction::GASPRICE: - case Instruction::COINBASE: - case Instruction::TIMESTAMP: - case Instruction::NUMBER: - case Instruction::DIFFICULTY: - case Instruction::GASLIMIT: - case Instruction::PUSH1: - case Instruction::PUSH2: - case Instruction::PUSH3: - case Instruction::PUSH4: - case Instruction::PUSH5: - case Instruction::PUSH6: - case Instruction::PUSH7: - case Instruction::PUSH8: - case Instruction::PUSH9: - case Instruction::PUSH10: - case Instruction::PUSH11: - case Instruction::PUSH12: - case Instruction::PUSH13: - case Instruction::PUSH14: - case Instruction::PUSH15: - case Instruction::PUSH16: - case Instruction::PUSH17: - case Instruction::PUSH18: - case Instruction::PUSH19: - case Instruction::PUSH20: - case Instruction::PUSH21: - case Instruction::PUSH22: - case Instruction::PUSH23: - case Instruction::PUSH24: - case Instruction::PUSH25: - case Instruction::PUSH26: - case Instruction::PUSH27: - case Instruction::PUSH28: - case Instruction::PUSH29: - case Instruction::PUSH30: - case Instruction::PUSH31: - case Instruction::PUSH32: - break; - case Instruction::NOT: - case Instruction::ISZERO: - case Instruction::CALLDATALOAD: - case Instruction::EXTCODESIZE: - case Instruction::POP: - case Instruction::JUMP: - require(1); - break; - case Instruction::ADD: - case Instruction::MUL: - case Instruction::SUB: - case Instruction::DIV: - case Instruction::SDIV: - case Instruction::MOD: - case Instruction::SMOD: - case Instruction::LT: - case Instruction::GT: - case Instruction::SLT: - case Instruction::SGT: - case Instruction::EQ: - case Instruction::AND: - case Instruction::OR: - case Instruction::XOR: - case Instruction::BYTE: - case Instruction::JUMPI: - case Instruction::SIGNEXTEND: - require(2); - break; - case Instruction::ADDMOD: - case Instruction::MULMOD: - require(3); - break; - case Instruction::DUP1: - case Instruction::DUP2: - case Instruction::DUP3: - case Instruction::DUP4: - case Instruction::DUP5: - case Instruction::DUP6: - case Instruction::DUP7: - case Instruction::DUP8: - case Instruction::DUP9: - case Instruction::DUP10: - case Instruction::DUP11: - case Instruction::DUP12: - case Instruction::DUP13: - case Instruction::DUP14: - case Instruction::DUP15: - case Instruction::DUP16: - require(1 + (int)inst - (int)Instruction::DUP1); - break; - case Instruction::SWAP1: - case Instruction::SWAP2: - case Instruction::SWAP3: - case Instruction::SWAP4: - case Instruction::SWAP5: - case Instruction::SWAP6: - case Instruction::SWAP7: - case Instruction::SWAP8: - case Instruction::SWAP9: - case Instruction::SWAP10: - case Instruction::SWAP11: - case Instruction::SWAP12: - case Instruction::SWAP13: - case Instruction::SWAP14: - case Instruction::SWAP15: - case Instruction::SWAP16: - require((int)inst - (int)Instruction::SWAP1 + 2); - break; - default: - BOOST_THROW_EXCEPTION(BadInstruction()); + default:; } newTempSize = (newTempSize + 31) / 32 * 32; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index bba3d7745..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -162,136 +162,136 @@ const std::map dev::eth::c_instructions = }; static const std::map c_instructionInfo = -{ // Add, Args, Ret, SideEffects - { Instruction::STOP, { "STOP", 0, 0, 0, true } }, - { Instruction::ADD, { "ADD", 0, 2, 1, false } }, - { Instruction::SUB, { "SUB", 0, 2, 1, false } }, - { Instruction::MUL, { "MUL", 0, 2, 1, false } }, - { Instruction::DIV, { "DIV", 0, 2, 1, false } }, - { Instruction::SDIV, { "SDIV", 0, 2, 1, false } }, - { Instruction::MOD, { "MOD", 0, 2, 1, false } }, - { Instruction::SMOD, { "SMOD", 0, 2, 1, false } }, - { Instruction::EXP, { "EXP", 0, 2, 1, false } }, - { Instruction::NOT, { "NOT", 0, 1, 1, false } }, - { Instruction::LT, { "LT", 0, 2, 1, false } }, - { Instruction::GT, { "GT", 0, 2, 1, false } }, - { Instruction::SLT, { "SLT", 0, 2, 1, false } }, - { Instruction::SGT, { "SGT", 0, 2, 1, false } }, - { Instruction::EQ, { "EQ", 0, 2, 1, false } }, - { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false } }, - { Instruction::AND, { "AND", 0, 2, 1, false } }, - { Instruction::OR, { "OR", 0, 2, 1, false } }, - { Instruction::XOR, { "XOR", 0, 2, 1, false } }, - { Instruction::BYTE, { "BYTE", 0, 2, 1, false } }, - { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false } }, - { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false } }, - { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false } }, - { Instruction::SHA3, { "SHA3", 0, 2, 1, false } }, - { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false } }, - { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false } }, - { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false } }, - { Instruction::CALLER, { "CALLER", 0, 0, 1, false } }, - { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false } }, - { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false } }, - { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false } }, - { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true } }, - { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false } }, - { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true } }, - { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } }, - { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } }, - { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true } }, - { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false } }, - { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false } }, - { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } }, - { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } }, - { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false } }, - { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false } }, - { Instruction::POP, { "POP", 0, 1, 0, false } }, - { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false } }, - { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true } }, - { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true } }, - { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false } }, - { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true } }, - { Instruction::JUMP, { "JUMP", 0, 1, 0, true } }, - { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true } }, - { Instruction::PC, { "PC", 0, 0, 1, false } }, - { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false } }, - { Instruction::GAS, { "GAS", 0, 0, 1, false } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true } }, - { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false } }, - { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false } }, - { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false } }, - { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false } }, - { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false } }, - { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false } }, - { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false } }, - { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false } }, - { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false } }, - { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false } }, - { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false } }, - { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false } }, - { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false } }, - { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false } }, - { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false } }, - { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false } }, - { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false } }, - { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false } }, - { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false } }, - { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false } }, - { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false } }, - { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false } }, - { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false } }, - { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false } }, - { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false } }, - { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false } }, - { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false } }, - { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false } }, - { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false } }, - { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false } }, - { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false } }, - { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false } }, - { Instruction::DUP1, { "DUP1", 0, 1, 2, false } }, - { Instruction::DUP2, { "DUP2", 0, 2, 3, false } }, - { Instruction::DUP3, { "DUP3", 0, 3, 4, false } }, - { Instruction::DUP4, { "DUP4", 0, 4, 5, false } }, - { Instruction::DUP5, { "DUP5", 0, 5, 6, false } }, - { Instruction::DUP6, { "DUP6", 0, 6, 7, false } }, - { Instruction::DUP7, { "DUP7", 0, 7, 8, false } }, - { Instruction::DUP8, { "DUP8", 0, 8, 9, false } }, - { Instruction::DUP9, { "DUP9", 0, 9, 10, false } }, - { Instruction::DUP10, { "DUP10", 0, 10, 11, false } }, - { Instruction::DUP11, { "DUP11", 0, 11, 12, false } }, - { Instruction::DUP12, { "DUP12", 0, 12, 13, false } }, - { Instruction::DUP13, { "DUP13", 0, 13, 14, false } }, - { Instruction::DUP14, { "DUP14", 0, 14, 15, false } }, - { Instruction::DUP15, { "DUP15", 0, 15, 16, false } }, - { Instruction::DUP16, { "DUP16", 0, 16, 17, false } }, - { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false } }, - { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false } }, - { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false } }, - { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false } }, - { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false } }, - { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false } }, - { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false } }, - { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false } }, - { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false } }, - { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false } }, - { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false } }, - { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false } }, - { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false } }, - { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false } }, - { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false } }, - { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false } }, - { Instruction::LOG0, { "LOG0", 0, 2, 0, true } }, - { Instruction::LOG1, { "LOG1", 0, 3, 0, true } }, - { Instruction::LOG2, { "LOG2", 0, 4, 0, true } }, - { Instruction::LOG3, { "LOG3", 0, 5, 0, true } }, - { Instruction::LOG4, { "LOG4", 0, 6, 0, true } }, - { Instruction::CREATE, { "CREATE", 0, 3, 1, true } }, - { Instruction::CALL, { "CALL", 0, 7, 1, true } }, - { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true } }, - { Instruction::RETURN, { "RETURN", 0, 2, 0, true } }, - { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true } } +{ // Add, Args, Ret, SideEffects, GasPriceTier + { Instruction::STOP, { "STOP", 0, 0, 0, true, ZeroTier } }, + { Instruction::ADD, { "ADD", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SUB, { "SUB", 0, 2, 1, false, VeryLowTier } }, + { Instruction::MUL, { "MUL", 0, 2, 1, false, LowTier } }, + { Instruction::DIV, { "DIV", 0, 2, 1, false, LowTier } }, + { Instruction::SDIV, { "SDIV", 0, 2, 1, false, LowTier } }, + { Instruction::MOD, { "MOD", 0, 2, 1, false, LowTier } }, + { Instruction::SMOD, { "SMOD", 0, 2, 1, false, LowTier } }, + { Instruction::EXP, { "EXP", 0, 2, 1, false, SpecialTier } }, + { Instruction::NOT, { "NOT", 0, 1, 1, false, VeryLowTier } }, + { Instruction::LT, { "LT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::GT, { "GT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SLT, { "SLT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SGT, { "SGT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::EQ, { "EQ", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false, VeryLowTier } }, + { Instruction::AND, { "AND", 0, 2, 1, false, VeryLowTier } }, + { Instruction::OR, { "OR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::XOR, { "XOR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::BYTE, { "BYTE", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, MidTier } }, + { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, MidTier } }, + { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, LowTier } }, + { Instruction::SHA3, { "SHA3", 0, 2, 1, false, SpecialTier } }, + { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, BaseTier } }, + { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, ExtTier } }, + { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLER, { "CALLER", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false, BaseTier } }, + { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false, ExtTier } }, + { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, ExtTier } }, + { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, ExtTier } }, + { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, BaseTier } }, + { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, BaseTier } }, + { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false, BaseTier } }, + { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false, BaseTier } }, + { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false, BaseTier } }, + { Instruction::POP, { "POP", 0, 1, 0, false, BaseTier } }, + { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true, VeryLowTier } }, + { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true, VeryLowTier } }, + { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false, SpecialTier } }, + { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true, SpecialTier } }, + { Instruction::JUMP, { "JUMP", 0, 1, 0, true, MidTier } }, + { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, HighTier } }, + { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, + { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false, VeryLowTier } }, + { Instruction::DUP1, { "DUP1", 0, 1, 2, false, VeryLowTier } }, + { Instruction::DUP2, { "DUP2", 0, 2, 3, false, VeryLowTier } }, + { Instruction::DUP3, { "DUP3", 0, 3, 4, false, VeryLowTier } }, + { Instruction::DUP4, { "DUP4", 0, 4, 5, false, VeryLowTier } }, + { Instruction::DUP5, { "DUP5", 0, 5, 6, false, VeryLowTier } }, + { Instruction::DUP6, { "DUP6", 0, 6, 7, false, VeryLowTier } }, + { Instruction::DUP7, { "DUP7", 0, 7, 8, false, VeryLowTier } }, + { Instruction::DUP8, { "DUP8", 0, 8, 9, false, VeryLowTier } }, + { Instruction::DUP9, { "DUP9", 0, 9, 10, false, VeryLowTier } }, + { Instruction::DUP10, { "DUP10", 0, 10, 11, false, VeryLowTier } }, + { Instruction::DUP11, { "DUP11", 0, 11, 12, false, VeryLowTier } }, + { Instruction::DUP12, { "DUP12", 0, 12, 13, false, VeryLowTier } }, + { Instruction::DUP13, { "DUP13", 0, 13, 14, false, VeryLowTier } }, + { Instruction::DUP14, { "DUP14", 0, 14, 15, false, VeryLowTier } }, + { Instruction::DUP15, { "DUP15", 0, 15, 16, false, VeryLowTier } }, + { Instruction::DUP16, { "DUP16", 0, 16, 17, false, VeryLowTier } }, + { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false, VeryLowTier } }, + { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false, VeryLowTier } }, + { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false, VeryLowTier } }, + { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false, VeryLowTier } }, + { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false, VeryLowTier } }, + { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false, VeryLowTier } }, + { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false, VeryLowTier } }, + { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false, VeryLowTier } }, + { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false, VeryLowTier } }, + { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false, VeryLowTier } }, + { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false, VeryLowTier } }, + { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false, VeryLowTier } }, + { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false, VeryLowTier } }, + { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false, VeryLowTier } }, + { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false, VeryLowTier } }, + { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false, VeryLowTier } }, + { Instruction::LOG0, { "LOG0", 0, 2, 0, true, SpecialTier } }, + { Instruction::LOG1, { "LOG1", 0, 3, 0, true, SpecialTier } }, + { Instruction::LOG2, { "LOG2", 0, 4, 0, true, SpecialTier } }, + { Instruction::LOG3, { "LOG3", 0, 5, 0, true, SpecialTier } }, + { Instruction::LOG4, { "LOG4", 0, 6, 0, true, SpecialTier } }, + { Instruction::CREATE, { "CREATE", 0, 3, 1, true, SpecialTier } }, + { Instruction::CALL, { "CALL", 0, 7, 1, true, SpecialTier } }, + { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, SpecialTier } }, + { Instruction::RETURN, { "RETURN", 0, 2, 0, true, ZeroTier } }, + { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true, ZeroTier } } }; string dev::eth::disassemble(bytes const& _mem) @@ -326,12 +326,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } catch (...) { -#ifndef BOOST_NO_EXCEPTIONS - cwarn << "\n" << boost::current_exception_diagnostic_information(); -#else - cwarn << "\n"; -#endif - return InstructionInfo({"", 0, 0, 0, false}); + return InstructionInfo({"", 0, 0, 0, false, InvalidTier}); } } diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h index 5cf002c4c..9eab92713 100644 --- a/libevmcore/Instruction.h +++ b/libevmcore/Instruction.h @@ -223,6 +223,19 @@ inline Instruction logInstruction(unsigned _number) return Instruction(unsigned(Instruction::LOG0) + _number); } +enum Tier +{ + ZeroTier = 0, // 0, Zero + BaseTier, // 2, Quick + VeryLowTier, // 3, Fastest + LowTier, // 5, Fast + MidTier, // 8, Mid + HighTier, // 10, Slow + ExtTier, // 20, Ext + SpecialTier, // multiparam or otherwise special + InvalidTier // Invalid. +}; + /// Information structure for a particular instruction. struct InstructionInfo { @@ -231,6 +244,7 @@ struct InstructionInfo int args; ///< Number of items required on the stack for this instruction (and, for the purposes of ret, the number taken from the stack). int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed. bool sideEffects; ///< false if the only effect on the execution environment (apart from gas usage) is a change to a topmost segment of the stack + int gasPriceTier; ///< Tier for gas pricing. }; /// Information on all the instructions. From de177effb08484bfabd2060f5b7619a862ac8b77 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 032/313] Gas fixes. Trie fixes. --- libdevcore/Exceptions.h | 1 + libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 8 ++++++-- libethereum/Client.cpp | 5 +++-- libevm/VM.cpp | 15 +++++++-------- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index f3f9b1bf0..3861c69fe 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -40,6 +40,7 @@ struct BadRLP: virtual RLPException {}; struct NoNetworking: virtual Exception {}; struct NoUPnPDevice: virtual Exception {}; struct RootNotFound: virtual Exception {}; +struct BadRoot: virtual Exception {}; struct FileError: virtual Exception {}; struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): m_f("Interface " + _f + " not supported.") {} virtual const char* what() const noexcept { return m_f.c_str(); } private: std::string m_f; }; diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -93,7 +93,7 @@ public: /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). bool isEmpty() const { return m_root == c_shaNull && node(m_root).size(); } - h256 root() const { assert(node(m_root).size()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. + h256 root() const { if (!node(m_root).size()) BOOST_THROW_EXCEPTION(BadRoot()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. void debugPrint() {} @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 5ea513f0a..73e1092af 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -277,13 +277,14 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -#if ETH_DEBUG +#if ETH_DEBUG && 0 cdebug << "checkWatch" << _watchId; #endif auto& w = m_watches.at(_watchId); -#if ETH_DEBUG +#if ETH_DEBUG && 0 cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); #endif + auto& w = m_watches.at(_watchId); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index a52b0ec3e..6a6937f89 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -75,21 +75,20 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { // INSTRUCTION... Instruction inst = (Instruction)_ext.getCode(m_curPC); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -186,7 +185,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = (newTempSize + 31) / 32 * 32; if (newTempSize > m_temp.size()) runGas += gasForMem(newTempSize) - gasForMem(m_temp.size()); - runGas += c_copyGas * (copySize + 31) / 32; + runGas += c_copyGas * ((copySize + 31) / 32); onOperation(); // if (_onOp) From c6c25b933dfa96bc47d5cd11fc401223e4d8acfb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 033/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 6a6937f89..2243da2e7 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From a04ae1dabd74b6c353a724ad2bb67f72ad8d5cc5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 034/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- test/vm.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 40ff62175..2ff270de5 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/test/vm.h b/test/vm.h index 0a5b5fb45..c13a97276 100644 --- a/test/vm.h +++ b/test/vm.h @@ -50,6 +50,7 @@ public: virtual u256 store(u256 _n) override { return std::get<2>(addresses[myAddress])[_n]; } virtual void setStore(u256 _n, u256 _v) override { std::get<2>(addresses[myAddress])[_n] = _v; } + virtual bool exists(Address _a) override { return !!addresses.count(_a); } virtual u256 balance(Address _a) override { return std::get<0>(addresses[_a]); } virtual void subBalance(u256 _a) override { std::get<0>(addresses[myAddress]) -= _a; } virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); } From e6e0f13e2f2453099b4b36dc3faf5878319c4606 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 035/313] only check rootHash of state if FATDB is off --- test/state.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/state.cpp b/test/state.cpp index 1581e4055..37ffa7f8e 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -71,7 +71,13 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } if (_fillin) + { +#if ETH_FATDB importer.exportTest(output, theState); +#else + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off")); +#endif + } else { BOOST_REQUIRE(o.count("post") > 0); @@ -84,6 +90,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); // check addresses +#if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -102,6 +110,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } } checkAddresses >(expectedAddrs, resultAddrs); +#endif + BOOST_CHECK_MESSAGE(theState.rootHash() == h256(o["postStateRoot"].get_str()), "wrong post state root"); } } } From 91d31a94dc8069da02f1b2bfbdab895c63087e49 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 036/313] add memory tests --- test/TestHelper.cpp | 2 ++ test/stMemoryTestFiller.json | 4 +--- test/state.cpp | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index ea44111c9..1d544304c 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -203,6 +203,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost) } m_TestObject["post"] = json_spirit::mValue(postState); + m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes()); + // export pre state json_spirit::mObject preState; diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json index e2b3b95a0..eac2d5875 100644 --- a/test/stMemoryTestFiller.json +++ b/test/stMemoryTestFiller.json @@ -1459,7 +1459,5 @@ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "0xff55883355001144bbccddffeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } - }, - - + } } diff --git a/test/state.cpp b/test/state.cpp index 37ffa7f8e..d49938db2 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -91,7 +91,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -207,7 +206,20 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) BOOST_AUTO_TEST_CASE(stSolidityTest) { - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } BOOST_AUTO_TEST_CASE(stMemoryTest) @@ -215,6 +227,24 @@ BOOST_AUTO_TEST_CASE(stMemoryTest) dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } +BOOST_AUTO_TEST_CASE(stMemoryStressTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From 0e97752530c0d139d85d138f35454b2b15e29aa6 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 037/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From 0360b20af11ce5a628a076041d4024d76a0930bd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:18:00 +0100 Subject: [PATCH 038/313] Avoid invalid paranoia tests. --- libethereum/State.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 014d0f91e..6b594e7a5 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -133,7 +133,7 @@ State::State(State const& _s): void State::paranoia(std::string const& _when, bool _enforceRefs) const { -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB // TODO: variable on context; just need to work out when there should be no leftovers // [in general this is hard since contract alteration will result in nodes in the DB that are no directly part of the state DB]. if (!isTrieGood(_enforceRefs, false)) @@ -1084,7 +1084,7 @@ u256 State::execute(LastHashes const& _lh, bytesConstRef _rlp, bytes* o_output, commit(); -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB ctrace << "Executed; now" << rootHash(); ctrace << old.diff(*this); From cf440f7ae798157909e7622b2cd02549f880b92d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 039/313] update gas costs --- libevm/FeeStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..58d756bae 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From 14496b68aa77081a991456f06bee3cbffe68336f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 040/313] Log/bloom alterations. --- libdevcore/FixedHash.h | 2 ++ libethcore/BlockInfo.cpp | 2 +- libethcore/CommonEth.h | 7 +++++-- libethereum/BlockDetails.h | 4 ++-- libevm/FeeStructure.cpp | 7 ++++--- libevm/FeeStructure.h | 1 + libevm/VM.cpp | 17 ++--------------- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 3113b5427..eec988d76 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -240,6 +240,8 @@ inline std::ostream& operator<<(std::ostream& _out, FixedHash const& _h) } // Common types of FixedHash. +using h2048 = FixedHash<256>; +using h1024 = FixedHash<128>; using h520 = FixedHash<65>; using h512 = FixedHash<64>; using h256 = FixedHash<32>; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ce158c3cc..ce4407317 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -101,7 +101,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) stateRoot = _header[field = 3].toHash(); transactionsRoot = _header[field = 4].toHash(); receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + logBloom = _header[field = 6].toHash(); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 79525082f..89ca0aa06 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -44,8 +44,11 @@ std::string formatBalance(bigint const& _b); /// Get information concerning the currency denominations. std::vector> const& units(); -/// The log bloom's size (512 bit). -using LogBloom = h512; +/// The log bloom's size (2048-bit). +using LogBloom = h2048; + +/// Many log blooms. +using LogBlooms = std::vector; template inline u256 exp10() { diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 61b9667c4..9a3ac9ff1 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -55,10 +55,10 @@ struct BlockDetails struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } bytes rlp() const { RLPStream s; s << blooms; return s.out(); } - h512s blooms; + LogBlooms blooms; }; struct BlockReceipts diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 58d756bae..03dd14850 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 1b58c80e9..120034b0e 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2243da2e7..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -563,21 +563,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::JUMPDEST: break; -/* case Instruction::LOG0: - _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); - break; - case Instruction::LOG1: - _ext.log({m_stack[m_stack.size() - 1]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 2], (unsigned)m_stack[m_stack.size() - 3])); - break; - case Instruction::LOG2: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 3], (unsigned)m_stack[m_stack.size() - 4])); - break; - case Instruction::LOG3: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 4], (unsigned)m_stack[m_stack.size() - 5])); - break; - case Instruction::LOG4: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3], m_stack[m_stack.size() - 4]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 5], (unsigned)m_stack[m_stack.size() - 6])); - break;*/ case Instruction::LOG0: _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); m_stack.pop_back(); @@ -635,6 +620,8 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALLCODE: { u256 gas = m_stack.back(); + if (m_stack[m_stack.size() - 3] > 0) + gas += c_callStipend; m_stack.pop_back(); Address receiveAddress = asAddress(m_stack.back()); m_stack.pop_back(); From 7ffdabdaca1792ebe647e1e66c4419760f2bbd32 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 041/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba25e74ce..43ee58eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 732782d3f..97e9a220b 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -82,10 +82,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)500; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)1 + (i.size() + 31) / 32 * 1; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index aa453925d..bdb188651 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -72,6 +72,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From d07ea7a8d374ba8b8e1a3d8dbd2324d9ea85abad Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 042/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 38 +++++++++++++++++++++++++++++++++++++ libethereum/GenesisInfo.cpp | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 feeStructure.json diff --git a/feeStructure.json b/feeStructure.json new file mode 100644 index 000000000..f09464a5a --- /dev/null +++ b/feeStructure.json @@ -0,0 +1,38 @@ +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, + + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index b9b45d4b4..d7224b7cc 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -24,6 +24,10 @@ std::string const dev::eth::c_genesisInfo = R"ETHEREUM( { + "0000000000000000000000000000000000000001": { "wei": "1" }, + "0000000000000000000000000000000000000002": { "wei": "1" }, + "0000000000000000000000000000000000000003": { "wei": "1" }, + "0000000000000000000000000000000000000004": { "wei": "1" }, "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e6716f9544a56c530d868e4bfbacb172315bdead": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "b9c015918bdaba24b4ff057a92a3873d6eb201be": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, From 989d684aff74dc5dea63e85790a0507165248dbd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 043/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethereum/GenesisInfo.cpp | 4 -- libethereum/Precompiled.cpp | 9 ++-- libevm/FeeStructure.cpp | 85 ++++++++++++++++++----------------- libevm/FeeStructure.h | 8 ++++ 5 files changed, 109 insertions(+), 85 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index d7224b7cc..4e6a48284 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -36,9 +36,5 @@ R"ETHEREUM( "cd2a3d9f938e13cd947ec05abc7fe734df8dd826": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "6c386a4b26f73c802f34673f7248bb118f97424a": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e4157b34ea9615cfbde6b4fda419828124b70c78": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, - "b0afc46d9ce366d06ab4952ca27db1d9557ae9fd": { "finney": "154162184" }, - "f6b1e9dc460d4d62cc22ec5f987d726929c0f9f0": { "finney": "102774789" }, - "cc45122d8b7fa0b1eaa6b29e0fb561422a9239d0": { "finney": "51387394" }, - "b7576e9d314df41ec5506494293afb1bd5d3f65d": { "finney": "69423399" }, } )ETHEREUM"; diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 97e9a220b..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace std; using namespace dev; using namespace dev::eth; @@ -82,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 03dd14850..78c6ebfb2 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,45 +22,48 @@ #include "FeeStructure.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 120034b0e..9d60ac1bd 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } From b2a4ded0bcdc4fa01285535a4777f62785404c3e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 044/313] VM CALLCODE fix. --- libevm/FeeStructure.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9d60ac1bd..9109347dc 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From 91cabff0597c7580d8382c45c2d9c1104ab57508 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:03:47 +0100 Subject: [PATCH 045/313] Lenient gas limit. Two uncles only. Min 2048 difficulty & assoc adjustment. --- libethcore/BlockInfo.cpp | 9 ++++++--- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 3 ++- libethereum/State.cpp | 21 +++++++++++---------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ce4407317..49ed1578b 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -191,16 +191,19 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(1024, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty >> 10) : (_parent.difficulty + (_parent.difficulty >> 10))); + return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } +template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } + void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (gasLimit != calculateGasLimit(_parent)) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent))); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + // Check timestamp is after previous timestamp. if (parentHash) diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index 9b07743c5..c4628f4aa 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " valid:" + toString(valid) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 3fd62afbd..4679c1961 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -47,6 +47,7 @@ struct InvalidSignature: virtual dev::Exception {}; class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual const char* what() const noexcept; }; struct InvalidUnclesHash: virtual dev::Exception {}; struct InvalidUncle: virtual dev::Exception {}; +struct TooManyUncles: virtual dev::Exception {}; struct UncleTooOld: virtual dev::Exception {}; class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual const char* what() const noexcept; }; struct DuplicateUncleNonce: virtual dev::Exception {}; @@ -55,7 +56,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 6b594e7a5..a9837d118 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -486,10 +486,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) receiptsTrie.init(); LastHashes lh = getLastHashes(_bc, (unsigned)m_previousBlock.number); + RLP rlp(_block); // All ok with the block generally. Play back the transactions now... unsigned i = 0; - for (auto const& tr: RLP(_block)[1]) + for (auto const& tr: rlp[1]) { RLPStream k; k << i; @@ -503,17 +504,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) ++i; } - if (transactionsTrie.root() != m_currentBlock.transactionsRoot) - { - cwarn << "Bad transactions state root!"; - BOOST_THROW_EXCEPTION(InvalidTransactionsStateRoot()); - } - if (receiptsTrie.root() != m_currentBlock.receiptsRoot) { cwarn << "Bad receipts state root."; cwarn << "Block:" << toHex(_block); - cwarn << "Block RLP:" << RLP(_block); + cwarn << "Block RLP:" << rlp; cwarn << "Calculated: " << receiptsTrie.root(); for (unsigned j = 0; j < i; ++j) { @@ -548,10 +543,14 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) u256 tdIncrease = m_currentBlock.difficulty; // Check uncles & apply their rewards to state. + if (rlp[2].itemCount() > 2) + BOOST_THROW_EXCEPTION(TooManyUncles()); + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); - for (auto const& i: RLP(_block)[2]) + + for (auto const& i: rlp[2]) { if (knownUncles.count(sha3(i.data()))) BOOST_THROW_EXCEPTION(UncleInChain(knownUncles, sha3(i.data()) )); @@ -699,7 +698,7 @@ void State::commitToMine(BlockChain const& _bc) // cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); auto p = m_previousBlock.parentHash; - for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash(); ++gen, p = _bc.details(p).parent) + for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash() && unclesCount < 2; ++gen, p = _bc.details(p).parent) { auto us = _bc.details(p).children; assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent! @@ -710,6 +709,8 @@ void State::commitToMine(BlockChain const& _bc) ubi.streamRLP(unclesData, WithNonce); ++unclesCount; uncleAddresses.push_back(ubi.coinbaseAddress); + if (unclesCount == 2) + break; } } } From 83952acf0e4c0487d934900aea6daf96943f60f7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:12:27 +0100 Subject: [PATCH 046/313] state rebase. --- test/state.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index d49938db2..7230d05fc 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -227,24 +227,6 @@ BOOST_AUTO_TEST_CASE(stMemoryTest) dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stMemoryStressTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From b0efa82daa46a5c6822bba2013dcf4c593414cb7 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 17:36:09 +0100 Subject: [PATCH 047/313] remove genesis state from state tests Conflicts: test/state.cpp --- test/TestHelper.cpp | 10 +------ test/TestHelper.h | 3 +-- test/state.cpp | 64 +++++++++++++++++++++++++++------------------ 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 1d544304c..6d5a91cdd 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -67,7 +67,7 @@ namespace test struct ValueTooLarge: virtual Exception {}; bigint const c_max256plus1 = bigint(1) << 256; -ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o) +ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller) : m_statePre(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) { importEnv(_o["env"].get_obj()); importState(_o["pre"].get_obj(), m_statePre); @@ -181,13 +181,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost) // export post state json_spirit::mObject postState; - std::map genesis = genesisState(); - for (auto const& a: _statePost.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(_statePost.balance(a.first)); o["nonce"] = toString(_statePost.transactionsFrom(a.first)); @@ -210,9 +205,6 @@ void ImportTest::exportTest(bytes _output, State& _statePost) for (auto const& a: m_statePre.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(m_statePre.balance(a.first)); o["nonce"] = toString(m_statePre.transactionsFrom(a.first)); diff --git a/test/TestHelper.h b/test/TestHelper.h index c4dde1a60..75edcbf31 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -45,9 +45,8 @@ namespace test class ImportTest { public: - ImportTest(json_spirit::mObject& _o) : m_TestObject(_o) {} + ImportTest(json_spirit::mObject& _o) : m_statePre(Address(), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) {} ImportTest(json_spirit::mObject& _o, bool isFiller); - // imports void importEnv(json_spirit::mObject& _o); void importState(json_spirit::mObject& _o, eth::State& _state); diff --git a/test/state.cpp b/test/state.cpp index 7649dae61..8db082d0c 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -64,6 +64,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) catch (Exception const& _e) { cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); } catch (std::exception const& _e) { @@ -168,39 +169,52 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } +//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--quadratic" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); + +// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} + BOOST_AUTO_TEST_CASE(stMemoryStressTest) { - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - else if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } + BOOST_AUTO_TEST_CASE(stMemoryTest) { - dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); -} BOOST_AUTO_TEST_CASE(stCreateTest) { From 2ffb554a9d46122cdcb6a1e2da53df5c93f6ae66 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 11:55:22 +0100 Subject: [PATCH 048/313] New Proof-of-Work. --- CMakeLists.txt | 3 +- alethzero/MainWin.cpp | 2 +- eth/CMakeLists.txt | 2 +- libdevcore/Common.h | 1 + libdevcore/CommonData.h | 5 +- libdevcore/CommonIO.cpp | 23 +++ libdevcore/CommonIO.h | 4 + libdevcore/FixedHash.h | 1 + libethcore/BlockInfo.cpp | 20 ++- libethcore/BlockInfo.h | 8 +- libethcore/CMakeLists.txt | 1 + libethcore/CommonEth.cpp | 2 +- libethcore/CommonEth.h | 2 + libethcore/Exceptions.h | 3 +- libethcore/ProofOfWork.cpp | 182 ++++++++++++++------ libethcore/ProofOfWork.h | 67 ++++--- libethereum/CanonBlockChain.cpp | 4 +- libethereum/Client.cpp | 4 +- libethereum/Client.h | 6 +- libethereum/Interface.h | 2 +- libethereum/State.cpp | 21 ++- libethereum/State.h | 2 +- libweb3jsonrpc/WebThreeStubServerBase.cpp | 4 +- libweb3jsonrpc/WebThreeStubServerBase.h | 2 +- libweb3jsonrpc/abstractwebthreestubserver.h | 6 +- libweb3jsonrpc/spec.json | 2 +- mix/MixClient.h | 2 +- test/block.cpp | 56 +++--- test/dagger.cpp | 2 + test/webthreestubclient.h | 3 +- 30 files changed, 301 insertions(+), 141 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ee58eaa..dffdd9027 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ function(configureProject) endif() endfunction() - +set(CPPETHEREUM 1) function(createBuildInfo) # Set build platform; to be written to BuildInfo.h @@ -174,6 +174,7 @@ add_subdirectory(libp2p) add_subdirectory(libdevcrypto) add_subdirectory(libwhisper) +add_subdirectory(libethash) add_subdirectory(libethcore) add_subdirectory(libevm) add_subdirectory(libethereum) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index a4c8a7b60..08117e596 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1362,7 +1362,7 @@ void Main::on_blocks_currentItemChanged() s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info.headerHash(WithoutNonce), info.nonce) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index bc458a50f..64cee3e12 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -26,7 +26,7 @@ if (JSONRPC) endif() target_link_libraries(${EXECUTABLE} webthree) -target_link_libraries(${EXECUTABLE} secp256k1) +target_link_libraries(${EXECUTABLE} ethash) if (WIN32) add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 9edeacccb..764b3454e 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -65,6 +65,7 @@ using bytesConstRef = vector_ref; // Numeric types. using bigint = boost::multiprecision::number>; +using u64 = boost::multiprecision::number>; using u128 = boost::multiprecision::number>; using u256 = boost::multiprecision::number>; using s256 = boost::multiprecision::number>; diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 3cdf3b449..2c9fd30ef 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -96,7 +96,10 @@ template inline void toBigEndian(_T _val, _Out& o_out) { for (auto i = o_out.size(); i-- != 0; _val >>= 8) - o_out[i] = (typename _Out::value_type)(uint8_t)_val; + { + _T v = _val & (_T)0xff; + o_out[i] = (typename _Out::value_type)(uint8_t)v; + } } /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index feb4121cb..288dbd1ff 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -57,6 +57,24 @@ string dev::memDump(bytes const& _bytes, unsigned _width, bool _html) return ret.str(); } +// Don't forget to delete[] later. +bytesRef dev::contentsNew(std::string const& _file) +{ + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return bytesRef(); + // get length of file: + is.seekg (0, is.end); + streamoff length = is.tellg(); + if (length == 0) // return early, MSVC does not like reading 0 bytes + return bytesRef(); + is.seekg (0, is.beg); + bytesRef ret(new byte[length], length); + is.read((char*)ret.data(), length); + is.close(); + return ret; +} + bytes dev::contents(std::string const& _file) { std::ifstream is(_file, std::ifstream::binary); @@ -79,3 +97,8 @@ void dev::writeFile(std::string const& _file, bytes const& _data) ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); } +void dev::writeFile(std::string const& _file, bytesConstRef _data) +{ + ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); +} + diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 23092b702..5769b6c64 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -42,9 +42,13 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +/// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. +bytesRef contentsNew(std::string const& _file); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytes const& _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +void writeFile(std::string const& _file, bytesConstRef _data); /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index eec988d76..7fa5b411a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -247,6 +247,7 @@ using h512 = FixedHash<64>; using h256 = FixedHash<32>; using h160 = FixedHash<20>; using h128 = FixedHash<16>; +using h64 = FixedHash<8>; using h512s = std::vector; using h256s = std::vector; using h160s = std::vector; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 49ed1578b..6c645372e 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -30,7 +30,7 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 17; +u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; BlockInfo::BlockInfo(): timestamp(Invalid256) { @@ -56,7 +56,9 @@ void BlockInfo::setEmpty() gasUsed = 0; timestamp = 0; extraData.clear(); - nonce = h256(); + seedHash = h256(); + mixBytes = h256(); + nonce = Nonce(); hash = headerHash(WithNonce); } @@ -76,11 +78,11 @@ h256 BlockInfo::headerHash(IncludeNonce _n) const void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const { - _s.appendList(_n == WithNonce ? 14 : 13) + _s.appendList(_n == WithNonce ? 16 : 14) << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom - << difficulty << number << gasLimit << gasUsed << timestamp << extraData; + << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << nonce; + _s << mixBytes << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -108,7 +110,9 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - nonce = _header[field = 13].toHash(); + seedHash = _header[field = 13].toHash(); + mixBytes = _header[field = 14].toHash(); + nonce = _header[field = 15].toHash(); } catch (Exception const& _e) @@ -118,7 +122,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) } // check it hashes according to proof of work or that it's the genesis block. - if (_checkNonce && parentHash && !ProofOfWork::verify(headerHash(WithoutNonce), nonce, difficulty)) + if (_checkNonce && parentHash && !ProofOfWork::verify(*this)) BOOST_THROW_EXCEPTION(InvalidBlockNonce(headerHash(WithoutNonce), nonce, difficulty)); if (gasUsed > gasLimit) @@ -176,6 +180,7 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); + seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -204,7 +209,6 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); - // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 99efc6a17..fbc459b76 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -76,7 +76,9 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 nonce; + h256 mixBytes; + h256 seedHash; + Nonce nonce; BlockInfo(); explicit BlockInfo(bytes const& _block): BlockInfo(&_block) {} @@ -104,6 +106,8 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && + mixBytes == _cmp.mixBytes && + seedHash == _cmp.seedHash && nonce == _cmp.nonce; } bool operator!=(BlockInfo const& _cmp) const { return !operator==(_cmp); } @@ -129,7 +133,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 920f9f652..88308b630 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -22,6 +22,7 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() +target_link_libraries(${EXECUTABLE} ethash) target_link_libraries(${EXECUTABLE} devcrypto) target_link_libraries(${EXECUTABLE} devcore) diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index ad41780e9..822ede5aa 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 55; +const unsigned c_protocolVersion = 56; const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 89ca0aa06..edefda380 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -66,5 +66,7 @@ static const u256 finney = exp10<15>(); static const u256 szabo = exp10<12>(); static const u256 wei = exp10<0>(); +using Nonce = h64; + } } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 4679c1961..5a8a2d055 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,6 +22,7 @@ #pragma once #include +#include "CommonEth.h" namespace dev { @@ -64,7 +65,7 @@ struct InvalidReceiptsStateRoot: virtual dev::Exception {}; struct InvalidTimestamp: virtual dev::Exception {}; struct InvalidLogBloom: virtual dev::Exception {}; class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; }; -class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual const char* what() const noexcept; }; +class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), Nonce _n = Nonce(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; Nonce n; u256 d; virtual const char* what() const noexcept; }; struct InvalidParentHash: virtual dev::Exception {}; struct InvalidNumber: virtual dev::Exception {}; struct InvalidContractAddress: virtual public dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 181e379b5..084225a38 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -20,12 +20,18 @@ */ #include +#include #include #include #include #include +#include +#include #include +#include #include +#include +#include "BlockInfo.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -35,72 +41,144 @@ namespace dev namespace eth { -template -static inline void update(_T& _sha, u256 const& _value) +class Ethasher { - int i = 0; - for (u256 v = _value; v; ++i, v >>= 8) {} - byte buf[32]; - bytesRef bufRef(buf, i); - toBigEndian(_value, bufRef); - _sha.Update(buf, i); -} +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; + } + + byte const* full(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash].data(); + } + + static ethash_params params(BlockInfo const& _header) + { + return params((unsigned)_header.number); + } + + static ethash_params params(unsigned _n) + { + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; + } + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; -template -static inline void update(_T& _sha, h256 const& _value) +Ethasher* Ethasher::s_this = nullptr; + +bool Ethash::verify(BlockInfo const& _header) { - int i = 0; - byte const* data = _value.data(); - for (; i != 32 && data[i] == 0; ++i); - _sha.Update(data + i, 32 - i); + bigint boundary = (bigint(1) << 256) / _header.difficulty; + u256 e(eval(_header, _header.nonce)); + return e <= boundary; } -template -static inline h256 get(_T& _sha) +h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { - h256 ret; - _sha.TruncatedFinal(&ret[0], 32); - return ret; + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return h256(r.result, h256::ConstructFromPointer); } -h256 DaggerEvaluator::node(h256 const& _root, h256 const& _xn, uint_fast32_t _L, uint_fast32_t _i) +std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - if (_L == _i) - return _root; - u256 m = (_L == 9) ? 16 : 3; - CryptoPP::SHA3_256 bsha; - for (uint_fast32_t k = 0; k < m; ++k) + auto h = _header.headerHash(WithoutNonce); + auto p = Ethasher::params(_header); + auto d = Ethasher::get()->full(_header); + + std::pair ret; + static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); + uint64_t tryNonce = (uint64_t)(u64)(m_last = Nonce::random(s_eng)); + + bigint boundary = (bigint(1) << 256) / _header.difficulty; + ret.first.requirement = log2((double)boundary); + + // 2^ 0 32 64 128 256 + // [--------*-------------------------] + // + // evaluate until we run out of time + auto startTime = std::chrono::steady_clock::now(); + if (!_turbo) + std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); + double best = 1e99; // high enough to be effectively infinity :) + Proof result; + ethash_return_value ethashReturn; + unsigned hashCount = 0; + for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - CryptoPP::SHA3_256 sha; - update(sha, _root); - update(sha, _xn); - update(sha, (u256)_L); - update(sha, (u256)_i); - update(sha, (u256)k); - uint_fast32_t pk = (uint_fast32_t)(u256)get(sha) & ((1 << ((_L - 1) * 3)) - 1); - auto u = node(_root, _xn, _L - 1, pk); - update(bsha, u); + ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); + u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + best = std::min(best, log2((double)val)); + if (val <= boundary) + { + ret.first.completed = true; + result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.nonce = u64(tryNonce); + break; + } } - return get(bsha); -} + ret.first.hashes = hashCount; + ret.first.best = best; + ret.second = result; -h256 DaggerEvaluator::eval(h256 const& _root, h256 const& _nonce) -{ - h256 extranonce = (u256)_nonce >> 26; // with xn = floor(n / 2^26) -> assuming this is with xn = floor(N / 2^26) - CryptoPP::SHA3_256 bsha; - for (uint_fast32_t k = 0; k < 4; ++k) + if (ret.first.completed) { - //sha256(D || xn || i || k) -> sha256(D || xn || k) - there's no 'i' here! - CryptoPP::SHA3_256 sha; - update(sha, _root); - update(sha, extranonce); - update(sha, _nonce); - update(sha, (u256)k); - uint_fast32_t pk = (uint_fast32_t)(u256)get(sha) & 0x1ffffff; // mod 8^8 * 2 [ == mod 2^25 ?! ] [ == & ((1 << 25) - 1) ] [ == & 0x1ffffff ] - auto u = node(_root, extranonce, 9, pk); - update(bsha, u); + BlockInfo test = _header; + assignResult(result, test); + assert(verify(test)); } - return get(bsha); + + return ret; } } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index c3c3f192b..7b9787f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -28,6 +28,7 @@ #include #include #include "CommonEth.h" +#include "BlockInfo.h" #define FAKE_DAGGER 1 @@ -45,47 +46,63 @@ struct MineInfo bool completed = false; }; -template -class ProofOfWorkEngine: public Evaluator +class Ethash { public: - static bool verify(h256 const& _root, h256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)Evaluator::eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; } + // bit-compatible with ethash_return_value + struct Proof + { + Nonce nonce; + h256 mixHash; + }; - inline std::pair mine(h256 const& _root, u256 const& _difficulty, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static bool verify(BlockInfo const& _header); + std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } protected: - h256 m_last; + Nonce m_last; }; -class SHA3Evaluator +template +class ProofOfWorkEngine: public Evaluator { public: - static h256 eval(h256 const& _root, h256 const& _nonce) { h256 b[2] = { _root, _nonce }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } -}; + using Proof = Nonce; + + static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } + + inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); -// TODO: class ARPoWEvaluator + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } -class DaggerEvaluator +protected: + Nonce m_last; +}; + +class SHA3Evaluator { public: - static h256 eval(h256 const& _root, h256 const& _nonce); - -private: - static h256 node(h256 const& _root, h256 const& _xn, uint_fast32_t _L, uint_fast32_t _i); + static h256 eval(h256 const& _root, Nonce const& _nonce) { h256 b[2] = { _root, h256(_nonce) }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } }; using SHA3ProofOfWork = ProofOfWorkEngine; -using ProofOfWork = SHA3ProofOfWork; +using ProofOfWork = Ethash; template -std::pair ProofOfWorkEngine::mine(h256 const& _root, u256 const& _difficulty, unsigned _msTimeout, bool _continue, bool _turbo) +std::pair::Proof> ProofOfWorkEngine::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - std::pair ret; + auto headerHashWithoutNonce = _header.headerHash(WithoutNonce); + auto difficulty = _header.difficulty; + + std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); - u256 s = (m_last = h256::random(s_eng)); + Nonce::Arith s = (m_last = Nonce::random(s_eng)); - bigint d = (bigint(1) << 256) / _difficulty; + bigint d = (bigint(1) << 256) / difficulty; ret.first.requirement = log2((double)d); // 2^ 0 32 64 128 256 @@ -96,12 +113,12 @@ std::pair ProofOfWorkEngine::mine(h256 const& _root, if (!_turbo) std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) - h256 solution; + ProofOfWorkEngine::Proof solution; unsigned h = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; s++, h++) { - solution = (h256)s; - auto e = (bigint)(u256)Evaluator::eval(_root, solution); + solution = (ProofOfWorkEngine::Proof)s; + auto e = (bigint)(u256)Evaluator::eval(headerHashWithoutNonce, solution); best = std::min(best, log2((double)e)); if (e <= d) { @@ -114,7 +131,11 @@ std::pair ProofOfWorkEngine::mine(h256 const& _root, ret.second = solution; if (ret.first.completed) - assert(verify(_root, solution, _difficulty)); + { + BlockInfo test = _header; + assignResult(solution, test); + assert(verify(test)); + } return ret; } diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index 29fdc9acc..418373745 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -82,8 +82,8 @@ bytes CanonBlockChain::createGenesisBlock() stateRoot = state.root(); } - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); + block.appendList(16) + << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << h256() << h256() << Nonce(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index ae809b1ac..0462d1c7c 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -499,10 +499,10 @@ pair Client::getWork() return make_pair(m_remoteMiner.workHash(), m_remoteMiner.difficulty()); } -bool Client::submitNonce(h256 const&_nonce) +bool Client::submitWork(ProofOfWork::Proof const& _proof) { Guard l(x_remoteMiner); - return m_remoteMiner.submitWork(_nonce); + return m_remoteMiner.submitWork(_proof); } void Client::doWork() diff --git a/libethereum/Client.h b/libethereum/Client.h index 7cd520ab6..03debb750 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -145,7 +145,7 @@ public: h256 workHash() const { return m_state.info().headerHash(IncludeNonce::WithoutNonce); } u256 const& difficulty() const { return m_state.info().difficulty; } - bool submitWork(h256 const& _nonce) { return (m_isComplete = m_state.completeMine(_nonce)); } + bool submitWork(ProofOfWork::Proof const& _result) { return (m_isComplete = m_state.completeMine(_result)); } virtual bool isComplete() const override { return m_isComplete; } virtual bytes const& blockData() const { return m_state.blockData(); } @@ -294,8 +294,8 @@ public: /// 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::pair getWork() override; - /// Submit the nonce for the proof-of-work. - virtual bool submitNonce(h256 const&_nonce) override; + /// Submit the proof for the proof-of-work. + virtual bool submitWork(ProofOfWork::Proof const& _proof) override; // Debug stuff: diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 847c181e0..2a9de14d1 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -154,7 +154,7 @@ public: /// Get hash of the current block to be mined minus the nonce (the 'work hash'). virtual std::pair getWork() = 0; /// Submit the nonce for the proof-of-work. - virtual bool submitNonce(h256 const&) = 0; + virtual bool submitWork(ProofOfWork::Proof const& _proof) = 0; /// Check the progress of the mining. virtual MineProgress miningProgress() const = 0; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index a9837d118..fcb84821b 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -255,7 +255,7 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi) { auto b = _bc.block(_block); bi.populate(b); - // bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. +// bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. break; } catch (Exception const& _e) @@ -546,7 +546,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) if (rlp[2].itemCount() > 2) BOOST_THROW_EXCEPTION(TooManyUncles()); - set nonces = { m_currentBlock.nonce }; + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); @@ -773,23 +773,28 @@ MineInfo State::mine(unsigned _msTimeout, bool _turbo) MineInfo ret; // TODO: Miner class that keeps dagger between mine calls (or just non-polling mining). - tie(ret, m_currentBlock.nonce) = m_pow.mine(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.difficulty, _msTimeout, true, _turbo); + ProofOfWork::Proof r; + tie(ret, r) = m_pow.mine(m_currentBlock, _msTimeout, true, _turbo); if (!ret.completed) m_currentBytes.clear(); else - cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.nonce, m_currentBlock.difficulty); + { + ProofOfWork::assignResult(r, m_currentBlock); + cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); + } return ret; } -bool State::completeMine(h256 const& _nonce) +bool State::completeMine(ProofOfWork::Proof const& _nonce) { - if (!m_pow.verify(m_currentBlock.headerHash(WithoutNonce), _nonce, m_currentBlock.difficulty)) + ProofOfWork::assignResult(_nonce, m_currentBlock); + + if (!m_pow.verify(m_currentBlock)) return false; - m_currentBlock.nonce = _nonce; - cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.nonce, m_currentBlock.difficulty); + cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); completeMine(); diff --git a/libethereum/State.h b/libethereum/State.h index a496a4a03..33843c65c 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -112,7 +112,7 @@ public: /// Pass in a solution to the proof-of-work. /// @returns true iff the given nonce is a proof-of-work for this State's block. - bool completeMine(h256 const& _nonce); + bool completeMine(ProofOfWork::Proof const& _result); /// Attempt to find valid nonce for block that this state represents. /// This function is thread-safe. You can safely have other interactions with this object while it is happening. diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index dbf3b2ec9..382115ba2 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -457,9 +457,9 @@ Json::Value WebThreeStubServerBase::eth_getWork() return ret; } -bool WebThreeStubServerBase::eth_submitWork(std::string const& _nonce) +bool WebThreeStubServerBase::eth_submitWork(std::string const& _nonce, std::string const& _mixHash) { - return client()->submitNonce(jsToFixed<32>(_nonce)); + return client()->submitWork(ProofOfWork::Proof{jsToFixed(_nonce), jsToFixed<32>(_mixHash)}); } int WebThreeStubServerBase::eth_register(std::string const& _address) diff --git a/libweb3jsonrpc/WebThreeStubServerBase.h b/libweb3jsonrpc/WebThreeStubServerBase.h index 9535c33a0..993c82c5c 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.h +++ b/libweb3jsonrpc/WebThreeStubServerBase.h @@ -110,7 +110,7 @@ public: virtual bool eth_uninstallFilter(int _id); virtual Json::Value eth_getWork(); - virtual bool eth_submitWork(std::string const& _nonce); + virtual bool eth_submitWork(std::string const& _nonce, std::string const& _mixHash); virtual int eth_register(std::string const& _address); virtual bool eth_unregister(int _id); diff --git a/libweb3jsonrpc/abstractwebthreestubserver.h b/libweb3jsonrpc/abstractwebthreestubserver.h index e40c68acd..bb84afc9b 100644 --- a/libweb3jsonrpc/abstractwebthreestubserver.h +++ b/libweb3jsonrpc/abstractwebthreestubserver.h @@ -54,7 +54,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServerbindAndAddMethod(jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI); - this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); + this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); this->bindAndAddMethod(jsonrpc::Procedure("eth_register", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_registerI); this->bindAndAddMethod(jsonrpc::Procedure("eth_unregister", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_unregisterI); this->bindAndAddMethod(jsonrpc::Procedure("eth_queuedTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_queuedTransactionsI); @@ -254,7 +254,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServereth_submitWork(request[0u].asString()); + response = this->eth_submitWork(request[0u].asString(), request[1u].asString()); } inline virtual void eth_registerI(const Json::Value &request, Json::Value &response) { @@ -363,7 +363,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer getWork() override { return std::pair(); } - bool submitNonce(h256 const&) override { return false; } + bool submitWork(eth::ProofOfWork::Proof const&) override { return false; } /// @returns the last mined block information eth::BlockInfo blockInfo() const; diff --git a/test/block.cpp b/test/block.cpp index fdf65affa..4441da299 100644 --- a/test/block.cpp +++ b/test/block.cpp @@ -131,8 +131,12 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // find new valid nonce ProofOfWork pow; MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + ProofOfWork::Proof proof; + while (!ProofOfWork::verify(blockFromFields)) + { + tie(ret, proof) = pow.mine(blockFromFields, 1000, true, true); + ProofOfWork::assignResult(proof, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); @@ -211,7 +215,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) o["transactions"] = txArray; o["rlp"] = "0x" + toHex(state.blockData()); - BlockInfo current_BlockHeader = state.info(); + BlockInfo currentBlockHeader = state.info(); // overwrite blockheader with (possible wrong) data from "blockheader" in filler; @@ -220,7 +224,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) if (o["blockHeader"].get_obj().size() != 14) { - BlockInfo tmp = current_BlockHeader; + BlockInfo tmp = currentBlockHeader; if (o["blockHeader"].get_obj().count("parentHash")) tmp.parentHash = h256(o["blockHeader"].get_obj()["parentHash"].get_str()); @@ -263,14 +267,18 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // find new valid nonce - if (tmp != current_BlockHeader) + if (tmp != currentBlockHeader) { - current_BlockHeader = tmp; + currentBlockHeader = tmp; cout << "new header!\n"; ProofOfWork pow; MineInfo ret; - while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) - tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + ProofOfWork::Proof proof; + while (!ProofOfWork::verify(currentBlockHeader)) + { + tie(ret, proof) = pow.mine(currentBlockHeader, 10000, true, true); + ProofOfWork::assignResult(proof, currentBlockHeader); + } } } else @@ -278,27 +286,27 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // take the blockheader as is const bytes c_blockRLP = createBlockRLPFromFields(o["blockHeader"].get_obj()); const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); + currentBlockHeader.populateFromHeader(c_bRLP, false); } } // write block header mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["parentHash"] = toString(currentBlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(currentBlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(currentBlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(currentBlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(currentBlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(currentBlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(currentBlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(currentBlockHeader.difficulty); + oBlockHeader["number"] = toString(currentBlockHeader.number); + oBlockHeader["gasLimit"] = toString(currentBlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(currentBlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(currentBlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(currentBlockHeader.extraData); + oBlockHeader["nonce"] = toString(currentBlockHeader.nonce); o["blockHeader"] = oBlockHeader; @@ -318,7 +326,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) } RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + currentBlockHeader.streamRLP(rlpStream2, WithNonce); RLPStream block2(3); block2.appendRaw(rlpStream2.out()); diff --git a/test/dagger.cpp b/test/dagger.cpp index 9422b6a96..87c49bd7d 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -30,6 +30,7 @@ using namespace dev::eth; int daggerTest() { +#if 0 cnote << "Testing ProofOfWork..."; // Test dagger { @@ -46,6 +47,7 @@ int daggerTest() cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; } +#endif return 0; } diff --git a/test/webthreestubclient.h b/test/webthreestubclient.h index 70aa9db99..6d97ea67a 100644 --- a/test/webthreestubclient.h +++ b/test/webthreestubclient.h @@ -437,10 +437,11 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } - bool eth_submitWork(const std::string& param1) throw (jsonrpc::JsonRpcException) + bool eth_submitWork(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) { Json::Value p; p.append(param1); + p.append(param2); Json::Value result = this->CallMethod("eth_submitWork",p); if (result.isBool()) return result.asBool(); From 78773565101a2f43a826bd6aeaefa2a366e2d67f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 12:04:15 +0100 Subject: [PATCH 049/313] blockchain tests Conflicts: test/block.cpp --- test/bcBlockChainTestFiller.json | 45 +++ test/block.cpp | 527 ------------------------------ test/blockchain.cpp | 537 +++++++++++++++++++++++++++++++ test/vm.cpp | 54 ++-- 4 files changed, 609 insertions(+), 554 deletions(-) create mode 100644 test/bcBlockChainTestFiller.json delete mode 100644 test/block.cpp create mode 100644 test/blockchain.cpp diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json new file mode 100644 index 000000000..050def25b --- /dev/null +++ b/test/bcBlockChainTestFiller.json @@ -0,0 +1,45 @@ +{ + "minDifficulty" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + } + ] + } +} diff --git a/test/block.cpp b/test/block.cpp deleted file mode 100644 index 4441da299..000000000 --- a/test/block.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . -*/ -/** @file block.cpp - * @author Christoph Jentzsch - * @date 2015 - * block test functions. - */ - -#include -#include -#include "TestHelper.h" - -using namespace std; -using namespace json_spirit; -using namespace dev; -using namespace dev::eth; - -namespace dev { namespace test { - -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - - return rlpStream.out(); -} - -void doBlockTests(json_spirit::mValue& _v, bool _fillin) -{ - for (auto& i: _v.get_obj()) - { - cerr << i.first << endl; - mObject& o = i.second.get_obj(); - - BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } - - BOOST_REQUIRE(o.count("pre")); - - ImportTest importer(o["pre"].get_obj()); - State state(Address(), OverlayDB(), BaseState::Empty); - importer.importState(o["pre"].get_obj(), state); - state.commit(); - - if (_fillin) - blockFromFields.stateRoot = state.rootHash(); - else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); - - if (_fillin) - { - // find new valid nonce - ProofOfWork pow; - MineInfo ret; - ProofOfWork::Proof proof; - while (!ProofOfWork::verify(blockFromFields)) - { - tie(ret, proof) = pow.mine(blockFromFields, 1000, true, true); - ProofOfWork::assignResult(proof, blockFromFields); - } - - //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - } - - // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); - - // construct blockchain - BlockChain bc(block.out(), string(), true); - - if (_fillin) - { - BOOST_REQUIRE(o.count("transactions")); - - TransactionQueue txs; - - for (auto const& txObj: o["transactions"].get_array()) - { - mObject tx = txObj.get_obj(); - importer.importTransaction(tx); - if (!txs.attemptImport(importer.m_transaction.rlp())) - cnote << "failed importing transaction\n"; - } - - try - { - state.sync(bc); - state.sync(bc,txs); - state.commitToMine(bc); - MineInfo info; - for (info.completed = false; !info.completed; info = state.mine()) {} - state.completeMine(); - } - catch (Exception const& _e) - { - cnote << "state sync or mining did throw an exception: " << diagnostic_information(_e); - return; - } - catch (std::exception const& _e) - { - cnote << "state sync or mining did throw an exception: " << _e.what(); - return; - } - - // write valid txs - mArray txArray; - Transactions txList; - for (auto const& txi: txs.transactions()) - { - Transaction tx(txi.second, CheckSignature::Sender); - txList.push_back(tx); - mObject txObject; - txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); - txObject["gasLimit"] = toString(tx.gas()); - txObject["gasPrice"] = toString(tx.gasPrice()); - txObject["r"] = "0x" + toString(tx.signature().r); - txObject["s"] = "0x" + toString(tx.signature().s); - txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); - txObject["value"] = toString(tx.value()); - - txArray.push_back(txObject); - } - - o["transactions"] = txArray; - o["rlp"] = "0x" + toHex(state.blockData()); - - BlockInfo currentBlockHeader = state.info(); - - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - - if (o.count("blockHeader")) - { - if (o["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = currentBlockHeader; - - if (o["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(o["blockHeader"].get_obj()["parentHash"].get_str()); - - if (o["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(o["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (o["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(o["blockHeader"].get_obj()["coinbase"].get_str()); - - if (o["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(o["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (o["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(o["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (o["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(o["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (o["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(o["blockHeader"].get_obj()["bloom"].get_str()); - - if (o["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(o["blockHeader"].get_obj()["difficulty"]); - - if (o["blockHeader"].get_obj().count("number")) - tmp.number = toInt(o["blockHeader"].get_obj()["number"]); - - if (o["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(o["blockHeader"].get_obj()["gasLimit"]); - - if (o["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(o["blockHeader"].get_obj()["gasUsed"]); - - if (o["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(o["blockHeader"].get_obj()["timestamp"]); - - if (o["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(o["blockHeader"].get_obj()["extraData"].get_str()); - - // find new valid nonce - - if (tmp != currentBlockHeader) - { - currentBlockHeader = tmp; - cout << "new header!\n"; - ProofOfWork pow; - MineInfo ret; - ProofOfWork::Proof proof; - while (!ProofOfWork::verify(currentBlockHeader)) - { - tie(ret, proof) = pow.mine(currentBlockHeader, 10000, true, true); - ProofOfWork::assignResult(proof, currentBlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(o["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - currentBlockHeader.populateFromHeader(c_bRLP, false); - } - } - - // write block header - - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(currentBlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(currentBlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(currentBlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(currentBlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(currentBlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(currentBlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(currentBlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(currentBlockHeader.difficulty); - oBlockHeader["number"] = toString(currentBlockHeader.number); - oBlockHeader["gasLimit"] = toString(currentBlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(currentBlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(currentBlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(currentBlockHeader.extraData); - oBlockHeader["nonce"] = toString(currentBlockHeader.nonce); - - o["blockHeader"] = oBlockHeader; - - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - o["uncleHeaders"] = aUncleList; - - //txs: - - RLPStream txStream; - txStream.appendList(txList.size()); - for (unsigned i = 0; i < txList.size(); ++i) - { - RLPStream txrlp; - txList[i].streamRLP(txrlp); - txStream.appendRaw(txrlp.out()); - } - - RLPStream rlpStream2; - currentBlockHeader.streamRLP(rlpStream2, WithNonce); - - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); - - o["rlp"] = "0x" + toHex(block2.out()); - - if (sha3(RLP(state.blockData())[0].data()) != sha3(RLP(block2.out())[0].data())) - cnote << "block header mismatch\n"; - - if (sha3(RLP(state.blockData())[1].data()) != sha3(RLP(block2.out())[1].data())) - cnote << "txs mismatch\n"; - - if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; - - try - { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); - } - // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given - catch (...) - { - cnote << "block is invalid!\n"; - o.erase(o.find("blockHeader")); - o.erase(o.find("uncleHeaders")); - o.erase(o.find("transactions")); - } - } - - else - { - bytes blockRLP; - try - { - state.sync(bc); - blockRLP = importByteArray(o["rlp"].get_str()); - bc.import(blockRLP, state.db()); - state.sync(bc); - } - // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given - catch (Exception const& _e) - { - cnote << "state sync or block import did throw an exception: " << diagnostic_information(_e); - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - catch (std::exception const& _e) - { - cnote << "state sync or block import did throw an exception: " << _e.what(); - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - catch(...) - { - cnote << "state sync or block import did throw an exception\n"; - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - - BOOST_REQUIRE(o.count("blockHeader")); - - mObject tObj = o["blockHeader"].get_obj(); - BlockInfo blockHeaderFromFields; - const bytes c_rlpBytesBlockHeader = createBlockRLPFromFields(tObj); - const RLP c_blockHeaderRLP(c_rlpBytesBlockHeader); - blockHeaderFromFields.populateFromHeader(c_blockHeaderRLP, false); - - BlockInfo blockFromRlp = bc.info(); - - //Check the fields restored from RLP to original fields - BOOST_CHECK_MESSAGE(blockHeaderFromFields.headerHash(WithNonce) == blockFromRlp.headerHash(WithNonce), "hash in given RLP not matching the block hash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.parentHash == blockFromRlp.parentHash, "parentHash in given RLP not matching the block parentHash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.sha3Uncles == blockFromRlp.sha3Uncles, "sha3Uncles in given RLP not matching the block sha3Uncles!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.coinbaseAddress == blockFromRlp.coinbaseAddress,"coinbaseAddress in given RLP not matching the block coinbaseAddress!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.stateRoot == blockFromRlp.stateRoot, "stateRoot in given RLP not matching the block stateRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.transactionsRoot == blockFromRlp.transactionsRoot, "transactionsRoot in given RLP not matching the block transactionsRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.receiptsRoot == blockFromRlp.receiptsRoot, "receiptsRoot in given RLP not matching the block receiptsRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.logBloom == blockFromRlp.logBloom, "logBloom in given RLP not matching the block logBloom!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.difficulty == blockFromRlp.difficulty, "difficulty in given RLP not matching the block difficulty!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.number == blockFromRlp.number, "number in given RLP not matching the block number!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasLimit == blockFromRlp.gasLimit,"gasLimit in given RLP not matching the block gasLimit!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); - - BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); - - //Check transaction list - - Transactions txsFromField; - - for (auto const& txObj: o["transactions"].get_array()) - { - mObject tx = txObj.get_obj(); - - BOOST_REQUIRE(tx.count("nonce")); - BOOST_REQUIRE(tx.count("gasPrice")); - BOOST_REQUIRE(tx.count("gasLimit")); - BOOST_REQUIRE(tx.count("to")); - BOOST_REQUIRE(tx.count("value")); - BOOST_REQUIRE(tx.count("v")); - BOOST_REQUIRE(tx.count("r")); - BOOST_REQUIRE(tx.count("s")); - BOOST_REQUIRE(tx.count("data")); - - try - { - Transaction t(createRLPStreamFromTransactionFields(tx).out(), CheckSignature::Sender); - txsFromField.push_back(t); - } - catch (Exception const& _e) - { - BOOST_ERROR("Failed transaction constructor with Exception: " << diagnostic_information(_e)); - } - catch (exception const& _e) - { - cnote << _e.what(); - } - } - - Transactions txsFromRlp; - RLP root(blockRLP); - for (auto const& tr: root[1]) - { - Transaction tx(tr.data(), CheckSignature::Sender); - txsFromRlp.push_back(tx); - } - - BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), "transaction list size does not match"); - - for (size_t i = 0; i < txsFromField.size(); ++i) - { - BOOST_CHECK_MESSAGE(txsFromField[i].data() == txsFromRlp[i].data(), "transaction data in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].gas() == txsFromRlp[i].gas(), "transaction gasLimit in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].gasPrice() == txsFromRlp[i].gasPrice(), "transaction gasPrice in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].nonce() == txsFromRlp[i].nonce(), "transaction nonce in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().r == txsFromRlp[i].signature().r, "transaction r in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().s == txsFromRlp[i].signature().s, "transaction s in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().v == txsFromRlp[i].signature().v, "transaction v in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); - } - - // check uncle list - BOOST_CHECK_MESSAGE((o["uncleList"].type() == json_spirit::null_type ? 0 : o["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); - } - } -} - -} }// Namespace Close - - -BOOST_AUTO_TEST_SUITE(BlockTests) - -BOOST_AUTO_TEST_CASE(blValidBlockTest) -{ - dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -{ - dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -{ - dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blForkBlocks) -{ - dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(userDefinedFileBl) -{ - dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/test/blockchain.cpp b/test/blockchain.cpp new file mode 100644 index 000000000..7dad5b4f2 --- /dev/null +++ b/test/blockchain.cpp @@ -0,0 +1,537 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file block.cpp + * @author Christoph Jentzsch + * @date 2015 + * block test functions. + */ + +#include +#include +#include "TestHelper.h" + +using namespace std; +using namespace json_spirit; +using namespace dev; +using namespace dev::eth; + +namespace dev { namespace test { + +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << importByteArray(_tObj["extraData"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void doBlockTests(json_spirit::mValue& _v, bool _fillin) +{ + for (auto& i: _v.get_obj()) + { + cerr << i.first << endl; + mObject& o = i.second.get_obj(); + + BOOST_REQUIRE(o.count("genesisBlockHeader")); + BlockInfo blockFromFields; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + blockFromFields.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch(...) + { + cnote << "block population did throw an unknown exception\n"; + continue; + } + + BOOST_REQUIRE(o.count("pre")); + + ImportTest importer(o["pre"].get_obj()); + State state(Address(), OverlayDB(), BaseState::Empty); + importer.importState(o["pre"].get_obj(), state); + state.commit(); + + if (_fillin) + blockFromFields.stateRoot = state.rootHash(); + else + BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + + if (_fillin) + { + // find new valid nonce + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) + tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + + //update genesis block in json file + o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); + o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + } + + // create new "genesis" block + RLPStream rlpStream; + blockFromFields.streamRLP(rlpStream, WithNonce); + + RLPStream block(3); + block.appendRaw(rlpStream.out()); + block.appendRaw(RLPEmptyList); + block.appendRaw(RLPEmptyList); + + blockFromFields.verifyInternals(&block.out()); + + // construct blockchain + BlockChain bc(block.out(), string(), true); + + if (_fillin) + { + BOOST_REQUIRE(o.count("blocks")); + mArray blArray; + for (auto const& bl: o["blocks"].get_array()) + { + mObject blObj = bl.get_obj(); + BOOST_REQUIRE(blObj.count("transactions")); + + TransactionQueue txs; + + for (auto const& txObj: blObj["transactions"].get_array()) + { + mObject tx = txObj.get_obj(); + importer.importTransaction(tx); + if (!txs.attemptImport(importer.m_transaction.rlp())) + cnote << "failed importing transaction\n"; + } + + try + { + state.sync(bc); + state.sync(bc,txs); + state.commitToMine(bc); + MineInfo info; + for (info.completed = false; !info.completed; info = state.mine()) {} + state.completeMine(); + } + catch (Exception const& _e) + { + cnote << "state sync or mining did throw an exception: " << diagnostic_information(_e); + return; + } + catch (std::exception const& _e) + { + cnote << "state sync or mining did throw an exception: " << _e.what(); + return; + } + + // write valid txs + mArray txArray; + Transactions txList; + for (auto const& txi: txs.transactions()) + { + Transaction tx(txi.second, CheckSignature::Sender); + txList.push_back(tx); + mObject txObject; + txObject["nonce"] = toString(tx.nonce()); + txObject["data"] = toHex(tx.data()); + txObject["gasLimit"] = toString(tx.gas()); + txObject["gasPrice"] = toString(tx.gasPrice()); + txObject["r"] = "0x" + toString(tx.signature().r); + txObject["s"] = "0x" + toString(tx.signature().s); + txObject["v"] = to_string(tx.signature().v + 27); + txObject["to"] = toString(tx.receiveAddress()); + txObject["value"] = toString(tx.value()); + + txArray.push_back(txObject); + } + + blObj["transactions"] = txArray; + blObj["rlp"] = "0x" + toHex(state.blockData()); + + BlockInfo current_BlockHeader = state.info(); + + // overwrite blockheader with (possible wrong) data from "blockheader" in filler; + + if (blObj.count("blockHeader")) + { + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + cout << "new header!\n"; + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) + tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } + } + + // write block header + + mObject oBlockHeader; + oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); + oBlockHeader["number"] = toString(current_BlockHeader.number); + oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + + blObj["blockHeader"] = oBlockHeader; + + // write uncle list + mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. + blObj["uncleHeaders"] = aUncleList; + + //txs: + + RLPStream txStream; + txStream.appendList(txList.size()); + for (unsigned i = 0; i < txList.size(); ++i) + { + RLPStream txrlp; + txList[i].streamRLP(txrlp); + txStream.appendRaw(txrlp.out()); + } + + RLPStream rlpStream2; + current_BlockHeader.streamRLP(rlpStream2, WithNonce); + + RLPStream block2(3); + block2.appendRaw(rlpStream2.out()); + block2.appendRaw(txStream.out()); + block2.appendRaw(RLPEmptyList); + + blObj["rlp"] = "0x" + toHex(block2.out()); + + if (sha3(RLP(state.blockData())[0].data()) != sha3(RLP(block2.out())[0].data())) + cnote << "block header mismatch\n"; + + if (sha3(RLP(state.blockData())[1].data()) != sha3(RLP(block2.out())[1].data())) + cnote << "txs mismatch\n"; + + if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) + cnote << "uncle list mismatch\n"; + + try + { + ImportTest importerTmp(o["pre"].get_obj()); + State stateTmp(Address(), OverlayDB(), BaseState::Empty); + importerTmp.importState(o["pre"].get_obj(), stateTmp); + stateTmp.commit(); + BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); + stateTmp.sync(bcTmp); + bc.import(block2.out(), stateTmp.db()); + stateTmp.sync(bcTmp); + } + // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given + catch (...) + { + cnote << "block is invalid!\n"; + blObj.erase(blObj.find("blockHeader")); + blObj.erase(blObj.find("uncleHeaders")); + blObj.erase(blObj.find("transactions")); + } + blArray.push_back(blObj); + } + o["blocks"] = blArray; + } + + else + { + for (auto const& bl: o["blocks"].get_array()) + { + mObject blObj = bl.get_obj(); + bytes blockRLP; + try + { + state.sync(bc); + blockRLP = importByteArray(blObj["rlp"].get_str()); + bc.import(blockRLP, state.db()); + state.sync(bc); + } + // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given + catch (Exception const& _e) + { + cnote << "state sync or block import did throw an exception: " << diagnostic_information(_e); + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + catch (std::exception const& _e) + { + cnote << "state sync or block import did throw an exception: " << _e.what(); + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + catch(...) + { + cnote << "state sync or block import did throw an exception\n"; + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + + BOOST_REQUIRE(blObj.count("blockHeader")); + + mObject tObj = blObj["blockHeader"].get_obj(); + BlockInfo blockHeaderFromFields; + const bytes c_rlpBytesBlockHeader = createBlockRLPFromFields(tObj); + const RLP c_blockHeaderRLP(c_rlpBytesBlockHeader); + blockHeaderFromFields.populateFromHeader(c_blockHeaderRLP, false); + + BlockInfo blockFromRlp = bc.info(); + + //Check the fields restored from RLP to original fields + BOOST_CHECK_MESSAGE(blockHeaderFromFields.headerHash(WithNonce) == blockFromRlp.headerHash(WithNonce), "hash in given RLP not matching the block hash!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.parentHash == blockFromRlp.parentHash, "parentHash in given RLP not matching the block parentHash!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.sha3Uncles == blockFromRlp.sha3Uncles, "sha3Uncles in given RLP not matching the block sha3Uncles!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.coinbaseAddress == blockFromRlp.coinbaseAddress,"coinbaseAddress in given RLP not matching the block coinbaseAddress!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.stateRoot == blockFromRlp.stateRoot, "stateRoot in given RLP not matching the block stateRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.transactionsRoot == blockFromRlp.transactionsRoot, "transactionsRoot in given RLP not matching the block transactionsRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.receiptsRoot == blockFromRlp.receiptsRoot, "receiptsRoot in given RLP not matching the block receiptsRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.logBloom == blockFromRlp.logBloom, "logBloom in given RLP not matching the block logBloom!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.difficulty == blockFromRlp.difficulty, "difficulty in given RLP not matching the block difficulty!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.number == blockFromRlp.number, "number in given RLP not matching the block number!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasLimit == blockFromRlp.gasLimit,"gasLimit in given RLP not matching the block gasLimit!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); + + BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); + + //Check transaction list + + Transactions txsFromField; + + for (auto const& txObj: blObj["transactions"].get_array()) + { + mObject tx = txObj.get_obj(); + + BOOST_REQUIRE(tx.count("nonce")); + BOOST_REQUIRE(tx.count("gasPrice")); + BOOST_REQUIRE(tx.count("gasLimit")); + BOOST_REQUIRE(tx.count("to")); + BOOST_REQUIRE(tx.count("value")); + BOOST_REQUIRE(tx.count("v")); + BOOST_REQUIRE(tx.count("r")); + BOOST_REQUIRE(tx.count("s")); + BOOST_REQUIRE(tx.count("data")); + + try + { + Transaction t(createRLPStreamFromTransactionFields(tx).out(), CheckSignature::Sender); + txsFromField.push_back(t); + } + catch (Exception const& _e) + { + BOOST_ERROR("Failed transaction constructor with Exception: " << diagnostic_information(_e)); + } + catch (exception const& _e) + { + cnote << _e.what(); + } + } + + Transactions txsFromRlp; + RLP root(blockRLP); + for (auto const& tr: root[1]) + { + Transaction tx(tr.data(), CheckSignature::Sender); + txsFromRlp.push_back(tx); + } + + BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), "transaction list size does not match"); + + for (size_t i = 0; i < txsFromField.size(); ++i) + { + BOOST_CHECK_MESSAGE(txsFromField[i].data() == txsFromRlp[i].data(), "transaction data in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].gas() == txsFromRlp[i].gas(), "transaction gasLimit in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].gasPrice() == txsFromRlp[i].gasPrice(), "transaction gasPrice in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].nonce() == txsFromRlp[i].nonce(), "transaction nonce in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().r == txsFromRlp[i].signature().r, "transaction r in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().s == txsFromRlp[i].signature().s, "transaction s in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().v == txsFromRlp[i].signature().v, "transaction v in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); + + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + } + + // check uncle list + BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + } + } + } +} + +} }// Namespace Close + + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); +} + +//BOOST_AUTO_TEST_CASE(blValidBlockTest) +//{ +// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) +//{ +// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) +//{ +// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blForkBlocks) +//{ +// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); +//} + +BOOST_AUTO_TEST_CASE(userDefinedFileBl) +{ + dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); +} + +BOOST_AUTO_TEST_SUITE_END() + diff --git a/test/vm.cpp b/test/vm.cpp index 21bea0650..959edae73 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -531,33 +531,33 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest) } } -BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--inputlimits" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - -BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--inputlimits" || arg == "--all") - dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests); - } -} +//BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--inputlimits" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); + +// dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); + +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} + +//BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--inputlimits" || arg == "--all") +// dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests); +// } +//} BOOST_AUTO_TEST_CASE(vmRandom) { From e3bb9ae173fb5976d1207582549c3c0c35b27407 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:24:06 +0100 Subject: [PATCH 050/313] more block tests + bugfix for longer chains --- test/bcBlockChainTestFiller.json | 15 + ...er.json => bcInvalidHeaderTestFiller.json} | 427 ++++++++++-------- ...iller.json => bcValidBlockTestFiller.json} | 320 +++++++------ test/blockchain.cpp | 45 +- 4 files changed, 431 insertions(+), 376 deletions(-) rename test/{blInvalidHeaderTestFiller.json => bcInvalidHeaderTestFiller.json} (69%) rename test/{blValidBlockTestFiller.json => bcValidBlockTestFiller.json} (60%) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 050def25b..75ed62943 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -39,6 +39,21 @@ ], "uncleHeaders" : [ ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } ] } diff --git a/test/blInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json similarity index 69% rename from test/blInvalidHeaderTestFiller.json rename to test/bcInvalidHeaderTestFiller.json index 482eafc56..bba00834b 100644 --- a/test/blInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,8 +1,5 @@ { "log1_wrongBlockNumber" : { - "blockHeader" : { - "number" : "2" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -33,25 +30,30 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "number" : "2" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "log1_wrongBloom" : { - "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - }, + "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -68,6 +70,7 @@ "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, + "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10000000000", @@ -82,25 +85,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongCoinbase" : { - "blockHeader" : { - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -131,25 +138,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongDifficulty" : { - "blockHeader" : { - "difficulty" : "10000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -180,25 +191,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "difficulty" : "10000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "DifferentExtraData" : { - "blockHeader" : { - "extraData" : "42" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -229,25 +244,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "extraData" : "42" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongGasLimit" : { - "blockHeader" : { - "gasLimit" : "100000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -278,25 +297,30 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "gasLimit" : "100000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ + ] }, "wrongGasUsed" : { - "blockHeader" : { - "gasUsed" : "0" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -327,25 +351,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "gasUsed" : "0" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongNumber" : { - "blockHeader" : { - "number" : "0" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -376,25 +404,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "number" : "0" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongParentHash" : { - "blockHeader" : { - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -425,25 +457,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, - "wrongReceiptTrie" : { - "blockHeader" : { - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }, + "wrongReceiptTrie" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -474,25 +510,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongStateRoot" : { - "blockHeader" : { - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -523,25 +563,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongTimestamp" : { - "blockHeader" : { - "timestamp" : "0x54c98c80" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -572,25 +616,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "timestamp" : "0x54c98c80" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, - "wrongTransactionsTrie" : { - "blockHeader" : { - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }, + "wrongTransactionsTrie" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -621,25 +669,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "transactionsTrie" : "0x55e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongUncleHash" : { - "blockHeader" : { - "uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -670,18 +722,25 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] } } diff --git a/test/blValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json similarity index 60% rename from test/blValidBlockTestFiller.json rename to test/bcValidBlockTestFiller.json index 8099c0dd6..3ce79cf4d 100644 --- a/test/blValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -1,43 +1,4 @@ { - "diffTooLowToChange" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "42", - "gasLimit" : "100000", - "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, "diff1024" : { "genesisBlockHeader" : { @@ -64,19 +25,24 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] + }, "gasPrice0" : { @@ -104,18 +70,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "0", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "85000", + "gasPrice" : "0", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -144,18 +114,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "0", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "1000001", + "gasPrice" : "0", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -184,18 +158,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "500", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -224,27 +202,31 @@ "storage": {} } }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "7000000000" - }, + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "8000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "7000000000" + }, + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "8000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -273,27 +255,31 @@ "storage": {} } }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" - }, + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "9", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + }, + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "9", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -328,54 +314,64 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ - ], - - "firstBlockTest" : { - "block" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", - "extraData" : "42", - "gasLimit" : "0x0dddb6", - "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", - "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - }, - "transactions" : [ - { - "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", - "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", - "to" : "", - "v" : "0x1b", - "value" : "" - } - ], - } + ] + }, + "dataTx" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "023101", + "extraData" : "42", + "gasLimit" : "0x0dddb6", + "gasUsed" : "100", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "62", + "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", + "gasLimit" : "0x0f3e6f", + "gasPrice" : "0x09184e72a000", + "nonce" : "0", + "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", + "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "to" : "", + "v" : "0x1b", + "value" : "" + } + ], + "uncleHeaders" : [ + ] + } + ] } } + diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 7dad5b4f2..69ea8fa2b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -81,7 +81,7 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void doBlockTests(json_spirit::mValue& _v, bool _fillin) +void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { for (auto& i: _v.get_obj()) { @@ -271,7 +271,6 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) if (tmp != current_BlockHeader) { current_BlockHeader = tmp; - cout << "new header!\n"; ProofOfWork pow; MineInfo ret; while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) @@ -343,14 +342,9 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) try { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); + state.sync(bc); + bc.import(block2.out(), state.db()); + state.sync(bc); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -505,32 +499,23 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcBlockChainTest) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); } -//BOOST_AUTO_TEST_CASE(blValidBlockTest) -//{ -// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -//} - -//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -//{ -// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -//{ -// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blForkBlocks) -//{ -// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -//} -BOOST_AUTO_TEST_CASE(userDefinedFileBl) +BOOST_AUTO_TEST_CASE(userDefinedFileBc) { - dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); + dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_SUITE_END() From d3cab2e01085ddadeb2cf61fbfb799399c433917 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:44:41 +0100 Subject: [PATCH 051/313] fix blockGasLimit bug : 1024 -> 2048 --- libethcore/BlockInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 6c645372e..71cd0d110 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -206,8 +206,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); // Check timestamp is after previous timestamp. if (parentHash) From 5134da58c1e2f50a0fb6b5125069e0db3d4d3153 Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 4 Mar 2015 16:01:13 +0300 Subject: [PATCH 052/313] Transaction Test Fillers POC9 gas fees increased, most tests are incorrect now need to review (wip) --- test/stPreCompiledContractsFiller.json | 6 +- test/stTransactionTestFiller.json | 144 ++++++++++++------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/test/stPreCompiledContractsFiller.json b/test/stPreCompiledContractsFiller.json index 7c7fd8e4b..d571dfccc 100644 --- a/test/stPreCompiledContractsFiller.json +++ b/test/stPreCompiledContractsFiller.json @@ -378,16 +378,16 @@ "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "currentNumber" : "0", - "currentGasLimit" : "10000000", + "currentGasLimit" : "100000000", "currentDifficulty" : "256", "currentTimestamp" : 1, "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" }, "pre" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "20000000", + "balance" : "200000000", "nonce" : "0", - "code" : "{ [[ 2 ]] (CALL 500 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", + "code" : "{ [[ 2 ]] (CALL 20000000 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { diff --git a/test/stTransactionTestFiller.json b/test/stTransactionTestFiller.json index 37b752f86..f77c7bab5 100644 --- a/test/stTransactionTestFiller.json +++ b/test/stTransactionTestFiller.json @@ -52,7 +52,7 @@ "transaction" : { "data" : "", - "gasLimit" : "500", + "gasLimit" : "21000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -84,7 +84,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -116,7 +116,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -138,7 +138,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1101", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -148,12 +148,12 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21600", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "502" + "value" : "5000" } }, @@ -170,7 +170,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -180,20 +180,20 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21600", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "502" + "value" : "5000" } }, "InternalCallHittingGasLimit" : { "env" : { - "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentCoinbase" : "2adf5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "22000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -227,7 +227,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1100", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -240,7 +240,7 @@ "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "21100", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -258,7 +258,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1100", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -271,7 +271,7 @@ "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "21100", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -289,7 +289,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1101", + "gasLimit" : "21101", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -302,7 +302,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -310,7 +310,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "140000", "code" : "", "nonce" : "0", "storage" : { @@ -339,7 +339,7 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "130000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -352,7 +352,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "100000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -360,7 +360,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "30000", "code" : "", "nonce" : "0", "storage" : { @@ -389,7 +389,7 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -402,7 +402,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -410,7 +410,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -449,7 +449,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -462,7 +462,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -470,7 +470,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "500000", "code" : "", "nonce" : "0", "storage" : { @@ -514,7 +514,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -527,7 +527,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -535,7 +535,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -544,7 +544,7 @@ "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10", - "code" : "{(CALL 0 0 1 0 0 0 0) (SUICIDE 0)}", + "code" : "{(CALL 20000 0x0000000000000000000000000000000000000000 1 0 0 0 0) (SUICIDE 0)}", "nonce" : "0", "storage" : { } @@ -552,7 +552,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "0", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -563,7 +563,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "50000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -576,7 +576,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -584,7 +584,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -592,8 +592,8 @@ }, "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10", - "code" : "{(CALL 20 0 1 0 0 0 0) (SUICIDE 0)}", + "balance" : "1000", + "code" : "{(CALL 22000 0x0000000000000000000000000000000000000000 1 0 0 0 0) (SUICIDE 0)}", "nonce" : "0", "storage" : { } @@ -601,7 +601,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "0", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -612,7 +612,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "50000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -633,7 +633,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "122000", "code" : "", "nonce" : "0", "storage" : { @@ -642,7 +642,7 @@ "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10000", - "code" : "{(SUICIDE 0) (CALL 0 2000 0 0 0 0 0) }", + "code" : "{(SUICIDE 0) (CALL 2000 0x0000000000000000000000000000000000000000 0 0 0 0 0) }", "nonce" : "0", "storage" : { } @@ -650,7 +650,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "1110", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -660,7 +660,7 @@ "transaction" : { "data" : "", - "gasLimit" : "3700", + "gasLimit" : "33700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -673,7 +673,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -681,7 +681,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "122000", "code" : "", "nonce" : "0", "storage" : { @@ -700,7 +700,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1700", + "gasLimit" : "31700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -713,7 +713,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -721,7 +721,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -740,7 +740,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1700", + "gasLimit" : "21700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -771,7 +771,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -784,7 +784,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -802,7 +802,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -815,7 +815,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -833,7 +833,7 @@ "transaction" : { "data" : "0x00000000000000000000112233445566778f32", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -846,7 +846,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -854,7 +854,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "43000", "code" : "", "nonce" : "0", "storage" : { @@ -864,7 +864,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5100", + "gasLimit" : "35100", "gasPrice" : "0", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -877,7 +877,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -885,7 +885,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "33000", "code" : "", "nonce" : "0", "storage" : { @@ -908,7 +908,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -916,7 +916,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "33000", "code" : "", "nonce" : "0", "storage" : { @@ -926,8 +926,8 @@ "transaction" : { "data" : "0x3240349548983454", - "gasLimit" : "500", - "gasPrice" : "0", + "gasLimit" : "32600", + "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", @@ -999,7 +999,7 @@ "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "900" + "value" : "" } }, @@ -1048,7 +1048,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "100000", + "balance" : "1000000", "code" : "", "nonce" : "0", "storage" : { @@ -1058,7 +1058,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1079,7 +1079,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "132000", "code" : "", "nonce" : "0", "storage" : { @@ -1089,7 +1089,7 @@ "transaction" : { "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", - "gasLimit" : "882", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1110,7 +1110,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -1120,7 +1120,7 @@ "transaction" : { "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", - "gasLimit" : "883", + "gasLimit" : "70000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1141,7 +1141,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "30000", "code" : "", "nonce" : "0", "storage" : { @@ -1159,7 +1159,7 @@ "transaction" : { "data" : "", - "gasLimit" : "882", + "gasLimit" : "21882", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From 169e36aeb8a5ddd70be96dfe32bcc95f5ab63084 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:48:01 +0100 Subject: [PATCH 053/313] update block tests to latest changes PoW changes --- libethcore/ProofOfWork.cpp | 2 +- test/bcBlockChainTestFiller.json | 4 ++- test/bcInvalidHeaderTestFiller.json | 56 +++++++++++++++++++++-------- test/bcValidBlockTestFiller.json | 52 ++++++++++++++++++--------- test/blockchain.cpp | 36 +++++++++++++++---- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 084225a38..04e4249b6 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -162,7 +162,7 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign if (val <= boundary) { ret.first.completed = true; - result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); result.nonce = u64(tryNonce); break; } diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 75ed62943..827f49c58 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -7,12 +7,14 @@ "extraData" : "42", "gasLimit" : "100000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index bba00834b..5665a3418 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -7,7 +7,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -61,7 +63,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,7 +119,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -168,7 +174,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -221,7 +229,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -274,7 +284,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -328,7 +340,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -381,7 +395,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -434,7 +450,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -487,7 +505,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -540,7 +560,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -593,7 +615,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -646,7 +670,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -699,7 +725,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 3ce79cf4d..abb8afdf5 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -8,7 +8,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -30,7 +32,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "850", + "gasLimit" : "85000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -53,7 +55,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,7 +101,9 @@ "extraData" : "42", "gasLimit" : "1000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -141,7 +147,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -163,7 +171,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "500", + "gasLimit" : "50000", "gasPrice" : "10", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -185,7 +193,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -238,7 +248,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -291,7 +303,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -341,8 +355,10 @@ "extraData" : "42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "number" : "0", "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", @@ -351,19 +367,23 @@ "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } }, "blocks" : [ { "transactions" : [ { "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", + "gasLimit" : "50000", + "gasPrice" : "50", "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "", - "v" : "0x1b", "value" : "" } ], diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 69ea8fa2b..ccfd57722 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -75,6 +75,12 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("extraData")) rlpStream << importByteArray(_tObj["extraData"].get_str()); + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixBytes")) + rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -130,13 +136,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { // find new valid nonce ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + std::pair ret; + while (!ProofOfWork::verify(blockFromFields)) + { + ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); } // create new "genesis" block @@ -266,15 +276,25 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixBytes")) + tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + // find new valid nonce if (tmp != current_BlockHeader) { current_BlockHeader = tmp; + ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) - tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } } } else @@ -302,6 +322,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); blObj["blockHeader"] = oBlockHeader; @@ -423,6 +445,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); From 3946eacd0c2ca1df43dbc4048aa4aabb0ff086c6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 15:17:34 +0100 Subject: [PATCH 054/313] More info in AZ. --- alethzero/MainWin.cpp | 22 ++++++++++++++++++---- libethcore/BlockInfo.cpp | 18 +++++++++++++----- libethcore/BlockInfo.h | 7 ++++--- libethcore/Exceptions.h | 1 + libethcore/ProofOfWork.cpp | 10 +++++----- libethcore/ProofOfWork.h | 11 ++++++++--- 6 files changed, 49 insertions(+), 20 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 08117e596..e6f380e47 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1358,11 +1358,16 @@ void Main::on_blocks_currentItemChanged() s << "   Children: " << details.children.size() << ""; s << "
Gas used/limit: " << info.gasUsed << "/" << info.gasLimit << ""; s << "
Coinbase: " << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << " " << info.coinbaseAddress; + s << "
Seed hash: " << info.seedHash << ""; + s << "
Mix hash: " << info.mixHash << ""; s << "
Nonce: " << info.nonce << ""; s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + { + auto e = ProofOfWork::eval(info); + s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; + } else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; @@ -1374,9 +1379,18 @@ void Main::on_blocks_currentItemChanged() for (auto u: block[2]) { BlockInfo uncle = BlockInfo::fromHeader(u.data()); - s << "
 Hash: " << uncle.hash << ""; - s << "
 Parent: " << uncle.parentHash << ""; - s << "
 Number: " << uncle.number << ""; + char const* line = "
 "; + s << line << "Hash: " << uncle.hash << ""; + s << line << "Parent: " << uncle.parentHash << ""; + s << line << "Number: " << uncle.number << ""; + s << line << "Coinbase: " << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << " " << uncle.coinbaseAddress; + s << line << "Seed hash: " << uncle.seedHash << ""; + s << line << "Mix hash: " << uncle.mixHash << ""; + s << line << "Nonce: " << uncle.nonce << ""; + s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; + s << line << "Difficulty: " << uncle.difficulty << ""; + auto e = ProofOfWork::eval(uncle); + s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) s << "
Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << ""; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 6c645372e..98bd12b9b 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -57,7 +57,7 @@ void BlockInfo::setEmpty() timestamp = 0; extraData.clear(); seedHash = h256(); - mixBytes = h256(); + mixHash = h256(); nonce = Nonce(); hash = headerHash(WithNonce); } @@ -82,7 +82,7 @@ void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << mixBytes << nonce; + _s << mixHash << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -111,7 +111,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); seedHash = _header[field = 13].toHash(); - mixBytes = _header[field = 14].toHash(); + mixHash = _header[field = 14].toHash(); nonce = _header[field = 15].toHash(); } @@ -180,7 +180,12 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); - seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; + seedHash = calculateSeedHash(_parent); +} + +h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const +{ + return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -196,7 +201,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -209,6 +214,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + if (seedHash != calculateSeedHash(_parent)) + BOOST_THROW_EXCEPTION(InvalidSeedHash()); + // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index fbc459b76..d2072046d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -76,7 +76,7 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 mixBytes; + h256 mixHash; h256 seedHash; Nonce nonce; @@ -106,7 +106,7 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && - mixBytes == _cmp.mixBytes && + mixHash == _cmp.mixHash && seedHash == _cmp.seedHash && nonce == _cmp.nonce; } @@ -123,6 +123,7 @@ public: u256 calculateDifficulty(BlockInfo const& _parent) const; u256 calculateGasLimit(BlockInfo const& _parent) const; + h256 calculateSeedHash(BlockInfo const& _parent) const; /// sha3 of the header only. h256 headerHash(IncludeNonce _n) const; @@ -133,7 +134,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixHash << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 5a8a2d055..833bc2b04 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -57,6 +57,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; +struct InvalidSeedHash: virtual dev::Exception {}; class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 084225a38..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -118,16 +118,16 @@ Ethasher* Ethasher::s_this = nullptr; bool Ethash::verify(BlockInfo const& _header) { bigint boundary = (bigint(1) << 256) / _header.difficulty; - u256 e(eval(_header, _header.nonce)); - return e <= boundary; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; } -h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) +Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { auto p = Ethasher::params(_header); ethash_return_value r; ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return h256(r.result, h256::ConstructFromPointer); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) @@ -162,7 +162,7 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign if (val <= boundary) { ret.first.completed = true; - result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); result.nonce = u64(tryNonce); break; } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7b9787f61..fdf51f0d4 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -55,12 +55,17 @@ public: Nonce nonce; h256 mixHash; }; + struct Result + { + h256 value; + h256 mixHash; + }; - static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } protected: Nonce m_last; From 111b65ef74dedb5a278da0ccd1cb0f44921ecc1d Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 4 Mar 2015 19:01:37 +0300 Subject: [PATCH 055/313] Gas Fee Test Changes (1) State Tests --- test/stBlockHashTestFiller.json | 6 +- test/stExampleFiller.json | 2 +- test/stInitCodeTestFiller.json | 34 +++++----- test/stLogTestsFiller.json | 92 +++++++++++++------------- test/stMemoryTestFiller.json | 2 +- test/stRefundTestFiller.json | 32 ++++----- test/stSolidityTestFiller.json | 14 ++-- test/stSpecialTestFiller.json | 4 +- test/stSystemOperationsTestFiller.json | 58 ++++++++-------- 9 files changed, 122 insertions(+), 122 deletions(-) diff --git a/test/stBlockHashTestFiller.json b/test/stBlockHashTestFiller.json index af2234976..5ecc5b1c7 100644 --- a/test/stBlockHashTestFiller.json +++ b/test/stBlockHashTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -59,7 +59,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -93,7 +93,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stExampleFiller.json b/test/stExampleFiller.json index 7acf695ed..9daefbd54 100644 --- a/test/stExampleFiller.json +++ b/test/stExampleFiller.json @@ -26,7 +26,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "10000", + "gasLimit" : "400000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stInitCodeTestFiller.json b/test/stInitCodeTestFiller.json index ea5467df8..902290121 100644 --- a/test/stInitCodeTestFiller.json +++ b/test/stInitCodeTestFiller.json @@ -21,7 +21,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "599", + "gasLimit" : "32599", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -43,7 +43,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "2", + "balance" : "22177", "code" : "", "nonce" : "0", "storage" : { @@ -53,7 +53,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "599", + "gasLimit" : "22176", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -74,7 +74,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "70000", "code" : "", "nonce" : "0", "storage" : { @@ -84,7 +84,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "590", + "gasLimit" : "21590", "gasPrice" : "3", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -104,7 +104,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "50000", "code" : "", "nonce" : "0", "storage" : { @@ -114,7 +114,7 @@ "transaction" : { "data" : "0x6000f1", - "gasLimit" : "1000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -135,7 +135,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -145,7 +145,7 @@ "transaction" : { "data" : "0x600a80600c6000396000fff2ffff600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -166,7 +166,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -176,7 +176,7 @@ "transaction" : { "data" : "0x600a80600c600039600000f20000600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -207,7 +207,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200ff600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -245,7 +245,7 @@ "transaction" : { "data" : "0x00", - "gasLimit" : "10000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -283,7 +283,7 @@ "transaction" : { "data" : "0x00", - "gasLimit" : "10000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -521,7 +521,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "41000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -560,7 +560,7 @@ "transaction" : { "data" : "", - "gasLimit" : "15000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stLogTestsFiller.json b/test/stLogTestsFiller.json index 0f31c4c63..3b13698cf 100644 --- a/test/stLogTestsFiller.json +++ b/test/stLogTestsFiller.json @@ -32,7 +32,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -73,7 +73,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -114,9 +114,9 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "100000", + "value" : "2100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "" } @@ -156,7 +156,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -238,7 +238,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -279,7 +279,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -320,7 +320,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -361,7 +361,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -402,7 +402,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -444,7 +444,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -485,7 +485,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -526,7 +526,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -567,7 +567,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -608,7 +608,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -649,7 +649,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -690,7 +690,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -731,7 +731,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -772,7 +772,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -814,7 +814,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -855,7 +855,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -896,7 +896,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -937,7 +937,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -978,7 +978,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1019,7 +1019,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1060,7 +1060,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1101,7 +1101,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1142,7 +1142,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1184,7 +1184,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1225,7 +1225,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1266,7 +1266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1307,7 +1307,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1348,7 +1348,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1389,7 +1389,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1430,7 +1430,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1471,7 +1471,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1512,7 +1512,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1553,7 +1553,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1595,7 +1595,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1636,7 +1636,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1677,7 +1677,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1718,7 +1718,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1759,7 +1759,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1800,7 +1800,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1841,7 +1841,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json index eac2d5875..f34307443 100644 --- a/test/stMemoryTestFiller.json +++ b/test/stMemoryTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "1000", + "gasLimit" : "22000", "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stRefundTestFiller.json b/test/stRefundTestFiller.json index 6c0674613..3dfebaca0 100644 --- a/test/stRefundTestFiller.json +++ b/test/stRefundTestFiller.json @@ -18,7 +18,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -27,7 +27,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -54,7 +54,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -63,7 +63,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -90,7 +90,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -99,7 +99,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "500", + "gasLimit" : "21000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -126,7 +126,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "502", + "balance" : "50200", "nonce" : "0", "code" : "", "storage": {} @@ -135,7 +135,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "502", + "gasLimit" : "21002", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -166,7 +166,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -175,7 +175,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -206,7 +206,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -215,7 +215,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -247,7 +247,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -256,7 +256,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -288,7 +288,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -297,7 +297,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSolidityTestFiller.json b/test/stSolidityTestFiller.json index 253ba8016..3c323d1f3 100644 --- a/test/stSolidityTestFiller.json +++ b/test/stSolidityTestFiller.json @@ -278,7 +278,7 @@ { "//" : "run()", "data" : "0xc0406226", - "gasLimit" : "15000", + "gasLimit" : "35000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -333,7 +333,7 @@ { "//" : "testRecursiveMethods()", "data" : "0x981a3165", - "gasLimit" : "2000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -378,7 +378,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -388,7 +388,7 @@ { "//" : "testInfiniteLoop()", "data" : "0x296df0df", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -463,7 +463,7 @@ { "//" : "run(uint256)", "data" : "0xa444f5e900000000000000000000000000000000000000000000000000000000000204", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -508,7 +508,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -518,7 +518,7 @@ { "//" : "run()", "data" : "0xc0406226", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSpecialTestFiller.json b/test/stSpecialTestFiller.json index d01072b46..223d9f75f 100644 --- a/test/stSpecialTestFiller.json +++ b/test/stSpecialTestFiller.json @@ -22,7 +22,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -31,7 +31,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSystemOperationsTestFiller.json b/test/stSystemOperationsTestFiller.json index 9f47b2fef..81b76f724 100644 --- a/test/stSystemOperationsTestFiller.json +++ b/test/stSystemOperationsTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -60,7 +60,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -95,7 +95,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -129,7 +129,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -163,7 +163,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -232,7 +232,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -257,7 +257,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -266,7 +266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -300,7 +300,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -334,7 +334,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -368,7 +368,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -410,7 +410,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -452,7 +452,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -494,7 +494,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -536,7 +536,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -578,7 +578,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -619,7 +619,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -660,7 +660,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -701,7 +701,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -743,7 +743,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -785,7 +785,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -827,7 +827,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -870,7 +870,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -911,7 +911,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -952,7 +952,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -993,7 +993,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1035,7 +1035,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1076,7 +1076,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From d14df543ffc9ae4c2be607388a4e15c1dc15fdc3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 17:35:23 +0100 Subject: [PATCH 056/313] Add date/time language to solidity. --- libdevcore/FixedHash.h | 4 ++-- libsolidity/AST.h | 8 +++++++- libsolidity/ExpressionCompiler.cpp | 3 +++ libsolidity/Parser.cpp | 9 +++++++++ libsolidity/Token.h | 24 ++++++++++++++++-------- libsolidity/Types.cpp | 19 ++++++++++++++++++- mix/MixClient.cpp | 9 ++++++--- test/SolidityScanner.cpp | 17 +++++++++++++++++ test/blockchain.cpp | 14 +++++++------- 9 files changed, 85 insertions(+), 22 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 7fa5b411a..b00a80c04 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -85,8 +85,8 @@ public: // The obvious comparison operators. bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; } bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; } - bool operator<(FixedHash const& _c) const { return m_data < _c.m_data; } - bool operator>=(FixedHash const& _c) const { return m_data >= _c.m_data; } + bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; } + bool operator>=(FixedHash const& _c) const { return !operator<(_c); } // The obvious binary operators. FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; } diff --git a/libsolidity/AST.h b/libsolidity/AST.h index c91c433ed..c3c2cd8d3 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1197,7 +1197,13 @@ public: Wei = Token::SubWei, Szabo = Token::SubSzabo, Finney = Token::SubFinney, - Ether = Token::SubEther + Ether = Token::SubEther, + Second = Token::SubSecond, + Minute = Token::SubMinute, + Hour = Token::SubHour, + Day = Token::SubDay, + Week = Token::SubWeek, + Year = Token::SubYear }; Literal(SourceLocation const& _location, Token::Value _token, ASTPointer const& _value, diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 619b06738..38d9aac86 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -250,6 +250,9 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) case Token::BitNot: // ~ m_context << eth::Instruction::NOT; break; + case Token::After: // after + m_context << eth::Instruction::TIMESTAMP << eth::Instruction::ADD; + break; case Token::Delete: // delete solAssert(!!m_currentLValue, "LValue not retrieved."); m_currentLValue->setToZero(_unaryOperation.getLocation()); diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 3c88efc7c..44d111591 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -822,6 +822,15 @@ ASTPointer Parser::parsePrimaryExpression() expression = nodeFactory.createNode(token, literal, subdenomination); break; } + if (Token::isTimeSubdenomination(m_scanner->peekNextToken())) + { + ASTPointer literal = getLiteralAndAdvance(); + nodeFactory.markEndPosition(); + Literal::SubDenomination subdenomination = static_cast(m_scanner->getCurrentToken()); + m_scanner->next(); + expression = nodeFactory.createNode(token, literal, subdenomination); + break; + } // fall-through case Token::StringLiteral: nodeFactory.markEndPosition(); diff --git a/libsolidity/Token.h b/libsolidity/Token.h index 5e4a6317f..2997bb493 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -162,7 +162,7 @@ namespace solidity K(New, "new", 0) \ K(Public, "public", 0) \ K(Private, "private", 0) \ - K(Internal, "internal", 0) \ + K(Internal, "internal", 0) \ K(Return, "return", 0) \ K(Returns, "returns", 0) \ K(Struct, "struct", 0) \ @@ -171,11 +171,18 @@ namespace solidity K(While, "while", 0) \ K(Enum, "enum", 0) \ \ - /* Ether subdenominations */ \ - K(SubWei, "wei", 0) \ - K(SubSzabo, "szabo", 0) \ - K(SubFinney, "finney", 0) \ - K(SubEther, "ether", 0) \ + /* Ether subdenominations */ \ + K(SubWei, "wei", 0) \ + K(SubSzabo, "szabo", 0) \ + K(SubFinney, "finney", 0) \ + K(SubEther, "ether", 0) \ + K(SubSecond, "seconds", 0) \ + K(SubMinute, "minutes", 0) \ + K(SubHour, "hours", 0) \ + K(SubDay, "days", 0) \ + K(SubWeek, "weeks", 0) \ + K(SubYear, "years", 0) \ + K(After, "after", 0) \ /* type keywords, keep them in this order, keep int as first keyword * the implementation in Types.cpp has to be synced to this here */\ K(Int, "int", 0) \ @@ -376,12 +383,13 @@ public: } static bool isBitOp(Value op) { return (BitOr <= op && op <= SHR) || op == BitNot; } - static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub; } + static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub || op == After; } static bool isCountOp(Value op) { return op == Inc || op == Dec; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; } static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Internal; } - static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; } + static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; } + static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; } // Returns a string corresponding to the JS token string // (.e., "<" for the token LT) or NULL if the token doesn't diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 22d612cd9..2105d6299 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -195,7 +195,8 @@ TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const return TypePointer(); // for non-hash integers, we allow +, -, ++ and -- else if (_operator == Token::Add || _operator == Token::Sub || - _operator == Token::Inc || _operator == Token::Dec) + _operator == Token::Inc || _operator == Token::Dec || + _operator == Token::After) return shared_from_this(); else return TypePointer(); @@ -251,6 +252,7 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) switch (_literal.getSubDenomination()) { case Literal::SubDenomination::Wei: + case Literal::SubDenomination::Second: case Literal::SubDenomination::None: break; case Literal::SubDenomination::Szabo: @@ -262,6 +264,21 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) case Literal::SubDenomination::Ether: m_value *= bigint("1000000000000000000"); break; + case Literal::SubDenomination::Minute: + m_value *= bigint("60"); + break; + case Literal::SubDenomination::Hour: + m_value *= bigint("3600"); + break; + case Literal::SubDenomination::Day: + m_value *= bigint("86400"); + break; + case Literal::SubDenomination::Week: + m_value *= bigint("604800"); + break; + case Literal::SubDenomination::Year: + m_value *= bigint("31536000"); + break; } } diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index 04cec6344..5b446a6a4 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -46,15 +46,18 @@ const u256 c_mixGenesisDifficulty = (u256) 1 << 4; class MixBlockChain: public dev::eth::BlockChain { public: - MixBlockChain(std::string const& _path, h256 _stateRoot): BlockChain(createGenesisBlock(_stateRoot), _path, true) + MixBlockChain(std::string const& _path, h256 _stateRoot): + BlockChain(createGenesisBlock(_stateRoot), _path, true) { } static bytes createGenesisBlock(h256 _stateRoot) { RLPStream block(3); - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_mixGenesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << std::string() << sha3(bytes(1, 42)); + block.appendList(16) + << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie + << LogBloom() << c_mixGenesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 + << std::string() << h256() << h256() << h64(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); diff --git a/test/SolidityScanner.cpp b/test/SolidityScanner.cpp index 2e4e5db08..8d3e53929 100644 --- a/test/SolidityScanner.cpp +++ b/test/SolidityScanner.cpp @@ -264,6 +264,23 @@ BOOST_AUTO_TEST_CASE(ether_subdenominations) BOOST_CHECK_EQUAL(scanner.next(), Token::SubEther); } +BOOST_AUTO_TEST_CASE(time_subdenominations) +{ + Scanner scanner(CharStream("seconds minutes hours days weeks years")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::SubSecond); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubMinute); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubHour); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubDay); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubWeek); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubYear); +} + +BOOST_AUTO_TEST_CASE(time_after) +{ + Scanner scanner(CharStream("after 1")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::After); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ccfd57722..aea2bab07 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -78,8 +78,8 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("seedHash")) rlpStream << importByteArray(_tObj["seedHash"].get_str()); - if (_tObj.count("mixBytes")) - rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -146,7 +146,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); + o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); } // create new "genesis" block @@ -276,8 +276,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixBytes")) - tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); if (blObj["blockHeader"].get_obj().count("seedHash")) tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); @@ -322,7 +322,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); @@ -445,7 +445,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixHash == blockFromRlp.mixHash, "mixHash in given RLP not matching the block mixHash!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); From d7d88753990a7bcd28fa3a8a325decebf7d66e82 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 19:55:52 +0100 Subject: [PATCH 057/313] Params & JSON file. --- libdevcrypto/OverlayDB.cpp | 2 -- libethcore/BlockInfo.cpp | 19 +++++++++---------- libethcore/BlockInfo.h | 2 -- .../FeeStructure.cpp => libethcore/Params.cpp | 11 ++++++++++- libevm/FeeStructure.h => libethcore/Params.h | 10 ++++++++++ libethcore/ProofOfWork.cpp | 2 ++ libethereum/Client.h | 2 +- libethereum/Interface.h | 2 +- libethereum/Precompiled.cpp | 2 +- libethereum/State.h | 2 +- libevm/All.h | 1 - libevm/VM.h | 2 +- libsolidity/Types.cpp | 2 ++ feeStructure.json => params.json | 12 +++++++++++- 14 files changed, 49 insertions(+), 22 deletions(-) rename libevm/FeeStructure.cpp => libethcore/Params.cpp (84%) rename libevm/FeeStructure.h => libethcore/Params.h (91%) rename feeStructure.json => params.json (75%) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4bd698f57 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -56,10 +56,8 @@ void OverlayDB::commit() if (m_aux.count(i)) { m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; m_aux.erase(i); } - cdebug << "Discarding " << keysOf(m_aux); m_auxActive.clear(); m_aux.clear(); m_over.clear(); diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index c04f6fc29..ef7f7b8f0 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -25,13 +25,12 @@ #include #include "ProofOfWork.h" #include "Exceptions.h" +#include "Params.h" #include "BlockInfo.h" using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; - BlockInfo::BlockInfo(): timestamp(Invalid256) { } @@ -128,7 +127,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) if (gasUsed > gasLimit) BOOST_THROW_EXCEPTION(TooMuchGasUsed()); - if (number && extraData.size() > 1024) + if (number && extraData.size() > c_maximumExtraDataSize) BOOST_THROW_EXCEPTION(ExtraDataTooBig()); } @@ -185,23 +184,23 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const { - return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; + return number % c_epochDuration == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const { if (!parentHash) - return 1000000; + return c_genesisGasLimit; else - return max(125000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024); + return max(c_minGasLimit, (_parent.gasLimit * (c_gasLimitBoundDivisor - 1) + (_parent.gasUsed * 6 / 5)) / c_gasLimitBoundDivisor); } u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const { if (!parentHash) - return c_genesisDifficulty; + return (u256)c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -211,8 +210,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index d2072046d..bf986e3a1 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -30,8 +30,6 @@ namespace dev namespace eth { -extern u256 c_genesisDifficulty; - enum IncludeNonce { WithoutNonce = 0, diff --git a/libevm/FeeStructure.cpp b/libethcore/Params.cpp similarity index 84% rename from libevm/FeeStructure.cpp rename to libethcore/Params.cpp index 78c6ebfb2..f36af1375 100644 --- a/libevm/FeeStructure.cpp +++ b/libethcore/Params.cpp @@ -19,7 +19,7 @@ * @date 2014 */ -#include "FeeStructure.h" +#include "Params.h" using namespace std; namespace dev @@ -28,6 +28,15 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_genesisDifficulty = 2048; +u256 const c_maximumExtraDataSize = 1024; +u256 const c_epochDuration = 3000; +u256 const c_genesisGasLimit = 1000000; +u256 const c_minGasLimit = 125000; +u256 const c_gasLimitBoundDivisor = 1024; +u256 const c_minimumDifficulty = 2048; +u256 const c_difficultyBoundDivisor = 2048; +u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; u256 const c_expGas = 10; u256 const c_expByteGas = 10; diff --git a/libevm/FeeStructure.h b/libethcore/Params.h similarity index 91% rename from libevm/FeeStructure.h rename to libethcore/Params.h index 9109347dc..cab1852fa 100644 --- a/libevm/FeeStructure.h +++ b/libethcore/Params.h @@ -29,6 +29,16 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +extern u256 const c_genesisDifficulty; +extern u256 const c_maximumExtraDataSize; +extern u256 const c_epochDuration; +extern u256 const c_genesisGasLimit; +extern u256 const c_minGasLimit; +extern u256 const c_gasLimitBoundDivisor; +extern u256 const c_minimumDifficulty; +extern u256 const c_difficultyBoundDivisor; +extern u256 const c_durationLimit; + extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..332d739bb 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,6 +66,7 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } + cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -90,6 +91,7 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } + cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/libethereum/Client.h b/libethereum/Client.h index 03debb750..c4f2b3705 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include "CanonBlockChain.h" #include "TransactionQueue.h" diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 2a9de14d1..817a5e4b0 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include "LogFilter.h" #include "Transaction.h" #include "AccountDiff.h" diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..6e0d4756c 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/libethereum/State.h b/libethereum/State.h index 33843c65c..00a735291 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include "TransactionQueue.h" #include "Account.h" diff --git a/libevm/All.h b/libevm/All.h index 89c451ef4..2360d91b8 100644 --- a/libevm/All.h +++ b/libevm/All.h @@ -1,5 +1,4 @@ #pragma once #include "ExtVMFace.h" -#include "FeeStructure.h" #include "VM.h" diff --git a/libevm/VM.h b/libevm/VM.h index ecf5de292..f100badc4 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -27,7 +27,7 @@ #include #include #include -#include "FeeStructure.h" +#include #include "VMFace.h" namespace dev diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 2105d6299..865a32c3a 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -308,6 +308,8 @@ TypePointer IntegerConstantType::unaryOperatorResult(Token::Value _operator) con case Token::Sub: value = -m_value; break; + case Token::After: + return shared_from_this(); default: return TypePointer(); } diff --git a/feeStructure.json b/params.json similarity index 75% rename from feeStructure.json rename to params.json index f5acf0f0b..1b5682544 100644 --- a/feeStructure.json +++ b/params.json @@ -1,5 +1,15 @@ var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." }, + "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, + "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, + "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, + "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, + "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, + "minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." }, + "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, + "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, + + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "expGas": { "v": 10, "d": "Once per EXP instuction." }, "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, From 8617e38311e79e69b0679c40f8172e289068ddea Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 21:32:26 +0100 Subject: [PATCH 058/313] merge --- libethcore/BlockInfo.cpp | 20 +- test/bcBlockChainTestFiller.json | 6 +- test/bcInvalidHeaderTestFiller.json | 88 ++++----- test/bcUncleTestFiller.json | 114 ++++++++++++ test/bcValidBlockTestFiller.json | 48 ++--- test/blockchain.cpp | 275 +++++++++++++++------------- 6 files changed, 341 insertions(+), 210 deletions(-) create mode 100644 test/bcUncleTestFiller.json diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ef7f7b8f0..d8a2357a1 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -96,22 +96,22 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) int field = 0; try { - parentHash = _header[field = 0].toHash(); - sha3Uncles = _header[field = 1].toHash(); - coinbaseAddress = _header[field = 2].toHash
(); - stateRoot = _header[field = 3].toHash(); - transactionsRoot = _header[field = 4].toHash(); - receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + parentHash = _header[field = 0].toHash(RLP::VeryStrict); + sha3Uncles = _header[field = 1].toHash(RLP::VeryStrict); + coinbaseAddress = _header[field = 2].toHash
(RLP::VeryStrict); + stateRoot = _header[field = 3].toHash(RLP::VeryStrict); + transactionsRoot = _header[field = 4].toHash(RLP::VeryStrict); + receiptsRoot = _header[field = 5].toHash(RLP::VeryStrict); + logBloom = _header[field = 6].toHash(RLP::VeryStrict); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - seedHash = _header[field = 13].toHash(); - mixHash = _header[field = 14].toHash(); - nonce = _header[field = 15].toHash(); + seedHash = _header[field = 13].toHash(RLP::VeryStrict); + mixHash = _header[field = 14].toHash(RLP::VeryStrict); + nonce = _header[field = 15].toHash(RLP::VeryStrict); } catch (Exception const& _e) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 827f49c58..8a0bf89fe 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -1,10 +1,10 @@ { "minDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1023", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", "number" : "0", @@ -12,7 +12,7 @@ "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index 5665a3418..aa32dfbab 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,13 +1,13 @@ { "log1_wrongBlockNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -57,13 +57,13 @@ "log1_wrongBloom" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -92,7 +92,7 @@ "blocks" : [ { "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, "transactions" : [ { @@ -113,13 +113,13 @@ "wrongCoinbase" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -168,13 +168,13 @@ "wrongDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -223,13 +223,13 @@ "DifferentExtraData" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -257,7 +257,7 @@ "blocks" : [ { "blockHeader" : { - "extraData" : "42" + "extraData" : "0x42" }, "transactions" : [ { @@ -278,13 +278,13 @@ "wrongGasLimit" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -334,13 +334,13 @@ "wrongGasUsed" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -389,13 +389,13 @@ "wrongNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -444,13 +444,13 @@ "wrongParentHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -499,13 +499,13 @@ "wrongReceiptTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -554,13 +554,13 @@ "wrongStateRoot" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -609,13 +609,13 @@ "wrongTimestamp" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -664,13 +664,13 @@ "wrongTransactionsTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -719,13 +719,13 @@ "wrongUncleHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json new file mode 100644 index 000000000..839e3ba46 --- /dev/null +++ b/test/bcUncleTestFiller.json @@ -0,0 +1,114 @@ +{ + "minDifficulty" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "2049", + "extraData" : "0x", + "gasLimit" : "99804806", + "gasUsed" : "21000", + "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", + "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", + "nonce" : "17ed77999bef2e4b", + "number" : "2", + "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", + "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", + "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", + "timestamp" : "1425490151", + "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "1", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + } +} diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index abb8afdf5..29b2e978e 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -2,13 +2,13 @@ "diff1024" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1024", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -49,13 +49,13 @@ "gasPrice0" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -95,13 +95,13 @@ "gasLimitTooHigh" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "1000000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -141,13 +141,13 @@ "SimpleTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -187,13 +187,13 @@ "txOrder" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -242,13 +242,13 @@ "txEqualValue" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -297,13 +297,13 @@ "log1_correct" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -349,13 +349,13 @@ "dataTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "023101", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index aea2bab07..55c39f56b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -31,61 +31,10 @@ using namespace dev::eth; namespace dev { namespace test { -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("seedHash")) - rlpStream << importByteArray(_tObj["seedHash"].get_str()); - - if (_tObj.count("mixHash")) - rlpStream << importByteArray(_tObj["mixHash"].get_str()); +bytes createBlockRLPFromFields(mObject& _tObj); +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - return rlpStream.out(); -} void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -147,6 +96,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); + o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); } // create new "genesis" block @@ -211,13 +161,13 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txList.push_back(tx); mObject txObject; txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); + txObject["data"] = "0x" + toHex(tx.data()); txObject["gasLimit"] = toString(tx.gas()); txObject["gasPrice"] = toString(tx.gasPrice()); txObject["r"] = "0x" + toString(tx.signature().r); txObject["s"] = "0x" + toString(tx.signature().s); txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); + txObject["to"] = tx.isCreation() ? "" : toString(tx.receiveAddress()); txObject["value"] = toString(tx.value()); txArray.push_back(txObject); @@ -232,78 +182,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj.count("blockHeader")) { - if (blObj["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = current_BlockHeader; - - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); - - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); - - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); - - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); - - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); - - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); - - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); - - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); - - // find new valid nonce - - if (tmp != current_BlockHeader) - { - current_BlockHeader = tmp; - - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) - { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); - } + overwriteBlockHeader(current_BlockHeader, blObj); } // write block header @@ -321,10 +200,11 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["hash"] = toString(current_BlockHeader.hash); blObj["blockHeader"] = oBlockHeader; @@ -506,7 +386,9 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions from rlp and transaction from field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].rlp() == txsFromRlp[i].rlp(), "transactions rlp do not match"); + } // check uncle list @@ -516,6 +398,137 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } } +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.count("hash") > 0 ? (_tObj.size() - 1) : _tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << fromHex(_tObj["extraData"].get_str()); + + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +{ + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } +} } }// Namespace Close @@ -536,6 +549,10 @@ BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); } +//BOOST_AUTO_TEST_CASE(bcUncleTest) +//{ +// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +//} BOOST_AUTO_TEST_CASE(userDefinedFileBc) { From f15e53a8d6dea10b8fad15690e8c9a3f2182b1db Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 22:38:05 +0100 Subject: [PATCH 059/313] fix evmjit build --- evmjit/libevmjit-cpp/Env.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmjit/libevmjit-cpp/Env.cpp b/evmjit/libevmjit-cpp/Env.cpp index 11882d79d..874993c84 100644 --- a/evmjit/libevmjit-cpp/Env.cpp +++ b/evmjit/libevmjit-cpp/Env.cpp @@ -1,7 +1,7 @@ #pragma GCC diagnostic ignored "-Wconversion" #include -#include +#include #include #include "Utils.h" From 7b6f8c460b356d057b3c27ad299cfc4c240493f1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:24:01 +0100 Subject: [PATCH 060/313] RLP tool. --- CMakeLists.txt | 1 + eth/main.cpp | 43 +++--- libdevcore/CommonIO.cpp | 19 ++- libdevcore/CommonIO.h | 6 +- libethcore/Params.cpp | 4 +- libethcore/ProofOfWork.cpp | 2 - params.json | 8 +- rlp/CMakeLists.txt | 16 +++ rlp/base64.cpp | 128 +++++++++++++++++ rlp/base64.h | 40 ++++++ rlp/main.cpp | 279 +++++++++++++++++++++++++++++++++++++ 11 files changed, 511 insertions(+), 35 deletions(-) create mode 100644 rlp/CMakeLists.txt create mode 100644 rlp/base64.cpp create mode 100644 rlp/base64.h create mode 100644 rlp/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dffdd9027..59cfe4ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ if (EVMJIT) endif() add_subdirectory(libdevcore) +add_subdirectory(rlp) add_subdirectory(libevmcore) add_subdirectory(liblll) diff --git a/eth/main.cpp b/eth/main.cpp index 5051580a5..dff97f7fa 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -97,38 +97,38 @@ void interactiveHelp() void help() { cout - << "Usage eth [OPTIONS] " << endl - << "Options:" << endl - << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl + << "Usage eth [OPTIONS] " << endl + << "Options:" << endl + << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl << " -b,--bootstrap Connect to the default Ethereum peerserver." << endl - << " -c,--client-name Add a name to your client's version string (default: blank)." << endl - << " -d,--db-path Load database from path (default: ~/.ethereum " << endl - << " /Etherum or Library/Application Support/Ethereum)." << endl + << " -c,--client-name Add a name to your client's version string (default: blank)." << endl + << " -d,--db-path Load database from path (default: ~/.ethereum " << endl + << " /Etherum or Library/Application Support/Ethereum)." << endl << " -f,--force-mining Mine even when there are no transaction to mine (Default: off)" << endl << " -h,--help Show this help message and exit." << endl - << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl + << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl #if ETH_JSONRPC << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl #endif - << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl + << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl << " -m,--mining Enable mining, optionally for a specified number of blocks (Default: off)" << endl << " -n,--upnp Use upnp for NAT (default: on)." << endl << " -L,--local-networking Use peers whose addresses are local." << endl << " -o,--mode Start a full node or a peer node (Default: full)." << endl - << " -p,--port Connect to remote port (default: 30303)." << endl - << " -r,--remote Connect to remote host (default: none)." << endl - << " -s,--secret Set the secret key for use with send command (default: auto)." << endl + << " -p,--port Connect to remote port (default: 30303)." << endl + << " -r,--remote Connect to remote host (default: none)." << endl + << " -s,--secret Set the secret key for use with send command (default: auto)." << endl << " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl - << " -u,--public-ip Force public ip to given (default; auto)." << endl - << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl - << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl - << " -V,--version Show the version and exit." << endl + << " -u,--public-ip Force public ip to given (default; auto)." << endl + << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl + << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl + << " -V,--version Show the version and exit." << endl #if ETH_EVMJIT << " --jit Use EVM JIT (default: off)." << endl #endif ; - exit(0); + exit(0); } string credits(bool _interactive = false) @@ -136,15 +136,14 @@ string credits(bool _interactive = false) std::ostringstream cout; cout << "Ethereum (++) " << dev::Version << endl - << " Code by Gav Wood, (c) 2013, 2014." << endl + << " Code by Gav Wood et al, (c) 2013, 2014, 2015." << endl << " Based on a design by Vitalik Buterin." << endl << endl; if (_interactive) - { - cout << "Type 'netstart 30303' to start networking" << endl; - cout << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl; - cout << "Type 'exit' to quit" << endl << endl; - } + cout + << "Type 'netstart 30303' to start networking" << endl + << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl + << "Type 'exit' to quit" << endl << endl; return cout.str(); } diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 288dbd1ff..4fa132073 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -84,7 +84,7 @@ bytes dev::contents(std::string const& _file) is.seekg (0, is.end); streamoff length = is.tellg(); if (length == 0) // return early, MSVC does not like reading 0 bytes - return {}; + return bytes(); is.seekg (0, is.beg); bytes ret(length); is.read((char*)ret.data(), length); @@ -92,9 +92,22 @@ bytes dev::contents(std::string const& _file) return ret; } -void dev::writeFile(std::string const& _file, bytes const& _data) +string dev::contentsString(std::string const& _file) { - ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return string(); + // get length of file: + is.seekg (0, is.end); + streamoff length = is.tellg(); + if (length == 0) // return early, MSVC does not like reading 0 bytes + return string(); + is.seekg (0, is.beg); + string ret; + ret.resize(length); + is.read((char*)ret.data(), length); + is.close(); + return ret; } void dev::writeFile(std::string const& _file, bytesConstRef _data) diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 5769b6c64..1fc8a65e4 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -42,13 +42,15 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +std::string contentsString(std::string const& _file); /// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. bytesRef contentsNew(std::string const& _file); -/// Write the given binary data into the given file, replacing the file if it pre-exists. -void writeFile(std::string const& _file, bytes const& _data); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytesConstRef _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +inline void writeFile(std::string const& _file, bytes const& _data) { writeFile(_file, bytesConstRef(&_data)); } +inline void writeFile(std::string const& _file, std::string const& _data) { writeFile(_file, bytesConstRef(_data)); } /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index f36af1375..d1154abcc 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -28,13 +28,13 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_genesisDifficulty = 2048; +u256 const c_genesisDifficulty = 131072; u256 const c_maximumExtraDataSize = 1024; u256 const c_epochDuration = 3000; u256 const c_genesisGasLimit = 1000000; u256 const c_minGasLimit = 125000; u256 const c_gasLimitBoundDivisor = 1024; -u256 const c_minimumDifficulty = 2048; +u256 const c_minimumDifficulty = 131072; u256 const c_difficultyBoundDivisor = 2048; u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 332d739bb..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,7 +66,6 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } - cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -91,7 +90,6 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } - cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/params.json b/params.json index 1b5682544..744f92154 100644 --- a/params.json +++ b/params.json @@ -1,13 +1,13 @@ var x = { - "genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." }, + "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, + "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, + "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, + "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "expGas": { "v": 10, "d": "Once per EXP instuction." }, diff --git a/rlp/CMakeLists.txt b/rlp/CMakeLists.txt new file mode 100644 index 000000000..0e2b5f57b --- /dev/null +++ b/rlp/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_policy(SET CMP0015 NEW) +set(CMAKE_AUTOMOC OFF) + +aux_source_directory(. SRC_LIST) + +include_directories(BEFORE ..) +include_directories(${LEVELDB_INCLUDE_DIRS}) + +set(EXECUTABLE rlp) + +add_executable(${EXECUTABLE} ${SRC_LIST}) + +target_link_libraries(${EXECUTABLE} devcrypto) + +install( TARGETS ${EXECUTABLE} DESTINATION bin) + diff --git a/rlp/base64.cpp b/rlp/base64.cpp new file mode 100644 index 000000000..5e2b32000 --- /dev/null +++ b/rlp/base64.cpp @@ -0,0 +1,128 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. + +#include "base64.h" + +#include + +using namespace std; +using namespace dev; + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +static inline bool is_base64(byte c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +std::string dev::base64_encode(bytesConstRef _in) { + std::string ret; + int i = 0; + int j = 0; + byte char_array_3[3]; + byte char_array_4[4]; + + auto buf = _in.data(); + auto bufLen = _in.size(); + + while (bufLen--) { + char_array_3[i++] = *(buf++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + } + + return ret; +} + +bytes dev::base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + byte char_array_4[4], char_array_3[3]; + bytes ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret.push_back(char_array_3[i]); + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); + } + + return ret; +} diff --git a/rlp/base64.h b/rlp/base64.h new file mode 100644 index 000000000..53ba282c8 --- /dev/null +++ b/rlp/base64.h @@ -0,0 +1,40 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +#pragma once + +#include +#include +#include + +namespace dev +{ + +std::string base64_encode(bytesConstRef _in); +bytes base64_decode(std::string const& _in); + +} diff --git a/rlp/main.cpp b/rlp/main.cpp new file mode 100644 index 000000000..9bd51cdfc --- /dev/null +++ b/rlp/main.cpp @@ -0,0 +1,279 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file main.cpp + * @author Gav Wood + * @date 2014 + * RLP tool. + */ +#include +#include +#include +#include +#include +#include +#include +#include "base64.h" +using namespace std; +using namespace dev; + +void help() +{ + cout + << "Usage rlp [OPTIONS] [ | -- ]" << endl + << "Options:" << endl + << " -V,--version Show the version and exit." << endl + ; + exit(0); +} + +void version() +{ + cout << "rlp version " << dev::Version << endl; + exit(0); +} + +enum class Mode { + ListArchive, + ExtractArchive, + Render, +}; + +enum class Encoding { + Auto, + Hex, + Base64, + Binary, +}; + +bool isAscii(string const& _s) +{ + for (char c: _s) + if (c < 32) + return false; + return true; +} + +class RLPStreamer +{ +public: + struct Prefs + { + string indent = " "; + bool hexInts = false; + bool forceString = false; + bool escapeAll = false; + bool forceHex = false; + }; + + RLPStreamer(ostream& _out, Prefs _p): m_out(_out), m_prefs(_p) {} + + void output(RLP const& _d, unsigned _level = 0) + { + if (_d.isNull()) + m_out << "null"; + else if (_d.isInt()) + if (m_prefs.hexInts) + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + else + m_out << _d.toInt(RLP::LaisezFaire); + else if (_d.isData()) + if (m_prefs.forceString || (!m_prefs.forceHex && isAscii(_d.toString()))) + m_out << escaped(_d.toString(), m_prefs.escapeAll); + else + m_out << toHex(_d.data()); + else if (_d.isList()) + { + m_out << "["; + string newline = "\n"; + for (unsigned i = 0; i < _level + 1; ++i) + newline += m_prefs.indent; + int j = 0; + for (auto i: _d) + { + m_out << (j++ ? + (m_prefs.indent.empty() ? ", " : ("," + newline)) : + (m_prefs.indent.empty() ? " " : newline)); + output(i, _level + 1); + } + newline = newline.substr(0, newline.size() - m_prefs.indent.size()); + m_out << (m_prefs.indent.empty() ? (j ? " ]" : "]") : (j ? newline + "]" : "]")); + } + } + +private: + std::ostream& m_out; + Prefs m_prefs; +}; + +int main(int argc, char** argv) +{ + Encoding encoding = Encoding::Auto; + Mode mode = Mode::Render; + string inputFile = "--"; + bool lenience = false; + RLPStreamer::Prefs prefs; + + for (int i = 1; i < argc; ++i) + { + string arg = argv[i]; + if (arg == "-h" || arg == "--help") + help(); + else if (arg == "-r" || arg == "--render") + mode = Mode::Render; + else if ((arg == "-i" || arg == "--indent") && argc > i) + prefs.indent = argv[++i]; + else if (arg == "--hex-ints") + prefs.hexInts = true; + else if (arg == "--force-string") + prefs.forceString = true; + else if (arg == "--force-hex") + prefs.forceHex = true; + else if (arg == "--force-escape") + prefs.escapeAll = true; + else if (arg == "-l" || arg == "--list-archive") + mode = Mode::ListArchive; + else if (arg == "-e" || arg == "--extract-archive") + mode = Mode::ExtractArchive; + else if (arg == "-L" || arg == "--lenience") + lenience = true; + else if (arg == "-V" || arg == "--version") + version(); + else if (arg == "-x" || arg == "--hex" || arg == "--base-16") + encoding = Encoding::Hex; + else if (arg == "--64" || arg == "--base-64") + encoding = Encoding::Base64; + else if (arg == "-b" || arg == "--bin" || arg == "--base-256") + encoding = Encoding::Binary; + else + inputFile = arg; + } + + bytes in; + if (inputFile == "--") + for (int i = cin.get(); i != -1; i = cin.get()) + in.push_back((byte)i); + else + in = contents(inputFile); + if (encoding == Encoding::Auto) + { + encoding = Encoding::Hex; + for (char b: in) + if (b != '\n' && b != ' ' && b != '\t') + { + if (encoding == Encoding::Hex && (b < '0' || b > '9' ) && (b < 'a' || b > 'f' ) && (b < 'A' || b > 'F' )) + { + cerr << "'" << b << "':" << (int)b << endl; + encoding = Encoding::Base64; + } + if (encoding == Encoding::Base64 && (b < '0' || b > '9' ) && (b < 'a' || b > 'z' ) && (b < 'A' || b > 'Z' ) && b != '+' && b != '/') + { + encoding = Encoding::Binary; + break; + } + } + } + bytes b; + switch (encoding) + { + case Encoding::Hex: + { + string s = asString(in); + boost::algorithm::replace_all(s, " ", ""); + boost::algorithm::replace_all(s, "\n", ""); + boost::algorithm::replace_all(s, "\t", ""); + b = fromHex(s); + break; + } + case Encoding::Base64: + { + string s = asString(in); + boost::algorithm::replace_all(s, " ", ""); + boost::algorithm::replace_all(s, "\n", ""); + boost::algorithm::replace_all(s, "\t", ""); + b = base64_decode(s); + break; + } + default: + swap(b, in); + break; + } + + try + { + RLP rlp(b); + switch (mode) + { + case Mode::ListArchive: + { + if (!rlp.isList()) + { + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); + } + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; + } + case Mode::ExtractArchive: + { + if (!rlp.isList()) + { + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); + } + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; + } + } + catch (...) + { + cerr << "Error: Invalid format; bad RLP." << endl; + exit(1); + } + + return 0; +} From c2a9ba7dca25914ee9006d8e9280aff51872b75f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:36:20 +0100 Subject: [PATCH 061/313] Improvements to help text of RLP. --- rlp/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 9bd51cdfc..c3c04535b 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -35,6 +35,20 @@ void help() cout << "Usage rlp [OPTIONS] [ | -- ]" << endl << "Options:" << endl + << " -r,--render Render the given RLP. Options:" << endl + << " --indent Use string as the level indentation (default ' ')." << endl + << " --hex-ints Render integers in hex." << endl + << " --force-string Force all data to be rendered as C-style strings." << endl + << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl + << " --force-hex Force all data to be rendered as raw hex." << endl + << " -l,--list-archive List the items in the RLP list by hash and size." << endl + << " -e,--extract-archive Extract all items in the RLP list, named by hash." << endl + << "General options:" << endl + << " -L,--lenience Try not to bomb out early if possible." << endl + << " -x,--hex,--base-16 Treat input RLP as hex encoded data." << endl + << " --64,--base-64 Treat input RLP as base-64 encoded data." << endl + << " -b,--bin,--base-256 Treat input RLP as raw binary data." << endl + << " -h,--help Print this help message and exit." << endl << " -V,--version Show the version and exit." << endl ; exit(0); @@ -87,7 +101,7 @@ public: m_out << "null"; else if (_d.isInt()) if (m_prefs.hexInts) - m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire), 1), 1); else m_out << _d.toInt(RLP::LaisezFaire); else if (_d.isData()) From b51c2e9652ca8942a3f6ad056ae95c92079b38ce Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 5 Mar 2015 12:48:30 +0300 Subject: [PATCH 062/313] VMTest Fillers execution gas amount changed --- test/vmArithmeticTestFiller.json | 324 ++++++------- test/vmBitwiseLogicOperationTestFiller.json | 248 +++++----- test/vmBlockInfoTestFiller.json | 44 +- test/vmEnvironmentalInfoTestFiller.json | 92 ++-- test/vmIOandFlowOperationsTestFiller.json | 488 ++++++++++---------- test/vmLogTestFiller.json | 184 ++++---- test/vmPerformanceTestFiller.json | 16 +- test/vmPushDupSwapTestFiller.json | 282 +++++------ test/vmSha3TestFiller.json | 26 +- test/vmSystemOperationsTestFiller.json | 64 +-- test/vmtestsFiller.json | 16 +- 11 files changed, 892 insertions(+), 892 deletions(-) diff --git a/test/vmArithmeticTestFiller.json b/test/vmArithmeticTestFiller.json index 36d11875b..c657b0c3c 100644 --- a/test/vmArithmeticTestFiller.json +++ b/test/vmArithmeticTestFiller.json @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -221,7 +221,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -249,7 +249,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -277,7 +277,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -305,7 +305,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -333,7 +333,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -361,7 +361,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -389,7 +389,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -417,7 +417,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -445,7 +445,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -473,7 +473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -501,7 +501,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -529,7 +529,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -557,7 +557,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -585,7 +585,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -613,7 +613,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -641,7 +641,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -669,7 +669,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -697,7 +697,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -725,7 +725,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -753,7 +753,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -781,7 +781,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -809,7 +809,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -837,7 +837,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -865,7 +865,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -893,7 +893,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -921,7 +921,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -949,7 +949,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -977,7 +977,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1005,7 +1005,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1033,7 +1033,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1061,7 +1061,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1089,7 +1089,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1117,7 +1117,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1145,7 +1145,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1173,7 +1173,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1201,7 +1201,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1229,7 +1229,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1257,7 +1257,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1285,7 +1285,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1313,7 +1313,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1341,7 +1341,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1369,7 +1369,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1397,7 +1397,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1425,7 +1425,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1453,7 +1453,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1481,7 +1481,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1510,7 +1510,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1538,7 +1538,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1566,7 +1566,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1594,7 +1594,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1622,7 +1622,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1650,7 +1650,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1678,7 +1678,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1706,7 +1706,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1734,7 +1734,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1762,7 +1762,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1790,7 +1790,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1819,7 +1819,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1847,7 +1847,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1875,7 +1875,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1903,7 +1903,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1931,7 +1931,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1959,7 +1959,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1987,7 +1987,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2015,7 +2015,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2043,7 +2043,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2071,7 +2071,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2099,7 +2099,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2127,7 +2127,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2155,7 +2155,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2183,7 +2183,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2211,7 +2211,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2239,7 +2239,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2267,7 +2267,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2295,7 +2295,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2323,7 +2323,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2351,7 +2351,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2379,7 +2379,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2407,7 +2407,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2435,7 +2435,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2463,7 +2463,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2491,7 +2491,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2519,7 +2519,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2547,7 +2547,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2575,7 +2575,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2603,7 +2603,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2631,7 +2631,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2659,7 +2659,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2687,7 +2687,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2715,7 +2715,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2743,7 +2743,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2771,7 +2771,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2799,7 +2799,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2827,7 +2827,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2855,7 +2855,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2883,7 +2883,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2911,7 +2911,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2939,7 +2939,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2967,7 +2967,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2995,7 +2995,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3023,7 +3023,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3051,7 +3051,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3079,7 +3079,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3107,7 +3107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3135,7 +3135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3163,7 +3163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3191,7 +3191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3219,7 +3219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3247,7 +3247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3275,7 +3275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3303,7 +3303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3331,7 +3331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3359,7 +3359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3387,7 +3387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3415,7 +3415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3443,7 +3443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3471,7 +3471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3499,7 +3499,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3527,7 +3527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3555,7 +3555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3583,7 +3583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3611,7 +3611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3639,7 +3639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3667,7 +3667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3695,7 +3695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3723,7 +3723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3751,7 +3751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3779,7 +3779,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3807,7 +3807,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3835,7 +3835,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3863,7 +3863,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3891,7 +3891,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3919,7 +3919,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3947,7 +3947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3975,7 +3975,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4003,7 +4003,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4031,7 +4031,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4059,7 +4059,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4087,7 +4087,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4115,7 +4115,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4143,7 +4143,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4171,7 +4171,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4199,7 +4199,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4227,7 +4227,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4255,7 +4255,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4283,7 +4283,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4311,7 +4311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4339,7 +4339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4367,7 +4367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4395,7 +4395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4423,7 +4423,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4451,7 +4451,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4479,7 +4479,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4507,7 +4507,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4535,7 +4535,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmBitwiseLogicOperationTestFiller.json b/test/vmBitwiseLogicOperationTestFiller.json index 8954dca1e..1eb923f4f 100644 --- a/test/vmBitwiseLogicOperationTestFiller.json +++ b/test/vmBitwiseLogicOperationTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT (- 0 2) 0 )}", "storage": {} @@ -20,10 +20,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "value" : "10000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "10000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 0 (- 0 2) )}", "storage": {} @@ -48,10 +48,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "value" : "10000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "10000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -76,10 +76,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", - "data" : "", + "value" : "10000000000000000000", + "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -95,7 +95,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -108,7 +108,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -123,7 +123,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] ( GT (- 0 2) 0 )}", "storage": {} @@ -136,7 +136,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -151,7 +151,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 0 (- 0 2) )}", "storage": {} @@ -164,7 +164,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -208,7 +208,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -221,7 +221,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -236,7 +236,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT (- 0 2) 0 )}", "storage": {} @@ -249,7 +249,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -264,7 +264,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 0 (- 0 2) )}", "storage": {} @@ -277,7 +277,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -292,7 +292,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -305,7 +305,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -321,7 +321,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -334,7 +334,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -349,7 +349,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT (- 0 5) (- 0 3) )}", "storage": {} @@ -362,7 +362,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -377,7 +377,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT (- 0 2) 0 )}", "storage": {} @@ -390,7 +390,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -405,7 +405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 0 (- 0 2) )}", "storage": {} @@ -418,7 +418,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -433,7 +433,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -446,7 +446,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -462,7 +462,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -475,7 +475,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -490,7 +490,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT (- 0 5) (- 0 3) )}", "storage": {} @@ -503,7 +503,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -518,7 +518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (- 0 5) (- 0 3) )}", "storage": {} @@ -531,7 +531,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -546,7 +546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ 0 0)}", "storage": {} @@ -559,7 +559,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -574,7 +574,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ 115792089237316195423570985008687907853269984665640564039457584007913129639935 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -587,7 +587,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -602,7 +602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -615,7 +615,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -630,7 +630,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO 0 )}", "storage": {} @@ -643,7 +643,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "iszeo2": { @@ -657,7 +657,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO (- 0 2) )}", "storage": {} @@ -670,7 +670,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -685,7 +685,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 2 2) }", "storage": {} @@ -698,7 +698,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -713,7 +713,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 2 1) }", "storage": {} @@ -726,7 +726,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -741,7 +741,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 3 1) }", "storage": {} @@ -754,7 +754,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "and3": { @@ -768,7 +768,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -781,7 +781,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "and4": { @@ -795,7 +795,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -808,7 +808,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 2 2) } ", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -879,7 +879,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 2 1) } ", "storage": {} @@ -892,7 +892,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -907,7 +907,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 3 1) } ", "storage": {} @@ -920,7 +920,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "or3": { @@ -934,7 +934,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -947,7 +947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "or4": { @@ -961,7 +961,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -974,7 +974,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -989,7 +989,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1002,7 +1002,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1017,7 +1017,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 2 2) } ", "storage": {} @@ -1030,7 +1030,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1045,7 +1045,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 2 1) } ", "storage": {} @@ -1058,7 +1058,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1073,7 +1073,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 3 1) } ", "storage": {} @@ -1086,7 +1086,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "xor3": { @@ -1100,7 +1100,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -1113,7 +1113,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "xor4": { @@ -1127,7 +1127,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1140,7 +1140,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1155,7 +1155,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1168,7 +1168,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1183,7 +1183,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 0 )}", "storage": {} @@ -1196,7 +1196,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1211,7 +1211,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 2 )}", "storage": {} @@ -1224,7 +1224,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1239,7 +1239,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -1252,7 +1252,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1267,7 +1267,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 2) )}", "storage": {} @@ -1280,7 +1280,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1295,7 +1295,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 115792089237316195423570985008687907853269984665640564039457584007913129639935) )}", "storage": {} @@ -1308,7 +1308,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1323,7 +1323,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 0) )}", "storage": {} @@ -1336,7 +1336,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1351,7 +1351,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 0) 0x8040201008040201 ) } ", "storage": {} @@ -1364,7 +1364,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "byte1": { @@ -1378,7 +1378,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 1) 0x8040201008040201 ) } ", "storage": {} @@ -1391,7 +1391,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "byte2": { @@ -1405,7 +1405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 2) 0x8040201008040201 ) } ", "storage": {} @@ -1418,7 +1418,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1433,7 +1433,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 3) 0x8040201008040201 ) } ", "storage": {} @@ -1446,7 +1446,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1461,7 +1461,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 4) 0x8040201008040201 ) } ", "storage": {} @@ -1474,7 +1474,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1489,7 +1489,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 5) 0x8040201008040201 ) } ", "storage": {} @@ -1502,7 +1502,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1518,7 +1518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 6) 0x8040201008040201 ) } ", "storage": {} @@ -1531,7 +1531,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1546,7 +1546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 7) 0x8040201008040201 ) } ", "storage": {} @@ -1559,7 +1559,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1575,7 +1575,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 31) 0x8040201008040201 ) } ", "storage": {} @@ -1588,7 +1588,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1603,7 +1603,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (SDIV 31 32) 0x8040201008040201 ) } ", "storage": {} @@ -1616,7 +1616,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1631,7 +1631,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8040201008040201 ) } ", "storage": {} @@ -1644,7 +1644,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1659,7 +1659,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE 0 0x8040201008040201) } ", "storage": {} @@ -1672,7 +1672,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmBlockInfoTestFiller.json b/test/vmBlockInfoTestFiller.json index 04cbec51c..c86a9f2cb 100644 --- a/test/vmBlockInfoTestFiller.json +++ b/test/vmBlockInfoTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 2) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) }", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 0) }", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (COINBASE) }", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (TIMESTAMP) }", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NUMBER) }", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (DIFFICULTY) }", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GASLIMIT) }", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmEnvironmentalInfoTestFiller.json b/test/vmEnvironmentalInfoTestFiller.json index 3f99b3db7..210b14dc5 100644 --- a/test/vmEnvironmentalInfoTestFiller.json +++ b/test/vmEnvironmentalInfoTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADDRESS)}", "storage": {} @@ -38,7 +38,7 @@ }, "pre" : { "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADDRESS)}", "storage": {} @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681 )}", "storage": {} @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681aa )}", "storage": {} @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}", "storage": {} @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -207,7 +207,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6) (BALANCE (ADDRESS)))}", "storage": {} @@ -236,7 +236,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681) (BALANCE (CALLER)))}", "storage": {} @@ -264,7 +264,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ORIGIN)}", "storage": {} @@ -292,7 +292,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLER)}", "storage": {} @@ -321,7 +321,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLVALUE)}", "storage": {} @@ -350,7 +350,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 0)}", "storage": {} @@ -378,7 +378,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 1)}", "storage": {} @@ -406,7 +406,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 5)}", "storage": {} @@ -434,7 +434,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa)}", "storage": {} @@ -462,7 +462,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -490,7 +490,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -518,7 +518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -546,7 +546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 2 ) [[ 0 ]] @0}", "storage": {} @@ -574,7 +574,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0 0 ) [[ 0 ]] @0}", "storage": {} @@ -602,7 +602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 0xff ) [[ 0 ]] @0}", "storage": {} @@ -630,7 +630,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 9 ) [[ 0 ]] @0}", "storage": {} @@ -658,7 +658,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 1 ) [[ 0 ]] @0}", "storage": {} @@ -686,7 +686,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 0 ) [[ 0 ]] @0}", "storage": {} @@ -714,7 +714,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CODESIZE)}", "storage": {} @@ -742,7 +742,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}", "storage": {} @@ -770,7 +770,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }", "storage": {} @@ -798,7 +798,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }", "storage": {} @@ -826,7 +826,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 0 ) [[ 0 ]] @0 }", "storage": {} @@ -854,7 +854,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GASPRICE) }", "storage": {} @@ -882,7 +882,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}", "storage": {} @@ -910,7 +910,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -939,13 +939,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (EXTCODESIZE (CALLER)) (CODESIZE) ) }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (EXTCODESIZE (CALLER)) (CODESIZE) ) }", "storage": {} @@ -972,13 +972,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CODESIZE) }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE (CALLER) ) }", "storage": {} @@ -1006,7 +1006,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (ADDRESS) 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}", "storage": {} @@ -1034,13 +1034,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (CALLER) 0 0 0 ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1069,13 +1069,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (CALLER) 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1103,13 +1103,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY 0xaacd1722f3947def4cf144679da39c4c32bdc35681 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1137,13 +1137,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY 0xcd1722f3947def4cf144679da39c4c32bdc35681aa 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} diff --git a/test/vmIOandFlowOperationsTestFiller.json b/test/vmIOandFlowOperationsTestFiller.json index 6822b3fcc..0125c1b02 100644 --- a/test/vmIOandFlowOperationsTestFiller.json +++ b/test/vmIOandFlowOperationsTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600360045055", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5060026003600455", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600260035155", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600260035255", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 23) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{[[ 0 ]] (MLOAD 0) } ", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 1 23) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 1 ]] (MLOAD 7489573) } ", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 (+ 2 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23 ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -318,7 +318,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23 ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -331,7 +331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -346,7 +346,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -359,7 +359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -374,7 +374,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xff) (MSTORE8 2 0xee) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -387,7 +387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -402,7 +402,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 10 0xee) [[ 20 ]] (SLOAD 0) } ", "storage": {} @@ -415,7 +415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -430,7 +430,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 10 0xee) [[ 20 ]] (SLOAD 100) } ", "storage": {} @@ -443,7 +443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -458,7 +458,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 1 0xee) (SSTORE 2 0xdd) [[ 10 ]] (SLOAD 1) [[ 20 ]] (SLOAD 2) } ", "storage": {} @@ -471,7 +471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -486,7 +486,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6009565b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b", "storage": {} @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6006560060015b6002600355", "storage": {} @@ -527,7 +527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -542,7 +542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016008570060015b6002600355", "storage": {} @@ -555,7 +555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -570,7 +570,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60055661eeff", "storage": {} @@ -583,7 +583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -598,7 +598,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600456655b6001600155", "storage": {} @@ -611,7 +611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -626,7 +626,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160075761eeff", "storage": {} @@ -639,7 +639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -654,7 +654,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600657655b6001600155", "storage": {} @@ -667,7 +667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -682,7 +682,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600056", "storage": {} @@ -695,7 +695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -710,7 +710,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x565b600056", "storage": {} @@ -723,7 +723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -738,7 +738,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600401565b600360005260206000f3600656", "storage": {} @@ -751,7 +751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -766,7 +766,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007566001600255", "storage": {} @@ -779,7 +779,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "jump0_jumpdest0": { @@ -793,7 +793,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360075660015b600255", "storage": {} @@ -806,7 +806,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -821,7 +821,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007566001600255", "storage": {} @@ -834,7 +834,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -849,7 +849,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360085660015b600255", "storage": {} @@ -862,7 +862,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -877,7 +877,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a6008505660015b600255", "storage": {} @@ -890,7 +890,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -905,7 +905,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b6008505660015b600255", "storage": {} @@ -918,7 +918,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -933,7 +933,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff0156", "storage": {} @@ -946,7 +946,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -961,7 +961,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360016009576001600255", "storage": {} @@ -974,7 +974,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -989,7 +989,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a5760015b600255", "storage": {} @@ -1002,7 +1002,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1017,7 +1017,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360006009576001600255", "storage": {} @@ -1030,7 +1030,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1045,7 +1045,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff576002600355", "storage": {} @@ -1058,7 +1058,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1073,7 +1073,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600101560060015b6002600355", "storage": {} @@ -1086,7 +1086,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1101,7 +1101,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016008600301570060015b6002600355", "storage": {} @@ -1114,7 +1114,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1129,7 +1129,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60056003015661eeff", "storage": {} @@ -1142,7 +1142,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1157,7 +1157,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460030156655b6001600155", "storage": {} @@ -1170,7 +1170,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1185,7 +1185,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160076003015761eeff", "storage": {} @@ -1198,7 +1198,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1213,7 +1213,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600660030157655b6001600155", "storage": {} @@ -1226,7 +1226,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1241,7 +1241,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b586000555960115758600052596000575b58600055", "storage": {} @@ -1254,7 +1254,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1269,7 +1269,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage": {} @@ -1282,7 +1282,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1297,7 +1297,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600301566001600255", "storage": {} @@ -1310,7 +1310,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "DynamicJump0_jumpdest0": { @@ -1324,7 +1324,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360076003015660015b600255", "storage": {} @@ -1337,7 +1337,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1352,7 +1352,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600301566001600255", "storage": {} @@ -1365,7 +1365,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1380,7 +1380,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360086003015660015b600255", "storage": {} @@ -1393,7 +1393,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1408,7 +1408,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a6008506003015660015b600255", "storage": {} @@ -1421,7 +1421,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1436,7 +1436,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b6008506003015660015b600255", "storage": {} @@ -1449,7 +1449,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1464,7 +1464,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff0160030156", "storage": {} @@ -1477,7 +1477,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1492,7 +1492,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360016009600301576001600255", "storage": {} @@ -1505,7 +1505,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1520,7 +1520,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a6003015760015b600255", "storage": {} @@ -1533,7 +1533,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1548,7 +1548,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360006009600301576001600255", "storage": {} @@ -1561,7 +1561,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1576,7 +1576,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0600301576002600355", "storage": {} @@ -1589,7 +1589,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1604,7 +1604,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160084301570060015b6002600355", "storage": {} @@ -1617,7 +1617,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1632,7 +1632,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600543015661eeff", "storage": {} @@ -1645,7 +1645,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1660,7 +1660,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6004430156655b6001600155", "storage": {} @@ -1673,7 +1673,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1688,7 +1688,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600743015761eeff", "storage": {} @@ -1701,7 +1701,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1716,7 +1716,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016006430157655b6001600155", "storage": {} @@ -1729,7 +1729,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1744,7 +1744,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage": {} @@ -1757,7 +1757,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1772,7 +1772,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360074301566001600255", "storage": {} @@ -1785,7 +1785,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "BlockNumberDynamicJump0_jumpdest0": { @@ -1799,7 +1799,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600743015660015b600255", "storage": {} @@ -1812,7 +1812,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1827,7 +1827,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360074301566001600255", "storage": {} @@ -1840,7 +1840,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1855,7 +1855,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600843015660015b600255", "storage": {} @@ -1868,7 +1868,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1883,7 +1883,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a60085043015660015b600255", "storage": {} @@ -1896,7 +1896,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1911,7 +1911,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b60085043015660015b600255", "storage": {} @@ -1924,7 +1924,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1939,7 +1939,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff01430156", "storage": {} @@ -1952,7 +1952,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1967,7 +1967,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600160094301576001600255", "storage": {} @@ -1980,7 +1980,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1995,7 +1995,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a43015760015b600255", "storage": {} @@ -2008,7 +2008,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2023,7 +2023,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600060094301576001600255", "storage": {} @@ -2036,7 +2036,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2051,7 +2051,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04301576002600355", "storage": {} @@ -2064,7 +2064,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2080,7 +2080,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PUSH1 3 JUMP", "code" : "0x6009436006575b566001", @@ -2094,7 +2094,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2109,7 +2109,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a436006575b5660015b6001600155", "storage": {} @@ -2122,7 +2122,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2137,7 +2137,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435660615b4343025660615b60615b5b5b6001600155", "storage": {} @@ -2150,7 +2150,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2165,7 +2165,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435660615b4343025660615b60615b605b6001600155", "storage": {} @@ -2178,7 +2178,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2193,7 +2193,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2206,7 +2206,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2221,7 +2221,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2234,7 +2234,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2249,7 +2249,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2262,7 +2262,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2277,7 +2277,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600860005401570060015b6002600355", "storage" : { @@ -2292,7 +2292,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2307,7 +2307,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600054015661eeff", "storage" : { @@ -2322,7 +2322,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2337,7 +2337,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60046000540156655b6001600155", "storage" : { @@ -2352,7 +2352,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2367,7 +2367,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016007600054015761eeff", "storage" : { @@ -2382,7 +2382,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2397,7 +2397,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160066000540157655b6001600155", "storage" : { @@ -2412,7 +2412,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2427,7 +2427,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage" : { @@ -2442,7 +2442,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2457,7 +2457,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600760005401566001600255", "storage" : { @@ -2473,7 +2473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "JDfromStorageDynamicJump0_jumpdest0": { @@ -2487,7 +2487,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600054015660015b600255", "storage" : { @@ -2502,7 +2502,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2517,7 +2517,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600760005401566001600255", "storage" : { @@ -2533,7 +2533,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2548,7 +2548,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236008600054015660015b600255", "storage" : { @@ -2563,7 +2563,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2578,7 +2578,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a600850600054015660015b600255", "storage" : { @@ -2594,7 +2594,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2609,7 +2609,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b600850600054015660015b600255", "storage" : { @@ -2624,7 +2624,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2639,7 +2639,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff016000540156", "storage" : { @@ -2655,7 +2655,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2670,7 +2670,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600960005401576001600255", "storage" : { @@ -2685,7 +2685,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2700,7 +2700,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a600054015760015b600255", "storage" : { @@ -2716,7 +2716,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2731,7 +2731,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236000600960005401576001600255", "storage" : { @@ -2746,7 +2746,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2761,7 +2761,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff060005401576002600355", "storage" : { @@ -2776,7 +2776,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2792,7 +2792,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (PC)}", "storage": {} @@ -2805,7 +2805,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2820,7 +2820,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(SSTORE 0 0xff) [[ 0 ]] (PC)}", "storage": {} @@ -2833,7 +2833,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2848,7 +2848,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xff) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2861,7 +2861,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2876,7 +2876,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2889,7 +2889,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2904,7 +2904,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 32 0xeeee) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2917,7 +2917,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2932,7 +2932,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 90 0xeeee) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2945,7 +2945,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2960,7 +2960,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 90 0xeeee) [[ 0 ]] (GAS)}", "storage": {} @@ -2973,7 +2973,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2988,7 +2988,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{[[ 0 ]] (GAS)}", "storage": {} @@ -3001,7 +3001,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3016,7 +3016,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0x112233445566778899001122334455667788990011223344556677889900aabb 0 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 1 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 2 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 3 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 4 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 5 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 6 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 7 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 8 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 9 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 10 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 11 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 12 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 13 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 14 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 15 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 16 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 17 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 18 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 19 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 20 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 21 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 22 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 23 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 24 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 25 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 26 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 27 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 28 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 29 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 30 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 31 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 32 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 2014 BYTE 0 0 SSTORE)", "storage": {} @@ -3029,7 +3029,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3044,7 +3044,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 2 0 MSTORE8 3 1 MSTORE8 0 MLOAD 1 MLOAD ADD 2 MSTORE 64 0 RETURN)", "storage": {} @@ -3057,7 +3057,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3072,7 +3072,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 1000000 RETURN)", "storage": {} @@ -3085,7 +3085,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3100,7 +3100,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [i] 1 ( if (> @i 0) { (return 39) [i] 2 } (return 1) ) }", "storage": {} @@ -3113,7 +3113,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3128,7 +3128,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0x4 0x6 0x9 0x14 JUMP JUMPDEST 0xa SUB 0x0 MSTORE MSIZE 0x0 RETURN JUMPDEST 0x0 MSTORE ADD 0x9 JUMP)", "storage": {} @@ -3141,7 +3141,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3156,7 +3156,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[69]] (caller) (return 0 (lll (when (= (caller) @@69) (for {} (< @i (calldatasize)) [i](+ @i 64) [[ (calldataload @i) ]] (calldataload (+ @i 32)) ) ) 0))}", "storage": {} @@ -3169,7 +3169,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3194,7 +3194,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "code" : "(asm 10 0 MSTORE JUMPDEST 0 MLOAD 1 SWAP1 SUB DUP1 0 MSTORE 5 JUMPI)", "nonce" : "0", "storage" : {} @@ -3213,7 +3213,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 27 37 MUL JUMP JUMPDEST)", "storage": {} @@ -3226,7 +3226,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3241,7 +3241,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 3 3 MUL JUMPI 0 0 JUMP)", "storage": {} @@ -3254,7 +3254,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3269,7 +3269,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(for [i]:10 (> @i 0) [i](- @i 1) [j](+ @i @j))", "storage": {} @@ -3282,7 +3282,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3297,7 +3297,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(for [i]:0 (< @i 10) [i](+ @i 1) [j](+ @i @j))", "storage": {} @@ -3310,7 +3310,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3325,7 +3325,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 4 3 ADD JUMP STOP JUMPDEST 1 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3338,7 +3338,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3353,7 +3353,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 8 6 ADD JUMP STOP JUMPDEST 1 0 MSTORE STOP JUMPDEST 2 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3366,7 +3366,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3381,7 +3381,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 4 5 ADD JUMPI STOP JUMPDEST 1 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3394,7 +3394,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3409,7 +3409,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0 7 5 ADD JUMPI 1 0 MSTORE STOP JUMPDEST)", "storage": {} @@ -3422,7 +3422,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3437,7 +3437,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 10 JUMPDEST 1 DUP2 SUB DUP1 2 JUMPI 0 MSTORE8 1 MSTORE8 2 MSTORE8 3 MSTORE8 4 MSTORE8 5 MSTORE8 6 MSTORE8 7 MSTORE8 8 MSTORE8 9 MSTORE8 MSIZE 0 RETURN)", "storage": {} @@ -3450,7 +3450,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3465,7 +3465,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(when (> 1 0) [i] 13)", "storage": {} @@ -3478,7 +3478,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmLogTestFiller.json b/test/vmLogTestFiller.json index 5b63957c5..fea69a4a9 100644 --- a/test/vmLogTestFiller.json +++ b/test/vmLogTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG0 0 0) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) (LOG0 2 16) }", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 0 1) }", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -123,7 +123,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 31 1) }", "storage": {} @@ -136,7 +136,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -151,7 +151,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1) }", "storage": {} @@ -164,7 +164,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -207,7 +207,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 1 0) }", "storage": {} @@ -220,7 +220,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -235,7 +235,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG1 0 0 0) }", "storage": {} @@ -248,7 +248,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -263,7 +263,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG1 0 32 0) }", "storage": {} @@ -276,7 +276,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -291,7 +291,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0 1 0) }", "storage": {} @@ -304,7 +304,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -320,7 +320,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 31 1 0) }", "storage": {} @@ -333,7 +333,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -348,7 +348,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0) }", "storage": {} @@ -361,7 +361,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -376,7 +376,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0) }", "storage": {} @@ -389,7 +389,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -404,7 +404,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 1 0 0) }", "storage": {} @@ -417,7 +417,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -432,7 +432,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -445,7 +445,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -460,7 +460,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG1 0 32 (CALLER)) }", "storage": {} @@ -473,7 +473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -488,7 +488,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG2 0 0 0 0) }", "storage": {} @@ -501,7 +501,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -516,7 +516,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG2 0 32 0 0) }", "storage": {} @@ -529,7 +529,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -544,7 +544,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0 1 0 0) }", "storage": {} @@ -557,7 +557,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -573,7 +573,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 31 1 0 0) }", "storage": {} @@ -586,7 +586,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -601,7 +601,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0) }", "storage": {} @@ -614,7 +614,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -629,7 +629,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0) }", "storage": {} @@ -642,7 +642,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -657,7 +657,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 1 0 0 0) }", "storage": {} @@ -670,7 +670,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -685,7 +685,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -698,7 +698,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -713,7 +713,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG2 0 32 0 (CALLER) ) }", "storage": {} @@ -726,7 +726,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -741,7 +741,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG3 0 0 0 0 0) }", "storage": {} @@ -754,7 +754,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -769,7 +769,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG3 0 32 0 0 0) }", "storage": {} @@ -782,7 +782,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -797,7 +797,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0 1 0 0 0) }", "storage": {} @@ -810,7 +810,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -826,7 +826,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 31 1 0 0 0) }", "storage": {} @@ -839,7 +839,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -854,7 +854,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0 0) }", "storage": {} @@ -867,7 +867,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -882,7 +882,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0 0) }", "storage": {} @@ -895,7 +895,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -910,7 +910,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 1 0 0 0 0) }", "storage": {} @@ -923,7 +923,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -951,7 +951,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -966,7 +966,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 0 0 (CALLER) ) }", "storage": {} @@ -979,7 +979,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -994,7 +994,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 (PC) (PC) (PC) ) }", "storage": {} @@ -1007,7 +1007,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1022,7 +1022,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG4 0 0 0 0 0 0) }", "storage": {} @@ -1035,7 +1035,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1050,7 +1050,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG4 0 32 0 0 0 0) }", "storage": {} @@ -1063,7 +1063,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1078,7 +1078,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0 1 0 0 0 0) }", "storage": {} @@ -1091,7 +1091,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1107,7 +1107,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 31 1 0 0 0 0) }", "storage": {} @@ -1120,7 +1120,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1135,7 +1135,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0 0 0) }", "storage": {} @@ -1148,7 +1148,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1163,7 +1163,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0 0 0) }", "storage": {} @@ -1176,7 +1176,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1191,7 +1191,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 1 0 0 0 0 0) }", "storage": {} @@ -1204,7 +1204,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1219,7 +1219,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -1232,7 +1232,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1247,7 +1247,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 0 0 0 (CALLER) ) }", "storage": {} @@ -1260,7 +1260,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1275,7 +1275,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 (PC) (PC) (PC) (PC) ) }", "storage": {} @@ -1288,7 +1288,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmPerformanceTestFiller.json b/test/vmPerformanceTestFiller.json index e33bd1955..e9cb4806d 100644 --- a/test/vmPerformanceTestFiller.json +++ b/test/vmPerformanceTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "ManyFunctions.sol", "code" : "0x60e060020a60003504806301f99ad7146108c3578063023a624a146108d857806303bdecf5146108ed57806305fe035f14610902578063082d8f4914610917578063090bf3b71461092c5780630bd9c534146109415780630c4bfa94146109565780630e20ebe21461096b5780630f76de0d1461098057806310cfcc191461099557806313ce15a9146109aa578063140dcec4146109bf57806314d07a3e146109d45780631687f112146109e957806316eb6603146109fe578063172cf71714610a135780631bd6f59614610a285780631cdb857114610a3d5780631cf74ece14610a525780631d09ba2c14610a675780631f69aa5114610a7c578063223dcc7414610a9157806325e524d314610aa6578063261de7c414610abb5780632632924d14610ad05780632909cc5d14610ae55780632981699814610afa5780632a85a45d14610b0f5780632ca36da014610b245780632cbf1f0d14610b395780632d0f557314610b4e5780632d97867814610b6357806331db9efd14610b7857806332064db714610b8d57806332931fbb14610ba2578063355f51a014610bb7578063361bb34014610bcc578063364ddb0e14610be15780633792a01814610bf657806338c68f8f14610c0b57806338e586fd14610c20578063392d42ae14610c3557806339a87bd914610c4a5780633a95a33214610c5f5780633b8ecdf914610c745780633cf0659a14610c895780633eaf992314610c9e5780633fe97ead14610cb35780633ff11c8b14610cc8578063404efc5314610cdd578063407fce7b14610cf257806340c3b18714610d07578063440208c314610d1c57806344e86b2f14610d31578063455df57914610d465780634689ab4d14610d5b57806346be2e0c14610d70578063487cd86f14610d8557806348e6178214610d9a57806349d4a34414610daf5780634a0f597414610dc45780634bc24ec514610dd95780634c2fe45614610dee5780634cc885d414610e035780634eaaad7b14610e185780634eb166af14610e2d5780635050093414610e42578063506bff1114610e57578063508762c114610e6c578063526938f814610e8157806354400c6014610e96578063559510d814610eab57806355a5f70214610ec057806356ca528f14610ed5578063570a2a1614610eea5780635dab2e0f14610eff5780635dca53d314610f1457806362017ebc14610f29578063621a25f814610f3e578063626d4a3614610f5357806362b6a28214610f6857806364faf22c14610f7d57806366d7ffde14610f9257806367b886e814610fa757806367e902c714610fbc57806369d7774014610fd15780636b7ae8e614610fe65780636c3b659114610ffb5780636e54181e146110105780636e978d91146110255780636f63d2ec1461103a578063706332d11461104f57806370ac4bb9146110645780637138ef521461107957806371dd46a91461108e57806372a7c229146110a35780637376fc8d146110b8578063738a2679146110cd57806374552650146110e2578063746fc8d0146110f757806379254bb81461110c5780637adaa3f8146111215780637e4eb35b14611136578063885ec18e1461114b5780638b9ff6b6146111605780638ce113dc146111755780638defbc5e1461118a5780638f4613d51461119f5780638fdc24ba146111b45780639002dba4146111c957806391d15735146111de57806391d43b23146111f357806393b14daa1461120857806394d63afd1461121d57806395805dad1461123257806396f68782146112475780639740e4a21461125c578063981290131461127157806399a3f0e8146112865780639acb1ad41461129b5780639be07908146112b05780639c15be0b146112c55780639d451c4d146112da5780639d8ee943146112ef5780639ef6ca0f14611304578063a0db0a2214611319578063a18e2eb91461132e578063a408384914611343578063a57544da14611358578063a5a83e4d1461136d578063a6843f3414611382578063a6dacdd714611397578063a8c4c8bc146113ac578063aa058a73146113c1578063aad62da2146113d6578063aaf3e4f4146113eb578063ab81e77314611400578063abc93aee14611415578063abde33f71461142a578063b114b96c1461143f578063b3df873714611454578063b4174cb014611469578063b5d02a561461147e578063b731e84814611493578063b7b96723146114a8578063bbcded7a146114bd578063bbececa9146114d2578063beca7440146114e7578063bf8981c0146114fc578063c028c67414611511578063c2385fa614611526578063c319a02c1461153b578063c569bae014611550578063c6715f8114611565578063c7b98dec1461157a578063c9acab841461158f578063ca9efc73146115a4578063cad80024146115b9578063cdadb0fa146115ce578063cdbdf391146115e3578063cf460fa5146115f8578063cf69318a1461160d578063d1835b8c14611622578063d353a1cb14611637578063d3e141e01461164c578063d5ec7e1d14611661578063d7ead1de14611676578063d90b02aa1461168b578063d959e244146116a0578063d9e68b44146116b5578063daacb24f146116ca578063dc12a805146116df578063dd946033146116f4578063dda5142414611709578063de6612171461171e578063dfb9560c14611733578063e03827d214611748578063e21720001461175d578063e2c718d814611772578063e3da539914611787578063e48e603f1461179c578063e5f9ec29146117b1578063e6c0459a146117c6578063e70addec146117db578063e7a01215146117f0578063ea7f4d2714611805578063ebb6c59f1461181a578063ed6302be1461182f578063ed64b36b14611844578063eecd278914611859578063f0ed14e01461186e578063f0f2134414611883578063f1e328f914611898578063f1e6f4cd146118ad578063f32fe995146118c2578063f75165c6146118d7578063f7ed71d0146118ec578063f80f44f314611901578063f8bc050514611916578063fbd3c51a1461192b578063fd72009014611940578063fed3a3001461195557005b6108ce600435612edf565b8060005260206000f35b6108e3600435612fb5565b8060005260206000f35b6108f8600435613f47565b8060005260206000f35b61090d600435612a11565b8060005260206000f35b6109226004356127ec565b8060005260206000f35b61093760043561215c565b8060005260206000f35b61094c6004356128c2565b8060005260206000f35b61096160043561310f565b8060005260206000f35b610976600435614e0b565b8060005260206000f35b61098b600435613269565b8060005260206000f35b6109a0600435611a82565b8060005260206000f35b6109b5600435613e71565b8060005260206000f35b6109ca600435611dd2565b8060005260206000f35b6109df6004356120d0565b8060005260206000f35b6109f4600435613755565b8060005260206000f35b610a096004356134e3565b8060005260206000f35b610a1e6004356137e1565b8060005260206000f35b610a3360043561382b565b8060005260206000f35b610a48600435612b0b565b8060005260206000f35b610a5d60043561386d565b8060005260206000f35b610a726004356131e5565b8060005260206000f35b610a876004356143e9565b8060005260206000f35b610a9c60043561319b565b8060005260206000f35b610ab1600435612e11565b8060005260206000f35b610ac660043561234a565b8060005260206000f35b610adb6004356121e8565b8060005260206000f35b610af06004356119f6565b8060005260206000f35b610b05600435613bff565b8060005260206000f35b610b1a600435612606565b8060005260206000f35b610b2f6004356126d4565b8060005260206000f35b610b44600435613bb5565b8060005260206000f35b610b59600435612462565b8060005260206000f35b610b6e600435611e14565b8060005260206000f35b610b836004356149ab565b8060005260206000f35b610b98600435611c26565b8060005260206000f35b610bad600435612a7f565b8060005260206000f35b610bc2600435613457565b8060005260206000f35b610bd760043561340d565b8060005260206000f35b610bec60043561363d565b8060005260206000f35b610c01600435612e53565b8060005260206000f35b610c1660043561477b565b8060005260206000f35b610c2b600435612c6d565b8060005260206000f35b610c40600435612648565b8060005260206000f35b610c55600435612274565b8060005260206000f35b610c6a6004356138f9565b8060005260206000f35b610c7f600435612b55565b8060005260206000f35b610c94600435611eea565b8060005260206000f35b610ca9600435613ebb565b8060005260206000f35b610cbe600435613499565b8060005260206000f35b610cd3600435614807565b8060005260206000f35b610ce8600435611fb8565b8060005260206000f35b610cfd600435613083565b8060005260206000f35b610d126004356125bc565b8060005260206000f35b610d27600435613041565b8060005260206000f35b610d3c6004356140a1565b8060005260206000f35b610d516004356147bd565b8060005260206000f35b610d66600435611c70565b8060005260206000f35b610d7b600435612300565b8060005260206000f35b610d906004356123d6565b8060005260206000f35b610da5600435612c23565b8060005260206000f35b610dba600435614faf565b8060005260206000f35b610dcf600435612044565b8060005260206000f35b610de4600435613ae7565b8060005260206000f35b610df9600435614cf3565b8060005260206000f35b610e0e600435613d17565b8060005260206000f35b610e2360043561412d565b8060005260206000f35b610e38600435614177565b8060005260206000f35b610e4d60043561208e565b8060005260206000f35b610e62600435612dc7565b8060005260206000f35b610e77600435612f29565b8060005260206000f35b610e8c6004356124a4565b8060005260206000f35b610ea1600435611b58565b8060005260206000f35b610eb66004356136c9565b8060005260206000f35b610ecb600435613227565b8060005260206000f35b610ee0600435611acc565b8060005260206000f35b610ef5600435613687565b8060005260206000f35b610f0a6004356146a5565b8060005260206000f35b610f1f6004356121a6565b8060005260206000f35b610f346004356132f5565b8060005260206000f35b610f49600435613da3565b8060005260206000f35b610f5e60043561379f565b8060005260206000f35b610f73600435612878565b8060005260206000f35b610f88600435611b0e565b8060005260206000f35b610f9d600435611ea0565b8060005260206000f35b610fb2600435614ed9565b8060005260206000f35b610fc7600435614bdb565b8060005260206000f35b610fdc600435614c1d565b8060005260206000f35b610ff1600435614245565b8060005260206000f35b6110066004356146ef565b8060005260206000f35b61101b60043561428f565b8060005260206000f35b611030600435614ac3565b8060005260206000f35b611045600435613de5565b8060005260206000f35b61105a6004356132b3565b8060005260206000f35b61106f6004356122be565b8060005260206000f35b611084600435612e9d565b8060005260206000f35b611099600435611b9a565b8060005260206000f35b6110ae6004356127aa565b8060005260206000f35b6110c3600435613e2f565b8060005260206000f35b6110d8600435614849565b8060005260206000f35b6110ed600435614dc1565b8060005260206000f35b61110260043561333f565b8060005260206000f35b61111760043561211a565b8060005260206000f35b61112c600435612692565b8060005260206000f35b611141600435612904565b8060005260206000f35b611156600435612d3b565b8060005260206000f35b61116b600435614b91565b8060005260206000f35b611180600435613a5b565b8060005260206000f35b611195600435612232565b8060005260206000f35b6111aa600435612f6b565b8060005260206000f35b6111bf600435614d35565b8060005260206000f35b6111d4600435611a40565b8060005260206000f35b6111e9600435612ff7565b8060005260206000f35b6111fe60043561431b565b8060005260206000f35b611213600435613159565b8060005260206000f35b611228600435612b97565b8060005260206000f35b61123d600435612990565b8060005260206000f35b611252600435613b73565b8060005260206000f35b611267600435614961565b8060005260206000f35b61127c600435613381565b8060005260206000f35b611291600435613fd3565b8060005260206000f35b6112a660043561257a565b8060005260206000f35b6112bb600435614501565b8060005260206000f35b6112d0600435613d59565b8060005260206000f35b6112e56004356143a7565b8060005260206000f35b6112fa60043561405f565b8060005260206000f35b61130f60043561238c565b8060005260206000f35b611324600435612be1565b8060005260206000f35b611339600435613f89565b8060005260206000f35b61134e60043561294e565b8060005260206000f35b6113636004356124ee565b8060005260206000f35b611378600435614b4f565b8060005260206000f35b61138d6004356133cb565b8060005260206000f35b6113a26004356139cf565b8060005260206000f35b6113b7600435613c8b565b8060005260206000f35b6113cc600435612cf9565b8060005260206000f35b6113e1600435614a79565b8060005260206000f35b6113f66004356149ed565b8060005260206000f35b61140b600435613b29565b8060005260206000f35b611420600435613ccd565b8060005260206000f35b611435600435611f76565b8060005260206000f35b61144a600435614ff1565b8060005260206000f35b61145f600435613525565b8060005260206000f35b61147460043561356f565b8060005260206000f35b6114896004356129dc565b8060005260206000f35b61149e600435614ca9565b8060005260206000f35b6114b3600435612d85565b8060005260206000f35b6114c86004356141b9565b8060005260206000f35b6114dd600435614475565b8060005260206000f35b6114f26004356135fb565b8060005260206000f35b611507600435612530565b8060005260206000f35b61151c600435614663565b8060005260206000f35b611531600435614433565b8060005260206000f35b611546600435614f23565b8060005260206000f35b61155b600435614c67565b8060005260206000f35b611570600435611d3e565b8060005260206000f35b611585600435612a3d565b8060005260206000f35b61159a600435613a11565b8060005260206000f35b6115af600435614619565b8060005260206000f35b6115c4600435613985565b8060005260206000f35b6115d9600435613943565b8060005260206000f35b6115ee600435612418565b8060005260206000f35b6116036004356119b4565b8060005260206000f35b611618600435613a9d565b8060005260206000f35b61162d600435611cb2565b8060005260206000f35b6116426004356129d2565b8060005260206000f35b611657600435612caf565b8060005260206000f35b61166c600435611d88565b8060005260206000f35b611681600435614203565b8060005260206000f35b61169660043561458d565b8060005260206000f35b6116ab600435611f2c565b8060005260206000f35b6116c0600435612a23565b8060005260206000f35b6116d5600435612836565b8060005260206000f35b6116ea6004356138b7565b8060005260206000f35b6116ff6004356145d7565b8060005260206000f35b61171460043561454b565b8060005260206000f35b6117296004356142d1565b8060005260206000f35b61173e600435611e5e565b8060005260206000f35b611753600435614015565b8060005260206000f35b611768600435613c41565b8060005260206000f35b61177d600435611be4565b8060005260206000f35b611792600435614b05565b8060005260206000f35b6117a7600435613713565b8060005260206000f35b6117bc6004356135b1565b8060005260206000f35b6117d16004356144bf565b8060005260206000f35b6117e660043561491f565b8060005260206000f35b6117fb600435612ac9565b8060005260206000f35b6118106004356130cd565b8060005260206000f35b6118256004356140eb565b8060005260206000f35b61183a600435614f65565b8060005260206000f35b61184f60043561196a565b8060005260206000f35b6118646004356148d5565b8060005260206000f35b611879600435614d7f565b8060005260206000f35b61188e600435612002565b8060005260206000f35b6118a3600435613efd565b8060005260206000f35b6118b860043561271e565b8060005260206000f35b6118cd600435614e4d565b8060005260206000f35b6118e2600435611cfc565b8060005260206000f35b6118f7600435612760565b8060005260206000f35b61190c600435614e97565b8060005260206000f35b61192160043561435d565b8060005260206000f35b611936600435614731565b8060005260206000f35b61194b600435614893565b8060005260206000f35b611960600435614a37565b8060005260206000f35b6000600061197f61197a846129dc565b6129dc565b9050605d60020a811015611992576119a2565b61199b816119f6565b91506119ae565b6119ab816119b4565b91505b50919050565b600060006119c1836129dc565b9050605e60020a8110156119d4576119e4565b6119dd81611a40565b91506119f0565b6119ed81611a82565b91505b50919050565b60006000611a0b611a06846129dc565b6129dc565b9050605e60020a811015611a1e57611a2e565b611a2781611a82565b9150611a3a565b611a3781611a40565b91505b50919050565b60006000611a4d836129dc565b9050605f60020a811015611a6057611a70565b611a6981611acc565b9150611a7c565b611a7981611b0e565b91505b50919050565b60006000611a97611a92846129dc565b6129dc565b9050605f60020a811015611aaa57611aba565b611ab381611b0e565b9150611ac6565b611ac381611acc565b91505b50919050565b60006000611ad9836129dc565b9050606060020a811015611aec57611afc565b611af581611b58565b9150611b08565b611b0581611b9a565b91505b50919050565b60006000611b23611b1e846129dc565b6129dc565b9050606060020a811015611b3657611b46565b611b3f81611b9a565b9150611b52565b611b4f81611b58565b91505b50919050565b60006000611b65836129dc565b9050606160020a811015611b7857611b88565b611b8181611be4565b9150611b94565b611b9181611c26565b91505b50919050565b60006000611baf611baa846129dc565b6129dc565b9050606160020a811015611bc257611bd2565b611bcb81611c26565b9150611bde565b611bdb81611be4565b91505b50919050565b60006000611bf1836129dc565b9050606260020a811015611c0457611c14565b611c0d81611c70565b9150611c20565b611c1d81611cb2565b91505b50919050565b60006000611c3b611c36846129dc565b6129dc565b9050606260020a811015611c4e57611c5e565b611c5781611cb2565b9150611c6a565b611c6781611c70565b91505b50919050565b60006000611c7d836129dc565b9050606360020a811015611c9057611ca0565b611c9981611cfc565b9150611cac565b611ca981611d88565b91505b50919050565b60006000611cc7611cc2846129dc565b6129dc565b9050606360020a811015611cda57611cea565b611ce381611d88565b9150611cf6565b611cf381611cfc565b91505b50919050565b60006000611d09836129dc565b9050606460020a811015611d1c57611d2c565b611d2581611dd2565b9150611d38565b611d3581611e14565b91505b50919050565b60006000611d53611d4e846129dc565b6129dc565b9050607a60020a811015611d6657611d76565b611d6f81613269565b9150611d82565b611d7f81613227565b91505b50919050565b60006000611d9d611d98846129dc565b6129dc565b9050606460020a811015611db057611dc0565b611db981611e14565b9150611dcc565b611dc981611dd2565b91505b50919050565b60006000611ddf836129dc565b9050606560020a811015611df257611e02565b611dfb81611e5e565b9150611e0e565b611e0b81611ea0565b91505b50919050565b60006000611e29611e24846129dc565b6129dc565b9050606560020a811015611e3c57611e4c565b611e4581611ea0565b9150611e58565b611e5581611e5e565b91505b50919050565b60006000611e6b836129dc565b9050606660020a811015611e7e57611e8e565b611e8781611eea565b9150611e9a565b611e9781611f2c565b91505b50919050565b60006000611eb5611eb0846129dc565b6129dc565b9050606660020a811015611ec857611ed8565b611ed181611f2c565b9150611ee4565b611ee181611eea565b91505b50919050565b60006000611ef7836129dc565b9050606760020a811015611f0a57611f1a565b611f1381611f76565b9150611f26565b611f2381611fb8565b91505b50919050565b60006000611f41611f3c846129dc565b6129dc565b9050606760020a811015611f5457611f64565b611f5d81611fb8565b9150611f70565b611f6d81611f76565b91505b50919050565b60006000611f83836129dc565b9050606860020a811015611f9657611fa6565b611f9f81612002565b9150611fb2565b611faf81612044565b91505b50919050565b60006000611fcd611fc8846129dc565b6129dc565b9050606860020a811015611fe057611ff0565b611fe981612044565b9150611ffc565b611ff981612002565b91505b50919050565b6000600061200f836129dc565b9050606960020a81101561202257612032565b61202b8161208e565b915061203e565b61203b816120d0565b91505b50919050565b60006000612059612054846129dc565b6129dc565b9050606960020a81101561206c5761207c565b612075816120d0565b9150612088565b6120858161208e565b91505b50919050565b6000600061209b836129dc565b9050606a60020a8110156120ae576120be565b6120b78161211a565b91506120ca565b6120c78161215c565b91505b50919050565b600060006120e56120e0846129dc565b6129dc565b9050606a60020a8110156120f857612108565b6121018161215c565b9150612114565b6121118161211a565b91505b50919050565b60006000612127836129dc565b9050606b60020a81101561213a5761214a565b612143816121a6565b9150612156565b612153816121e8565b91505b50919050565b6000600061217161216c846129dc565b6129dc565b9050606b60020a81101561218457612194565b61218d816121e8565b91506121a0565b61219d816121a6565b91505b50919050565b600060006121b3836129dc565b9050606c60020a8110156121c6576121d6565b6121cf81612232565b91506121e2565b6121df81612274565b91505b50919050565b600060006121fd6121f8846129dc565b6129dc565b9050606c60020a81101561221057612220565b61221981612274565b915061222c565b61222981612232565b91505b50919050565b6000600061223f836129dc565b9050606d60020a81101561225257612262565b61225b816122be565b915061226e565b61226b81612300565b91505b50919050565b60006000612289612284846129dc565b6129dc565b9050606d60020a81101561229c576122ac565b6122a581612300565b91506122b8565b6122b5816122be565b91505b50919050565b600060006122cb836129dc565b9050606e60020a8110156122de576122ee565b6122e78161234a565b91506122fa565b6122f78161238c565b91505b50919050565b60006000612315612310846129dc565b6129dc565b9050606e60020a81101561232857612338565b6123318161238c565b9150612344565b6123418161234a565b91505b50919050565b60006000612357836129dc565b9050606f60020a81101561236a5761237a565b612373816123d6565b9150612386565b61238381612418565b91505b50919050565b600060006123a161239c846129dc565b6129dc565b9050606f60020a8110156123b4576123c4565b6123bd81612418565b91506123d0565b6123cd816123d6565b91505b50919050565b600060006123e3836129dc565b9050607060020a8110156123f657612406565b6123ff81612462565b9150612412565b61240f816124a4565b91505b50919050565b6000600061242d612428846129dc565b6129dc565b9050607060020a81101561244057612450565b612449816124a4565b915061245c565b61245981612462565b91505b50919050565b6000600061246f836129dc565b9050607160020a81101561248257612492565b61248b816124ee565b915061249e565b61249b81612530565b91505b50919050565b600060006124b96124b4846129dc565b6129dc565b9050607160020a8110156124cc576124dc565b6124d581612530565b91506124e8565b6124e5816124ee565b91505b50919050565b600060006124fb836129dc565b9050607260020a81101561250e5761251e565b6125178161257a565b915061252a565b612527816125bc565b91505b50919050565b60006000612545612540846129dc565b6129dc565b9050607260020a81101561255857612568565b612561816125bc565b9150612574565b6125718161257a565b91505b50919050565b60006000612587836129dc565b9050607360020a81101561259a576125aa565b6125a381612606565b91506125b6565b6125b381612648565b91505b50919050565b600060006125d16125cc846129dc565b6129dc565b9050607360020a8110156125e4576125f4565b6125ed81612648565b9150612600565b6125fd81612606565b91505b50919050565b60006000612613836129dc565b9050607460020a81101561262657612636565b61262f81612692565b9150612642565b61263f816126d4565b91505b50919050565b6000600061265d612658846129dc565b6129dc565b9050607460020a81101561267057612680565b612679816126d4565b915061268c565b61268981612692565b91505b50919050565b6000600061269f836129dc565b9050607560020a8110156126b2576126c2565b6126bb8161271e565b91506126ce565b6126cb81612760565b91505b50919050565b600060006126e96126e4846129dc565b6129dc565b9050607560020a8110156126fc5761270c565b61270581612760565b9150612718565b6127158161271e565b91505b50919050565b6000600061272b836129dc565b9050607660020a81101561273e5761274e565b612747816127aa565b915061275a565b612757816127ec565b91505b50919050565b60006000612775612770846129dc565b6129dc565b9050607660020a81101561278857612798565b612791816127ec565b91506127a4565b6127a1816127aa565b91505b50919050565b600060006127b7836129dc565b9050607760020a8110156127ca576127da565b6127d381612836565b91506127e6565b6127e381612878565b91505b50919050565b600060006128016127fc846129dc565b6129dc565b9050607760020a81101561281457612824565b61281d81612878565b9150612830565b61282d81612836565b91505b50919050565b60006000612843836129dc565b9050607860020a81101561285657612866565b61285f816128c2565b9150612872565b61286f81612904565b91505b50919050565b6000600061288d612888846129dc565b6129dc565b9050607860020a8110156128a0576128b0565b6128a981612904565b91506128bc565b6128b9816128c2565b91505b50919050565b600060006128cf836129dc565b9050607960020a8110156128e2576128f2565b6128eb8161294e565b91506128fe565b6128fb81611d3e565b91505b50919050565b60006000612919612914846129dc565b6129dc565b9050607960020a81101561292c5761293c565b61293581611d3e565b9150612948565b6129458161294e565b91505b50919050565b6000600061295b836129dc565b9050607a60020a81101561296e5761297e565b61297781613227565b915061298a565b61298781613269565b91505b50919050565b6000600061299d836129dc565b9050604e60020a8110156129b0576129c0565b6129b981612a7f565b91506129cc565b6129c981612a3d565b91505b50919050565b6000819050919050565b600060007f5851f42d4c957f2c0000000000000000000000000000000000000000000000019050828102600101915050919050565b6000612a1c826129d2565b9050919050565b6000612a36612a31836129dc565b6129d2565b9050919050565b60006000612a4a836129dc565b9050604f60020a811015612a5d57612a6d565b612a6681612ac9565b9150612a79565b612a7681612b0b565b91505b50919050565b60006000612a94612a8f846129dc565b6129dc565b9050604f60020a811015612aa757612ab7565b612ab081612b0b565b9150612ac3565b612ac081612ac9565b91505b50919050565b60006000612ad6836129dc565b9050605060020a811015612ae957612af9565b612af281612b55565b9150612b05565b612b0281612b97565b91505b50919050565b60006000612b20612b1b846129dc565b6129dc565b9050605060020a811015612b3357612b43565b612b3c81612b97565b9150612b4f565b612b4c81612b55565b91505b50919050565b60006000612b62836129dc565b9050605160020a811015612b7557612b85565b612b7e81612be1565b9150612b91565b612b8e81612c23565b91505b50919050565b60006000612bac612ba7846129dc565b6129dc565b9050605160020a811015612bbf57612bcf565b612bc881612c23565b9150612bdb565b612bd881612be1565b91505b50919050565b60006000612bee836129dc565b9050605260020a811015612c0157612c11565b612c0a81612c6d565b9150612c1d565b612c1a81612caf565b91505b50919050565b60006000612c38612c33846129dc565b6129dc565b9050605260020a811015612c4b57612c5b565b612c5481612caf565b9150612c67565b612c6481612c6d565b91505b50919050565b60006000612c7a836129dc565b9050605360020a811015612c8d57612c9d565b612c9681612cf9565b9150612ca9565b612ca681612d3b565b91505b50919050565b60006000612cc4612cbf846129dc565b6129dc565b9050605360020a811015612cd757612ce7565b612ce081612d3b565b9150612cf3565b612cf081612cf9565b91505b50919050565b60006000612d06836129dc565b9050605460020a811015612d1957612d29565b612d2281612d85565b9150612d35565b612d3281612dc7565b91505b50919050565b60006000612d50612d4b846129dc565b6129dc565b9050605460020a811015612d6357612d73565b612d6c81612dc7565b9150612d7f565b612d7c81612d85565b91505b50919050565b60006000612d92836129dc565b9050605560020a811015612da557612db5565b612dae81612e11565b9150612dc1565b612dbe81612e53565b91505b50919050565b60006000612ddc612dd7846129dc565b6129dc565b9050605560020a811015612def57612dff565b612df881612e53565b9150612e0b565b612e0881612e11565b91505b50919050565b60006000612e1e836129dc565b9050605660020a811015612e3157612e41565b612e3a81612e9d565b9150612e4d565b612e4a81612edf565b91505b50919050565b60006000612e68612e63846129dc565b6129dc565b9050605660020a811015612e7b57612e8b565b612e8481612edf565b9150612e97565b612e9481612e9d565b91505b50919050565b60006000612eaa836129dc565b9050605760020a811015612ebd57612ecd565b612ec681612f29565b9150612ed9565b612ed681612f6b565b91505b50919050565b60006000612ef4612eef846129dc565b6129dc565b9050605760020a811015612f0757612f17565b612f1081612f6b565b9150612f23565b612f2081612f29565b91505b50919050565b60006000612f36836129dc565b9050605860020a811015612f4957612f59565b612f5281612fb5565b9150612f65565b612f6281612ff7565b91505b50919050565b60006000612f80612f7b846129dc565b6129dc565b9050605860020a811015612f9357612fa3565b612f9c81612ff7565b9150612faf565b612fac81612fb5565b91505b50919050565b60006000612fc2836129dc565b9050605960020a811015612fd557612fe5565b612fde81613041565b9150612ff1565b612fee81613083565b91505b50919050565b6000600061300c613007846129dc565b6129dc565b9050605960020a81101561301f5761302f565b61302881613083565b915061303b565b61303881613041565b91505b50919050565b6000600061304e836129dc565b9050605a60020a81101561306157613071565b61306a816130cd565b915061307d565b61307a8161310f565b91505b50919050565b60006000613098613093846129dc565b6129dc565b9050605a60020a8110156130ab576130bb565b6130b48161310f565b91506130c7565b6130c4816130cd565b91505b50919050565b600060006130da836129dc565b9050605b60020a8110156130ed576130fd565b6130f681613159565b9150613109565b6131068161319b565b91505b50919050565b6000600061312461311f846129dc565b6129dc565b9050605b60020a81101561313757613147565b6131408161319b565b9150613153565b61315081613159565b91505b50919050565b60006000613166836129dc565b9050605c60020a81101561317957613189565b613182816131e5565b9150613195565b6131928161196a565b91505b50919050565b600060006131b06131ab846129dc565b6129dc565b9050605c60020a8110156131c3576131d3565b6131cc8161196a565b91506131df565b6131dc816131e5565b91505b50919050565b600060006131f2836129dc565b9050605d60020a81101561320557613215565b61320e816119b4565b9150613221565b61321e816119f6565b91505b50919050565b60006000613234836129dc565b9050607b60020a81101561324757613257565b613250816132b3565b9150613263565b613260816132f5565b91505b50919050565b6000600061327e613279846129dc565b6129dc565b9050607b60020a811015613291576132a1565b61329a816132f5565b91506132ad565b6132aa816132b3565b91505b50919050565b600060006132c0836129dc565b9050607c60020a8110156132d3576132e3565b6132dc8161333f565b91506132ef565b6132ec81613381565b91505b50919050565b6000600061330a613305846129dc565b6129dc565b9050607c60020a81101561331d5761332d565b61332681613381565b9150613339565b6133368161333f565b91505b50919050565b6000600061334c836129dc565b9050607d60020a81101561335f5761336f565b613368816133cb565b915061337b565b6133788161340d565b91505b50919050565b60006000613396613391846129dc565b6129dc565b9050607d60020a8110156133a9576133b9565b6133b28161340d565b91506133c5565b6133c2816133cb565b91505b50919050565b600060006133d8836129dc565b9050607e60020a8110156133eb576133fb565b6133f481613457565b9150613407565b61340481613499565b91505b50919050565b6000600061342261341d846129dc565b6129dc565b9050607e60020a81101561343557613445565b61343e81613499565b9150613451565b61344e81613457565b91505b50919050565b60006000613464836129dc565b9050607f60020a81101561347757613487565b613480816134e3565b9150613493565b61349081613525565b91505b50919050565b600060006134ae6134a9846129dc565b6129dc565b9050607f60020a8110156134c1576134d1565b6134ca81613525565b91506134dd565b6134da816134e3565b91505b50919050565b600060006134f0836129dc565b9050608060020a81101561350357613513565b61350c8161356f565b915061351f565b61351c816135b1565b91505b50919050565b6000600061353a613535846129dc565b6129dc565b9050608060020a81101561354d5761355d565b613556816135b1565b9150613569565b6135668161356f565b91505b50919050565b6000600061357c836129dc565b9050608160020a81101561358f5761359f565b613598816135fb565b91506135ab565b6135a88161363d565b91505b50919050565b600060006135c66135c1846129dc565b6129dc565b9050608160020a8110156135d9576135e9565b6135e28161363d565b91506135f5565b6135f2816135fb565b91505b50919050565b60006000613608836129dc565b9050608260020a81101561361b5761362b565b61362481613687565b9150613637565b613634816136c9565b91505b50919050565b6000600061365261364d846129dc565b6129dc565b9050608260020a81101561366557613675565b61366e816136c9565b9150613681565b61367e81613687565b91505b50919050565b60006000613694836129dc565b9050608360020a8110156136a7576136b7565b6136b081613713565b91506136c3565b6136c081613755565b91505b50919050565b600060006136de6136d9846129dc565b6129dc565b9050608360020a8110156136f157613701565b6136fa81613755565b915061370d565b61370a81613713565b91505b50919050565b60006000613720836129dc565b9050608460020a81101561373357613743565b61373c8161379f565b915061374f565b61374c816137e1565b91505b50919050565b6000600061376a613765846129dc565b6129dc565b9050608460020a81101561377d5761378d565b613786816137e1565b9150613799565b6137968161379f565b91505b50919050565b600060006137ac836129dc565b9050608560020a8110156137bf576137cf565b6137c88161382b565b91506137db565b6137d88161386d565b91505b50919050565b600060006137f66137f1846129dc565b6129dc565b9050608560020a81101561380957613819565b6138128161386d565b9150613825565b6138228161382b565b91505b50919050565b60006000613838836129dc565b9050608660020a81101561384b5761385b565b613854816138b7565b9150613867565b613864816138f9565b91505b50919050565b6000600061388261387d846129dc565b6129dc565b9050608660020a811015613895576138a5565b61389e816138f9565b91506138b1565b6138ae816138b7565b91505b50919050565b600060006138c4836129dc565b9050608760020a8110156138d7576138e7565b6138e081613943565b91506138f3565b6138f081613985565b91505b50919050565b6000600061390e613909846129dc565b6129dc565b9050608760020a81101561392157613931565b61392a81613985565b915061393d565b61393a81613943565b91505b50919050565b60006000613950836129dc565b9050608860020a81101561396357613973565b61396c816139cf565b915061397f565b61397c81613a11565b91505b50919050565b6000600061399a613995846129dc565b6129dc565b9050608860020a8110156139ad576139bd565b6139b681613a11565b91506139c9565b6139c6816139cf565b91505b50919050565b600060006139dc836129dc565b9050608960020a8110156139ef576139ff565b6139f881613a5b565b9150613a0b565b613a0881613a9d565b91505b50919050565b60006000613a26613a21846129dc565b6129dc565b9050608960020a811015613a3957613a49565b613a4281613a9d565b9150613a55565b613a5281613a5b565b91505b50919050565b60006000613a68836129dc565b9050608a60020a811015613a7b57613a8b565b613a8481613ae7565b9150613a97565b613a9481613b29565b91505b50919050565b60006000613ab2613aad846129dc565b6129dc565b9050608a60020a811015613ac557613ad5565b613ace81613b29565b9150613ae1565b613ade81613ae7565b91505b50919050565b60006000613af4836129dc565b9050608b60020a811015613b0757613b17565b613b1081613b73565b9150613b23565b613b2081613bb5565b91505b50919050565b60006000613b3e613b39846129dc565b6129dc565b9050608b60020a811015613b5157613b61565b613b5a81613bb5565b9150613b6d565b613b6a81613b73565b91505b50919050565b60006000613b80836129dc565b9050608c60020a811015613b9357613ba3565b613b9c81613bff565b9150613baf565b613bac81613c41565b91505b50919050565b60006000613bca613bc5846129dc565b6129dc565b9050608c60020a811015613bdd57613bed565b613be681613c41565b9150613bf9565b613bf681613bff565b91505b50919050565b60006000613c0c836129dc565b9050608d60020a811015613c1f57613c2f565b613c2881613c8b565b9150613c3b565b613c3881613ccd565b91505b50919050565b60006000613c56613c51846129dc565b6129dc565b9050608d60020a811015613c6957613c79565b613c7281613ccd565b9150613c85565b613c8281613c8b565b91505b50919050565b60006000613c98836129dc565b9050608e60020a811015613cab57613cbb565b613cb481613d17565b9150613cc7565b613cc481613d59565b91505b50919050565b60006000613ce2613cdd846129dc565b6129dc565b9050608e60020a811015613cf557613d05565b613cfe81613d59565b9150613d11565b613d0e81613d17565b91505b50919050565b60006000613d24836129dc565b9050608f60020a811015613d3757613d47565b613d4081613da3565b9150613d53565b613d5081613de5565b91505b50919050565b60006000613d6e613d69846129dc565b6129dc565b9050608f60020a811015613d8157613d91565b613d8a81613de5565b9150613d9d565b613d9a81613da3565b91505b50919050565b60006000613db0836129dc565b9050609060020a811015613dc357613dd3565b613dcc81613e2f565b9150613ddf565b613ddc81613e71565b91505b50919050565b60006000613dfa613df5846129dc565b6129dc565b9050609060020a811015613e0d57613e1d565b613e1681613e71565b9150613e29565b613e2681613e2f565b91505b50919050565b60006000613e3c836129dc565b9050609160020a811015613e4f57613e5f565b613e5881613ebb565b9150613e6b565b613e6881613efd565b91505b50919050565b60006000613e86613e81846129dc565b6129dc565b9050609160020a811015613e9957613ea9565b613ea281613efd565b9150613eb5565b613eb281613ebb565b91505b50919050565b60006000613ec8836129dc565b9050609260020a811015613edb57613eeb565b613ee481613f47565b9150613ef7565b613ef481613f89565b91505b50919050565b60006000613f12613f0d846129dc565b6129dc565b9050609260020a811015613f2557613f35565b613f2e81613f89565b9150613f41565b613f3e81613f47565b91505b50919050565b60006000613f54836129dc565b9050609360020a811015613f6757613f77565b613f7081613fd3565b9150613f83565b613f8081614015565b91505b50919050565b60006000613f9e613f99846129dc565b6129dc565b9050609360020a811015613fb157613fc1565b613fba81614015565b9150613fcd565b613fca81613fd3565b91505b50919050565b60006000613fe0836129dc565b9050609460020a811015613ff357614003565b613ffc8161405f565b915061400f565b61400c816140a1565b91505b50919050565b6000600061402a614025846129dc565b6129dc565b9050609460020a81101561403d5761404d565b614046816140a1565b9150614059565b6140568161405f565b91505b50919050565b6000600061406c836129dc565b9050609560020a81101561407f5761408f565b614088816140eb565b915061409b565b6140988161412d565b91505b50919050565b600060006140b66140b1846129dc565b6129dc565b9050609560020a8110156140c9576140d9565b6140d28161412d565b91506140e5565b6140e2816140eb565b91505b50919050565b600060006140f8836129dc565b9050609660020a81101561410b5761411b565b61411481614177565b9150614127565b614124816141b9565b91505b50919050565b6000600061414261413d846129dc565b6129dc565b9050609660020a81101561415557614165565b61415e816141b9565b9150614171565b61416e81614177565b91505b50919050565b60006000614184836129dc565b9050609760020a811015614197576141a7565b6141a081614203565b91506141b3565b6141b081614245565b91505b50919050565b600060006141ce6141c9846129dc565b6129dc565b9050609760020a8110156141e1576141f1565b6141ea81614245565b91506141fd565b6141fa81614203565b91505b50919050565b60006000614210836129dc565b9050609860020a81101561422357614233565b61422c8161428f565b915061423f565b61423c816142d1565b91505b50919050565b6000600061425a614255846129dc565b6129dc565b9050609860020a81101561426d5761427d565b614276816142d1565b9150614289565b6142868161428f565b91505b50919050565b6000600061429c836129dc565b9050609960020a8110156142af576142bf565b6142b88161431b565b91506142cb565b6142c88161435d565b91505b50919050565b600060006142e66142e1846129dc565b6129dc565b9050609960020a8110156142f957614309565b6143028161435d565b9150614315565b6143128161431b565b91505b50919050565b60006000614328836129dc565b9050609a60020a81101561433b5761434b565b614344816143a7565b9150614357565b614354816143e9565b91505b50919050565b6000600061437261436d846129dc565b6129dc565b9050609a60020a81101561438557614395565b61438e816143e9565b91506143a1565b61439e816143a7565b91505b50919050565b600060006143b4836129dc565b9050609b60020a8110156143c7576143d7565b6143d081614433565b91506143e3565b6143e081614475565b91505b50919050565b600060006143fe6143f9846129dc565b6129dc565b9050609b60020a81101561441157614421565b61441a81614475565b915061442d565b61442a81614433565b91505b50919050565b60006000614440836129dc565b9050609c60020a81101561445357614463565b61445c816144bf565b915061446f565b61446c81614501565b91505b50919050565b6000600061448a614485846129dc565b6129dc565b9050609c60020a81101561449d576144ad565b6144a681614501565b91506144b9565b6144b6816144bf565b91505b50919050565b600060006144cc836129dc565b9050609d60020a8110156144df576144ef565b6144e88161454b565b91506144fb565b6144f88161458d565b91505b50919050565b60006000614516614511846129dc565b6129dc565b9050609d60020a81101561452957614539565b6145328161458d565b9150614545565b6145428161454b565b91505b50919050565b60006000614558836129dc565b9050609e60020a81101561456b5761457b565b614574816145d7565b9150614587565b61458481614619565b91505b50919050565b600060006145a261459d846129dc565b6129dc565b9050609e60020a8110156145b5576145c5565b6145be81614619565b91506145d1565b6145ce816145d7565b91505b50919050565b600060006145e4836129dc565b9050609f60020a8110156145f757614607565b61460081614663565b9150614613565b614610816146a5565b91505b50919050565b6000600061462e614629846129dc565b6129dc565b9050609f60020a81101561464157614651565b61464a816146a5565b915061465d565b61465a81614663565b91505b50919050565b60006000614670836129dc565b905060a060020a81101561468357614693565b61468c816146ef565b915061469f565b61469c81614731565b91505b50919050565b600060006146ba6146b5846129dc565b6129dc565b905060a060020a8110156146cd576146dd565b6146d681614731565b91506146e9565b6146e6816146ef565b91505b50919050565b600060006146fc836129dc565b905060a160020a81101561470f5761471f565b6147188161477b565b915061472b565b614728816147bd565b91505b50919050565b60006000614746614741846129dc565b6129dc565b905060a160020a81101561475957614769565b614762816147bd565b9150614775565b6147728161477b565b91505b50919050565b60006000614788836129dc565b905060a260020a81101561479b576147ab565b6147a481614807565b91506147b7565b6147b481614849565b91505b50919050565b600060006147d26147cd846129dc565b6129dc565b905060a260020a8110156147e5576147f5565b6147ee81614849565b9150614801565b6147fe81614807565b91505b50919050565b60006000614814836129dc565b905060a360020a81101561482757614837565b61483081614893565b9150614843565b614840816148d5565b91505b50919050565b6000600061485e614859846129dc565b6129dc565b905060a360020a81101561487157614881565b61487a816148d5565b915061488d565b61488a81614893565b91505b50919050565b600060006148a0836129dc565b905060a460020a8110156148b3576148c3565b6148bc8161491f565b91506148cf565b6148cc81614961565b91505b50919050565b600060006148ea6148e5846129dc565b6129dc565b905060a460020a8110156148fd5761490d565b61490681614961565b9150614919565b6149168161491f565b91505b50919050565b6000600061492c836129dc565b905060a560020a81101561493f5761494f565b614948816149ab565b915061495b565b614958816149ed565b91505b50919050565b60006000614976614971846129dc565b6129dc565b905060a560020a81101561498957614999565b614992816149ed565b91506149a5565b6149a2816149ab565b91505b50919050565b600060006149b8836129dc565b905060a660020a8110156149cb576149db565b6149d481614a37565b91506149e7565b6149e481614a79565b91505b50919050565b60006000614a026149fd846129dc565b6129dc565b905060a660020a811015614a1557614a25565b614a1e81614a79565b9150614a31565b614a2e81614a37565b91505b50919050565b60006000614a44836129dc565b905060a760020a811015614a5757614a67565b614a6081614ac3565b9150614a73565b614a7081614b05565b91505b50919050565b60006000614a8e614a89846129dc565b6129dc565b905060a760020a811015614aa157614ab1565b614aaa81614b05565b9150614abd565b614aba81614ac3565b91505b50919050565b60006000614ad0836129dc565b905060a860020a811015614ae357614af3565b614aec81614b4f565b9150614aff565b614afc81614b91565b91505b50919050565b60006000614b1a614b15846129dc565b6129dc565b905060a860020a811015614b2d57614b3d565b614b3681614b91565b9150614b49565b614b4681614b4f565b91505b50919050565b60006000614b5c836129dc565b905060a960020a811015614b6f57614b7f565b614b7881614bdb565b9150614b8b565b614b8881614c1d565b91505b50919050565b60006000614ba6614ba1846129dc565b6129dc565b905060a960020a811015614bb957614bc9565b614bc281614c1d565b9150614bd5565b614bd281614bdb565b91505b50919050565b60006000614be8836129dc565b905060aa60020a811015614bfb57614c0b565b614c0481614c67565b9150614c17565b614c1481614ca9565b91505b50919050565b60006000614c32614c2d846129dc565b6129dc565b905060aa60020a811015614c4557614c55565b614c4e81614ca9565b9150614c61565b614c5e81614c67565b91505b50919050565b60006000614c74836129dc565b905060ab60020a811015614c8757614c97565b614c9081614cf3565b9150614ca3565b614ca081614d35565b91505b50919050565b60006000614cbe614cb9846129dc565b6129dc565b905060ab60020a811015614cd157614ce1565b614cda81614d35565b9150614ced565b614cea81614cf3565b91505b50919050565b60006000614d00836129dc565b905060ac60020a811015614d1357614d23565b614d1c81614d7f565b9150614d2f565b614d2c81614dc1565b91505b50919050565b60006000614d4a614d45846129dc565b6129dc565b905060ac60020a811015614d5d57614d6d565b614d6681614dc1565b9150614d79565b614d7681614d7f565b91505b50919050565b60006000614d8c836129dc565b905060ad60020a811015614d9f57614daf565b614da881614e0b565b9150614dbb565b614db881614e4d565b91505b50919050565b60006000614dd6614dd1846129dc565b6129dc565b905060ad60020a811015614de957614df9565b614df281614e4d565b9150614e05565b614e0281614e0b565b91505b50919050565b60006000614e18836129dc565b905060ae60020a811015614e2b57614e3b565b614e3481614e97565b9150614e47565b614e4481614ed9565b91505b50919050565b60006000614e62614e5d846129dc565b6129dc565b905060ae60020a811015614e7557614e85565b614e7e81614ed9565b9150614e91565b614e8e81614e97565b91505b50919050565b60006000614ea4836129dc565b905060af60020a811015614eb757614ec7565b614ec081614f23565b9150614ed3565b614ed081614f65565b91505b50919050565b60006000614eee614ee9846129dc565b6129dc565b905060af60020a811015614f0157614f11565b614f0a81614f65565b9150614f1d565b614f1a81614f23565b91505b50919050565b60006000614f30836129dc565b905060b060020a811015614f4357614f53565b614f4c81614faf565b9150614f5f565b614f5c81614ff1565b91505b50919050565b60006000614f7a614f75846129dc565b6129dc565b905060b060020a811015614f8d57614f9d565b614f9681614ff1565b9150614fa9565b614fa681614faf565b91505b50919050565b60006000614fbc836129dc565b905060b160020a811015614fcf57614fdf565b614fd881612a11565b9150614feb565b614fe881612a23565b91505b50919050565b60006000615006615001846129dc565b6129dc565b905060b160020a81101561501957615029565b61502281612a23565b9150615035565b61503281612a11565b91505b5091905056", @@ -25,7 +25,7 @@ "//" : "ManyFunctions.start(1)", "data" : "0x95805DAD0000000000000000000000000000000000000000000000000000000000000001", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "ackermann31": { @@ -39,7 +39,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -54,7 +54,7 @@ "//" : "ackermann(3, 1)", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "ackermann32": { @@ -68,7 +68,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -97,7 +97,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -126,7 +126,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -155,7 +155,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", diff --git a/test/vmPushDupSwapTestFiller.json b/test/vmPushDupSwapTestFiller.json index 1aca47922..9b8930e01 100644 --- a/test/vmPushDupSwapTestFiller.json +++ b/test/vmPushDupSwapTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60ff600355", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x61eeff600355", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x62ddeeff600355", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x63ccddeeff600355", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x64bbccddeeff600355", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x65aabbccddeeff600355", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6699aabbccddeeff600355", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x678899aabbccddeeff600355", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x68778899aabbccddeeff600355", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6966778899aabbccddeeff600355", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -318,7 +318,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6a5566778899aabbccddeeff600355", "storage": {} @@ -331,7 +331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -346,7 +346,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6b445566778899aabbccddeeff600355", "storage": {} @@ -359,7 +359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -374,7 +374,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6c33445566778899aabbccddeeff600355", "storage": {} @@ -387,7 +387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -402,7 +402,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6d2233445566778899aabbccddeeff600355", "storage": {} @@ -415,7 +415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -430,7 +430,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6e112233445566778899aabbccddeeff600355", "storage": {} @@ -443,7 +443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -458,7 +458,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6f10112233445566778899aabbccddeeff600355", "storage": {} @@ -471,7 +471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -486,7 +486,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x70ff00112233445566778899aabbccddeeff600355", "storage": {} @@ -499,7 +499,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x71eeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -527,7 +527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -542,7 +542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x72ddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -555,7 +555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -570,7 +570,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x73ccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -583,7 +583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -598,7 +598,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x74bbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -611,7 +611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -626,7 +626,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x75aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -639,7 +639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -654,7 +654,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7699aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -667,7 +667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -682,7 +682,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -695,7 +695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -710,7 +710,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x78778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -723,7 +723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -738,7 +738,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7966778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -751,7 +751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -767,7 +767,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7a5566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -780,7 +780,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -795,7 +795,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7b445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -808,7 +808,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7c33445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7d2233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -879,7 +879,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7e112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -892,7 +892,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -907,7 +907,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -920,7 +920,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -935,7 +935,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7fff10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -948,7 +948,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -964,7 +964,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7fff10112233445566778899aabbccddeeff00112233445566778899aabbccdd", "storage": {} @@ -977,7 +977,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -992,7 +992,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 101 2002 303303 40444404 50555555505 60666666666606 7777777777777777 888888888888888888 99999999999999999999 10000000000000000000001 10111111111111111111111101 2022222222222222222222222202 303333333333333333333333333303 4044444444444444444444444444444404 505555555555555555555555555555555505 60666666666666666666666666666666666606 7077777777777777777777777777777777777707 808888888888888888888888888888888888888808 90999999999999999999999999999999999999999909 100000000000000000000000000000000000000000000001 10111111111111111111111111111111111111111111111101 2022222222222222222222222222222222222222222222222202 303333333333333333333333333333333333333333333333333303 40444444444444444444444444444444444444444444444444444404 50555555555555555555555555555555555555555555555555555555505 6066666666666666666666666666666666666666666666666666666666606 707777777777777777777777777777777777777777777777777777777777707 808888888888888888888888888888888888888888888888888888888888888808 90999999999999999999999999999999999999999999999999999999999999999909 100000000000000000000000000000000000000000000000000000000000000000000001 10111111111111111111111111111111111111111111111111111111111111111111111101 2022222222222222222222222222222222222222222222222222222222222222222222222202)", "storage": {} @@ -1020,7 +1020,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff80600355", "storage": {} @@ -1033,7 +1033,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1048,7 +1048,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff81600355", "storage": {} @@ -1061,7 +1061,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1076,7 +1076,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600181600355", "storage": {} @@ -1089,7 +1089,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1104,7 +1104,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60036002600182600355", "storage": {} @@ -1117,7 +1117,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1132,7 +1132,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460036002600183600355", "storage": {} @@ -1145,7 +1145,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1160,7 +1160,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600460036002600184600355", "storage": {} @@ -1173,7 +1173,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1188,7 +1188,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60066005600460036002600185600355", "storage": {} @@ -1201,7 +1201,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1216,7 +1216,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600760066005600460036002600186600355", "storage": {} @@ -1229,7 +1229,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1244,7 +1244,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600760066005600460036002600187600355", "storage": {} @@ -1257,7 +1257,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1272,7 +1272,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60096008600760066005600460036002600188600355", "storage": {} @@ -1285,7 +1285,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1300,7 +1300,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a60096008600760066005600460036002600189600355", "storage": {} @@ -1313,7 +1313,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1328,7 +1328,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600b600a6009600860076006600560046003600260018a600355", "storage": {} @@ -1341,7 +1341,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1356,7 +1356,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600c600b600a6009600860076006600560046003600260018b600355", "storage": {} @@ -1369,7 +1369,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1384,7 +1384,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600d600c600b600a6009600860076006600560046003600260018c600355", "storage": {} @@ -1397,7 +1397,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1412,7 +1412,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600e600d600c600b600a6009600860076006600560046003600260018d600355", "storage": {} @@ -1425,7 +1425,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1440,7 +1440,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600f600e600d600c600b600a6009600860076006600560046003600260018e600355", "storage": {} @@ -1453,7 +1453,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1468,7 +1468,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6010600f600e600d600c600b600a6009600860076006600560046003600260018f600355", "storage": {} @@ -1481,7 +1481,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1496,7 +1496,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff60039055", "storage": {} @@ -1509,7 +1509,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1524,7 +1524,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff60039155", "storage": {} @@ -1537,7 +1537,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1552,7 +1552,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600160039155", "storage": {} @@ -1565,7 +1565,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1580,7 +1580,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60036002600160039255", "storage": {} @@ -1593,7 +1593,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1608,7 +1608,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460036002600160039355", "storage": {} @@ -1621,7 +1621,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1636,7 +1636,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600460036002600160039455", "storage": {} @@ -1649,7 +1649,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1664,7 +1664,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60066005600460036002600160039555", "storage": {} @@ -1677,7 +1677,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1692,7 +1692,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600760066005600460036002600160039655", "storage": {} @@ -1705,7 +1705,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1720,7 +1720,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600760066005600460036002600160039755", "storage": {} @@ -1733,7 +1733,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1748,7 +1748,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60096008600760066005600460036002600160039855", "storage": {} @@ -1761,7 +1761,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1776,7 +1776,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a60096008600760066005600460036002600160039955", "storage": {} @@ -1789,7 +1789,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1804,7 +1804,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600b600a60096008600760066005600460036002600160039a55", "storage": {} @@ -1817,7 +1817,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1832,7 +1832,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600c600b600a60096008600760066005600460036002600160039b55", "storage": {} @@ -1845,7 +1845,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1860,7 +1860,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600d600c600b600a60096008600760066005600460036002600160039c55", "storage": {} @@ -1873,7 +1873,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1888,7 +1888,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600e600d600c600b600a60096008600760066005600460036002600160039d55", "storage": {} @@ -1901,7 +1901,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1916,7 +1916,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600f600e600d600c600b600a60096008600760066005600460036002600160039e55", "storage": {} @@ -1929,7 +1929,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1944,7 +1944,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6010600f600e600d600c600b600a60096008600760066005600460036002600160039f55", "storage": {} @@ -1957,7 +1957,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1972,7 +1972,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 5 2 1 12 JUMPI POP POP STOP JUMPDEST SWAP1 1 22 JUMPI POP POP STOP JUMPDEST SUB 0 MSTORE 1 31 RETURN)", "storage": {} @@ -1985,7 +1985,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmSha3TestFiller.json b/test/vmSha3TestFiller.json index 48a395e80..e43c52f9b 100644 --- a/test/vmSha3TestFiller.json +++ b/test/vmSha3TestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0 0)}", "storage": {} @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 4 5)}", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 10 10)}", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 1000 0xfffff)}", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0xfffffffff 100)}", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 10000 0xfffffffff )}", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)}", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, diff --git a/test/vmSystemOperationsTestFiller.json b/test/vmSystemOperationsTestFiller.json index 709af7079..bdbbdc29b 100644 --- a/test/vmSystemOperationsTestFiller.json +++ b/test/vmSystemOperationsTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 3 29) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -51,7 +51,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -79,7 +79,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -107,7 +107,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -161,14 +161,14 @@ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "code" : "0x4243434242434243f14555", "data" : "0x", - "gas" : "10000", + "gas" : "100000", "gasPrice" : "100000000000000", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "code" : "0x4243434242434243f14555", "nonce" : "0", "storage" : { @@ -188,7 +188,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2) }", "storage": {} @@ -224,7 +224,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) (POST 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 ) }", "storage": {} @@ -260,7 +260,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLSTATELESS 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2 ) }", "storage": {} @@ -296,7 +296,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2 ) }", "storage": {} @@ -333,7 +333,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 100 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -369,7 +369,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 987654321 64 64 0) }", "storage": {} @@ -405,7 +405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 9865432 64 0) }", "storage": {} @@ -441,7 +441,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 987654 1) }", "storage": {} @@ -478,7 +478,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 987654 0) }", "storage": {} @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 987654 0 64 0) }", "storage": {} @@ -556,7 +556,7 @@ "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (+ (SLOAD 0) 1) [[ 1 ]] (CALL (- (GAS) 224) (ADDRESS) 0 0 0 0 0) } ", "storage": {} @@ -668,7 +668,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE (CALLER))}", "storage": {} @@ -704,7 +704,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE 0xaa1722f3947def4cf144679da39c4c32bdc35681 )}", "storage": {} @@ -740,7 +740,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE (ADDRESS) )}", "storage": {} @@ -866,7 +866,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) (POST 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 ) }", "storage": {} @@ -902,7 +902,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLSTATELESS 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -974,7 +974,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6000355415600957005b60203560003555", "storage": {} @@ -987,7 +987,7 @@ "value" : "1000000000000000000", "data" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffafffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1002,7 +1002,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} @@ -1038,7 +1038,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} @@ -1074,7 +1074,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", "storage": {} @@ -1146,7 +1146,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) (SUICIDE 0x945304eb96065b2a98b57a48a06ae28d285a71b5) }", "storage": {} @@ -1182,7 +1182,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} diff --git a/test/vmtestsFiller.json b/test/vmtestsFiller.json index 75bf1da8f..c9f157f11 100644 --- a/test/vmtestsFiller.json +++ b/test/vmtestsFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(suicide (caller))", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (call (- (gas) 200) (caller) (+ 2 2 (* 4 4 4) (/ 2 2) (% 3 2) (- 8 2 2)) 0 0 0 0) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(seq (when (and 1 1) (call (- (gas) 200) (caller) 2 0 0 0 0)) (when (and 1 0) (call (- (gas) 200) (caller) 3 0 0 0 0)) (when (and 0 1) (call (- (gas) 200) (caller) 4 0 0 0 0)) (when (and 0 0) (call (- (gas) 200) (caller) 5 0 0 0 0)) (when (or 1 1) (call (- (gas) 200) (caller) 12 0 0 0 0)) (when (or 1 0) (call (- (gas) 200) (caller) 13 0 0 0 0)) (when (or 0 1) (call (- (gas) 200) (caller) 14 0 0 0 0)) (when (or 0 0) (call (- (gas) 200) (caller) 15 0 0 0 0)) )", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(call (- (gas) 200) (caller) 500000000000000000 0 0 0 0)", "storage": {} @@ -107,7 +107,7 @@ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000", "gasPrice" : "100000000000000", - "gas" : "10000", + "gas" : "100000", "data" : "" } } From 210104395fbd0cd1bd00ed2700395f1c4b8b713a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 11:09:34 +0100 Subject: [PATCH 063/313] Bunch of repotting/curating. [10:59:28] Vitalik Buterin: block.parent.gas_limit * 1023 / 1024 <= block.gas_limit <= block.parent.gas_limit * 1025/1024 --- alethzero/Context.cpp | 2 +- alethzero/Context.h | 2 +- alethzero/Debugger.h | 2 +- alethzero/MainWin.h | 2 +- alethzero/Transact.h | 2 +- rlp/base64.cpp => libdevcore/Base64.cpp | 12 +-- rlp/base64.h => libdevcore/Base64.h | 9 +- libdevcore/Common.h | 6 ++ libdevcore/CommonIO.h | 1 + libdevcore/CommonJS.cpp | 101 ++++++++++++++++++++ libdevcore/CommonJS.h | 116 +++++++++++++++++++++++ libethcore/BlockInfo.cpp | 12 +-- libethcore/BlockInfo.h | 2 +- libethcore/{CommonEth.cpp => Common.cpp} | 4 +- libethcore/{CommonEth.h => Common.h} | 2 +- libethcore/CommonJS.cpp | 79 +-------------- libethcore/CommonJS.h | 114 +++------------------- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 4 +- libethcore/ProofOfWork.h | 2 +- libethereum/Account.cpp | 2 +- libethereum/AccountDiff.h | 2 +- libethereum/BlockChain.h | 2 +- libethereum/BlockQueue.h | 2 +- libethereum/CanonBlockChain.h | 2 +- libethereum/EthereumHost.h | 2 +- libethereum/EthereumPeer.h | 2 +- libethereum/Executive.h | 2 +- libethereum/ExtVM.h | 2 +- libethereum/LogFilter.h | 2 +- libethereum/Miner.h | 2 +- libethereum/Precompiled.cpp | 2 +- libethereum/Transaction.h | 2 +- libethereum/TransactionQueue.h | 2 +- libethereum/Utility.cpp | 2 +- libevm/ExtVMFace.h | 2 +- libevm/VM.h | 2 +- mix/QEther.h | 2 +- rlp/main.cpp | 94 +++++++++--------- test/MemTrie.cpp | 2 +- test/TrieHash.cpp | 2 +- test/commonjs.cpp | 2 +- third/MainWin.h | 2 +- 43 files changed, 339 insertions(+), 275 deletions(-) rename rlp/base64.cpp => libdevcore/Base64.cpp (91%) rename rlp/base64.h => libdevcore/Base64.h (80%) create mode 100644 libdevcore/CommonJS.cpp create mode 100644 libdevcore/CommonJS.h rename libethcore/{CommonEth.cpp => Common.cpp} (97%) rename libethcore/{CommonEth.h => Common.h} (98%) diff --git a/alethzero/Context.cpp b/alethzero/Context.cpp index d187e6d47..7a5a986d1 100644 --- a/alethzero/Context.cpp +++ b/alethzero/Context.cpp @@ -21,7 +21,7 @@ #include "Context.h" #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/alethzero/Context.h b/alethzero/Context.h index 098690455..beb368c26 100644 --- a/alethzero/Context.h +++ b/alethzero/Context.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include class QComboBox; diff --git a/alethzero/Debugger.h b/alethzero/Debugger.h index 370ad6e30..76ef6a0d3 100644 --- a/alethzero/Debugger.h +++ b/alethzero/Debugger.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 638469fbe..072911ff7 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/alethzero/Transact.h b/alethzero/Transact.h index f14005eff..8ef4f41e0 100644 --- a/alethzero/Transact.h +++ b/alethzero/Transact.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/rlp/base64.cpp b/libdevcore/Base64.cpp similarity index 91% rename from rlp/base64.cpp rename to libdevcore/Base64.cpp index 5e2b32000..684556cd5 100644 --- a/rlp/base64.cpp +++ b/libdevcore/Base64.cpp @@ -23,13 +23,11 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. - -#include "base64.h" +/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// Originally by René Nyffenegger, modified by some other guy and then devified by Gav Wood. +#include "Base64.h" #include - using namespace std; using namespace dev; @@ -42,7 +40,7 @@ static inline bool is_base64(byte c) { return (isalnum(c) || (c == '+') || (c == '/')); } -std::string dev::base64_encode(bytesConstRef _in) { +std::string dev::toBase64(bytesConstRef _in) { std::string ret; int i = 0; int j = 0; @@ -86,7 +84,7 @@ std::string dev::base64_encode(bytesConstRef _in) { return ret; } -bytes dev::base64_decode(std::string const& encoded_string) { +bytes dev::fromBase64(std::string const& encoded_string) { int in_len = encoded_string.size(); int i = 0; int j = 0; diff --git a/rlp/base64.h b/libdevcore/Base64.h similarity index 80% rename from rlp/base64.h rename to libdevcore/Base64.h index 53ba282c8..1e9c88429 100644 --- a/rlp/base64.h +++ b/libdevcore/Base64.h @@ -23,8 +23,9 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// Originally by René Nyffenegger. +/// DEVified by Gav Wood. #pragma once #include @@ -34,7 +35,7 @@ namespace dev { -std::string base64_encode(bytesConstRef _in); -bytes base64_decode(std::string const& _in); +std::string toBase64(bytesConstRef _in); +bytes fromBase64(std::string const& _in); } diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 764b3454e..b82cb827e 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -119,6 +119,12 @@ inline unsigned int toLog2(u256 _x) return ret; } +template +inline N diff(N const& _a, N const& _b) +{ + return std::max(_a, _b) - std::min(_a, _b); +} + /// RAII utility class whose destructor calls a given function. class ScopeGuard { public: diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 1fc8a65e4..03fc9cffc 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -36,6 +36,7 @@ #include #include #include "Common.h" +#include "Base64.h" namespace dev { diff --git a/libdevcore/CommonJS.cpp b/libdevcore/CommonJS.cpp new file mode 100644 index 000000000..f173e779e --- /dev/null +++ b/libdevcore/CommonJS.cpp @@ -0,0 +1,101 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CommonJS.cpp + * @authors: + * Gav Wood + * Marek Kotewicz + * @date 2014 + */ + +#include "CommonJS.h" + +namespace dev +{ + +bytes jsToBytes(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return fromHex(_s.substr(2)); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return toCompactBigEndian(bigint(_s)); + else + return bytes(); +} + +bytes padded(bytes _b, unsigned _l) +{ + while (_b.size() < _l) + _b.insert(_b.begin(), 0); + return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l))); +} + +bytes paddedRight(bytes _b, unsigned _l) +{ + _b.resize(_l); + return _b; +} + +bytes unpadded(bytes _b) +{ + auto p = asString(_b).find_last_not_of((char)0); + _b.resize(p == std::string::npos ? 0 : (p + 1)); + return _b; +} + +bytes unpadLeft(bytes _b) +{ + unsigned int i = 0; + if (_b.size() == 0) + return _b; + + while (i < _b.size() && _b[i] == byte(0)) + i++; + + if (i != 0) + _b.erase(_b.begin(), _b.begin() + i); + return _b; +} + +std::string fromRaw(h256 _n, unsigned* _inc) +{ + if (_n) + { + std::string s((char const*)_n.data(), 32); + auto l = s.find_first_of('\0'); + if (!l) + return ""; + if (l != std::string::npos) + { + auto p = s.find_first_not_of('\0', l); + if (!(p == std::string::npos || (_inc && p == 31))) + return ""; + if (_inc) + *_inc = (byte)s[31]; + s.resize(l); + } + for (auto i: s) + if (i < 32) + return ""; + return s; + } + return ""; +} + +} + diff --git a/libdevcore/CommonJS.h b/libdevcore/CommonJS.h new file mode 100644 index 000000000..d3e8e6daa --- /dev/null +++ b/libdevcore/CommonJS.h @@ -0,0 +1,116 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CommonJS.h + * @authors: + * Gav Wood + * Marek Kotewicz + * @date 2014 + */ + +#pragma once + +#include +#include "FixedHash.h" +#include "CommonData.h" +#include "CommonIO.h" + +namespace dev +{ + +template std::string toJS(FixedHash const& _h) +{ + return "0x" + toHex(_h.ref()); +} + +template std::string toJS(boost::multiprecision::number> const& _n) +{ + return "0x" + toHex(toCompactBigEndian(_n)); +} + +inline std::string toJS(dev::bytes const& _n) +{ + return "0x" + dev::toHex(_n); +} + +/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. +bytes jsToBytes(std::string const& _s); +/// Add '0' on the head of @a _b until @a _l. +bytes padded(bytes _b, unsigned _l); +/// Add '0' on the queue of @a _b until @a _l. +bytes paddedRight(bytes _b, unsigned _l); +/// Removing all trailing '0'. Returns empty array if input contains only '0' char. +bytes unpadded(bytes _s); +/// Remove all 0 byte on the head of @a _s. +bytes unpadLeft(bytes _s); +/// Convert h256 into user-readable string (by directly using std::string constructor). +std::string fromRaw(h256 _n, unsigned* _inc = nullptr); + +template FixedHash jsToFixed(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return FixedHash(_s.substr(2 + std::max(N * 2, _s.size() - 2) - N * 2)); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return (typename FixedHash::Arith)(_s); + else + // Binary + return FixedHash(); // FAIL +} + +inline std::string jsToFixed(double _s) +{ + return toJS(dev::u256(_s * (double)(dev::u256(1) << 128))); +} + +template boost::multiprecision::number> jsToInt(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return fromBigEndian>>(fromHex(_s.substr(2))); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return boost::multiprecision::number>(_s); + else + // Binary + return 0; // FAIL +} + +inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } + +inline std::string jsToDecimal(std::string const& _s) +{ + return dev::toString(jsToU256(_s)); +} + +inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32) +{ + _s.resize(std::max(_s.size(), _padding)); + return "0x" + dev::toHex(_s); +} + +inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) +{ + return jsFromBinary(asBytes(_s), _padding); +} + +inline double jsFromFixed(std::string const& _s) +{ + return (double)jsToU256(_s) / (double)(dev::u256(1) << 128); +} + +} diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index d8a2357a1..270f96b07 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "ProofOfWork.h" #include "Exceptions.h" #include "Params.h" @@ -203,15 +203,15 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } -template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } - void BlockInfo::verifyParent(BlockInfo const& _parent) const -{ // Check difficulty is correct given the two timestamps. +{ + // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); + if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || + gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index bf986e3a1..a119d92eb 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -23,7 +23,7 @@ #include #include -#include "CommonEth.h" +#include "Common.h" namespace dev { diff --git a/libethcore/CommonEth.cpp b/libethcore/Common.cpp similarity index 97% rename from libethcore/CommonEth.cpp rename to libethcore/Common.cpp index 822ede5aa..65c0b8b92 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/Common.cpp @@ -14,12 +14,12 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file CommonEth.cpp +/** @file Common.cpp * @author Gav Wood * @date 2014 */ -#include "CommonEth.h" +#include "Common.h" #include #include #include "Exceptions.h" diff --git a/libethcore/CommonEth.h b/libethcore/Common.h similarity index 98% rename from libethcore/CommonEth.h rename to libethcore/Common.h index edefda380..80a253bdd 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/Common.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file CommonEth.h +/** @file Common.h * @author Gav Wood * @date 2014 * diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index 388738528..ef9ac9f65 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -26,75 +26,12 @@ namespace dev { -bytes jsToBytes(std::string const& _s) +Address toAddress(std::string const& _sn) { - if (_s.substr(0, 2) == "0x") - // Hex - return fromHex(_s.substr(2)); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return toCompactBigEndian(bigint(_s)); + if (_sn.size() == 40) + return Address(fromHex(_sn)); else - return bytes(); -} - -bytes padded(bytes _b, unsigned _l) -{ - while (_b.size() < _l) - _b.insert(_b.begin(), 0); - return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l))); -} - -bytes paddedRight(bytes _b, unsigned _l) -{ - _b.resize(_l); - return _b; -} - -bytes unpadded(bytes _b) -{ - auto p = asString(_b).find_last_not_of((char)0); - _b.resize(p == std::string::npos ? 0 : (p + 1)); - return _b; -} - -bytes unpadLeft(bytes _b) -{ - unsigned int i = 0; - if (_b.size() == 0) - return _b; - - while (i < _b.size() && _b[i] == byte(0)) - i++; - - if (i != 0) - _b.erase(_b.begin(), _b.begin() + i); - return _b; -} - -std::string fromRaw(h256 _n, unsigned* _inc) -{ - if (_n) - { - std::string s((char const*)_n.data(), 32); - auto l = s.find_first_of('\0'); - if (!l) - return ""; - if (l != std::string::npos) - { - auto p = s.find_first_not_of('\0', l); - if (!(p == std::string::npos || (_inc && p == 31))) - return ""; - if (_inc) - *_inc = (byte)s[31]; - s.resize(l); - } - for (auto i: s) - if (i < 32) - return ""; - return s; - } - return ""; + return Address(); } std::string prettyU256(u256 _n, bool _abridged) @@ -128,13 +65,5 @@ std::string prettyU256(u256 _n, bool _abridged) return s.str(); } -Address fromString(std::string const& _sn) -{ - if (_sn.size() == 40) - return Address(fromHex(_sn)); - else - return Address(); -} - } diff --git a/libethcore/CommonJS.h b/libethcore/CommonJS.h index abe74f0af..7d3071c68 100644 --- a/libethcore/CommonJS.h +++ b/libethcore/CommonJS.h @@ -24,124 +24,38 @@ #pragma once #include -#include -#include -#include -#include -#include "CommonEth.h" +#include +#include +#include "Common.h" + +// devcrypto namespace dev { -template std::string toJS(FixedHash const& _h) -{ - return "0x" + toHex(_h.ref()); -} +/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40). +Address toAddress(std::string const& _a); -template std::string toJS(boost::multiprecision::number> const& _n) -{ - return "0x" + toHex(toCompactBigEndian(_n)); -} +/// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length. +inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } -inline std::string toJS(dev::bytes const& _n) -{ - return "0x" + dev::toHex(_n); -} +/// Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length. +inline Secret jsToSecret(std::string const& _s) { return jsToFixed(_s); } + +/// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length. +inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } -/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. -bytes jsToBytes(std::string const& _s); -/// Add '0' on the head of @a _b until @a _l. -bytes padded(bytes _b, unsigned _l); -/// Add '0' on the queue of @a _b until @a _l. -bytes paddedRight(bytes _b, unsigned _l); -/// Removing all trailing '0'. Returns empty array if input contains only '0' char. -bytes unpadded(bytes _s); -/// Remove all 0 byte on the head of @a _s. -bytes unpadLeft(bytes _s); /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. std::string prettyU256(u256 _n, bool _abridged = true); -/// Convert h256 into user-readable string (by directly using std::string constructor). -std::string fromRaw(h256 _n, unsigned* _inc = nullptr); -/// Convert string to Address (h160), returns empty address if (_a.size != 40). -Address fromString(std::string const& _a); - -template FixedHash jsToFixed(std::string const& _s) -{ - if (_s.substr(0, 2) == "0x") - // Hex - return FixedHash(_s.substr(2 + std::max(N * 2, _s.size() - 2) - N * 2)); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return (typename FixedHash::Arith)(_s); - else - // Binary - return FixedHash(); // FAIL -} - -inline std::string jsToFixed(double _s) -{ - return toJS(dev::u256(_s * (double)(dev::u256(1) << 128))); -} - -template boost::multiprecision::number> jsToInt(std::string const& _s) -{ - if (_s.substr(0, 2) == "0x") - // Hex - return fromBigEndian>>(fromHex(_s.substr(2))); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return boost::multiprecision::number>(_s); - else - // Binary - return 0; // FAIL -} - -inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } - -inline std::string jsToDecimal(std::string const& _s) -{ - return dev::toString(jsToU256(_s)); -} -inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32) -{ - _s.resize(std::max(_s.size(), _padding)); - return "0x" + dev::toHex(_s); } -inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) -{ - return jsFromBinary(asBytes(_s), _padding); -} - -inline double jsFromFixed(std::string const& _s) -{ - return (double)jsToU256(_s) / (double)(dev::u256(1) << 128); -} - -} - -// devcrypto - -#include - -namespace dev -{ - -inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } -inline Secret jsToSecret(std::string const& _s) { return jsToFixed(_s); } - -} - - // ethcore namespace dev { namespace eth { -inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } - struct TransactionSkeleton { bool creation = false; diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c4628f4aa..c489c8f4a 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 833bc2b04..2d732325b 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,7 +22,7 @@ #pragma once #include -#include "CommonEth.h" +#include "Common.h" namespace dev { @@ -58,7 +58,7 @@ class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTr struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; struct InvalidSeedHash: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index fdf51f0d4..7006f6f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -27,7 +27,7 @@ #include #include #include -#include "CommonEth.h" +#include "Common.h" #include "BlockInfo.h" #define FAKE_DAGGER 1 diff --git a/libethereum/Account.cpp b/libethereum/Account.cpp index 74b6ebe7b..13eb0a8cd 100644 --- a/libethereum/Account.cpp +++ b/libethereum/Account.cpp @@ -20,7 +20,7 @@ */ #include "Account.h" -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/libethereum/AccountDiff.h b/libethereum/AccountDiff.h index 0c0ede4ae..dd494c0a5 100644 --- a/libethereum/AccountDiff.h +++ b/libethereum/AccountDiff.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace dev { diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 0c5587d2a..dbcab2580 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "BlockDetails.h" diff --git a/libethereum/BlockQueue.h b/libethereum/BlockQueue.h index 210b9eeb0..5eefa9d8e 100644 --- a/libethereum/BlockQueue.h +++ b/libethereum/BlockQueue.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include namespace dev diff --git a/libethereum/CanonBlockChain.h b/libethereum/CanonBlockChain.h index d9739097a..7110dbc90 100644 --- a/libethereum/CanonBlockChain.h +++ b/libethereum/CanonBlockChain.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "BlockDetails.h" diff --git a/libethereum/EthereumHost.h b/libethereum/EthereumHost.h index dfa928675..16c7056ca 100644 --- a/libethereum/EthereumHost.h +++ b/libethereum/EthereumHost.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include "CommonNet.h" #include "EthereumPeer.h" diff --git a/libethereum/EthereumPeer.h b/libethereum/EthereumPeer.h index 71bfc544f..94142ef86 100644 --- a/libethereum/EthereumPeer.h +++ b/libethereum/EthereumPeer.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include "CommonNet.h" #include "DownloadMan.h" diff --git a/libethereum/Executive.h b/libethereum/Executive.h index bb5563604..2e89f0623 100644 --- a/libethereum/Executive.h +++ b/libethereum/Executive.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include "Transaction.h" diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 2ff270de5..d63cd943a 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "State.h" diff --git a/libethereum/LogFilter.h b/libethereum/LogFilter.h index 5f68cd5d0..7b8922a03 100644 --- a/libethereum/LogFilter.h +++ b/libethereum/LogFilter.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include "TransactionReceipt.h" namespace dev diff --git a/libethereum/Miner.h b/libethereum/Miner.h index fd449e995..bdd49abb9 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "State.h" namespace dev diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 6e0d4756c..62d159418 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using namespace std; using namespace dev; diff --git a/libethereum/Transaction.h b/libethereum/Transaction.h index a9044970f..7dd28f7c6 100644 --- a/libethereum/Transaction.h +++ b/libethereum/Transaction.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace dev { diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 22a420602..b58944e4f 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -23,7 +23,7 @@ #include #include -#include "libethcore/CommonEth.h" +#include "libethcore/Common.h" #include namespace dev diff --git a/libethereum/Utility.cpp b/libethereum/Utility.cpp index 31c5e278a..7b0a961b2 100644 --- a/libethereum/Utility.cpp +++ b/libethereum/Utility.cpp @@ -22,7 +22,7 @@ #include "Utility.h" #include -#include +#include #include using namespace std; using namespace dev; diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 1bca3e2b2..9a49db113 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace dev diff --git a/libevm/VM.h b/libevm/VM.h index f100badc4..f2c773e4b 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/mix/QEther.h b/mix/QEther.h index 794ba2ba1..f50c39e7c 100644 --- a/mix/QEther.h +++ b/mix/QEther.h @@ -23,7 +23,7 @@ #pragma once #include -#include +#include #include "QBigInt.h" namespace dev diff --git a/rlp/main.cpp b/rlp/main.cpp index c3c04535b..85c08e0e6 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -22,11 +22,9 @@ #include #include #include -#include #include #include #include -#include "base64.h" using namespace std; using namespace dev; @@ -218,7 +216,7 @@ int main(int argc, char** argv) boost::algorithm::replace_all(s, " ", ""); boost::algorithm::replace_all(s, "\n", ""); boost::algorithm::replace_all(s, "\t", ""); - b = base64_decode(s); + b = fromBase64(s); break; } default: @@ -228,60 +226,60 @@ int main(int argc, char** argv) try { - RLP rlp(b); - switch (mode) - { - case Mode::ListArchive: - { - if (!rlp.isList()) + RLP rlp(b); + switch (mode) { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); - } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ListArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; - } - break; - } - case Mode::ExtractArchive: - { - if (!rlp.isList()) - { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ExtractArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - ofstream fout; - fout.open(toString(sha3(i.data()))); - fout.write(reinterpret_cast(i.data().data()), i.data().size()); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; } - break; - } - case Mode::Render: - { - RLPStreamer s(cout, prefs); - s.output(rlp); - cout << endl; - break; - } - default:; - } } catch (...) { diff --git a/test/MemTrie.cpp b/test/MemTrie.cpp index c3a44e1e5..ab5a13b60 100644 --- a/test/MemTrie.cpp +++ b/test/MemTrie.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/TrieHash.cpp b/test/TrieHash.cpp index ee4f2e87d..ccf12c162 100644 --- a/test/TrieHash.cpp +++ b/test/TrieHash.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/commonjs.cpp b/test/commonjs.cpp index 041a14f68..72582c540 100644 --- a/test/commonjs.cpp +++ b/test/commonjs.cpp @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(jsToAddress) cnote << "Testing jsToPublic..."; KeyPair kp = KeyPair::create(); string string = toJS(kp.address()); - Address address = dev::eth::jsToAddress(string); + Address address = dev::jsToAddress(string); BOOST_CHECK_EQUAL(kp.address(), address); } diff --git a/third/MainWin.h b/third/MainWin.h index 513cfe96e..2f8f95f0e 100644 --- a/third/MainWin.h +++ b/third/MainWin.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace Ui { From 369abf4294b7a556a9520c07d0702a3d40030bfe Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Tue, 3 Mar 2015 18:11:10 +0100 Subject: [PATCH 064/313] to include source lines in output stream AssemblyItem's appropriate function is now receiving the map of fileNames to sourceCodes as argument. --- libevmcore/Assembly.cpp | 3 ++- libevmcore/Assembly.h | 6 +----- libsolidity/Compiler.h | 7 +++++-- libsolidity/CompilerContext.h | 5 ++++- libsolidity/CompilerStack.cpp | 4 ++-- libsolidity/CompilerStack.h | 7 +++---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 80ac8c68f..0a568cbfb 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -171,8 +171,9 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i) return _out; } -ostream& Assembly::streamRLP(ostream& _out, string const& _prefix) const +ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap _sourceCodes) const { + (void)_sourceCodes; _out << _prefix << ".code:" << endl; for (AssemblyItem const& i: m_items) switch (i.m_type) diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 73d2b663c..8bab175a8 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -100,9 +100,7 @@ public: AssemblyItem appendJumpI() { auto ret = append(newPushTag()); append(Instruction::JUMPI); return ret; } AssemblyItem appendJump(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(Instruction::JUMP); return ret; } AssemblyItem appendJumpI(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(Instruction::JUMPI); return ret; } - template Assembly& operator<<(T const& _d) { append(_d); return *this; } - AssemblyItems const& getItems() const { return m_items; } AssemblyItem const& back() const { return m_items.back(); } std::string backString() const { return m_items.size() && m_items.back().m_type == PushString ? m_strings.at((h256)m_items.back().m_data) : std::string(); } @@ -116,16 +114,14 @@ public: void popTo(int _deposit) { while (m_deposit > _deposit) append(Instruction::POP); } void injectStart(AssemblyItem const& _i); - std::string out() const { std::stringstream ret; streamRLP(ret); return ret.str(); } - int deposit() const { return m_deposit; } void adjustDeposit(int _adjustment) { m_deposit += _adjustment; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); } void setDeposit(int _deposit) { m_deposit = _deposit; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); } bytes assemble() const; Assembly& optimise(bool _enable); - std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "") const; + std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "", StringMap _sourceCodes = StringMap()) const; private: void donePath() { if (m_totalDeposit != INT_MAX && m_totalDeposit != m_deposit) BOOST_THROW_EXCEPTION(InvalidDeposit()); } diff --git a/libsolidity/Compiler.h b/libsolidity/Compiler.h index 2804e8eca..76f16f3ab 100644 --- a/libsolidity/Compiler.h +++ b/libsolidity/Compiler.h @@ -41,8 +41,11 @@ public: std::map const& _contracts); bytes getAssembledBytecode() { return m_context.getAssembledBytecode(m_optimize); } bytes getRuntimeBytecode() { return m_runtimeContext.getAssembledBytecode(m_optimize);} - void streamAssembly(std::ostream& _stream) const { m_context.streamAssembly(_stream); } - + /// @arg _sourceCodes is the map of input files to source code strings + void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const + { + m_context.streamAssembly(_stream, _sourceCodes); + } /// @returns Assembly items of the normal compiler context eth::AssemblyItems const& getAssemblyItems() const { return m_context.getAssembly().getItems(); } /// @returns Assembly items of the runtime compiler context diff --git a/libsolidity/CompilerContext.h b/libsolidity/CompilerContext.h index 301ef1468..e42e7c76c 100644 --- a/libsolidity/CompilerContext.h +++ b/libsolidity/CompilerContext.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace dev { namespace solidity { @@ -118,7 +119,9 @@ public: CompilerContext& operator<<(bytes const& _data); eth::Assembly const& getAssembly() const { return m_asm; } - void streamAssembly(std::ostream& _stream) const { _stream << m_asm; } + /// @arg _sourceCodes is the map of input files to source code strings + void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const { m_asm.streamRLP(_stream, "", _sourceCodes); } + bytes getAssembledBytecode(bool _optimize = false) { return m_asm.optimise(_optimize).assemble(); } /** diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 10504a245..a878bb61a 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -180,9 +180,9 @@ dev::h256 CompilerStack::getContractCodeHash(string const& _contractName) const return dev::sha3(getRuntimeBytecode(_contractName)); } -void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName) const +void CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const { - getContract(_contractName).compiler->streamAssembly(_outStream); + getContract(_contractName).compiler->streamAssembly(_outStream, _sourceCodes); } string const& CompilerStack::getInterface(string const& _contractName) const diff --git a/libsolidity/CompilerStack.h b/libsolidity/CompilerStack.h index 2f34ab722..1cf576ab4 100644 --- a/libsolidity/CompilerStack.h +++ b/libsolidity/CompilerStack.h @@ -59,8 +59,6 @@ enum class DocumentationType: uint8_t ABISolidityInterface }; -extern const std::map StandardSources; - /** * Easy to use and self-contained Solidity compiler with as few header dependencies as possible. * It holds state and can be used to either step through the compilation stages (and abort e.g. @@ -74,7 +72,7 @@ public: /// Adds a source object (e.g. file) to the parser. After this, parse has to be called again. /// @returns true if a source object by the name already existed and was replaced. - void addSources(std::map const& _nameContents, bool _isLibrary = false) { for (auto const& i: _nameContents) addSource(i.first, i.second, _isLibrary); } + void addSources(StringMap const& _nameContents, bool _isLibrary = false) { for (auto const& i: _nameContents) addSource(i.first, i.second, _isLibrary); } bool addSource(std::string const& _name, std::string const& _content, bool _isLibrary = false); void setSource(std::string const& _sourceCode); /// Parses all source units that were added @@ -103,8 +101,9 @@ public: dev::h256 getContractCodeHash(std::string const& _contractName = "") const; /// Streams a verbose version of the assembly to @a _outStream. + /// @arg _sourceCodes is the map of input files to source code strings /// Prerequisite: Successful compilation. - void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "") const; + void streamAssembly(std::ostream& _outStream, std::string const& _contractName = "", StringMap _sourceCodes = StringMap()) const; /// Returns a string representing the contract interface in JSON. /// Prerequisite: Successful call to parse or compile. From 18176ea3e4c5957c61adbfa10be5ea8301bf46c1 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Wed, 4 Mar 2015 18:01:23 +0100 Subject: [PATCH 065/313] added source code printing for each output line. some changes after pr review --- libevmcore/Assembly.cpp | 53 ++++++++++++++++++++++++++--------- libevmcore/Assembly.h | 5 ++-- solc/CommandLineInterface.cpp | 4 +-- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 0a568cbfb..7f6a16116 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -21,6 +21,8 @@ #include "Assembly.h" +#include + #include using namespace std; @@ -171,49 +173,74 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i) return _out; } -ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap _sourceCodes) const +string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const +{ + if (_location.isEmpty() || _sourceCodes.empty() || _location.start >= _location.end || _location.start < 0) + return ""; + + auto it = _sourceCodes.find(*_location.sourceName); + if (it == _sourceCodes.end()) + return ""; + + string toReturn = it->second; + if (_location.start >= (int)toReturn.size()) + return ""; + + toReturn = toReturn.substr(_location.start, _location.end - _location.start); + auto newLinePos = toReturn.find_first_of("\n"); + if (newLinePos != string::npos && newLinePos != toReturn.size() - 1) + toReturn = toReturn.substr(0, newLinePos) + "..."; + + return move(toReturn); +} + +ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const { - (void)_sourceCodes; _out << _prefix << ".code:" << endl; for (AssemblyItem const& i: m_items) + { + string sourceLine = getLocationFromSources(_sourceCodes, i.getLocation()); + _out << _prefix; switch (i.m_type) { case Operation: - _out << _prefix << " " << instructionInfo((Instruction)(byte)i.m_data).name << endl; + _out << " " << instructionInfo((Instruction)(byte)i.m_data).name; break; case Push: - _out << _prefix << " PUSH " << i.m_data << endl; + _out << " PUSH " << i.m_data; break; case PushString: - _out << _prefix << " PUSH \"" << m_strings.at((h256)i.m_data) << "\"" << endl; + _out << " PUSH \"" << m_strings.at((h256)i.m_data) << "\""; break; case PushTag: - _out << _prefix << " PUSH [tag" << i.m_data << "]" << endl; + _out << " PUSH [tag" << i.m_data << "]"; break; case PushSub: - _out << _prefix << " PUSH [$" << h256(i.m_data).abridged() << "]" << endl; + _out << " PUSH [$" << h256(i.m_data).abridged() << "]"; break; case PushSubSize: - _out << _prefix << " PUSH #[$" << h256(i.m_data).abridged() << "]" << endl; + _out << " PUSH #[$" << h256(i.m_data).abridged() << "]"; break; case PushProgramSize: - _out << _prefix << " PUSHSIZE" << endl; + _out << " PUSHSIZE"; break; case Tag: - _out << _prefix << "tag" << i.m_data << ": " << endl << _prefix << " JUMPDEST" << endl; + _out << "tag" << i.m_data << ": " << endl << _prefix << " JUMPDEST"; break; case PushData: - _out << _prefix << " PUSH [" << hex << (unsigned)i.m_data << "]" << endl; + _out << " PUSH [" << hex << (unsigned)i.m_data << "]"; break; case NoOptimizeBegin: - _out << _prefix << "DoNotOptimze{{" << endl; + _out << "DoNotOptimze{{"; break; case NoOptimizeEnd: - _out << _prefix << "DoNotOptimze}}" << endl; + _out << "DoNotOptimze}}"; break; default: BOOST_THROW_EXCEPTION(InvalidOpcode()); } + _out << string(20, ' ') << sourceLine << endl; + } if (!m_data.empty() || !m_subs.empty()) { diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index 8bab175a8..bd2c87f4c 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -121,9 +121,10 @@ public: bytes assemble() const; Assembly& optimise(bool _enable); - std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "", StringMap _sourceCodes = StringMap()) const; + std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap()) const; -private: +protected: + std::string getLocationFromSources(const StringMap &_sourceCodes, const SourceLocation &_location) const; void donePath() { if (m_totalDeposit != INT_MAX && m_totalDeposit != m_deposit) BOOST_THROW_EXCEPTION(InvalidDeposit()); } unsigned bytesRequired() const; diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index db12231a7..08acb5ebd 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -424,13 +424,13 @@ void CommandLineInterface::actOnInput() if (outputToStdout(choice)) { cout << "EVM assembly:" << endl; - m_compiler->streamAssembly(cout, contract); + m_compiler->streamAssembly(cout, contract, m_sourceCodes); } if (outputToFile(choice)) { ofstream outFile(contract + ".evm"); - m_compiler->streamAssembly(outFile, contract); + m_compiler->streamAssembly(outFile, contract, m_sourceCodes); outFile.close(); } } From 1e2aebbe1bf0908f81b5274eff9f69292c6da0cf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 12:48:28 +0100 Subject: [PATCH 066/313] Make RLP JSON compatible by default. --- rlp/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 85c08e0e6..663bbf14d 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -36,6 +36,7 @@ void help() << " -r,--render Render the given RLP. Options:" << endl << " --indent Use string as the level indentation (default ' ')." << endl << " --hex-ints Render integers in hex." << endl + << " --ascii-strings Render data as C-style strings or hex depending on content being ASCII." << endl << " --force-string Force all data to be rendered as C-style strings." << endl << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl << " --force-hex Force all data to be rendered as raw hex." << endl @@ -86,7 +87,7 @@ public: { string indent = " "; bool hexInts = false; - bool forceString = false; + bool forceString = true; bool escapeAll = false; bool forceHex = false; }; @@ -150,6 +151,8 @@ int main(int argc, char** argv) prefs.indent = argv[++i]; else if (arg == "--hex-ints") prefs.hexInts = true; + else if (arg == "--ascii-strings") + prefs.forceString = prefs.forceHex = false; else if (arg == "--force-string") prefs.forceString = true; else if (arg == "--force-hex") From a3b95811d44d711c0774169c65d0ba001687751e Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 3 Mar 2015 17:55:28 +0100 Subject: [PATCH 067/313] Index access for calldata arrays. --- libsolidity/AST.cpp | 7 +- libsolidity/ArrayUtils.cpp | 39 ++++++++--- libsolidity/Compiler.cpp | 2 +- libsolidity/CompilerUtils.cpp | 23 ++++--- libsolidity/CompilerUtils.h | 8 ++- libsolidity/ExpressionCompiler.cpp | 101 ++++++++++++++++++++++++----- libsolidity/LValue.cpp | 59 ++++++++++++++++- libsolidity/LValue.h | 25 +++++-- test/SolidityEndToEndTest.cpp | 59 +++++++++++++++++ 9 files changed, 273 insertions(+), 50 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index aba355768..3a0aed119 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -671,8 +671,11 @@ void IndexAccess::checkTypeRequirements() if (!m_index) BOOST_THROW_EXCEPTION(createTypeError("Index expression cannot be omitted.")); m_index->expectType(IntegerType(256)); - m_type = type.getBaseType(); - m_isLValue = true; + if (type.isByteArray()) + m_type = make_shared(8, IntegerType::Modifier::Hash); + else + m_type = type.getBaseType(); + m_isLValue = type.getLocation() != ArrayType::Location::CallData; break; } case Type::Category::Mapping: diff --git a/libsolidity/ArrayUtils.cpp b/libsolidity/ArrayUtils.cpp index 43cc6fd49..0dea5345c 100644 --- a/libsolidity/ArrayUtils.cpp +++ b/libsolidity/ArrayUtils.cpp @@ -70,22 +70,25 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons m_context << eth::Instruction::ISZERO; eth::AssemblyItem copyLoopEnd = m_context.newTag(); m_context.appendConditionalJumpTo(copyLoopEnd); + // add length to source offset + m_context << eth::Instruction::DUP5 << eth::Instruction::DUP5 << eth::Instruction::ADD; + // stack now: source_offset source_len target_ref target_data_end target_data_ref source_end // store start offset - m_context << eth::Instruction::DUP5; - // stack now: source_offset source_len target_ref target_data_end target_data_ref calldata_offset + m_context << eth::Instruction::DUP6; + // stack now: source_offset source_len target_ref target_data_end target_data_ref source_end calldata_offset eth::AssemblyItem copyLoopStart = m_context.newTag(); m_context << copyLoopStart // copy from calldata and store << eth::Instruction::DUP1 << eth::Instruction::CALLDATALOAD - << eth::Instruction::DUP3 << eth::Instruction::SSTORE + << eth::Instruction::DUP4 << eth::Instruction::SSTORE // increment target_data_ref by 1 - << eth::Instruction::SWAP1 << u256(1) << eth::Instruction::ADD + << eth::Instruction::SWAP2 << u256(1) << eth::Instruction::ADD // increment calldata_offset by 32 - << eth::Instruction::SWAP1 << u256(32) << eth::Instruction::ADD + << eth::Instruction::SWAP2 << u256(32) << eth::Instruction::ADD // check for loop condition - << eth::Instruction::DUP1 << eth::Instruction::DUP6 << eth::Instruction::GT; + << eth::Instruction::DUP1 << eth::Instruction::DUP3 << eth::Instruction::GT; m_context.appendConditionalJumpTo(copyLoopStart); - m_context << eth::Instruction::POP; + m_context << eth::Instruction::POP << eth::Instruction::POP; m_context << copyLoopEnd; // now clear leftover bytes of the old value @@ -179,6 +182,7 @@ void ArrayUtils::clearArray(ArrayType const& _type) const m_context << eth::Instruction::POP; else if (_type.getLength() < 5) // unroll loop for small arrays @todo choose a good value { + solAssert(!_type.isByteArray(), ""); for (unsigned i = 1; i < _type.getLength(); ++i) { StorageItem(m_context, *_type.getBaseType()).setToZero(SourceLocation(), false); @@ -188,6 +192,7 @@ void ArrayUtils::clearArray(ArrayType const& _type) const } else { + solAssert(!_type.isByteArray(), ""); m_context << eth::Instruction::DUP1 << u256(_type.getLength()) << u256(_type.getBaseType()->getStorageSize()) @@ -296,9 +301,23 @@ void ArrayUtils::convertLengthToSize(ArrayType const& _arrayType) const void ArrayUtils::retrieveLength(ArrayType const& _arrayType) const { - if (_arrayType.isDynamicallySized()) - m_context << eth::Instruction::DUP1 << eth::Instruction::SLOAD; - else + if (!_arrayType.isDynamicallySized()) m_context << _arrayType.getLength(); + else + { + m_context << eth::Instruction::DUP1; + switch (_arrayType.getLocation()) + { + case ArrayType::Location::CallData: + // length is stored on the stack + break; + case ArrayType::Location::Memory: + m_context << eth::Instruction::MLOAD; + break; + case ArrayType::Location::Storage: + m_context << eth::Instruction::SLOAD; + break; + } + } } diff --git a/libsolidity/Compiler.cpp b/libsolidity/Compiler.cpp index acc30cf35..c880d49d1 100644 --- a/libsolidity/Compiler.cpp +++ b/libsolidity/Compiler.cpp @@ -260,7 +260,7 @@ void Compiler::appendReturnValuePacker(TypePointers const& _typeParameters) for (TypePointer const& type: _typeParameters) { - CompilerUtils(m_context).copyToStackTop(stackDepth, *type); + CompilerUtils(m_context).copyToStackTop(stackDepth, type->getSizeOnStack()); ExpressionCompiler(m_context, m_optimize).appendTypeConversion(*type, *type, true); bool const c_padToWords = true; dataOffset += CompilerUtils(m_context).storeInMemory(dataOffset, *type, c_padToWords); diff --git a/libsolidity/CompilerUtils.cpp b/libsolidity/CompilerUtils.cpp index 826651e61..acb6412f9 100644 --- a/libsolidity/CompilerUtils.cpp +++ b/libsolidity/CompilerUtils.cpp @@ -41,18 +41,22 @@ unsigned CompilerUtils::loadFromMemory(unsigned _offset, Type const& _type, return loadFromMemoryHelper(_type, _fromCalldata, _padToWordBoundaries); } -void CompilerUtils::loadFromMemoryDynamic(Type const& _type, bool _fromCalldata, bool _padToWordBoundaries) +void CompilerUtils::loadFromMemoryDynamic( + Type const& _type, bool _fromCalldata, bool _padToWordBoundaries, bool _keepUpdatedMemoryOffset) { solAssert(_type.getCategory() != Type::Category::Array, "Arrays not yet implemented."); - m_context << eth::Instruction::DUP1; + if (_keepUpdatedMemoryOffset) + m_context << eth::Instruction::DUP1; unsigned numBytes = loadFromMemoryHelper(_type, _fromCalldata, _padToWordBoundaries); - // update memory counter - for (unsigned i = 0; i < _type.getSizeOnStack(); ++i) - m_context << eth::swapInstruction(1 + i); - m_context << u256(numBytes) << eth::Instruction::ADD; + if (_keepUpdatedMemoryOffset) + { + // update memory counter + for (unsigned i = 0; i < _type.getSizeOnStack(); ++i) + m_context << eth::swapInstruction(1 + i); + m_context << u256(numBytes) << eth::Instruction::ADD; + } } - unsigned CompilerUtils::storeInMemory(unsigned _offset, Type const& _type, bool _padToWordBoundaries) { solAssert(_type.getCategory() != Type::Category::Array, "Unable to statically store dynamic type."); @@ -134,12 +138,11 @@ void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable) m_context << eth::swapInstruction(stackPosition - size + 1) << eth::Instruction::POP; } -void CompilerUtils::copyToStackTop(unsigned _stackDepth, Type const& _type) +void CompilerUtils::copyToStackTop(unsigned _stackDepth, unsigned _itemSize) { if (_stackDepth > 16) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Stack too deep.")); - unsigned const size = _type.getSizeOnStack(); - for (unsigned i = 0; i < size; ++i) + for (unsigned i = 0; i < _itemSize; ++i) m_context << eth::dupInstruction(_stackDepth); } diff --git a/libsolidity/CompilerUtils.h b/libsolidity/CompilerUtils.h index 2df85f11c..b06f2c7a5 100644 --- a/libsolidity/CompilerUtils.h +++ b/libsolidity/CompilerUtils.h @@ -46,7 +46,8 @@ public: /// Dynamic version of @see loadFromMemory, expects the memory offset on the stack. /// Stack pre: memory_offset /// Stack post: value... (memory_offset+length) - void loadFromMemoryDynamic(Type const& _type, bool _fromCalldata = false, bool _padToWordBoundaries = true); + void loadFromMemoryDynamic(Type const& _type, bool _fromCalldata = false, + bool _padToWordBoundaries = true, bool _keepUpdatedMemoryOffset = true); /// Stores data from stack in memory. /// @param _offset offset in memory /// @param _type type of the data on the stack @@ -65,8 +66,9 @@ public: /// Moves the value that is at the top of the stack to a stack variable. void moveToStackVariable(VariableDeclaration const& _variable); - /// Copies a variable of type @a _type from a stack depth of @a _stackDepth to the top of the stack. - void copyToStackTop(unsigned _stackDepth, Type const& _type); + /// Copies an item that occupies @a _itemSize stack slots from a stack depth of @a _stackDepth + /// to the top of the stack. + void copyToStackTop(unsigned _stackDepth, unsigned _itemSize); /// Removes the current value from the top of the stack. void popStackElement(Type const& _type); diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 619b06738..793bd55e4 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -215,12 +215,20 @@ bool ExpressionCompiler::visit(Assignment const& _assignment) if (op != Token::Assign) // compound assignment { solAssert(_assignment.getType()->isValueType(), "Compound operators not implemented for non-value types."); - if (m_currentLValue->storesReferenceOnStack()) - m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2; + unsigned lvalueSize = m_currentLValue->sizeOnStack(); + unsigned itemSize = _assignment.getType()->getSizeOnStack(); + if (lvalueSize > 0) + { + CompilerUtils(m_context).copyToStackTop(lvalueSize + itemSize, itemSize); + CompilerUtils(m_context).copyToStackTop(itemSize + lvalueSize, lvalueSize); + // value lvalue_ref value lvalue_ref + } m_currentLValue->retrieveValue(_assignment.getLocation(), true); appendOrdinaryBinaryOperatorCode(Token::AssignmentToBinaryOp(op), *_assignment.getType()); - if (m_currentLValue->storesReferenceOnStack()) - m_context << eth::Instruction::SWAP1; + if (lvalueSize > 0) + // value [lvalue_ref] updated_value + for (unsigned i = 0; i < itemSize; ++i) + m_context << eth::swapInstruction(itemSize + lvalueSize) << eth::Instruction::POP; } m_currentLValue->storeValue(*_assignment.getRightHandSide().getType(), _assignment.getLocation()); m_currentLValue.reset(); @@ -259,9 +267,10 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) case Token::Dec: // -- (pre- or postfix) solAssert(!!m_currentLValue, "LValue not retrieved."); m_currentLValue->retrieveValue(_unaryOperation.getLocation()); + solAssert(m_currentLValue->sizeOnStack() <= 1, "Not implemented."); if (!_unaryOperation.isPrefixOperation()) { - if (m_currentLValue->storesReferenceOnStack()) + if (m_currentLValue->sizeOnStack() == 1) m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2; else m_context << eth::Instruction::DUP1; @@ -273,7 +282,7 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) m_context << eth::Instruction::SWAP1 << eth::Instruction::SUB; // @todo avoid the swap // Stack for prefix: [ref] (*ref)+-1 // Stack for postfix: *ref [ref] (*ref)+-1 - if (m_currentLValue->storesReferenceOnStack()) + if (m_currentLValue->sizeOnStack() == 1) m_context << eth::Instruction::SWAP1; m_currentLValue->storeValue( *_unaryOperation.getType(), _unaryOperation.getLocation(), @@ -714,18 +723,24 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) } else if (baseType.getCategory() == Type::Category::Array) { + // stack layout: [] ArrayType const& arrayType = dynamic_cast(baseType); - solAssert(arrayType.getLocation() == ArrayType::Location::Storage, - "TODO: Index acces only implemented for storage arrays."); - solAssert(!arrayType.isByteArray(), "TODO: Index acces not implemented for byte arrays."); solAssert(_indexAccess.getIndexExpression(), "Index expression expected."); + ArrayType::Location location = arrayType.getLocation(); + eth::Instruction load = + location == ArrayType::Location::Storage ? eth::Instruction::SLOAD : + location == ArrayType::Location::Memory ? eth::Instruction::MLOAD : + eth::Instruction::CALLDATALOAD; _indexAccess.getIndexExpression()->accept(*this); // retrieve length - if (arrayType.isDynamicallySized()) - m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD; - else + if (!arrayType.isDynamicallySized()) m_context << arrayType.getLength(); + else if (location == ArrayType::Location::CallData) + // length is stored on the stack + m_context << eth::Instruction::SWAP1; + else + m_context << eth::Instruction::DUP2 << load; // stack: // check out-of-bounds access m_context << eth::Instruction::DUP2 << eth::Instruction::LT; @@ -735,14 +750,64 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) m_context << legalAccess; // stack: - m_context << arrayType.getBaseType()->getStorageSize() << eth::Instruction::MUL; - if (arrayType.isDynamicallySized()) + if (arrayType.isByteArray()) + // byte array is packed differently, especially in storage + switch (location) + { + case ArrayType::Location::Storage: + // byte array index storage lvalue on stack (goal): + // = + m_context << u256(32) << eth::Instruction::SWAP2; + CompilerUtils(m_context).computeHashStatic(); + // stack: 32 index data_ref + m_context + << eth::Instruction::DUP3 << eth::Instruction::DUP3 + << eth::Instruction::DIV << eth::Instruction::ADD + // stack: 32 index (data_ref + index / 32) + << eth::Instruction::SWAP2 << eth::Instruction::SWAP1 << eth::Instruction::MOD; + setLValue(_indexAccess); + break; + case ArrayType::Location::CallData: + // no lvalue, just retrieve the value + m_context + << eth::Instruction::ADD << eth::Instruction::CALLDATALOAD + << u256(0) << eth::Instruction::BYTE; + break; + case ArrayType::Location::Memory: + solAssert(false, "Memory lvalues not yet implemented."); + } + else { - m_context << eth::Instruction::SWAP1; - CompilerUtils(m_context).computeHashStatic(); + u256 elementSize = + location == ArrayType::Location::Storage ? arrayType.getBaseType()->getStorageSize() : + CompilerUtils::getPaddedSize(arrayType.getBaseType()->getCalldataEncodedSize()); + solAssert(elementSize != 0, "Invalid element size."); + if (elementSize > 1) + m_context << elementSize << eth::Instruction::MUL; + if (arrayType.isDynamicallySized()) + { + if (location == ArrayType::Location::Storage) + { + m_context << eth::Instruction::SWAP1; + CompilerUtils(m_context).computeHashStatic(); + } + else if (location == ArrayType::Location::Memory) + m_context << u256(32) << eth::Instruction::ADD; + } + m_context << eth::Instruction::ADD; + switch (location) + { + case ArrayType::Location::CallData: + // no lvalue + CompilerUtils(m_context).loadFromMemoryDynamic(*arrayType.getBaseType(), true, true, false); + break; + case ArrayType::Location::Storage: + setLValueToStorageItem(_indexAccess); + break; + case ArrayType::Location::Memory: + solAssert(false, "Memory lvalues not yet implemented."); + } } - m_context << eth::Instruction::ADD; - setLValueToStorageItem(_indexAccess); } else solAssert(false, "Index access only allowed for mappings or arrays."); diff --git a/libsolidity/LValue.cpp b/libsolidity/LValue.cpp index 452ca1c73..f57300202 100644 --- a/libsolidity/LValue.cpp +++ b/libsolidity/LValue.cpp @@ -232,6 +232,64 @@ void StorageItem::setToZero(SourceLocation const&, bool _removeReference) const } } +/// Used in StorageByteArrayElement +static IntegerType byteType(8, IntegerType::Modifier::Hash); + +StorageByteArrayElement::StorageByteArrayElement(CompilerContext& _compilerContext): + LValue(_compilerContext, byteType) +{ +} + +void StorageByteArrayElement::retrieveValue(SourceLocation const&, bool _remove) const +{ + // stack: ref bytenr + if (_remove) + m_context << eth::Instruction::SWAP1 << eth::Instruction::SLOAD + << eth::Instruction::SWAP1 << eth::Instruction::BYTE; + else + m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD + << eth::Instruction::DUP2 << eth::Instruction::BYTE; +} + +void StorageByteArrayElement::storeValue(Type const&, SourceLocation const&, bool _move) const +{ + //@todo optimize this + + // stack: value ref bytenr + m_context << u256(31) << eth::Instruction::SUB << u256(0x100) << eth::Instruction::EXP; + // stack: value ref (1<<(8*(31-bytenr))) + m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD; + // stack: value ref (1<<(8*(31-bytenr))) old_full_value + // clear byte in old value + m_context << eth::Instruction::DUP2 << u256(0xff) << eth::Instruction::MUL + << eth::Instruction::NOT << eth::Instruction::AND; + // stack: value ref (1<<(32-bytenr)) old_full_value_with_cleared_byte + m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP4 << eth::Instruction::MUL + << eth::Instruction::OR; + // stack: value ref new_full_value + m_context << eth::Instruction::SWAP1 << eth::Instruction::SSTORE; + if (_move) + m_context << eth::Instruction::POP; +} + +void StorageByteArrayElement::setToZero(SourceLocation const&, bool _removeReference) const +{ + // stack: ref bytenr + if (!_removeReference) + m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2; + m_context << u256(31) << eth::Instruction::SUB << u256(0x100) << eth::Instruction::EXP; + // stack: ref (1<<(8*(31-bytenr))) + m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD; + // stack: ref (1<<(8*(31-bytenr))) old_full_value + // clear byte in old value + m_context << eth::Instruction::SWAP1 << u256(0xff) << eth::Instruction::MUL << eth::Instruction::AND; + // stack: ref old_full_value_with_cleared_byte + m_context << eth::Instruction::SWAP1 << eth::Instruction::SSTORE; + if (!_removeReference) + m_context << eth::Instruction::SWAP1; + else + m_context << eth::Instruction::POP; +} StorageArrayLength::StorageArrayLength(CompilerContext& _compilerContext, const ArrayType& _arrayType): LValue(_compilerContext, *_arrayType.getMemberType("length")), @@ -262,4 +320,3 @@ void StorageArrayLength::setToZero(SourceLocation const&, bool _removeReference) m_context << eth::Instruction::DUP1; ArrayUtils(m_context).clearDynamicArray(m_arrayType); } - diff --git a/libsolidity/LValue.h b/libsolidity/LValue.h index 1ed0ae011..0ada4f88b 100644 --- a/libsolidity/LValue.h +++ b/libsolidity/LValue.h @@ -46,8 +46,8 @@ protected: m_context(_compilerContext), m_dataType(_dataType) {} public: - /// @returns true if this lvalue reference type occupies a slot on the stack. - virtual bool storesReferenceOnStack() const = 0; + /// @returns the number of stack slots occupied by the lvalue reference + virtual unsigned sizeOnStack() const { return 1; } /// Copies the value of the current lvalue to the top of the stack and, if @a _remove is true, /// also removes the reference from the stack. /// @a _location source location of the current expression, used for error reporting. @@ -76,7 +76,7 @@ class StackVariable: public LValue public: StackVariable(CompilerContext& _compilerContext, Declaration const& _declaration); - virtual bool storesReferenceOnStack() const { return false; } + virtual unsigned sizeOnStack() const override { return 0; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void storeValue(Type const& _sourceType, SourceLocation const& _location = SourceLocation(), bool _move = false) const override; @@ -100,7 +100,6 @@ public: StorageItem(CompilerContext& _compilerContext, Declaration const& _declaration); /// Constructs the LValue and assumes that the storage reference is already on the stack. StorageItem(CompilerContext& _compilerContext, Type const& _type); - virtual bool storesReferenceOnStack() const { return true; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void storeValue(Type const& _sourceType, SourceLocation const& _location = SourceLocation(), bool _move = false) const override; @@ -113,6 +112,23 @@ private: unsigned m_size; }; +/** + * Reference to a single byte inside a storage byte array. + * Stack: + */ +class StorageByteArrayElement: public LValue +{ +public: + /// Constructs the LValue and assumes that the storage reference is already on the stack. + StorageByteArrayElement(CompilerContext& _compilerContext); + virtual unsigned sizeOnStack() const override { return 2; } + virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; + virtual void storeValue(Type const& _sourceType, + SourceLocation const& _location = SourceLocation(), bool _move = false) const override; + virtual void setToZero( + SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const override; +}; + /** * Reference to the "length" member of a dynamically-sized array. This is an LValue with special * semantics since assignments to it might reduce its length and thus arrays members have to be @@ -123,7 +139,6 @@ class StorageArrayLength: public LValue public: /// Constructs the LValue, assumes that the reference to the array head is already on the stack. StorageArrayLength(CompilerContext& _compilerContext, ArrayType const& _arrayType); - virtual bool storesReferenceOnStack() const { return true; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; virtual void storeValue(Type const& _sourceType, SourceLocation const& _location = SourceLocation(), bool _move = false) const override; diff --git a/test/SolidityEndToEndTest.cpp b/test/SolidityEndToEndTest.cpp index 0b3836ade..dae0ca03a 100644 --- a/test/SolidityEndToEndTest.cpp +++ b/test/SolidityEndToEndTest.cpp @@ -2949,6 +2949,65 @@ BOOST_AUTO_TEST_CASE(array_copy_storage_storage_struct) BOOST_CHECK(m_state.storage(m_contractAddress).empty()); } +BOOST_AUTO_TEST_CASE(external_array_args) +{ + char const* sourceCode = R"( + contract c { + function test(uint[8] a, uint[] b, uint[5] c, uint a_index, uint b_index, uint c_index) + external returns (uint av, uint bv, uint cv) { + av = a[a_index]; + bv = b[b_index]; + cv = c[c_index]; + } + } + )"; + compileAndRun(sourceCode); + bytes params = encodeArgs( + 1, 2, 3, 4, 5, 6, 7, 8, // a + 3, // b.length + 21, 22, 23, 24, 25, // c + 0, 1, 2, // (a,b,c)_index + 11, 12, 13 // b + ); + BOOST_CHECK(callContractFunction("test(uint256[8],uint256[],uint256[5],uint256,uint256,uint256)", params) == encodeArgs(1, 12, 23)); +} + +BOOST_AUTO_TEST_CASE(bytes_index_access) +{ + char const* sourceCode = R"( + contract c { + bytes data; + function direct(bytes arg, uint index) external returns (uint) { + return uint(arg[index]); + } + function storageCopyRead(bytes arg, uint index) external returns (uint) { + data = arg; + return uint(data[index]); + } + function storageWrite() external returns (uint) { + data.length = 35; + data[31] = 0x77; + data[32] = 0x14; + + data[31] = 1; + data[31] |= 8; + data[30] = 1; + data[32] = 3; + return uint(data[30]) * 0x100 | uint(data[31]) * 0x10 | uint(data[32]); + } + } + )"; + compileAndRun(sourceCode); + string array{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33}; + BOOST_CHECK(callContractFunction("direct(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32)); + BOOST_CHECK(callContractFunction("storageCopyRead(bytes,uint256)", u256(array.length()), 32, array) == encodeArgs(32)); + BOOST_CHECK(callContractFunction("storageWrite()") == encodeArgs(0x193)); +} + BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base) { char const* sourceCode = R"( From 7584f387d40019189c60f8c9c57d71ae91fa8e1a Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 5 Mar 2015 15:41:39 +0100 Subject: [PATCH 068/313] Styling --- libsolidity/CompilerUtils.cpp | 14 +++++++--- libsolidity/CompilerUtils.h | 21 +++++++++++---- libsolidity/LValue.cpp | 16 ++++++------ libsolidity/LValue.h | 48 +++++++++++++++++++++++++---------- 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/libsolidity/CompilerUtils.cpp b/libsolidity/CompilerUtils.cpp index acb6412f9..7f8f72ca7 100644 --- a/libsolidity/CompilerUtils.cpp +++ b/libsolidity/CompilerUtils.cpp @@ -33,8 +33,12 @@ namespace solidity const unsigned int CompilerUtils::dataStartOffset = 4; -unsigned CompilerUtils::loadFromMemory(unsigned _offset, Type const& _type, - bool _fromCalldata, bool _padToWordBoundaries) +unsigned CompilerUtils::loadFromMemory( + unsigned _offset, + Type const& _type, + bool _fromCalldata, + bool _padToWordBoundaries +) { solAssert(_type.getCategory() != Type::Category::Array, "Unable to statically load dynamic type."); m_context << u256(_offset); @@ -42,7 +46,11 @@ unsigned CompilerUtils::loadFromMemory(unsigned _offset, Type const& _type, } void CompilerUtils::loadFromMemoryDynamic( - Type const& _type, bool _fromCalldata, bool _padToWordBoundaries, bool _keepUpdatedMemoryOffset) + Type const& _type, + bool _fromCalldata, + bool _padToWordBoundaries, + bool _keepUpdatedMemoryOffset +) { solAssert(_type.getCategory() != Type::Category::Array, "Arrays not yet implemented."); if (_keepUpdatedMemoryOffset) diff --git a/libsolidity/CompilerUtils.h b/libsolidity/CompilerUtils.h index b06f2c7a5..24ebbc81f 100644 --- a/libsolidity/CompilerUtils.h +++ b/libsolidity/CompilerUtils.h @@ -41,20 +41,31 @@ public: /// @param _fromCalldata if true, load from calldata, not from memory /// @param _padToWordBoundaries if true, assume the data is padded to word (32 byte) boundaries /// @returns the number of bytes consumed in memory. - unsigned loadFromMemory(unsigned _offset, Type const& _type = IntegerType(256), - bool _fromCalldata = false, bool _padToWordBoundaries = false); + unsigned loadFromMemory( + unsigned _offset, + Type const& _type = IntegerType(256), + bool _fromCalldata = false, + bool _padToWordBoundaries = false + ); /// Dynamic version of @see loadFromMemory, expects the memory offset on the stack. /// Stack pre: memory_offset /// Stack post: value... (memory_offset+length) - void loadFromMemoryDynamic(Type const& _type, bool _fromCalldata = false, - bool _padToWordBoundaries = true, bool _keepUpdatedMemoryOffset = true); + void loadFromMemoryDynamic( + Type const& _type, + bool _fromCalldata = false, + bool _padToWordBoundaries = true, + bool _keepUpdatedMemoryOffset = true + ); /// Stores data from stack in memory. /// @param _offset offset in memory /// @param _type type of the data on the stack /// @param _padToWordBoundaries if true, pad the data to word (32 byte) boundaries /// @returns the number of bytes written to memory (can be different from _bytes if /// _padToWordBoundaries is true) - unsigned storeInMemory(unsigned _offset, Type const& _type = IntegerType(256), bool _padToWordBoundaries = false); + unsigned storeInMemory(unsigned _offset, + Type const& _type = IntegerType(256), + bool _padToWordBoundaries = false + ); /// Dynamic version of @see storeInMemory, expects the memory offset below the value on the stack /// and also updates that. /// Stack pre: memory_offset value... diff --git a/libsolidity/LValue.cpp b/libsolidity/LValue.cpp index f57300202..7a81ff927 100644 --- a/libsolidity/LValue.cpp +++ b/libsolidity/LValue.cpp @@ -242,7 +242,7 @@ StorageByteArrayElement::StorageByteArrayElement(CompilerContext& _compilerConte void StorageByteArrayElement::retrieveValue(SourceLocation const&, bool _remove) const { - // stack: ref bytenr + // stack: ref byte_number if (_remove) m_context << eth::Instruction::SWAP1 << eth::Instruction::SLOAD << eth::Instruction::SWAP1 << eth::Instruction::BYTE; @@ -255,15 +255,15 @@ void StorageByteArrayElement::storeValue(Type const&, SourceLocation const&, boo { //@todo optimize this - // stack: value ref bytenr + // stack: value ref byte_number m_context << u256(31) << eth::Instruction::SUB << u256(0x100) << eth::Instruction::EXP; - // stack: value ref (1<<(8*(31-bytenr))) + // stack: value ref (1<<(8*(31-byte_number))) m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD; - // stack: value ref (1<<(8*(31-bytenr))) old_full_value + // stack: value ref (1<<(8*(31-byte_number))) old_full_value // clear byte in old value m_context << eth::Instruction::DUP2 << u256(0xff) << eth::Instruction::MUL << eth::Instruction::NOT << eth::Instruction::AND; - // stack: value ref (1<<(32-bytenr)) old_full_value_with_cleared_byte + // stack: value ref (1<<(32-byte_number)) old_full_value_with_cleared_byte m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP4 << eth::Instruction::MUL << eth::Instruction::OR; // stack: value ref new_full_value @@ -274,13 +274,13 @@ void StorageByteArrayElement::storeValue(Type const&, SourceLocation const&, boo void StorageByteArrayElement::setToZero(SourceLocation const&, bool _removeReference) const { - // stack: ref bytenr + // stack: ref byte_number if (!_removeReference) m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2; m_context << u256(31) << eth::Instruction::SUB << u256(0x100) << eth::Instruction::EXP; - // stack: ref (1<<(8*(31-bytenr))) + // stack: ref (1<<(8*(31-byte_number))) m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD; - // stack: ref (1<<(8*(31-bytenr))) old_full_value + // stack: ref (1<<(8*(31-byte_number))) old_full_value // clear byte in old value m_context << eth::Instruction::SWAP1 << u256(0xff) << eth::Instruction::MUL << eth::Instruction::AND; // stack: ref old_full_value_with_cleared_byte diff --git a/libsolidity/LValue.h b/libsolidity/LValue.h index 0ada4f88b..c57c80e37 100644 --- a/libsolidity/LValue.h +++ b/libsolidity/LValue.h @@ -61,7 +61,9 @@ public: /// Stores zero in the lvalue. Removes the reference from the stack if @a _removeReference is true. /// @a _location is the source location of the requested operation virtual void setToZero( - SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const = 0; + SourceLocation const& _location = SourceLocation(), + bool _removeReference = true + ) const = 0; protected: CompilerContext& m_context; @@ -78,10 +80,15 @@ public: virtual unsigned sizeOnStack() const override { return 0; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; - virtual void storeValue(Type const& _sourceType, - SourceLocation const& _location = SourceLocation(), bool _move = false) const override; + virtual void storeValue( + Type const& _sourceType, + SourceLocation const& _location = SourceLocation(), + bool _move = false + ) const override; virtual void setToZero( - SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const override; + SourceLocation const& _location = SourceLocation(), + bool _removeReference = true + ) const override; private: /// Base stack offset (@see CompilerContext::getBaseStackOffsetOfVariable) of the local variable. @@ -101,10 +108,15 @@ public: /// Constructs the LValue and assumes that the storage reference is already on the stack. StorageItem(CompilerContext& _compilerContext, Type const& _type); virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; - virtual void storeValue(Type const& _sourceType, - SourceLocation const& _location = SourceLocation(), bool _move = false) const override; + virtual void storeValue( + Type const& _sourceType, + SourceLocation const& _location = SourceLocation(), + bool _move = false + ) const override; virtual void setToZero( - SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const override; + SourceLocation const& _location = SourceLocation(), + bool _removeReference = true + ) const override; private: /// Number of stack elements occupied by the value (not the reference). @@ -123,10 +135,15 @@ public: StorageByteArrayElement(CompilerContext& _compilerContext); virtual unsigned sizeOnStack() const override { return 2; } virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; - virtual void storeValue(Type const& _sourceType, - SourceLocation const& _location = SourceLocation(), bool _move = false) const override; + virtual void storeValue( + Type const& _sourceType, + SourceLocation const& _location = SourceLocation(), + bool _move = false + ) const override; virtual void setToZero( - SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const override; + SourceLocation const& _location = SourceLocation(), + bool _removeReference = true + ) const override; }; /** @@ -140,10 +157,15 @@ public: /// Constructs the LValue, assumes that the reference to the array head is already on the stack. StorageArrayLength(CompilerContext& _compilerContext, ArrayType const& _arrayType); virtual void retrieveValue(SourceLocation const& _location, bool _remove = false) const override; - virtual void storeValue(Type const& _sourceType, - SourceLocation const& _location = SourceLocation(), bool _move = false) const override; + virtual void storeValue( + Type const& _sourceType, + SourceLocation const& _location = SourceLocation(), + bool _move = false + ) const override; virtual void setToZero( - SourceLocation const& _location = SourceLocation(), bool _removeReference = true) const override; + SourceLocation const& _location = SourceLocation(), + bool _removeReference = true + ) const override; private: ArrayType const& m_arrayType; From 228f41b8eda986cfe43afe14f3152dbbf87474de Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 15:58:20 +0100 Subject: [PATCH 069/313] For Marek :) BlockChain::transaction(h256 _transactionHash) BlockChain::transactionHashes(h256 _blockHash) --- alethzero/MainWin.cpp | 5 +- libethcore/BlockInfo.h | 1 + libethcore/Ethasher.cpp | 115 +++++++++++++++++++++++++++++++++++++ libethcore/Ethasher.h | 97 +++++++++++++++++++++++++++++++ libethcore/ProofOfWork.cpp | 98 ++----------------------------- libethcore/ProofOfWork.h | 10 ---- libethereum/BlockChain.cpp | 6 ++ libethereum/BlockChain.h | 14 ++++- libethereum/BlockDetails.h | 14 +++++ test/dagger.cpp | 76 +++++++++++++++++------- 10 files changed, 308 insertions(+), 128 deletions(-) create mode 100644 libethcore/Ethasher.cpp create mode 100644 libethcore/Ethasher.h diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index e6f380e47..3c5dcf25a 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -36,6 +36,7 @@ #endif #include #include +#include #include #include #include @@ -1365,7 +1366,7 @@ void Main::on_blocks_currentItemChanged() s << "
Difficulty: " << info.difficulty << ""; if (info.number) { - auto e = ProofOfWork::eval(info); + auto e = Ethasher::eval(info); s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } else @@ -1389,7 +1390,7 @@ void Main::on_blocks_currentItemChanged() s << line << "Nonce: " << uncle.nonce << ""; s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; s << line << "Difficulty: " << uncle.difficulty << ""; - auto e = ProofOfWork::eval(uncle); + auto e = Ethasher::eval(uncle); s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index a119d92eb..95519b57d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -85,6 +85,7 @@ public: static h256 headerHash(bytes const& _block) { return headerHash(&_block); } static h256 headerHash(bytesConstRef _block); + static BlockInfo fromHeader(bytes const& _block) { return fromHeader(bytesConstRef(&_block)); } static BlockInfo fromHeader(bytesConstRef _block); explicit operator bool() const { return timestamp != Invalid256; } diff --git a/libethcore/Ethasher.cpp b/libethcore/Ethasher.cpp new file mode 100644 index 000000000..a28895a1a --- /dev/null +++ b/libethcore/Ethasher.cpp @@ -0,0 +1,115 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file Ethasher.cpp + * @author Gav Wood + * @date 2014 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "BlockInfo.h" +#include "Ethasher.h" +using namespace std; +using namespace chrono; +using namespace dev; +using namespace eth; + +Ethasher* dev::eth::Ethasher::s_this = nullptr; + +bytes const& Ethasher::cache(BlockInfo const& _header) +{ + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; +} + +bytesConstRef Ethasher::full(BlockInfo const& _header) +{ + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash]; +} + +ethash_params Ethasher::params(BlockInfo const& _header) +{ + return params((unsigned)_header.number); +} + +ethash_params Ethasher::params(unsigned _n) +{ + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; +} + +bool Ethasher::verify(BlockInfo const& _header) +{ + bigint boundary = (bigint(1) << 256) / _header.difficulty; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; +} + +Ethasher::Result Ethasher::eval(BlockInfo const& _header, Nonce const& _nonce) +{ + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; +} + diff --git a/libethcore/Ethasher.h b/libethcore/Ethasher.h new file mode 100644 index 000000000..cfe0d1c82 --- /dev/null +++ b/libethcore/Ethasher.h @@ -0,0 +1,97 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file Ethasher.h + * @author Gav Wood + * @date 2014 + * + * ProofOfWork algorithm. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include // TODO: REMOVE once everything merged into this class and an opaque API can be provided. +#include "Common.h" +#include "BlockInfo.h" + +namespace dev +{ +namespace eth +{ + +class Ethasher +{ +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header); + bytesConstRef full(BlockInfo const& _header); + static ethash_params params(BlockInfo const& _header); + static ethash_params params(unsigned _n); + + struct Result + { + h256 value; + h256 mixHash; + }; + + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); + static bool verify(BlockInfo const& _header); + + class Miner + { + public: + Miner(BlockInfo const& _header): + m_headerHash(_header.headerHash(WithoutNonce)), + m_params(Ethasher::params(_header)), + m_datasetPointer(Ethasher::get()->full(_header).data()) + {} + + inline h256 mine(uint64_t _nonce) + { + ethash_compute_full(&m_ethashReturn, m_datasetPointer, &m_params, m_headerHash.data(), _nonce); + return h256(m_ethashReturn.result, h256::ConstructFromPointer); + } + + inline h256 lastMixHash() const + { + return h256(m_ethashReturn.mix_hash, h256::ConstructFromPointer); + } + + private: + ethash_return_value m_ethashReturn; + h256 m_headerHash; + ethash_params m_params; + void const* m_datasetPointer; + }; + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; + +} +} diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..d261ccb1c 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -30,8 +30,8 @@ #include #include #include -#include #include "BlockInfo.h" +#include "Ethasher.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -41,100 +41,14 @@ namespace dev namespace eth { -class Ethasher -{ -public: - Ethasher() {} - - static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } - - bytes const& cache(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_caches.count(_header.seedHash)) - { - try { - boost::filesystem::create_directories(getDataDir() + "/ethashcache"); - } catch (...) {} - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; - m_caches[_header.seedHash] = contents(memoFile); - if (m_caches[_header.seedHash].empty()) - { - ethash_params p = params((unsigned)_header.number); - m_caches[_header.seedHash].resize(p.cache_size); - ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); - writeFile(memoFile, m_caches[_header.seedHash]); - } - } - return m_caches[_header.seedHash]; - } - - byte const* full(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_fulls.count(_header.seedHash)) - { - if (!m_fulls.empty()) - { - delete [] m_fulls.begin()->second.data(); - m_fulls.erase(m_fulls.begin()); - } - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; - m_fulls[_header.seedHash] = contentsNew(memoFile); - if (!m_fulls[_header.seedHash]) - { - ethash_params p = params((unsigned)_header.number); - m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); - auto c = cache(_header); - ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); - writeFile(memoFile, m_fulls[_header.seedHash]); - } - } - return m_fulls[_header.seedHash].data(); - } - - static ethash_params params(BlockInfo const& _header) - { - return params((unsigned)_header.number); - } - - static ethash_params params(unsigned _n) - { - ethash_params p; - p.cache_size = ethash_get_cachesize(_n); - p.full_size = ethash_get_datasize(_n); - return p; - } - -private: - static Ethasher* s_this; - RecursiveMutex x_this; - std::map m_caches; - std::map m_fulls; -}; - -Ethasher* Ethasher::s_this = nullptr; - bool Ethash::verify(BlockInfo const& _header) { - bigint boundary = (bigint(1) << 256) / _header.difficulty; - auto e = eval(_header, _header.nonce); - return (u256)e.value <= boundary && e.mixHash == _header.mixHash; -} - -Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) -{ - auto p = Ethasher::params(_header); - ethash_return_value r; - ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; + return Ethasher::verify(_header); } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - auto h = _header.headerHash(WithoutNonce); - auto p = Ethasher::params(_header); - auto d = Ethasher::get()->full(_header); + Ethasher::Miner m(_header); std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); @@ -152,17 +66,15 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) Proof result; - ethash_return_value ethashReturn; unsigned hashCount = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); - u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + u256 val(m.mine(tryNonce)); best = std::min(best, log2((double)val)); if (val <= boundary) { ret.first.completed = true; - result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); + result.mixHash = m.lastMixHash(); result.nonce = u64(tryNonce); break; } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7006f6f61..250ddb73d 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -49,20 +49,12 @@ struct MineInfo class Ethash { public: - // bit-compatible with ethash_return_value struct Proof { Nonce nonce; h256 mixHash; }; - struct Result - { - h256 value; - h256 mixHash; - }; - static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } @@ -78,9 +70,7 @@ public: using Proof = Nonce; static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } - inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } protected: diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index d5c5e710c..30e9e4204 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -307,7 +307,13 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); #if ETH_PARANOIA checkConsistency(); diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index dbcab2580..58bd7bf38 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -34,6 +34,7 @@ #include #include "BlockDetails.h" #include "Account.h" +#include "Transaction.h" #include "BlockQueue.h" namespace ldb = leveldb; @@ -61,6 +62,8 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using TransactionHashes = h256s; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -108,12 +111,19 @@ public: BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } BlockReceipts receipts() const { return receipts(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } + TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. bytes block(h256 _hash) const; bytes block() const { return block(currentHash()); } + /// Get a transaction from its hash. Thread-safe. + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. - bytes transaction(h256 _hash, unsigned _i) const { bytes b = block(_hash); return RLP(b)[1][_i].data().toBytes(); } + bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } bytes transaction(unsigned _i) const { return transaction(currentHash(), _i); } /// Get a number for the given hash (or the most recent mined if none given). Thread-safe. @@ -185,6 +195,8 @@ private: mutable BlockLogBloomsHash m_logBlooms; mutable boost::shared_mutex x_receipts; mutable BlockReceiptsHash m_receipts; + mutable boost::shared_mutex x_transactionAddresses; + mutable TransactionAddressHash m_transactionAddresses; mutable boost::shared_mutex x_cache; mutable std::map m_cache; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 9a3ac9ff1..b59d165ab 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -70,13 +70,27 @@ struct BlockReceipts TransactionReceipts receipts; }; +struct TransactionAddress +{ + TransactionAddress() {} + TransactionAddress(RLP const& _rlp) { blockHash = _rlp[0].toHash(); index = _rlp[1].toInt(); } + bytes rlp() const { RLPStream s(2); s << blockHash << index; return s.out(); } + + explicit operator bool() const { return !!blockHash; } + + h256 blockHash; + unsigned index = 0; +}; + using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; +using TransactionAddressHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; +static const TransactionAddress NullTransactionAddress; } } diff --git a/test/dagger.cpp b/test/dagger.cpp index 87c49bd7d..dec753fe7 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -17,37 +17,69 @@ /** @file dagger.cpp * @author Gav Wood * @date 2014 - * ProofOfWork test functions. + * Dashimoto test functions. */ -#include -#include +#include +#include +#include "JsonSpiritHeaders.h" +#include #include +#include +#include +#include "TestHelper.h" + using namespace std; -using namespace std::chrono; using namespace dev; using namespace dev::eth; -int daggerTest() +namespace js = json_spirit; + +using dev::operator <<; + +BOOST_AUTO_TEST_SUITE(DashimotoTests) + +BOOST_AUTO_TEST_CASE(basic_test) { -#if 0 - cnote << "Testing ProofOfWork..."; - // Test dagger - { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + string testPath = test::getTestPath(); + + testPath += "/PoWTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/ethash_tests.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'ethash_tests.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + BlockInfo header = BlockInfo::fromHeader(fromHex(o["header"].get_str())); + 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); + + unsigned cacheSize(o["cache_size"].get_int()); + h256 cacheHash(o["cache_hash"].get_str()); + BOOST_REQUIRE_EQUAL(Ethasher::get()->cache(header).size(), cacheSize); + BOOST_REQUIRE_EQUAL(sha3(Ethasher::get()->cache(header)), cacheHash); + +#if TEST_FULL + unsigned fullSize(o["full_size"].get_int()); + h256 fullHash(o["full_hash"].get_str()); + BOOST_REQUIRE_EQUAL(Ethasher::get()->full(header).size(), fullSize); + BOOST_REQUIRE_EQUAL(sha3(Ethasher::get()->full(header)), fullHash); #endif - return 0; + + h256 result(o["result"].get_str()); + Ethasher::Result r = Ethasher::eval(header); + BOOST_REQUIRE_EQUAL(r.value, result); + BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash); + } } +BOOST_AUTO_TEST_SUITE_END() + + From c17c9a4c3175c1e9ccb98164b2e6b3a4e68d1cbe Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 5 Mar 2015 17:20:38 +0100 Subject: [PATCH 070/313] style fixes --- libevmcore/Assembly.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libevmcore/Assembly.cpp b/libevmcore/Assembly.cpp index 7f6a16116..5e9d2fcd3 100644 --- a/libevmcore/Assembly.cpp +++ b/libevmcore/Assembly.cpp @@ -182,16 +182,16 @@ string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLoc if (it == _sourceCodes.end()) return ""; - string toReturn = it->second; - if (_location.start >= (int)toReturn.size()) + string const& source = it->second; + if (size_t(_location.start) >= source.size()) return ""; - toReturn = toReturn.substr(_location.start, _location.end - _location.start); - auto newLinePos = toReturn.find_first_of("\n"); - if (newLinePos != string::npos && newLinePos != toReturn.size() - 1) - toReturn = toReturn.substr(0, newLinePos) + "..."; + string cut = source.substr(_location.start, _location.end - _location.start); + auto newLinePos = cut.find_first_of("\n"); + if (newLinePos != string::npos) + cut = cut.substr(0, newLinePos) + "..."; - return move(toReturn); + return move(cut); } ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const @@ -239,7 +239,7 @@ ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap con default: BOOST_THROW_EXCEPTION(InvalidOpcode()); } - _out << string(20, ' ') << sourceLine << endl; + _out << string("\t\t") << sourceLine << endl; } if (!m_data.empty() || !m_subs.empty()) From 1b2efc5bf234239120753f35453c90646aadadab Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 5 Mar 2015 17:23:20 +0100 Subject: [PATCH 071/313] one more style fix --- libevmcore/Assembly.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Assembly.h b/libevmcore/Assembly.h index bd2c87f4c..4b818e624 100644 --- a/libevmcore/Assembly.h +++ b/libevmcore/Assembly.h @@ -124,7 +124,7 @@ public: std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap()) const; protected: - std::string getLocationFromSources(const StringMap &_sourceCodes, const SourceLocation &_location) const; + std::string getLocationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const; void donePath() { if (m_totalDeposit != INT_MAX && m_totalDeposit != m_deposit) BOOST_THROW_EXCEPTION(InvalidDeposit()); } unsigned bytesRequired() const; From 9c005828cc44982eba47509c5971236e58becd29 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 5 Mar 2015 18:28:32 +0100 Subject: [PATCH 072/313] refactored some exceptions for thread safety --- libdevcore/Exceptions.h | 10 ++++++++-- libethcore/Exceptions.cpp | 36 ++++++++++++++++++++---------------- libethcore/Exceptions.h | 14 +++++++------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index f3f9b1bf0..ab7b489f4 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -31,7 +31,13 @@ namespace dev { // base class for all exceptions -struct Exception: virtual std::exception, virtual boost::exception { mutable std::string m_message; }; +struct Exception: virtual std::exception, virtual boost::exception +{ + Exception(std::string _message = std::string()): m_message(_message) {} + const char* what() const noexcept override { return m_message.c_str(); } +private: + std::string m_message; +}; struct BadHexCharacter: virtual Exception {}; struct RLPException: virtual Exception {}; @@ -41,7 +47,7 @@ struct NoNetworking: virtual Exception {}; struct NoUPnPDevice: virtual Exception {}; struct RootNotFound: virtual Exception {}; struct FileError: virtual Exception {}; -struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): m_f("Interface " + _f + " not supported.") {} virtual const char* what() const noexcept { return m_f.c_str(); } private: std::string m_f; }; +struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): Exception("Interface " + _f + " not supported.") {} }; // error information to be added to exceptions using errinfo_invalidSymbol = boost::error_info; diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index 9b07743c5..4e758da76 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -27,20 +27,24 @@ using namespace std; using namespace dev; using namespace dev::eth; -#if ALL_COMPILERS_ARE_CPP11 -#define ETH_RETURN_STRING(S) thread_local static string s_what; s_what = S; return s_what.c_str(); -#elsif USE_BOOST_TLS -static boost::thread_specific_ptr g_exceptionMessage; -#define ETH_RETURN_STRING(S) if (!g_exceptionMessage.get()); g_exceptionMessage.reset(new string); *g_exceptionMessage.get() = S; return g_exceptionMessage.get()->c_str(); -#else -#define ETH_RETURN_STRING(S) m_message = S; return m_message.c_str(); -#endif - -const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } -const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } -const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " valid:" + toString(valid) + ")"); } -const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } -const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } -const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } +InvalidBlockFormat::InvalidBlockFormat(int _f, bytesConstRef _d): + Exception("Invalid block format: Bad field " + toString(_f) + " (" + toHex(_d) + ")"), f(_f), d(_d.toBytes()) {} + +UncleInChain::UncleInChain(h256Set _uncles, h256 _block): + Exception("Uncle in block already mentioned: Uncles " + toString(_uncles) + " (" + _block.abridged() + ")"), uncles(_uncles), block(_block) {} + +InvalidTransactionsHash::InvalidTransactionsHash(h256 _head, h256 _real): + Exception("Invalid transactions hash: header says: " + toHex(_head.ref()) + " block is:" + toHex(_real.ref())), head(_head), real(_real) {} + +InvalidGasLimit::InvalidGasLimit(u256 _provided, u256 _valid): + Exception("Invalid gas limit (provided: " + toString(_provided) + " valid:" + toString(_valid) + ")"), provided(_provided), valid(_valid) {} + +InvalidMinGasPrice::InvalidMinGasPrice(u256 _provided, u256 _limit): + Exception("Invalid minimum gas price (provided: " + toString(_provided) + " limit:" + toString(_limit) + ")"), provided(_provided), limit(_limit) {} + +InvalidNonce::InvalidNonce(u256 _required, u256 _candidate): + Exception("Invalid nonce (r: " + toString(_required) + " c:" + toString(_candidate) + ")"), required(_required), candidate(_candidate) {} + +InvalidBlockNonce::InvalidBlockNonce(h256 _h, h256 _n, u256 _d): + Exception("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"), h(_h), n(_n), d(_d) {} diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 3fd62afbd..21015cf6f 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -44,26 +44,26 @@ struct FeeTooSmall: virtual dev::Exception {}; struct TooMuchGasUsed: virtual dev::Exception {}; struct ExtraDataTooBig: virtual dev::Exception {}; struct InvalidSignature: virtual dev::Exception {}; -class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual const char* what() const noexcept; }; +class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d); int f; bytes d; }; struct InvalidUnclesHash: virtual dev::Exception {}; struct InvalidUncle: virtual dev::Exception {}; struct UncleTooOld: virtual dev::Exception {}; -class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual const char* what() const noexcept; }; +class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block); h256Set uncles; h256 block; }; struct DuplicateUncleNonce: virtual dev::Exception {}; struct InvalidStateRoot: virtual dev::Exception {}; struct InvalidGasUsed: virtual dev::Exception {}; -class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; }; +class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real); h256 head; h256 real; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual const char* what() const noexcept; }; -class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0); u256 provided; u256 valid; }; +class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0); u256 provided; u256 limit; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; struct InvalidReceiptsStateRoot: virtual dev::Exception {}; struct InvalidTimestamp: virtual dev::Exception {}; struct InvalidLogBloom: virtual dev::Exception {}; -class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; }; -class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual const char* what() const noexcept; }; +class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0); u256 required; u256 candidate; }; +class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0); h256 h; h256 n; u256 d; }; struct InvalidParentHash: virtual dev::Exception {}; struct InvalidNumber: virtual dev::Exception {}; struct InvalidContractAddress: virtual public dev::Exception {}; From 90bb001cf9c82c80fd266ad726f3176367b9f310 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 19:38:31 +0100 Subject: [PATCH 073/313] Fast block hash from number. --- libethcore/Common.cpp | 9 +++-- libethereum/BlockChain.cpp | 79 ++++++++++++++++++++------------------ libethereum/BlockChain.h | 52 ++++++++++++++++++------- libethereum/BlockDetails.h | 11 ++++++ libethereum/Client.cpp | 11 +++++- libethereum/Client.h | 1 + libethereum/Miner.h | 3 ++ 7 files changed, 111 insertions(+), 55 deletions(-) diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 65c0b8b92..9eb622fe3 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,13 +33,14 @@ namespace eth { const unsigned c_protocolVersion = 56; -const unsigned c_databaseVersion = 6 + +const unsigned c_databaseBaseVersion = 7; #if ETH_FATDB - 1000 +const unsigned c_databaseVersionModifier = 1000; #else - 0 +const unsigned c_databaseVersionModifier = 0; #endif -; + +const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier; vector> const& units() { diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 30e9e4204..65a55880c 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -45,7 +45,7 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_db->NewIterator(_bc.m_readOptions); + auto it = _bc.m_blocksDB->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { @@ -102,9 +102,9 @@ void BlockChain::open(std::string _path, bool _killExisting) ldb::Options o; o.create_if_missing = true; - ldb::DB::Open(o, _path + "/blocks", &m_db); + ldb::DB::Open(o, _path + "/blocks", &m_blocksDB); ldb::DB::Open(o, _path + "/details", &m_extrasDB); - if (!m_db) + if (!m_blocksDB) BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); if (!m_extrasDB) BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); @@ -132,10 +132,10 @@ void BlockChain::close() { cnote << "Closing blockchain DB"; delete m_extrasDB; - delete m_db; + delete m_blocksDB; m_lastBlockHash = m_genesisHash; m_details.clear(); - m_cache.clear(); + m_blocks.clear(); } template @@ -294,6 +294,23 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_details[newHash] = BlockDetails((unsigned)pd.number + 1, td, bi.parentHash, {}); m_details[bi.parentHash].children.push_back(newHash); } + { + WriteGuard l(x_blockHashes); + m_blockHashes[h256(bi.number)].value = newHash; + } + // Collate transaction hashes and remember who they were. + h256s tas; + { + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + WriteGuard l(x_transactionAddresses); + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + { + tas.push_back(sha3(blockRLP[1][ta.index].data())); + m_transactionAddresses[tas.back()] = ta; + } + } { WriteGuard l(x_logBlooms); m_logBlooms[newHash] = blb; @@ -303,17 +320,14 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_receipts[newHash] = br; } - m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)dev::ref(m_details[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); - RLP blockRLP(_block); - TransactionAddress ta; - ta.blockHash = newHash; - for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) - m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); + m_blocksDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(h256(bi.number), ExtraBlockHash), (ldb::Slice)dev::ref(m_blockHashes[h256(bi.number)].rlp())); + for (auto const& h: tas) + m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraTransactionAddress), (ldb::Slice)dev::ref(m_transactionAddresses[h].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraLogBlooms), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraReceipts), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); #if ETH_PARANOIA checkConsistency(); @@ -406,7 +420,7 @@ void BlockChain::checkConsistency() WriteGuard l(x_details); m_details.clear(); } - ldb::Iterator* it = m_db->NewIterator(m_readOptions); + ldb::Iterator* it = m_blocksDB->NewIterator(m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().size() == 32) { @@ -449,12 +463,12 @@ bool BlockChain::isKnown(h256 _hash) const if (_hash == m_genesisHash) return true; { - ReadGuard l(x_cache); - if (m_cache.count(_hash)) + ReadGuard l(x_blocks); + if (m_blocks.count(_hash)) return true; } string d; - m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); + m_blocksDB->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); return !!d.size(); } @@ -464,14 +478,14 @@ bytes BlockChain::block(h256 _hash) const return m_genesisBlock; { - ReadGuard l(x_cache); - auto it = m_cache.find(_hash); - if (it != m_cache.end()) + ReadGuard l(x_blocks); + auto it = m_blocks.find(_hash); + if (it != m_blocks.end()) return it->second; } string d; - m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); + m_blocksDB->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); if (!d.size()) { @@ -479,18 +493,9 @@ bytes BlockChain::block(h256 _hash) const return bytes(); } - WriteGuard l(x_cache); - m_cache[_hash].resize(d.size()); - memcpy(m_cache[_hash].data(), d.data(), d.size()); - - return m_cache[_hash]; -} + WriteGuard l(x_blocks); + m_blocks[_hash].resize(d.size()); + memcpy(m_blocks[_hash].data(), d.data(), d.size()); -h256 BlockChain::numberHash(unsigned _n) const -{ - if (!_n) - return genesisHash(); - h256 ret = currentHash(); - for (; _n < details().number; ++_n, ret = details(ret).parent) {} - return ret; + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 58bd7bf38..62a5bf792 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -62,8 +62,17 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using BlocksHash = std::map; using TransactionHashes = h256s; +enum { + ExtraDetails = 0, + ExtraBlockHash, + ExtraTransactionAddress, + ExtraLogBlooms, + ExtraReceipts +}; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -99,28 +108,31 @@ public: BlockInfo info(h256 _hash) const { return BlockInfo(block(_hash)); } BlockInfo info() const { return BlockInfo(block()); } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. + bytes block(h256 _hash) const; + bytes block() const { return block(currentHash()); } + /// Get the familial details concerning a block (or the most recent mined if none given). Thread-safe. - BlockDetails details(h256 _hash) const { return queryExtras(_hash, m_details, x_details, NullBlockDetails); } + BlockDetails details(h256 _hash) const { return queryExtras(_hash, m_details, x_details, NullBlockDetails); } BlockDetails details() const { return details(currentHash()); } /// Get the transactions' log blooms of a block (or the most recent mined if none given). Thread-safe. - BlockLogBlooms logBlooms(h256 _hash) const { return queryExtras(_hash, m_logBlooms, x_logBlooms, NullBlockLogBlooms); } + BlockLogBlooms logBlooms(h256 _hash) const { return queryExtras(_hash, m_logBlooms, x_logBlooms, NullBlockLogBlooms); } BlockLogBlooms logBlooms() const { return logBlooms(currentHash()); } /// Get the transactions' receipts of a block (or the most recent mined if none given). Thread-safe. - BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } + BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } BlockReceipts receipts() const { return receipts(currentHash()); } /// Get a list of transaction hashes for a given block. Thread-safe. TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } - /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. - bytes block(h256 _hash) const; - bytes block() const { return block(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + h256 numberHash(u256 _index) const { if (!_index) return genesisHash(); return queryExtras(h256(_index), m_blockHashes, x_blockHashes, NullBlockHash).value; } /// Get a transaction from its hash. Thread-safe. - bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } @@ -136,9 +148,6 @@ public: /// Get the hash of the genesis block. Thread-safe. h256 genesisHash() const { return m_genesisHash; } - /// Get the hash of a block of a given number. Slow; try not to use it too much. - h256 numberHash(unsigned _n) const; - /// Get all blocks not allowed as uncles given a parent (i.e. featured as uncles/main in parent, parent + 1, ... parent + 5). /// @returns set including the header-hash of every parent (including @a _parent) up to and including generation +5 /// togther with all their quoted uncles. @@ -160,6 +169,21 @@ public: */ h256s treeRoute(h256 _from, h256 _to, h256* o_common = nullptr, bool _pre = true, bool _post = true) const; + struct Statistics + { + unsigned memDetails; + unsigned memLogBlooms; + unsigned memReceipts; + unsigned memTransactionAddresses; + unsigned memCache; + }; + + /// @returns statistics about memory usage. + Statistics usage() const; + + /// Deallocate unused data. + void garbageCollect(); + private: void open(std::string _path, bool _killExisting = false); void close(); @@ -189,6 +213,8 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. + mutable boost::shared_mutex x_blocks; + mutable BlocksHash m_blocks; mutable boost::shared_mutex x_details; mutable BlockDetailsHash m_details; mutable boost::shared_mutex x_logBlooms; @@ -197,11 +223,11 @@ private: mutable BlockReceiptsHash m_receipts; mutable boost::shared_mutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_cache; - mutable std::map m_cache; + mutable boost::shared_mutex x_blockHashes; + mutable BlockHashHash m_blockHashes; /// The disk DBs. Thread-safe, so no need for locks. - ldb::DB* m_db; + ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; /// Hash of the last (valid) block on the longest chain. diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index b59d165ab..f9bccea1e 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -70,6 +70,15 @@ struct BlockReceipts TransactionReceipts receipts; }; +struct BlockHash +{ + BlockHash() {} + BlockHash(RLP const& _r) { value = _r.toHash(); } + bytes rlp() const { return dev::rlp(value); } + + h256 value; +}; + struct TransactionAddress { TransactionAddress() {} @@ -86,11 +95,13 @@ using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; using TransactionAddressHash = std::map; +using BlockHashHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; static const TransactionAddress NullTransactionAddress; +static const BlockHash NullBlockHash; } } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 0462d1c7c..4db4afe58 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -516,9 +516,18 @@ void Client::doWork() { if (m.isComplete()) { - cwork << "CHAIN <== postSTATE"; + // TODO: enable a short-circuit option since we mined it. will need to get the end state from the miner. + auto lm = dynamic_cast(&m); h256s hs; + if (false && lm && !m_verifyOwnBlocks) { + // TODO: implement + //m_bc.attemptImport(m_blockData(), m_stateDB, lm->state()); + // TODO: derive hs from lm->state() + } + else + { + cwork << "CHAIN <== postSTATE"; WriteGuard l(x_stateDB); hs = m_bc.attemptImport(m.blockData(), m_stateDB); } diff --git a/libethereum/Client.h b/libethereum/Client.h index c4f2b3705..02fc8b91b 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -359,6 +359,7 @@ private: bool m_paranoia = false; ///< Should we be paranoid about our state? bool m_turboMining = false; ///< Don't squander all of our time mining actually just sleeping. bool m_forceMining = false; ///< Mine even when there are no transactions pending? + bool m_verifyOwnBlocks = true; ///< Shoudl be verify blocks that we mined? mutable Mutex m_filterLock; std::map m_filters; diff --git a/libethereum/Miner.h b/libethereum/Miner.h index bdd49abb9..45cf9944b 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -130,6 +130,9 @@ public: /// Get and clear the mining history. std::list miningHistory() { Guard l(x_mineInfo); auto ret = m_mineHistory; m_mineHistory.clear(); return ret; } + /// @returns the state on which we mined. + State const& state() const { return m_mineState; } + private: /// Do some work on the mining. virtual void doWork(); From 7f4ff430ccd5a89877914059799a8279397e8667 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 5 Mar 2015 20:44:58 +0100 Subject: [PATCH 074/313] uninitialized member --- libethereum/EthereumPeer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/EthereumPeer.h b/libethereum/EthereumPeer.h index f33c9ddea..82adc4873 100644 --- a/libethereum/EthereumPeer.h +++ b/libethereum/EthereumPeer.h @@ -131,7 +131,7 @@ private: DownloadSub m_sub; /// Have we received a GetTransactions packet that we haven't yet answered? - bool m_requireTransactions; + bool m_requireTransactions = false; Mutex x_knownBlocks; h256Set m_knownBlocks; ///< Blocks that the peer already knows about (that don't need to be sent to them). From 114712aa43136d36c49f24f0cf435ca5dfba1795 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 21:19:21 +0100 Subject: [PATCH 075/313] Caching. --- alethzero/Main.ui | 7 ++ alethzero/MainWin.cpp | 8 +++ alethzero/MainWin.h | 1 + libethereum/BlockChain.cpp | 124 +++++++++++++++++++++++++++++++++++ libethereum/BlockChain.h | 34 +++++++--- libethereum/BlockDetails.cpp | 5 +- libethereum/BlockDetails.h | 17 +++-- libethereum/Client.cpp | 1 + 8 files changed, 181 insertions(+), 16 deletions(-) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index 9025aa846..8f6597ca5 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -38,6 +38,13 @@ + + + + 0 bytes used + + + diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 3c5dcf25a..978676795 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -137,6 +137,7 @@ Main::Main(QWidget *parent) : ui->configDock->close(); on_verbosity_valueChanged(); + statusBar()->addPermanentWidget(ui->cacheUsage); statusBar()->addPermanentWidget(ui->balance); statusBar()->addPermanentWidget(ui->peerCount); statusBar()->addPermanentWidget(ui->mineStatus); @@ -1140,6 +1141,12 @@ void Main::on_refresh_triggered() refreshAll(); } +void Main::refreshCache() +{ + BlockChain::Statistics s = ethereum()->blockChain().usage(); + ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); +} + void Main::timerEvent(QTimerEvent*) { // 7/18, Alex: aggregating timers, prelude to better threading? @@ -1168,6 +1175,7 @@ void Main::timerEvent(QTimerEvent*) interval = 0; refreshNetwork(); refreshWhispers(); + refreshCache(); poll(); } else diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 072911ff7..487272a7a 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -211,6 +211,7 @@ private: void refreshNetwork(); void refreshMining(); void refreshWhispers(); + void refreshCache(); void refreshAll(); void refreshPending(); diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 65a55880c..f4a5acea9 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -75,8 +75,33 @@ ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub) #endif } +#if ETH_DEBUG +static const chrono::system_clock::duration c_collectionDuration = chrono::seconds(15); +static const unsigned c_collectionQueueSize = 2; +static const unsigned c_maxCacheSize = 1024 * 1024 * 1; +static const unsigned c_minCacheSize = 1; +#else + +/// Duration between flushes. +static const chrono::system_clock::duration c_collectionDuration = chrono::seconds(60); + +/// Length of death row (total time in cache is multiple of this and collection duration). +static const unsigned c_collectionQueueSize = 20; + +/// Max size, above which we start forcing cache reduction. +static const unsigned c_maxCacheSize = 1024 * 1024 * 64; + +/// Min size, below which we don't bother flushing it. +static const unsigned c_minCacheSize = 1024 * 1024 * 32; + +#endif + BlockChain::BlockChain(bytes const& _genesisBlock, std::string _path, bool _killExisting) { + // initialise deathrow. + m_cacheUsage.resize(c_collectionQueueSize); + m_lastCollection = chrono::system_clock::now(); + // Initialise with the genesis as the last block on the longest chain. m_genesisBlock = _genesisBlock; m_genesisHash = sha3(RLP(m_genesisBlock)[0].data()); @@ -414,6 +439,103 @@ h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, boo return ret; } +void BlockChain::noteUsed(h256 const& _h, unsigned _extra) const +{ + auto id = CacheID(_h, _extra); + Guard l(x_cacheUsage); + m_cacheUsage[0].insert(id); + if (m_cacheUsage[1].count(id)) + m_cacheUsage[1].erase(id); + else + m_inUse.insert(id); +} + +template static unsigned getHashSize(map const& _map) +{ + unsigned ret = 0; + for (auto const& i: _map) + ret += i.second.size + 64; + return ret; +} + +void BlockChain::updateStats() const +{ + { + ReadGuard l1(x_blocks); + m_lastStats.memBlocks = 0; + for (auto const& i: m_blocks) + m_lastStats.memBlocks += i.second.size() + 64; + } + { + ReadGuard l2(x_details); + m_lastStats.memDetails = getHashSize(m_details); + } + { + ReadGuard l5(x_logBlooms); + m_lastStats.memLogBlooms = getHashSize(m_logBlooms); + } + { + ReadGuard l4(x_receipts); + m_lastStats.memReceipts = getHashSize(m_receipts); + } + { + ReadGuard l3(x_blockHashes); + m_lastStats.memBlockHashes = getHashSize(m_blockHashes); + } + { + ReadGuard l6(x_transactionAddresses); + m_lastStats.memTransactionAddresses = getHashSize(m_transactionAddresses); + } +} + +void BlockChain::garbageCollect(bool _force) +{ + updateStats(); + + if (!_force && chrono::system_clock::now() < m_lastCollection + c_collectionDuration && m_lastStats.memTotal() < c_maxCacheSize) + return; + if (m_lastStats.memTotal() < c_minCacheSize) + return; + + m_lastCollection = chrono::system_clock::now(); + + Guard l(x_cacheUsage); + WriteGuard l1(x_blocks); + WriteGuard l2(x_details); + WriteGuard l3(x_blockHashes); + WriteGuard l4(x_receipts); + WriteGuard l5(x_logBlooms); + WriteGuard l6(x_transactionAddresses); + for (CacheID const& id: m_cacheUsage.back()) + { + m_inUse.erase(id); + // kill i from cache. + switch (id.second) + { + case (unsigned)-1: + m_blocks.erase(id.first); + break; + case ExtraDetails: + m_details.erase(id.first); + break; + case ExtraBlockHash: + m_blockHashes.erase(id.first); + break; + case ExtraReceipts: + m_receipts.erase(id.first); + break; + case ExtraLogBlooms: + m_logBlooms.erase(id.first); + break; + case ExtraTransactionAddress: + m_transactionAddresses.erase(id.first); + break; + } + } + m_cacheUsage.pop_back(); + m_cacheUsage.push_front({}); +} + void BlockChain::checkConsistency() { { @@ -497,5 +619,7 @@ bytes BlockChain::block(h256 _hash) const m_blocks[_hash].resize(d.size()); memcpy(m_blocks[_hash].data(), d.data(), d.size()); + noteUsed(_hash); + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 62a5bf792..20c41b553 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -26,7 +26,7 @@ #include #pragma warning(pop) -#include +#include #include #include #include @@ -171,18 +171,20 @@ public: struct Statistics { + unsigned memBlocks; unsigned memDetails; unsigned memLogBlooms; unsigned memReceipts; unsigned memTransactionAddresses; - unsigned memCache; + unsigned memBlockHashes; + unsigned memTotal() const { return memBlocks + memDetails + memLogBlooms + memReceipts + memTransactionAddresses + memBlockHashes; } }; /// @returns statistics about memory usage. - Statistics usage() const; + Statistics usage(bool _freshen = false) const { if (_freshen) updateStats(); return m_lastStats; } /// Deallocate unused data. - void garbageCollect(); + void garbageCollect(bool _force = false); private: void open(std::string _path, bool _killExisting = false); @@ -205,6 +207,8 @@ private: return _n; } + noteUsed(_h, N); + WriteGuard l(_x); auto ret = _m.insert(std::make_pair(_h, T(RLP(s)))); return ret.first->second; @@ -213,19 +217,29 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. - mutable boost::shared_mutex x_blocks; + mutable SharedMutex x_blocks; mutable BlocksHash m_blocks; - mutable boost::shared_mutex x_details; + mutable SharedMutex x_details; mutable BlockDetailsHash m_details; - mutable boost::shared_mutex x_logBlooms; + mutable SharedMutex x_logBlooms; mutable BlockLogBloomsHash m_logBlooms; - mutable boost::shared_mutex x_receipts; + mutable SharedMutex x_receipts; mutable BlockReceiptsHash m_receipts; - mutable boost::shared_mutex x_transactionAddresses; + mutable SharedMutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_blockHashes; + mutable SharedMutex x_blockHashes; mutable BlockHashHash m_blockHashes; + using CacheID = std::pair; + mutable Mutex x_cacheUsage; + mutable std::deque> m_cacheUsage; + mutable std::set m_inUse; + void noteUsed(h256 const& _h, unsigned _extra = (unsigned)-1) const; + std::chrono::system_clock::time_point m_lastCollection; + + void updateStats() const; + mutable Statistics m_lastStats; + /// The disk DBs. Thread-safe, so no need for locks. ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; diff --git a/libethereum/BlockDetails.cpp b/libethereum/BlockDetails.cpp index 58f37b7aa..c15939fdb 100644 --- a/libethereum/BlockDetails.cpp +++ b/libethereum/BlockDetails.cpp @@ -32,9 +32,12 @@ BlockDetails::BlockDetails(RLP const& _r) totalDifficulty = _r[1].toInt(); parent = _r[2].toHash(); children = _r[3].toVector(); + size = _r.size(); } bytes BlockDetails::rlp() const { - return rlpList(number, totalDifficulty, parent, children); + auto ret = rlpList(number, totalDifficulty, parent, children); + size = ret.size(); + return ret; } diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index f9bccea1e..ed478568d 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -46,28 +46,32 @@ struct BlockDetails bool isNull() const { return !totalDifficulty; } explicit operator bool() const { return !isNull(); } - unsigned number; // TODO: remove? + unsigned number; u256 totalDifficulty; h256 parent; h256s children; + + mutable unsigned size; }; struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } - bytes rlp() const { RLPStream s; s << blooms; return s.out(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); size = _r.data().size(); } + bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } LogBlooms blooms; + mutable unsigned size; }; struct BlockReceipts { BlockReceipts() {} - BlockReceipts(RLP const& _r) { for (auto const& i: _r) receipts.emplace_back(i.data()); } - bytes rlp() const { RLPStream s(receipts.size()); for (TransactionReceipt const& i: receipts) i.streamRLP(s); return s.out(); } + BlockReceipts(RLP const& _r) { for (auto const& i: _r) receipts.emplace_back(i.data()); size = _r.data().size(); } + bytes rlp() const { RLPStream s(receipts.size()); for (TransactionReceipt const& i: receipts) i.streamRLP(s); size = s.out().size(); return s.out(); } TransactionReceipts receipts; + mutable unsigned size; }; struct BlockHash @@ -77,6 +81,7 @@ struct BlockHash bytes rlp() const { return dev::rlp(value); } h256 value; + static const unsigned size = 65; }; struct TransactionAddress @@ -89,6 +94,8 @@ struct TransactionAddress h256 blockHash; unsigned index = 0; + + static const unsigned size = 67; }; using BlockDetailsHash = std::map; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 4db4afe58..448fdb9d6 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -629,6 +629,7 @@ void Client::doWork() uninstallWatch(i); m_lastGarbageCollection = chrono::system_clock::now(); } + m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From 8d6cb82083dfe86c6a83d85730ba5e0f319e9011 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 22:42:34 +0100 Subject: [PATCH 076/313] Cache reporting in AZ. --- alethzero/MainWin.cpp | 34 +++++++++++++++++++++++++++++++++- libethereum/Client.cpp | 7 +++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 978676795..a155207ba 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1141,10 +1141,42 @@ void Main::on_refresh_triggered() refreshAll(); } +static std::string niceUsed(unsigned _n) +{ + static const vector c_units = { "bytes", "KB", "MB", "GB", "TB", "PB" }; + unsigned u = 0; + while (_n > 10240) + { + _n /= 1024; + u++; + } + if (_n > 1000) + return toString(_n / 1000) + "." + toString((min(949, _n % 1000) + 50) / 100) + " " + c_units[u + 1]; + else + return toString(_n) + " " + c_units[u]; +} + void Main::refreshCache() { BlockChain::Statistics s = ethereum()->blockChain().usage(); - ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); + QString t; + auto f = [&](unsigned n, QString l) + { + t += ("%1 " + l).arg(QString::fromStdString(niceUsed(n))); + }; + f(s.memTotal(), "total"); + t += " ("; + f(s.memBlocks, "blocks"); + t += ", "; + f(s.memReceipts, "receipts"); + t += ", "; + f(s.memLogBlooms, "blooms"); + t += ", "; + f(s.memBlockHashes + s.memTransactionAddresses, "hashes"); + t += ", "; + f(s.memDetails, "family"); + t += ")"; + ui->cacheUsage->setText(t); } void Main::timerEvent(QTimerEvent*) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 448fdb9d6..9a249a645 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -614,7 +614,7 @@ void Client::doWork() this_thread::sleep_for(chrono::milliseconds(100)); if (chrono::system_clock::now() - m_lastGarbageCollection > chrono::seconds(5)) { - // garbage collect on watches + // watches garbage collection vector toUninstall; { Guard l(m_filterLock); @@ -627,9 +627,12 @@ void Client::doWork() } for (auto i: toUninstall) uninstallWatch(i); + + // blockchain GC + m_bc.garbageCollect(); + m_lastGarbageCollection = chrono::system_clock::now(); } - m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From 577b7dc9afa7c03334e684af312ef64d828f2712 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:11:24 +0100 Subject: [PATCH 077/313] add quadratic complexity tests --- test/state.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 8db082d0c..b18705148 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -169,23 +169,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -//{ -// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) -// { -// string arg = boost::unit_test::framework::master_test_suite().argv[i]; -// if (arg == "--quadratic" || arg == "--all") -// { -// auto start = chrono::steady_clock::now(); - -// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - -// auto end = chrono::steady_clock::now(); -// auto duration(chrono::duration_cast(end - start)); -// cnote << "test duration: " << duration.count() << " milliseconds.\n"; -// } -// } -//} +BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { From 7b0f09591e27efec50928e5fb135487b3feb180d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:12:51 +0100 Subject: [PATCH 078/313] add uncle header feature for fillers --- test/blockchain.cpp | 282 ++++++++++++++++++++++++++++---------------- 1 file changed, 182 insertions(+), 100 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 55c39f56b..a23a756b1 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -33,8 +33,10 @@ namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - - +BlockInfo constructBlock(mObject& _o); +void updatePoW(BlockInfo& _bi); +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); +RLPStream createFullBlockFromHeader(const BlockInfo& _bi, const bytes& _txs = RLPEmptyList, const bytes& _uncles = RLPEmptyList); void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -44,86 +46,47 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } + BlockInfo biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj()); BOOST_REQUIRE(o.count("pre")); - ImportTest importer(o["pre"].get_obj()); State state(Address(), OverlayDB(), BaseState::Empty); importer.importState(o["pre"].get_obj(), state); state.commit(); if (_fillin) - blockFromFields.stateRoot = state.rootHash(); + biGenesisBlock.stateRoot = state.rootHash(); else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + BOOST_CHECK_MESSAGE(biGenesisBlock.stateRoot == state.rootHash(), "root hash does not match"); if (_fillin) { // find new valid nonce - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(blockFromFields)) - { - ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, blockFromFields); - } + updatePoW(biGenesisBlock); //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); - o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); + writeBlockHeaderToJson(o["genesisBlockHeader"].get_obj(), biGenesisBlock); } // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); + RLPStream rlpGenesisBlock = createFullBlockFromHeader(biGenesisBlock); + biGenesisBlock.verifyInternals(&rlpGenesisBlock.out()); // construct blockchain - BlockChain bc(block.out(), string(), true); + BlockChain bc(rlpGenesisBlock.out(), string(), true); if (_fillin) { BOOST_REQUIRE(o.count("blocks")); mArray blArray; + vector vBiBlocks; for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); - BOOST_REQUIRE(blObj.count("transactions")); + // get txs TransactionQueue txs; - + BOOST_REQUIRE(blObj.count("transactions")); for (auto const& txObj: blObj["transactions"].get_array()) { mObject tx = txObj.get_obj(); @@ -132,6 +95,35 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "failed importing transaction\n"; } + // write uncle list + BlockQueue uncleBlockQueue; + mArray aUncleList; + vector vBiUncles; + + for (auto const& uHObj: blObj["uncleHeaders"].get_array()) + { + mObject uncleHeaderObj = uHObj.get_obj(); + BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); + + // make uncle header valid + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + uncleBlockFromFields.timestamp = (u256)time(0); + + updatePoW(uncleBlockFromFields); + writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); + + aUncleList.push_back(uncleHeaderObj); + vBiUncles.push_back(uncleBlockFromFields); + + cnote << "import uncle in blockQueue"; + RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields); + uncleBlockQueue.import(&uncle.out(), bc); + } + + blObj["uncleHeaders"] = aUncleList; + bc.sync(uncleBlockQueue, state.db(), 4); + state.commitToMine(bc); + try { state.sync(bc); @@ -152,6 +144,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) return; } + blObj["rlp"] = "0x" + toHex(state.blockData()); + // write valid txs mArray txArray; Transactions txList; @@ -174,46 +168,19 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } blObj["transactions"] = txArray; - blObj["rlp"] = "0x" + toHex(state.blockData()); BlockInfo current_BlockHeader = state.info(); - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - if (blObj.count("blockHeader")) - { overwriteBlockHeader(current_BlockHeader, blObj); - } // write block header - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); - oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); - oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); - oBlockHeader["hash"] = toString(current_BlockHeader.hash); - + writeBlockHeaderToJson(oBlockHeader, current_BlockHeader); blObj["blockHeader"] = oBlockHeader; + vBiBlocks.push_back(current_BlockHeader); - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - blObj["uncleHeaders"] = aUncleList; - - //txs: - + // compare blocks from state and from rlp RLPStream txStream; txStream.appendList(txList.size()); for (unsigned i = 0; i < txList.size(); ++i) @@ -223,13 +190,16 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txStream.appendRaw(txrlp.out()); } - RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + RLPStream uncleStream; + uncleStream.appendList(vBiUncles.size()); + for (unsigned i = 0; i < vBiUncles.size(); ++i) + { + RLPStream uncleRlp; + vBiUncles[i].streamRLP(uncleRlp, WithNonce); + uncleStream.appendRaw(uncleRlp.out()); + } - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); + RLPStream block2 = createFullBlockFromHeader(current_BlockHeader, txStream.out(), uncleStream.out()); blObj["rlp"] = "0x" + toHex(block2.out()); @@ -240,13 +210,14 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "txs mismatch\n"; if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; + cnote << "uncle list mismatch\n" << RLP(state.blockData())[2].data() << "\n" << RLP(block2.out())[2].data(); try { state.sync(bc); bc.import(block2.out(), state.db()); state.sync(bc); + state.commit(); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -392,12 +363,51 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } // check uncle list - BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + + // uncles from uncle list field + vector uBlHsFromField; + if (blObj["uncleHeaders"].type() != json_spirit::null_type) + { + for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) + { + mObject uBlH = uBlHeaderObj.get_obj(); + cout << "uBlH.size(): " << uBlH.size() << endl; + BOOST_REQUIRE(uBlH.size() == 17); + bytes uncleRLP = createBlockRLPFromFields(uBlH); + const RLP c_uRLP(uncleRLP); + BlockInfo uncleBlockHeader; + try + { + uncleBlockHeader.populateFromHeader(c_uRLP, true); + } + catch(...) + { + BOOST_ERROR("invalid uncle header"); + } + uBlHsFromField.push_back(uncleBlockHeader); + } + } + + // uncles from block RLP + vector uBlHsFromRlp; + for (auto const& uRLP: root[2]) + { + BlockInfo uBl; + uBl.populateFromHeader(uRLP, true); + uBlHsFromRlp.push_back(uBl); + } + + BOOST_REQUIRE_EQUAL(uBlHsFromField.size(), uBlHsFromRlp.size()); + + for (size_t i = 0; i < uBlHsFromField.size(); ++i) + BOOST_CHECK_MESSAGE(uBlHsFromField[i] == uBlHsFromRlp[i], "block header in rlp and in field do not match"); } } } } +// helping functions + bytes createBlockRLPFromFields(mObject& _tObj) { RLPStream rlpStream; @@ -529,31 +539,103 @@ void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) current_BlockHeader.populateFromHeader(c_bRLP, false); } } -} }// Namespace Close +BlockInfo constructBlock(mObject& _o) +{ -BOOST_AUTO_TEST_SUITE(BlockChainTests) + BlockInfo ret; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(_o); + const RLP c_bRLP(c_blockRLP); + ret.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch(...) + { + BOOST_ERROR("block population did throw an unknown exception\n"); + } + return ret; +} -BOOST_AUTO_TEST_CASE(bcBlockChainTest) +void updatePoW(BlockInfo& _bi) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(_bi)) + { + ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _bi); + } } -BOOST_AUTO_TEST_CASE(bcValidBlockTest) +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi) { - dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); + _o["parentHash"] = toString(_bi.parentHash); + _o["uncleHash"] = toString(_bi.sha3Uncles); + _o["coinbase"] = toString(_bi.coinbaseAddress); + _o["stateRoot"] = toString(_bi.stateRoot); + _o["transactionsTrie"] = toString(_bi.transactionsRoot); + _o["receiptTrie"] = toString(_bi.receiptsRoot); + _o["bloom"] = toString(_bi.logBloom); + _o["difficulty"] = toString(_bi.difficulty); + _o["number"] = toString(_bi.number); + _o["gasLimit"] = toString(_bi.gasLimit); + _o["gasUsed"] = toString(_bi.gasUsed); + _o["timestamp"] = toString(_bi.timestamp); + _o["extraData"] ="0x" + toHex(_bi.extraData); + _o["mixHash"] = toString(_bi.mixHash); + _o["seedHash"] = toString(_bi.seedHash); + _o["nonce"] = toString(_bi.nonce); + _o["hash"] = toString(_bi.hash); } -BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, const bytes& _uncles ) { - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); + RLPStream rlpStream; + _bi.streamRLP(rlpStream, WithNonce); + + RLPStream ret(3); + ret.appendRaw(rlpStream.out()); + ret.appendRaw(_txs); + ret.appendRaw(_uncles); + + return ret; } +} }// Namespace Close -//BOOST_AUTO_TEST_CASE(bcUncleTest) + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +//BOOST_AUTO_TEST_CASE(bcBlockChainTest) +//{ +// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcValidBlockTest) +//{ +// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) //{ -// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); //} +BOOST_AUTO_TEST_CASE(bcUncleTest) +{ + dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +} + BOOST_AUTO_TEST_CASE(userDefinedFileBc) { dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); From 260aa0c4b2138ac62cb7ac8838b6108d58b6bd61 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:14:42 +0100 Subject: [PATCH 079/313] update blockchain test filler to new min diff and min gasLimit --- test/bcBlockChainTestFiller.json | 2 +- test/bcInvalidHeaderTestFiller.json | 56 ++++++++++++++--------------- test/bcValidBlockTestFiller.json | 32 ++++++++--------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 8a0bf89fe..b149f5938 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -3,7 +3,7 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index aa32dfbab..39a91a583 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -3,9 +3,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -59,9 +59,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,9 +115,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -170,9 +170,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -225,9 +225,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -280,9 +280,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -336,9 +336,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -391,9 +391,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -446,9 +446,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -501,9 +501,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -556,9 +556,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -611,9 +611,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -666,9 +666,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -721,9 +721,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 29b2e978e..14d4cfb2c 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -4,9 +4,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1024", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -51,9 +51,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,9 +97,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "1000000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -143,9 +143,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -189,9 +189,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -244,9 +244,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -299,9 +299,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -351,9 +351,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "0x0dddb6", + "gasLimit" : "125000", "gasUsed" : "100", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", From f4563c84a3311636355fd22ef6be70964d8d21da Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:16:17 +0100 Subject: [PATCH 080/313] add first uncle test --- test/bcUncleTestFiller.json | 73 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index 839e3ba46..d866b887c 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,9 +1,9 @@ { - "minDifficulty" : { + "oneUncle" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", @@ -54,24 +54,39 @@ "value" : "10" } ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], "uncleHeaders" : [ { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "2049", + "difficulty" : "131072", "extraData" : "0x", - "gasLimit" : "99804806", - "gasUsed" : "21000", - "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", - "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", - "nonce" : "17ed77999bef2e4b", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", "number" : "2", - "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", - "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", - "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", - "timestamp" : "1425490151", - "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] @@ -80,35 +95,19 @@ "transactions" : [ { "data" : "", - "gasLimit" : "8000000", - "gasPrice" : "0", - "nonce" : "2", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "3", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" } ], "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "1", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } ] - } + }, ] } + + } From b491686a2f31afb856b183a87bc8de854d58fd32 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:19:48 +0100 Subject: [PATCH 081/313] style --- test/blockchain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index a23a756b1..ec9f7b68d 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -367,7 +367,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // uncles from uncle list field vector uBlHsFromField; if (blObj["uncleHeaders"].type() != json_spirit::null_type) - { for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) { mObject uBlH = uBlHeaderObj.get_obj(); @@ -386,7 +385,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } uBlHsFromField.push_back(uncleBlockHeader); } - } // uncles from block RLP vector uBlHsFromRlp; From 8877fba8ddc352f50f1b5ac48a91bee18b67b8ed Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:32 +0100 Subject: [PATCH 082/313] style + add test cases --- test/blockchain.cpp | 108 ++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ec9f7b68d..e453e32ab 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -32,7 +32,7 @@ using namespace dev::eth; namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj); BlockInfo constructBlock(mObject& _o); void updatePoW(BlockInfo& _bi); void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); @@ -106,8 +106,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); // make uncle header valid - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); uncleBlockFromFields.timestamp = (u256)time(0); + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); @@ -462,79 +462,79 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj) { - if (blObj["blockHeader"].get_obj().size() != 14) + if (_blObj["blockHeader"].get_obj().size() != 14) { - BlockInfo tmp = current_BlockHeader; + BlockInfo tmp = _current_BlockHeader; - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(_blObj["blockHeader"].get_obj()["parentHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(_blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + if (_blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(_blObj["blockHeader"].get_obj()["coinbase"].get_str()); - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + if (_blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(_blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(_blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(_blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + if (_blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(_blObj["blockHeader"].get_obj()["bloom"].get_str()); - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + if (_blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(_blObj["blockHeader"].get_obj()["difficulty"]); - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + if (_blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(_blObj["blockHeader"].get_obj()["number"]); - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + if (_blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(_blObj["blockHeader"].get_obj()["gasLimit"]); - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + if (_blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(_blObj["blockHeader"].get_obj()["gasUsed"]); - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + if (_blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(_blObj["blockHeader"].get_obj()["timestamp"]); - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (_blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(_blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(_blObj["blockHeader"].get_obj()["mixHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(_blObj["blockHeader"].get_obj()["seedHash"].get_str()); // find new valid nonce - if (tmp != current_BlockHeader) + if (tmp != _current_BlockHeader) { - current_BlockHeader = tmp; + _current_BlockHeader = tmp; ProofOfWork pow; std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) + while (!ProofOfWork::verify(_current_BlockHeader)) { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); + ret = pow.mine(_current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _current_BlockHeader); } } } else { // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const bytes c_blockRLP = createBlockRLPFromFields(_blObj["blockHeader"].get_obj()); const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); + _current_BlockHeader.populateFromHeader(c_bRLP, false); } } @@ -614,20 +614,20 @@ RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, cons BOOST_AUTO_TEST_SUITE(BlockChainTests) -//BOOST_AUTO_TEST_CASE(bcBlockChainTest) -//{ -// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcValidBlockTest) -//{ -// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) -//{ -// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} BOOST_AUTO_TEST_CASE(bcUncleTest) { From 6a8eecffa4f7433d7983e6f7627ee5a0a8df6788 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:49 +0100 Subject: [PATCH 083/313] add uncle tests --- test/bcUncleTestFiller.json | 348 +++++++++++++++++++++++++++++++++++- 1 file changed, 347 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index d866b887c..c0233ff91 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -90,6 +90,181 @@ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] + } + ] + }, + + "twoEqualUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "twoUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] }, { "transactions" : [ @@ -97,7 +272,91 @@ "data" : "", "gasLimit" : "80000050", "gasPrice" : "1", - "nonce" : "3", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "threeUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" @@ -106,6 +365,93 @@ "uncleHeaders" : [ ] }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "a55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } ] } From e2fe258d41eba8d3b47e639f9aa4c48c575a9c7f Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 6 Mar 2015 01:05:57 +0100 Subject: [PATCH 084/313] Super effective exception constructor --- libdevcore/Exceptions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index ab7b489f4..e631a3b49 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -33,7 +33,7 @@ namespace dev // base class for all exceptions struct Exception: virtual std::exception, virtual boost::exception { - Exception(std::string _message = std::string()): m_message(_message) {} + Exception(std::string _message = {}) : m_message(std::move(_message)) {} const char* what() const noexcept override { return m_message.c_str(); } private: std::string m_message; From fc9ad9eb5edf79944bb0c64f96f678c0ab5b394f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 14:34:45 +0100 Subject: [PATCH 085/313] add secure trie tests --- test/trie.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/test/trie.cpp b/test/trie.cpp index bdb188651..8a2598211 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -196,6 +196,48 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } +BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -277,6 +319,69 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } +BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trietest_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + vector keysToBeDeleted; + for (auto& i: o["in"].get_array()) + { + vector values; + for (auto& s: i.get_array()) + { + if (s.type() == json_spirit::str_type) + values.push_back(s.get_str()); + else if (s.type() == json_spirit::null_type) + { + // mark entry for deletion + values.push_back(""); + if (!values[0].find("0x")) + values[0] = asString(fromHex(values[0].substr(2))); + keysToBeDeleted.push_back(values[0]); + } + else + BOOST_FAIL("Bad type (expected string)"); + } + + BOOST_REQUIRE(values.size() == 2); + ss.push_back(make_pair(values[0], values[1])); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) + t.remove(k.first); + else + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } +} + inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From f572da381d53684f26c4615ff5a28a112400e04b Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:13:45 +0100 Subject: [PATCH 086/313] merge --- test/trie.cpp | 105 -------------------------------------------------- 1 file changed, 105 deletions(-) diff --git a/test/trie.cpp b/test/trie.cpp index 8a2598211..bdb188651 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -196,48 +196,6 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } -BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -319,69 +277,6 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } -BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trietest_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - vector keysToBeDeleted; - for (auto& i: o["in"].get_array()) - { - vector values; - for (auto& s: i.get_array()) - { - if (s.type() == json_spirit::str_type) - values.push_back(s.get_str()); - else if (s.type() == json_spirit::null_type) - { - // mark entry for deletion - values.push_back(""); - if (!values[0].find("0x")) - values[0] = asString(fromHex(values[0].substr(2))); - keysToBeDeleted.push_back(values[0]); - } - else - BOOST_FAIL("Bad type (expected string)"); - } - - BOOST_REQUIRE(values.size() == 2); - ss.push_back(make_pair(values[0], values[1])); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); - else - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } -} - inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From a63893ede973f2ab4ff2771ea12ce9497c48d593 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:15:12 +0100 Subject: [PATCH 087/313] check for minGasLimit and minDifficulty when constructing block --- libethcore/BlockInfo.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 270f96b07..3b4878a7d 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -125,10 +125,16 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) BOOST_THROW_EXCEPTION(InvalidBlockNonce(headerHash(WithoutNonce), nonce, difficulty)); if (gasUsed > gasLimit) - BOOST_THROW_EXCEPTION(TooMuchGasUsed()); + BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(gasLimit), bigint(gasUsed)) ); + + if (difficulty < c_minimumDifficulty) + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); + + if (gasLimit < c_minGasLimit) + BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); if (number && extraData.size() > c_maximumExtraDataSize) - BOOST_THROW_EXCEPTION(ExtraDataTooBig()); + BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); } void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) @@ -207,7 +213,7 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) - BOOST_THROW_EXCEPTION(InvalidDifficulty()); + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError((bigint)calculateDifficulty(_parent), (bigint)difficulty)); if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) From 660c61301e1a338cd4db32b245a22da493688019 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:14:45 +0100 Subject: [PATCH 088/313] try to have a uncle with block number = 1 --- test/bcUncleTestFiller.json | 80 +++++++++++++++++++++++++++++++++++++ test/blockchain.cpp | 6 ++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index c0233ff91..e70f25bb4 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,4 +1,84 @@ { + "uncleHeaderAtBlock2" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + "oneUncle" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index e453e32ab..7f840bc76 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -80,6 +80,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_REQUIRE(o.count("blocks")); mArray blArray; vector vBiBlocks; + vBiBlocks.push_back(biGenesisBlock); for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); @@ -107,7 +108,10 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // make uncle header valid uncleBlockFromFields.timestamp = (u256)time(0); - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + if (vBiBlocks.size() > 2) + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + else + continue; updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); From 96c552820b1a8f82c0f31db82b4dcf4d7533ebaf Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:16:11 +0100 Subject: [PATCH 089/313] fix --- test/bcUncleTestFiller.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index e70f25bb4..639051f2b 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -65,7 +65,7 @@ "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", "nonce" : "18a524c1790fa83b", - "number" : "2", + "number" : "1", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", From 602ee47ef41edca8d8e87abda97a2b082345cc1d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 11:17:26 +0100 Subject: [PATCH 090/313] Don't use flawed way of generating random keys. --- libdevcore/FixedHash.cpp | 2 +- libdevcore/FixedHash.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdevcore/FixedHash.cpp b/libdevcore/FixedHash.cpp index 0369ea854..ae2d77c85 100644 --- a/libdevcore/FixedHash.cpp +++ b/libdevcore/FixedHash.cpp @@ -25,4 +25,4 @@ using namespace std; using namespace dev; -std::mt19937_64 dev::s_fixedHashEngine(time(0)); +std::random_device dev::s_fixedHashEngine; diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index b00a80c04..49c6ed2bf 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -31,7 +31,7 @@ namespace dev { -extern std::mt19937_64 s_fixedHashEngine; +extern std::random_device s_fixedHashEngine; /// Fixed-size raw-byte array container type, with an API optimised for storing hashes. /// Transparently converts to/from the corresponding arithmetic type; this will From 0ecf17e57848404a15817c52d530850ef5e23041 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 11:57:07 +0100 Subject: [PATCH 091/313] Add the library until we figure out git subtree/submodule --- libethash/CMakeLists.txt | 39 +++++ libethash/compiler.h | 33 ++++ libethash/data_sizes.h | 247 ++++++++++++++++++++++++++++++ libethash/endian.h | 74 +++++++++ libethash/ethash.h | 93 +++++++++++ libethash/fnv.h | 38 +++++ libethash/internal.c | 298 ++++++++++++++++++++++++++++++++++++ libethash/internal.h | 48 ++++++ libethash/sha3.c | 151 ++++++++++++++++++ libethash/sha3.h | 27 ++++ libethash/sha3_cryptopp.cpp | 34 ++++ libethash/sha3_cryptopp.h | 15 ++ libethash/util.c | 41 +++++ libethash/util.h | 47 ++++++ 14 files changed, 1185 insertions(+) create mode 100644 libethash/CMakeLists.txt create mode 100644 libethash/compiler.h create mode 100644 libethash/data_sizes.h create mode 100644 libethash/endian.h create mode 100644 libethash/ethash.h create mode 100644 libethash/fnv.h create mode 100644 libethash/internal.c create mode 100644 libethash/internal.h create mode 100644 libethash/sha3.c create mode 100644 libethash/sha3.h create mode 100644 libethash/sha3_cryptopp.cpp create mode 100644 libethash/sha3_cryptopp.h create mode 100644 libethash/util.c create mode 100644 libethash/util.h diff --git a/libethash/CMakeLists.txt b/libethash/CMakeLists.txt new file mode 100644 index 000000000..7bc147af7 --- /dev/null +++ b/libethash/CMakeLists.txt @@ -0,0 +1,39 @@ +set(LIBRARY ethash) + +if (CPPETHEREUM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +#else () +endif () + +set(CMAKE_BUILD_TYPE Release) + +if (NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +endif() + +set(FILES util.c + util.h + internal.c + ethash.h + endian.h + compiler.h + fnv.h + data_sizes.h) + +if (NOT CRYPTOPP_FOUND) + find_package(CryptoPP 5.6.2) +endif() + +if (CRYPTOPP_FOUND) + add_definitions(-DWITH_CRYPTOPP) + include_directories( ${CRYPTOPP_INCLUDE_DIRS} ) + list(APPEND FILES sha3_cryptopp.cpp sha3_cryptopp.h) +else() + list(APPEND FILES sha3.c sha3.h) +endif() + +add_library(${LIBRARY} ${FILES}) + +if (CRYPTOPP_FOUND) + TARGET_LINK_LIBRARIES(${LIBRARY} ${CRYPTOPP_LIBRARIES}) +endif() diff --git a/libethash/compiler.h b/libethash/compiler.h new file mode 100644 index 000000000..9695871cd --- /dev/null +++ b/libethash/compiler.h @@ -0,0 +1,33 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file compiler.h + * @date 2014 + */ +#pragma once + +// Visual Studio doesn't support the inline keyword in C mode +#if defined(_MSC_VER) && !defined(__cplusplus) +#define inline __inline +#endif + +// pretend restrict is a standard keyword +#if defined(_MSC_VER) +#define restrict __restrict +#else +#define restrict __restrict__ +#endif + diff --git a/libethash/data_sizes.h b/libethash/data_sizes.h new file mode 100644 index 000000000..ccdf554a8 --- /dev/null +++ b/libethash/data_sizes.h @@ -0,0 +1,247 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software FoundationUUU,either version 3 of the LicenseUUU,or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be usefulU, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If notUUU,see . +*/ + +/** @file data_sizes.h +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +// TODO: Update this after ~3.5 years + +#pragma once + +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +// 500 Epochs worth of tabulated DAG sizes (~3.5 Years) + +// Generated with the following Mathematica Code: +// GetDataSizes[n_] := Module[{ +// DAGSizeBytesInit = 2^30, +// MixBytes = 128, +// DAGGrowth = 113000000, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = +// Floor[(DAGSizeBytesInit + DAGGrowth * j) / MixBytes]}, +// While[! PrimeQ[i], i--]; +// Sow[i*MixBytes]; j++]]]][[2]][[1]] + +static const size_t dag_sizes[] = { + 1073739904U, 1186739584U, 1299741568U, 1412741248U, 1525741696U, + 1638736768U, 1751741312U, 1864740736U, 1977740672U, 2090740864U, + 2203740544U, 2316741248U, 2429739392U, 2542740352U, 2655741824U, + 2768739712U, 2881740416U, 2994741632U, 3107740544U, 3220741504U, + 3333738112U, 3446741632U, 3559741312U, 3672740224U, 3785740928U, + 3898738304U, 4011741824U, 4124739712U, 4237735808U, 4350740864U, + 4463741824U, 4576741504U, 4689741184U, 4802739328U, 4915741568U, + 5028740224U, 5141740672U, 5254738304U, 5367741824U, 5480737664U, + 5593738112U, 5706741632U, 5819740544U, 5932734592U, 6045739904U, + 6158740096U, 6271740032U, 6384731776U, 6497732992U, 6610740352U, + 6723741056U, 6836741504U, 6949740416U, 7062740096U, 7175741824U, + 7288740224U, 7401741184U, 7514741632U, 7627741568U, 7740739712U, + 7853739136U, 7966740352U, 8079741568U, 8192739712U, 8305738624U, + 8418740864U, 8531740288U, 8644740736U, 8757735808U, 8870738816U, + 8983739264U, 9096740992U, 9209740928U, 9322739584U, 9435741824U, + 9548741504U, 9661739392U, 9774738304U, 9887741312U, 10000738688U, + 10113739136U, 10226741632U, 10339739776U, 10452741248U, 10565740928U, + 10678736512U, 10791734656U, 10904741248U, 11017738112U, 11130741632U, + 11243741312U, 11356739456U, 11469740416U, 11582734976U, 11695739008U, + 11808741248U, 11921734784U, 12034739072U, 12147741568U, 12260737408U, + 12373741696U, 12486738304U, 12599740544U, 12712740224U, 12825741184U, + 12938736256U, 13051741312U, 13164737408U, 13277738368U, 13390738048U, + 13503741824U, 13616741504U, 13729737088U, 13842740096U, 13955741312U, + 14068741504U, 14181740416U, 14294741632U, 14407739776U, 14520740224U, + 14633740928U, 14746736512U, 14859741824U, 14972740736U, 15085740928U, + 15198738304U, 15311732096U, 15424740736U, 15537739904U, 15650741632U, + 15763741568U, 15876737152U, 15989741696U, 16102740608U, 16215741056U, + 16328741248U, 16441740416U, 16554737792U, 16667740288U, 16780740992U, + 16893738112U, 17006741632U, 17119739008U, 17232735616U, 17345739392U, + 17458740352U, 17571736192U, 17684739712U, 17797739392U, 17910740096U, + 18023741312U, 18136740736U, 18249738112U, 18362738816U, 18475735424U, + 18588740224U, 18701738368U, 18814736768U, 18927737216U, 19040739968U, + 19153739648U, 19266736768U, 19379737984U, 19492739456U, 19605738368U, + 19718740352U, 19831741312U, 19944736384U, 20057741696U, 20170741376U, + 20283741824U, 20396737408U, 20509741696U, 20622741376U, 20735739008U, + 20848741504U, 20961740672U, 21074739328U, 21187740032U, 21300739456U, + 21413741696U, 21526740608U, 21639741824U, 21752737408U, 21865741696U, + 21978741376U, 22091741824U, 22204738432U, 22317740672U, 22430740096U, + 22543736704U, 22656741248U, 22769739904U, 22882739584U, 22995740288U, + 23108740736U, 23221740928U, 23334741376U, 23447737216U, 23560740992U, + 23673741184U, 23786740864U, 23899737728U, 24012741248U, 24125734784U, + 24238736512U, 24351741824U, 24464740736U, 24577737088U, 24690741632U, + 24803739776U, 24916740736U, 25029740416U, 25142740864U, 25255741568U, + 25368741248U, 25481740672U, 25594741376U, 25707741568U, 25820741504U, + 25933730432U, 26046739072U, 26159741824U, 26272741504U, 26385740672U, + 26498740096U, 26611741568U, 26724740992U, 26837739904U, 26950735232U, + 27063738496U, 27176741248U, 27289741184U, 27402740864U, 27515740544U, + 27628737152U, 27741740672U, 27854741632U, 27967740544U, 28080739712U, + 28193738368U, 28306741376U, 28419737728U, 28532739968U, 28645739648U, + 28758740096U, 28871741312U, 28984739456U, 29097740416U, 29210740864U, + 29323741312U, 29436740224U, 29549741696U, 29662738304U, 29775741568U, + 29888741504U, 30001740928U, 30114737024U, 30227735168U, 30340737664U, + 30453738368U, 30566737024U, 30679733632U, 30792740224U, 30905740928U, + 31018740352U, 31131740032U, 31244738944U, 31357737344U, 31470741376U, + 31583740544U, 31696740224U, 31809738112U, 31922739328U, 32035737472U, + 32148740992U, 32261741696U, 32374740352U, 32487741824U, 32600740736U, + 32713739648U, 32826740608U, 32939729792U, 33052740992U, 33165740672U, + 33278739584U, 33391741312U, 33504739712U, 33617740928U, 33730740608U, + 33843738496U, 33956739968U, 34069741696U, 34182739328U, 34295741824U, + 34408739968U, 34521740672U, 34634736512U, 34747741568U, 34860741248U, + 34973739392U, 35086738304U, 35199741056U, 35312736896U, 35425741184U, + 35538741376U, 35651740288U, 35764737152U, 35877741184U, 35990739584U, + 36103740544U, 36216740992U, 36329739392U, 36442737536U, 36555741568U, + 36668740736U, 36781741184U, 36894737024U, 37007741312U, 37120739456U, + 37233741184U, 37346736256U, 37459736192U, 37572734336U, 37685739904U, + 37798740352U, 37911737728U, 38024741504U, 38137739648U, 38250740608U, + 38363741824U, 38476740992U, 38589741184U, 38702740096U, 38815741312U, + 38928741248U, 39041738368U, 39154739584U, 39267741824U, 39380739712U, + 39493735808U, 39606741632U, 39719741312U, 39832741504U, 39945739648U, + 40058740352U, 40171740032U, 40284740992U, 40397740672U, 40510740352U, + 40623740288U, 40736738176U, 40849737856U, 40962741376U, 41075739776U, + 41188737664U, 41301735808U, 41414738048U, 41527741312U, 41640740992U, + 41753739904U, 41866739072U, 41979738496U, 42092740736U, 42205739648U, + 42318740608U, 42431741312U, 42544738688U, 42657741184U, 42770738048U, + 42883741568U, 42996741248U, 43109740928U, 43222736512U, 43335741056U, + 43448730496U, 43561740416U, 43674741632U, 43787740544U, 43900741504U, + 44013739648U, 44126740864U, 44239740544U, 44352741248U, 44465738368U, + 44578735232U, 44691739264U, 44804741504U, 44917741696U, 45030741376U, + 45143741824U, 45256740992U, 45369739136U, 45482740096U, 45595739776U, + 45708739712U, 45821740672U, 45934741376U, 46047741056U, 46160741248U, + 46273737088U, 46386740864U, 46499739008U, 46612739968U, 46725735296U, + 46838740864U, 46951741568U, 47064737152U, 47177741696U, 47290741376U, + 47403738752U, 47516741248U, 47629739648U, 47742741632U, 47855737984U, + 47968740224U, 48081738368U, 48194741632U, 48307739264U, 48420739712U, + 48533739136U, 48646738304U, 48759741824U, 48872741504U, 48985739392U, + 49098741376U, 49211741056U, 49324740992U, 49437738368U, 49550740864U, + 49663735424U, 49776737408U, 49889740672U, 50002738816U, 50115738752U, + 50228739712U, 50341741696U, 50454736768U, 50567738752U, 50680739968U, + 50793736832U, 50906734976U, 51019741568U, 51132739456U, 51245741696U, + 51358741376U, 51471741056U, 51584738944U, 51697734272U, 51810739072U, + 51923736448U, 52036740736U, 52149741184U, 52262737024U, 52375738496U, + 52488740992U, 52601739136U, 52714740352U, 52827736448U, 52940738176U, + 53053741696U, 53166740864U, 53279741824U, 53392741504U, 53505739136U, + 53618739584U, 53731741312U, 53844741248U, 53957741696U, 54070741376U, + 54183740288U, 54296741504U, 54409741696U, 54522739072U, 54635737472U, + 54748741504U, 54861736064U, 54974740096U, 55087741568U, 55200733568U, + 55313741696U, 55426734464U, 55539741056U, 55652741504U, 55765741184U, + 55878741376U, 55991730304U, 56104740992U, 56217740672U, 56330731648U, + 56443737472U, 56556724352U, 56669740672U, 56782739072U, 56895740032U, + 57008741248U, 57121741696U, 57234740096U, 57347741312U, 57460741504U +}; + +// 500 Epochs worth of tabulated DAG sizes (~3.5 Years) + +// Generated with the following Mathematica Code: +// GetCacheSizes[n_] := Module[{ +// DAGSizeBytesInit = 2^30, +// MixBytes = 128, +// DAGGrowth = 113000000, +// HashBytes = 64, +// DAGParents = 1024, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = Floor[(DAGSizeBytesInit + DAGGrowth * j) / (DAGParents * HashBytes)]}, +// While[! PrimeQ[i], i--]; +// Sow[i*HashBytes]; j++]]]][[2]][[1]] + +const size_t cache_sizes[] = { + 1048384U, 1158208U, 1268416U, 1377856U, 1489856U, 1599296U, 1710656U, + 1820608U, 1930816U, 2041024U, 2151872U, 2261696U, 2371904U, 2482624U, + 2593216U, 2703296U, 2814016U, 2924224U, 3034816U, 3144896U, 3255488U, + 3365312U, 3475904U, 3586624U, 3696064U, 3806272U, 3917504U, 4027456U, + 4138304U, 4248512U, 4359104U, 4469312U, 4579264U, 4689728U, 4797376U, + 4909888U, 5020096U, 5131328U, 5241664U, 5351744U, 5461312U, 5572544U, + 5683264U, 5793472U, 5903552U, 6014144U, 6121664U, 6235072U, 6344896U, + 6454592U, 6565952U, 6675904U, 6786112U, 6896704U, 7006784U, 7117888U, + 7228096U, 7338304U, 7448768U, 7557952U, 7669184U, 7779776U, 7889216U, + 8000192U, 8110912U, 8220736U, 8331712U, 8441536U, 8552384U, 8662592U, + 8772928U, 8883136U, 8993728U, 9103168U, 9214528U, 9323968U, 9434816U, + 9545152U, 9655616U, 9766336U, 9876544U, 9986624U, 10097344U, 10207424U, + 10316864U, 10427968U, 10538432U, 10649152U, 10758976U, 10869568U, 10979776U, + 11089472U, 11200832U, 11309632U, 11420608U, 11531584U, 11641792U, 11751104U, + 11862976U, 11973184U, 12083264U, 12193856U, 12304064U, 12414656U, 12524608U, + 12635072U, 12745792U, 12855616U, 12965824U, 13076416U, 13187008U, 13297216U, + 13407808U, 13518016U, 13627072U, 13738688U, 13848256U, 13959488U, 14069696U, + 14180288U, 14290624U, 14399552U, 14511424U, 14621504U, 14732096U, 14841664U, + 14951744U, 15062336U, 15172672U, 15283264U, 15393088U, 15504448U, 15614272U, + 15723712U, 15834944U, 15945152U, 16055744U, 16165696U, 16277056U, 16387136U, + 16494784U, 16607936U, 16718272U, 16828736U, 16938176U, 17048384U, 17159872U, + 17266624U, 17380544U, 17490496U, 17600192U, 17711296U, 17821376U, 17931968U, + 18041152U, 18152896U, 18261952U, 18373568U, 18483392U, 18594112U, 18703936U, + 18814912U, 18924992U, 19034944U, 19145408U, 19256128U, 19366208U, 19477184U, + 19587136U, 19696576U, 19808192U, 19916992U, 20028352U, 20137664U, 20249024U, + 20358848U, 20470336U, 20580544U, 20689472U, 20801344U, 20911424U, 21020096U, + 21130688U, 21242176U, 21352384U, 21462208U, 21573824U, 21683392U, 21794624U, + 21904448U, 22013632U, 22125248U, 22235968U, 22344512U, 22456768U, 22566848U, + 22677056U, 22786496U, 22897984U, 23008064U, 23118272U, 23228992U, 23338816U, + 23449408U, 23560256U, 23670464U, 23780672U, 23891264U, 24001216U, 24110656U, + 24221888U, 24332608U, 24442688U, 24552512U, 24662464U, 24773696U, 24884032U, + 24994496U, 25105216U, 25215296U, 25324864U, 25435712U, 25546432U, 25655744U, + 25767232U, 25876672U, 25986368U, 26098112U, 26207936U, 26318912U, 26428736U, + 26539712U, 26650048U, 26760256U, 26869184U, 26979776U, 27091136U, 27201728U, + 27311552U, 27422272U, 27532352U, 27642304U, 27752896U, 27863744U, 27973952U, + 28082752U, 28194752U, 28305344U, 28415168U, 28524992U, 28636352U, 28746304U, + 28857152U, 28967104U, 29077184U, 29187904U, 29298496U, 29408576U, 29518912U, + 29628992U, 29739968U, 29850176U, 29960512U, 30070336U, 30180544U, 30290752U, + 30398912U, 30512192U, 30622784U, 30732992U, 30842176U, 30953536U, 31063744U, + 31174336U, 31284544U, 31395136U, 31504448U, 31615552U, 31725632U, 31835072U, + 31946176U, 32057024U, 32167232U, 32277568U, 32387008U, 32497984U, 32608832U, + 32719168U, 32829376U, 32939584U, 33050048U, 33160768U, 33271232U, 33381184U, + 33491648U, 33601856U, 33712576U, 33822016U, 33932992U, 34042816U, 34153024U, + 34263104U, 34373824U, 34485056U, 34594624U, 34704832U, 34816064U, 34926272U, + 35036224U, 35146816U, 35255104U, 35367104U, 35478208U, 35588416U, 35698496U, + 35808832U, 35918656U, 36029888U, 36139456U, 36250688U, 36360512U, 36471104U, + 36581696U, 36691136U, 36802112U, 36912448U, 37022912U, 37132864U, 37242944U, + 37354048U, 37464512U, 37574848U, 37684928U, 37794752U, 37904704U, 38015552U, + 38125888U, 38236864U, 38345792U, 38457152U, 38567744U, 38678336U, 38787776U, + 38897216U, 39009088U, 39117632U, 39230144U, 39340352U, 39450304U, 39560384U, + 39671488U, 39781312U, 39891392U, 40002112U, 40112704U, 40223168U, 40332608U, + 40443968U, 40553792U, 40664768U, 40774208U, 40884416U, 40993984U, 41105984U, + 41215424U, 41326528U, 41436992U, 41546048U, 41655872U, 41768128U, 41878336U, + 41988928U, 42098752U, 42209344U, 42319168U, 42429248U, 42540352U, 42649792U, + 42761024U, 42871616U, 42981824U, 43092032U, 43201856U, 43312832U, 43423552U, + 43533632U, 43643584U, 43753792U, 43864384U, 43974976U, 44084032U, 44195392U, + 44306368U, 44415296U, 44526016U, 44637248U, 44746816U, 44858048U, 44967872U, + 45078848U, 45188288U, 45299264U, 45409216U, 45518272U, 45630272U, 45740224U, + 45850432U, 45960896U, 46069696U, 46182208U, 46292416U, 46402624U, 46512064U, + 46623296U, 46733888U, 46843712U, 46953664U, 47065024U, 47175104U, 47285696U, + 47395904U, 47506496U, 47615296U, 47726912U, 47837632U, 47947712U, 48055232U, + 48168128U, 48277952U, 48387392U, 48499648U, 48609472U, 48720064U, 48830272U, + 48940096U, 49050944U, 49160896U, 49271744U, 49381568U, 49492288U, 49602752U, + 49712576U, 49822016U, 49934272U, 50042816U, 50154304U, 50264128U, 50374336U, + 50484416U, 50596288U, 50706752U, 50816704U, 50927168U, 51035456U, 51146944U, + 51258176U, 51366976U, 51477824U, 51589568U, 51699776U, 51809728U, 51920576U, + 52030016U, 52140736U, 52251328U, 52361152U, 52470592U, 52582592U, 52691776U, + 52803136U, 52912576U, 53020736U, 53132224U, 53242688U, 53354816U, 53465536U, + 53575232U, 53685568U, 53796544U, 53906752U, 54016832U, 54126656U, 54236992U, + 54347456U, 54457408U, 54569024U, 54679232U, 54789184U, 54899776U, 55008832U, + 55119296U, 55231168U, 55341248U, 55451584U, 55562048U, 55672256U, 55782208U, + 55893184U, 56002112U, 56113216U +}; + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/endian.h b/libethash/endian.h new file mode 100644 index 000000000..9ca842e47 --- /dev/null +++ b/libethash/endian.h @@ -0,0 +1,74 @@ +#pragma once + +#include +#include "compiler.h" + +static const uint8_t BitReverseTable256[] = + { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + +static inline uint32_t bitfn_swap32(uint32_t a) { + return (BitReverseTable256[a & 0xff] << 24) | + (BitReverseTable256[(a >> 8) & 0xff] << 16) | + (BitReverseTable256[(a >> 16) & 0xff] << 8) | + (BitReverseTable256[(a >> 24) & 0xff]); +} + +static inline uint64_t bitfn_swap64(uint64_t a) { + return ((uint64_t) bitfn_swap32((uint32_t) (a >> 32))) | + (((uint64_t) bitfn_swap32((uint32_t) a)) << 32); +} + +#if defined(__MINGW32__) || defined(_WIN32) + # define LITTLE_ENDIAN 1234 + # define BYTE_ORDER LITTLE_ENDIAN +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) + # include +#elif defined(__OpenBSD__) || defined(__SVR4) + # include +#elif defined(__APPLE__) +# include +#elif defined( BSD ) && (BSD >= 199103) + # include +#elif defined( __QNXNTO__ ) && defined( __LITTLEENDIAN__ ) + # define LITTLE_ENDIAN 1234 + # define BYTE_ORDER LITTLE_ENDIAN +#elif defined( __QNXNTO__ ) && defined( __BIGENDIAN__ ) + # define BIG_ENDIAN 1234 + # define BYTE_ORDER BIG_ENDIAN +#else + +# include + +#endif + + +#if LITTLE_ENDIAN == BYTE_ORDER + +#define fix_endian32(x) (x) +#define fix_endian64(x) (x) + +#elif BIG_ENDIAN == BYTE_ORDER + +#define fix_endian32(x) bitfn_swap32(x) +#define fix_endian64(x) bitfn_swap64(x) + +#else +# error "endian not supported" +#endif // BYTE_ORDER \ No newline at end of file diff --git a/libethash/ethash.h b/libethash/ethash.h new file mode 100644 index 000000000..918a77413 --- /dev/null +++ b/libethash/ethash.h @@ -0,0 +1,93 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file ethash.h +* @date 2015 +*/ +#pragma once + +#include +#include +#include +#include +#include "compiler.h" + +#define REVISION 19 +#define DAGSIZE_BYTES_INIT 1073741824U // 2**30 +#define DAG_GROWTH 113000000U +#define EPOCH_LENGTH 30000U +#define MIX_BYTES 128 +#define DAG_PARENTS 256 +#define CACHE_ROUNDS 3 +#define ACCESSES 64 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ethash_params { + size_t full_size; // Size of full data set (in bytes, multiple of mix size (128)). + size_t cache_size; // Size of compute cache (in bytes, multiple of node size (64)). +} ethash_params; + +typedef struct ethash_return_value { + uint8_t result[32]; + uint8_t mix_hash[32]; +} ethash_return_value; + +size_t ethash_get_datasize(const uint32_t block_number); +size_t ethash_get_cachesize(const uint32_t block_number); + +// initialize the parameters +static inline void ethash_params_init(ethash_params *params, const uint32_t block_number) { + params->full_size = ethash_get_datasize(block_number); + params->cache_size = ethash_get_cachesize(block_number); +} + +typedef struct ethash_cache { + void *mem; +} ethash_cache; + +void ethash_mkcache(ethash_cache *cache, ethash_params const *params, const uint8_t seed[32]); +void ethash_compute_full_data(void *mem, ethash_params const *params, ethash_cache const *cache); +void ethash_full(ethash_return_value *ret, void const *full_mem, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce); +void ethash_light(ethash_return_value *ret, ethash_cache const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce); + +static inline void ethash_prep_light(void *cache, ethash_params const *params, const uint8_t seed[32]) { ethash_cache c; c.mem = cache; ethash_mkcache(&c, params, seed); } +static inline void ethash_compute_light(ethash_return_value *ret, void const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_cache c; c.mem = (void*)cache; ethash_light(ret, &c, params, header_hash, nonce); } +static inline void ethash_prep_full(void *full, ethash_params const *params, void const *cache) { ethash_cache c; c.mem = (void*)cache; ethash_compute_full_data(full, params, &c); } +static inline void ethash_compute_full(ethash_return_value *ret, void const *full, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_full(ret, full, params, header_hash, nonce); } + +static inline int ethash_check_difficulty( + const uint8_t hash[32], + const uint8_t difficulty[32]) { + // Difficulty is big endian + for (int i = 0; i < 32; i++) { + if (hash[i] == difficulty[i]) continue; + return hash[i] < difficulty[i]; + } + return 1; +} + +int ethash_quick_check_difficulty( + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32], + const uint8_t difficulty[32]); + +#ifdef __cplusplus +} +#endif diff --git a/libethash/fnv.h b/libethash/fnv.h new file mode 100644 index 000000000..edabeaae2 --- /dev/null +++ b/libethash/fnv.h @@ -0,0 +1,38 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file fnv.h +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +#pragma once +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define FNV_PRIME 0x01000193 + +static inline uint32_t fnv_hash(const uint32_t x, const uint32_t y) { + return x*FNV_PRIME ^ y; +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/internal.c b/libethash/internal.c new file mode 100644 index 000000000..a2b82d375 --- /dev/null +++ b/libethash/internal.c @@ -0,0 +1,298 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file dash.cpp +* @author Tim Hughes +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +#include +#include +#include +#include "ethash.h" +#include "fnv.h" +#include "endian.h" +#include "internal.h" +#include "data_sizes.h" + +#ifdef WITH_CRYPTOPP + +#include "sha3_cryptopp.h" + +#else +#include "sha3.h" +#endif // WITH_CRYPTOPP + +size_t ethash_get_datasize(const uint32_t block_number) { + assert(block_number / EPOCH_LENGTH < 500); + return dag_sizes[block_number / EPOCH_LENGTH]; +} + +size_t ethash_get_cachesize(const uint32_t block_number) { + assert(block_number / EPOCH_LENGTH < 500); + return cache_sizes[block_number / EPOCH_LENGTH]; +} + +// Follows Sergio's "STRICT MEMORY HARD HASHING FUNCTIONS" (2014) +// https://bitslog.files.wordpress.com/2013/12/memohash-v0-3.pdf +// SeqMemoHash(s, R, N) +void static ethash_compute_cache_nodes( + node *const nodes, + ethash_params const *params, + const uint8_t seed[32]) { + assert((params->cache_size % sizeof(node)) == 0); + uint32_t const num_nodes = (uint32_t)(params->cache_size / sizeof(node)); + + SHA3_512(nodes[0].bytes, seed, 32); + + for (unsigned i = 1; i != num_nodes; ++i) { + SHA3_512(nodes[i].bytes, nodes[i - 1].bytes, 64); + } + + for (unsigned j = 0; j != CACHE_ROUNDS; j++) { + for (unsigned i = 0; i != num_nodes; i++) { + uint32_t const idx = nodes[i].words[0] % num_nodes; + node data; + data = nodes[(num_nodes - 1 + i) % num_nodes]; + for (unsigned w = 0; w != NODE_WORDS; ++w) + { + data.words[w] ^= nodes[idx].words[w]; + } + SHA3_512(nodes[i].bytes, data.bytes, sizeof(data)); + } + } + + // now perform endian conversion +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != (num_nodes*NODE_WORDS); ++w) + { + nodes->words[w] = fix_endian32(nodes->words[w]); + } +#endif +} + +void ethash_mkcache( + ethash_cache *cache, + ethash_params const *params, + const uint8_t seed[32]) { + node *nodes = (node *) cache->mem; + ethash_compute_cache_nodes(nodes, params, seed); +} + +void ethash_calculate_dag_item( + node *const ret, + const unsigned node_index, + const struct ethash_params *params, + const struct ethash_cache *cache) { + + uint32_t num_parent_nodes = (uint32_t)(params->cache_size / sizeof(node)); + node const *cache_nodes = (node const *) cache->mem; + node const *init = &cache_nodes[node_index % num_parent_nodes]; + + memcpy(ret, init, sizeof(node)); + ret->words[0] ^= node_index; + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); + +#if defined(_M_X64) && ENABLE_SSE + __m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = ret->xmm[0]; + __m128i xmm1 = ret->xmm[1]; + __m128i xmm2 = ret->xmm[2]; + __m128i xmm3 = ret->xmm[3]; +#endif + + for (unsigned i = 0; i != DAG_PARENTS; ++i) + { + uint32_t parent_index = ((node_index ^ i)*FNV_PRIME ^ ret->words[i % NODE_WORDS]) % num_parent_nodes; + node const *parent = &cache_nodes[parent_index]; + + #if defined(_M_X64) && ENABLE_SSE + { + xmm0 = _mm_mullo_epi32(xmm0, fnv_prime); + xmm1 = _mm_mullo_epi32(xmm1, fnv_prime); + xmm2 = _mm_mullo_epi32(xmm2, fnv_prime); + xmm3 = _mm_mullo_epi32(xmm3, fnv_prime); + xmm0 = _mm_xor_si128(xmm0, parent->xmm[0]); + xmm1 = _mm_xor_si128(xmm1, parent->xmm[1]); + xmm2 = _mm_xor_si128(xmm2, parent->xmm[2]); + xmm3 = _mm_xor_si128(xmm3, parent->xmm[3]); + + // have to write to ret as values are used to compute index + ret->xmm[0] = xmm0; + ret->xmm[1] = xmm1; + ret->xmm[2] = xmm2; + ret->xmm[3] = xmm3; + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + ret->words[w] = fnv_hash(ret->words[w], parent->words[w]); + } + } + #endif + } + + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); +} + +void ethash_compute_full_data( + void *mem, + ethash_params const *params, + ethash_cache const *cache) { + assert((params->full_size % (sizeof(uint32_t) * MIX_WORDS)) == 0); + assert((params->full_size % sizeof(node)) == 0); + node *full_nodes = mem; + + // now compute full nodes + for (unsigned n = 0; n != (params->full_size / sizeof(node)); ++n) { + ethash_calculate_dag_item(&(full_nodes[n]), n, params, cache); + } +} + +static void ethash_hash( + ethash_return_value * ret, + node const *full_nodes, + ethash_cache const *cache, + ethash_params const *params, + const uint8_t header_hash[32], + const uint64_t nonce) { + + assert((params->full_size % MIX_WORDS) == 0); + + // pack hash and nonce together into first 40 bytes of s_mix + assert(sizeof(node)*8 == 512); + node s_mix[MIX_NODES + 1]; + memcpy(s_mix[0].bytes, header_hash, 32); + +#if BYTE_ORDER != LITTLE_ENDIAN + s_mix[0].double_words[4] = fix_endian64(nonce); +#else + s_mix[0].double_words[4] = nonce; +#endif + + // compute sha3-512 hash and replicate across mix + SHA3_512(s_mix->bytes, s_mix->bytes, 40); + +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != 16; ++w) { + s_mix[0].words[w] = fix_endian32(s_mix[0].words[w]); + } +#endif + + node* const mix = s_mix + 1; + for (unsigned w = 0; w != MIX_WORDS; ++w) { + mix->words[w] = s_mix[0].words[w % NODE_WORDS]; + } + + unsigned const + page_size = sizeof(uint32_t) * MIX_WORDS, + num_full_pages = (unsigned)(params->full_size / page_size); + + + for (unsigned i = 0; i != ACCESSES; ++i) + { + uint32_t const index = ((s_mix->words[0] ^ i)*FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages; + + for (unsigned n = 0; n != MIX_NODES; ++n) + { + const node * dag_node = &full_nodes[MIX_NODES * index + n]; + + if (!full_nodes) { + node tmp_node; + ethash_calculate_dag_item(&tmp_node, index * MIX_NODES + n, params, cache); + dag_node = &tmp_node; + } + + #if defined(_M_X64) && ENABLE_SSE + { + __m128i fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]); + __m128i xmm1 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[1]); + __m128i xmm2 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[2]); + __m128i xmm3 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[3]); + mix[n].xmm[0] = _mm_xor_si128(xmm0, dag_node->xmm[0]); + mix[n].xmm[1] = _mm_xor_si128(xmm1, dag_node->xmm[1]); + mix[n].xmm[2] = _mm_xor_si128(xmm2, dag_node->xmm[2]); + mix[n].xmm[3] = _mm_xor_si128(xmm3, dag_node->xmm[3]); + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]); + } + } + #endif + } + + } + + // compress mix + for (unsigned w = 0; w != MIX_WORDS; w += 4) + { + uint32_t reduction = mix->words[w+0]; + reduction = reduction*FNV_PRIME ^ mix->words[w+1]; + reduction = reduction*FNV_PRIME ^ mix->words[w+2]; + reduction = reduction*FNV_PRIME ^ mix->words[w+3]; + mix->words[w/4] = reduction; + } + +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != MIX_WORDS/4; ++w) { + mix->words[w] = fix_endian32(mix->words[w]); + } +#endif + + memcpy(ret->mix_hash, mix->bytes, 32); + // final Keccak hash + SHA3_256(ret->result, s_mix->bytes, 64+32); // Keccak-256(s + compressed_mix) +} + +void ethash_quick_hash( + uint8_t return_hash[32], + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32]) { + + uint8_t buf[64+32]; + memcpy(buf, header_hash, 32); +#if BYTE_ORDER != LITTLE_ENDIAN + nonce = fix_endian64(nonce); +#endif + memcpy(&(buf[32]), &nonce, 8); + SHA3_512(buf, buf, 40); + memcpy(&(buf[64]), mix_hash, 32); + SHA3_256(return_hash, buf, 64+32); +} + +int ethash_quick_check_difficulty( + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32], + const uint8_t difficulty[32]) { + + uint8_t return_hash[32]; + ethash_quick_hash(return_hash, header_hash, nonce, mix_hash); + return ethash_check_difficulty(return_hash, difficulty); +} + +void ethash_full(ethash_return_value * ret, void const *full_mem, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) { + ethash_hash(ret, (node const *) full_mem, NULL, params, previous_hash, nonce); +} + +void ethash_light(ethash_return_value * ret, ethash_cache const *cache, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) { + ethash_hash(ret, NULL, cache, params, previous_hash, nonce); +} diff --git a/libethash/internal.h b/libethash/internal.h new file mode 100644 index 000000000..bcbacdaa4 --- /dev/null +++ b/libethash/internal.h @@ -0,0 +1,48 @@ +#pragma once +#include "compiler.h" +#include "endian.h" +#include "ethash.h" + +#define ENABLE_SSE 1 + +#if defined(_M_X64) && ENABLE_SSE +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// compile time settings +#define NODE_WORDS (64/4) +#define MIX_WORDS (MIX_BYTES/4) +#define MIX_NODES (MIX_WORDS / NODE_WORDS) +#include + +typedef union node { + uint8_t bytes[NODE_WORDS * 4]; + uint32_t words[NODE_WORDS]; + uint64_t double_words[NODE_WORDS / 2]; + +#if defined(_M_X64) && ENABLE_SSE + __m128i xmm[NODE_WORDS/4]; +#endif + +} node; + +void ethash_calculate_dag_item( + node *const ret, + const unsigned node_index, + ethash_params const *params, + ethash_cache const *cache +); + +void ethash_quick_hash( + uint8_t return_hash[32], + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32]); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/sha3.c b/libethash/sha3.c new file mode 100644 index 000000000..0c28230b8 --- /dev/null +++ b/libethash/sha3.c @@ -0,0 +1,151 @@ +/** libkeccak-tiny +* +* A single-file implementation of SHA-3 and SHAKE. +* +* Implementor: David Leon Gil +* License: CC0, attribution kindly requested. Blame taken too, +* but not liability. +*/ +#include "sha3.h" + +#include +#include +#include +#include + +/******** The Keccak-f[1600] permutation ********/ + +/*** Constants. ***/ +static const uint8_t rho[24] = \ + { 1, 3, 6, 10, 15, 21, + 28, 36, 45, 55, 2, 14, + 27, 41, 56, 8, 25, 43, + 62, 18, 39, 61, 20, 44}; +static const uint8_t pi[24] = \ + {10, 7, 11, 17, 18, 3, + 5, 16, 8, 21, 24, 4, + 15, 23, 19, 13, 12, 2, + 20, 14, 22, 9, 6, 1}; +static const uint64_t RC[24] = \ + {1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, + 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, + 0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL, + 0x8000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL, 0x8000000000008003ULL, + 0x8000000000008002ULL, 0x8000000000000080ULL, 0x800aULL, 0x800000008000000aULL, + 0x8000000080008081ULL, 0x8000000000008080ULL, 0x80000001ULL, 0x8000000080008008ULL}; + +/*** Helper macros to unroll the permutation. ***/ +#define rol(x, s) (((x) << s) | ((x) >> (64 - s))) +#define REPEAT6(e) e e e e e e +#define REPEAT24(e) REPEAT6(e e e e) +#define REPEAT5(e) e e e e e +#define FOR5(v, s, e) \ + v = 0; \ + REPEAT5(e; v += s;) + +/*** Keccak-f[1600] ***/ +static inline void keccakf(void* state) { + uint64_t* a = (uint64_t*)state; + uint64_t b[5] = {0}; + uint64_t t = 0; + uint8_t x, y; + + for (int i = 0; i < 24; i++) { + // Theta + FOR5(x, 1, + b[x] = 0; + FOR5(y, 5, + b[x] ^= a[x + y]; )) + FOR5(x, 1, + FOR5(y, 5, + a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) + // Rho and pi + t = a[1]; + x = 0; + REPEAT24(b[0] = a[pi[x]]; + a[pi[x]] = rol(t, rho[x]); + t = b[0]; + x++; ) + // Chi + FOR5(y, + 5, + FOR5(x, 1, + b[x] = a[y + x];) + FOR5(x, 1, + a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) + // Iota + a[0] ^= RC[i]; + } +} + +/******** The FIPS202-defined functions. ********/ + +/*** Some helper macros. ***/ + +#define _(S) do { S } while (0) +#define FOR(i, ST, L, S) \ + _(for (size_t i = 0; i < L; i += ST) { S; }) +#define mkapply_ds(NAME, S) \ + static inline void NAME(uint8_t* dst, \ + const uint8_t* src, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } +#define mkapply_sd(NAME, S) \ + static inline void NAME(const uint8_t* src, \ + uint8_t* dst, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } + +mkapply_ds(xorin, dst[i] ^= src[i]) // xorin +mkapply_sd(setout, dst[i] = src[i]) // setout + +#define P keccakf +#define Plen 200 + +// Fold P*F over the full blocks of an input. +#define foldP(I, L, F) \ + while (L >= rate) { \ + F(a, I, rate); \ + P(a); \ + I += rate; \ + L -= rate; \ + } + +/** The sponge-based hash construction. **/ +static inline int hash(uint8_t* out, size_t outlen, + const uint8_t* in, size_t inlen, + size_t rate, uint8_t delim) { + if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) { + return -1; + } + uint8_t a[Plen] = {0}; + // Absorb input. + foldP(in, inlen, xorin); + // Xor in the DS and pad frame. + a[inlen] ^= delim; + a[rate - 1] ^= 0x80; + // Xor in the last block. + xorin(a, in, inlen); + // Apply P + P(a); + // Squeeze output. + foldP(out, outlen, setout); + setout(a, out, outlen); + memset(a, 0, 200); + return 0; +} + +#define defsha3(bits) \ + int sha3_##bits(uint8_t* out, size_t outlen, \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ + } + +/*** FIPS202 SHA3 FOFs ***/ +defsha3(256) +defsha3(512) \ No newline at end of file diff --git a/libethash/sha3.h b/libethash/sha3.h new file mode 100644 index 000000000..36a0a5301 --- /dev/null +++ b/libethash/sha3.h @@ -0,0 +1,27 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "compiler.h" +#include +#include + +#define decsha3(bits) \ + int sha3_##bits(uint8_t*, size_t, const uint8_t*, size_t); + +decsha3(256) +decsha3(512) + +static inline void SHA3_256(uint8_t * const ret, uint8_t const *data, const size_t size) { + sha3_256(ret, 32, data, size); +} + +static inline void SHA3_512(uint8_t * const ret, uint8_t const *data, const size_t size) { + sha3_512(ret, 64, data, size); +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/sha3_cryptopp.cpp b/libethash/sha3_cryptopp.cpp new file mode 100644 index 000000000..9454ce04a --- /dev/null +++ b/libethash/sha3_cryptopp.cpp @@ -0,0 +1,34 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ + +/** @file sha3.cpp +* @author Tim Hughes +* @date 2015 +*/ + +#include +#include + +extern "C" { +void SHA3_256(uint8_t *const ret, const uint8_t *data, size_t size) { + CryptoPP::SHA3_256().CalculateDigest(ret, data, size); +} + +void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size) { + CryptoPP::SHA3_512().CalculateDigest(ret, data, size); +} +} \ No newline at end of file diff --git a/libethash/sha3_cryptopp.h b/libethash/sha3_cryptopp.h new file mode 100644 index 000000000..f910960e1 --- /dev/null +++ b/libethash/sha3_cryptopp.h @@ -0,0 +1,15 @@ +#pragma once + +#include "compiler.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void SHA3_256(uint8_t *const ret, const uint8_t *data, size_t size); +void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/util.c b/libethash/util.c new file mode 100644 index 000000000..fbf268b7d --- /dev/null +++ b/libethash/util.c @@ -0,0 +1,41 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file util.c + * @author Tim Hughes + * @date 2015 + */ +#include +#include +#include "util.h" + +#ifdef _MSC_VER + +// foward declare without all of Windows.h +__declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString); + +void debugf(const char *str, ...) +{ + va_list args; + va_start(args, str); + + char buf[1<<16]; + _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); + buf[sizeof(buf)-1] = '\0'; + OutputDebugStringA(buf); +} + +#endif diff --git a/libethash/util.h b/libethash/util.h new file mode 100644 index 000000000..2f59076f6 --- /dev/null +++ b/libethash/util.h @@ -0,0 +1,47 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file util.h + * @author Tim Hughes + * @date 2015 + */ +#pragma once +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +void debugf(const char *str, ...); +#else +#define debugf printf +#endif + +static inline uint32_t min_u32(uint32_t a, uint32_t b) +{ + return a < b ? a : b; +} + +static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_) +{ + return x < min_ ? min_ : (x > max_ ? max_ : x); +} + +#ifdef __cplusplus +} +#endif From 0b3ecf4b766631472247a293b90e2584e2b9c181 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 092/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 48 +++++++++++++++++++++++ libethcore/CommonEth.cpp | 2 +- libethereum/CachedAddressState.cpp | 6 +-- libethereum/CachedAddressState.h | 3 ++ libethereum/CanonBlockChain.cpp | 2 +- libethereum/State.cpp | 63 +++++++++++++----------------- libethereum/State.h | 9 ++--- mix/MixClient.cpp | 2 +- 8 files changed, 88 insertions(+), 47 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f5b7ff9c9..c08199e06 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -325,6 +325,54 @@ std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) return _out; } +template +class SecureGenericTrieDB: private TrieDB +{ + using Super = TrieDB; + +public: + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + using Super::open; + using Super::init; + using Super::setRoot; + using Super::haveRoot; + + /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). + using Super::isNull; + /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). + using Super::isEmpty; + + using Super::root; + + using Super::leftOvers; + using Super::check; + + std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } + void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } +}; + +template +class SecureTrieDB: public SecureGenericTrieDB +{ + using Super = SecureGenericTrieDB; + +public: + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + std::string operator[](KeyType _k) const { return at(_k); } + + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } +}; + } // Template implementations... diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 2264e6ec9..8facdf0f1 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 54; +const unsigned c_protocolVersion = 55; const unsigned c_databaseVersion = 5; vector> const& units() diff --git a/libethereum/CachedAddressState.cpp b/libethereum/CachedAddressState.cpp index 5f9be6944..e2fadc8b5 100644 --- a/libethereum/CachedAddressState.cpp +++ b/libethereum/CachedAddressState.cpp @@ -56,9 +56,9 @@ std::map CachedAddressState::storage() const std::map ret; if (m_r) { - TrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - ret[j.first] = RLP(j.second).toInt(); + SecureTrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) +// for (auto const& j: memdb) +// ret[j.first] = RLP(j.second).toInt(); } if (m_s) for (auto const& j: m_s->storageOverlay()) diff --git a/libethereum/CachedAddressState.h b/libethereum/CachedAddressState.h index 301f54338..8a3c3a607 100644 --- a/libethereum/CachedAddressState.h +++ b/libethereum/CachedAddressState.h @@ -45,7 +45,10 @@ public: u256 balance() const; u256 nonce() const; bytes code() const; + + // TODO: DEPRECATE. std::map storage() const; + AccountDiff diff(CachedAddressState const& _c); private: diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index b0fe90a78..29fdc9acc 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -76,7 +76,7 @@ bytes CanonBlockChain::createGenesisBlock() h256 stateRoot; { MemoryDB db; - TrieDB state(&db); + SecureTrieDB state(&db); state.init(); dev::eth::commit(genesisState(), db, state); stateRoot = state.root(); diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 76ad1f269..917239351 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -168,18 +168,6 @@ State::~State() { } -Address State::nextActiveAddress(Address _a) const -{ - auto it = m_state.lower_bound(_a); - if ((*it).first == _a) - ++it; - if (it == m_state.end()) - // exchange comments if we want to wraparound -// it = m_state.begin(); - return Address(); - return (*it).first; -} - StateDiff State::diff(State const& _c) const { StateDiff ret; @@ -188,13 +176,14 @@ StateDiff State::diff(State const& _c) const std::set
trieAds; std::set
trieAdsD; - auto trie = TrieDB(const_cast(&m_db), rootHash()); - auto trieD = TrieDB(const_cast(&_c.m_db), _c.rootHash()); + auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); + auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -356,9 +345,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -591,9 +581,10 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) { cwarn << "Bad state root!"; cnote << "Given to be:" << m_currentBlock.stateRoot; - cnote << TrieDB(&m_db, m_currentBlock.stateRoot); + // TODO: Fix +// cnote << SecureTrieDB(&m_db, m_currentBlock.stateRoot); cnote << "Calculated to be:" << rootHash(); - cnote << m_state; +// cnote << m_state; cnote << *this; // Rollback the trie. m_db.rollback(); @@ -932,7 +923,7 @@ u256 State::storage(Address _id, u256 _memory) const return mit->second; // Not in the storage cache - go to the DB. - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) string payload = memdb.at(_memory); u256 ret = payload.size() ? RLP(payload).toInt() : 0; it->second.setStorage(_memory, ret); @@ -950,9 +941,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1003,24 +995,24 @@ bool State::isTrieGood(bool _enforceRefs, bool _requireNoLeftOvers) const cwarn << "LEFTOVERS" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << "Left:" << lo; cnote << "Keys:" << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } // TODO: Enable once fixed. - for (auto const& i: m_state) +/* for (auto const& i: m_state) { RLP r(i.second); - TrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. + SecureTrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. for (auto const& j: storageDB) { (void)j; } if (!e && r[3].toHash() != EmptySHA3 && m_db.lookup(r[3].toHash()).empty()) return false; - } + }*/ } catch (InvalidTrie const&) { cwarn << "BAD TRIE" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } return true; @@ -1187,9 +1179,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) std::set cached; if (r) { - TrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index 813141d17..37af0cf0e 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -94,9 +94,6 @@ public: /// @returns the set containing all addresses currently in use in Ethereum. std::map addresses() const; - /// @returns the address b such that b > @a _a . - Address nextActiveAddress(Address _a) const; - /// Get the header information on the present block. BlockInfo const& info() const { return m_currentBlock; } @@ -299,7 +296,7 @@ private: void paranoia(std::string const& _when, bool _enforceRefs = false) const; OverlayDB m_db; ///< Our overlay for the state tree. - TrieDB m_state; ///< Our state tree, as an OverlayDB DB. + SecureTrieDB m_state; ///< Our state tree, as an OverlayDB DB. Transactions m_transactions; ///< The current list of transactions that we've included in the state. TransactionReceipts m_receipts; ///< The corresponding list of transaction receipts. std::set m_transactionSet; ///< The set of transaction hashes that we've included in the state. @@ -328,7 +325,7 @@ private: std::ostream& operator<<(std::ostream& _out, State const& _s); template -void commit(std::map const& _cache, DB& _db, TrieDB& _state) +void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) if (!i.second.isAlive()) @@ -345,7 +342,7 @@ void commit(std::map const& _cache, DB& _db, TrieDB storageDB(&_db, i.second.baseRoot()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); for (auto const& j: i.second.storageOverlay()) if (j.second) storageDB.insert(j.first, rlp(j.second)); diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index e45443d35..04cec6344 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -79,7 +79,7 @@ void MixClient::resetState(u256 _balance) m_watches.clear(); m_stateDB = OverlayDB(); - TrieDB accountState(&m_stateDB); + SecureTrieDB accountState(&m_stateDB); accountState.init(); std::map genesisState = { std::make_pair(KeyPair(c_userAccountSecret).address(), Account(_balance, Account::NormalCreation)) }; dev::eth::commit(genesisState, static_cast(m_stateDB), accountState); From d7b84f1731709980d39a87172b682f30ece775b0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 093/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 6 +- libdevcrypto/MemoryDB.cpp | 2 +- libdevcrypto/MemoryDB.h | 4 ++ libdevcrypto/TrieDB.h | 123 +++++++++++++++++++++++++------------- test/trie.cpp | 44 +++++++++++++- 5 files changed, 130 insertions(+), 49 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 2b4e6bc08..24fac9c0a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -53,7 +53,7 @@ public: enum ConstructFromStringType { FromHex, FromBinary }; /// Method to convert from a string. - enum ConstructFromHashType { AlignLeft, AlignRight }; + enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent }; /// Construct an empty hash. FixedHash() { m_data.fill(0); } @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.cpp b/libdevcrypto/MemoryDB.cpp index 4fc4ed9ad..56b77ddee 100644 --- a/libdevcrypto/MemoryDB.cpp +++ b/libdevcrypto/MemoryDB.cpp @@ -107,7 +107,7 @@ set MemoryDB::keys() const { set ret; for (auto const& i: m_refCount) - if (i.second) + if (i.second && h128(i.first.ref().cropped(0, 16))) ret.insert(i.first); return ret; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 4b8d3b3a2..816e393a3 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -26,6 +26,7 @@ #include #include #include +#include "SHA3.h" namespace dev { @@ -50,6 +51,9 @@ public: bool kill(h256 _h); void purge(); + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + std::set keys() const; protected: diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index c08199e06..676193112 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -62,17 +62,21 @@ extern const h256 EmptyTrie; * assert(t.isEmpty()); * @endcode */ -template +template class GenericTrieDB { public: + using DB = _DB; + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} + void open(DB* _db) { m_db = _db; } void open(DB* _db, h256 _root) { m_db = _db; setRoot(_root); } - void init(); + void init() { setRoot(insertNode(&RLPNull)); assert(node(m_root).size()); } + void setRoot(h256 _root) { m_root = _root; @@ -83,7 +87,6 @@ public: if (!node(m_root).size()) BOOST_THROW_EXCEPTION(RootNotFound()); } - bool haveRoot(h256 _root, bool _enforceRefs = true) { return _root == c_shaNull ? true : m_db->lookup(_root, _enforceRefs).size(); } /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). bool isNull() const { return !node(m_root).size(); } @@ -211,6 +214,9 @@ public: iterator lower_bound(bytesConstRef _key) const { return iterator(this, _key); } +protected: + DB* db() const { return m_db; } + private: RLPStream& streamNode(RLPStream& _s, bytes const& _b); @@ -281,30 +287,33 @@ std::ostream& operator<<(std::ostream& _out, GenericTrieDB const& _db) return _out; } -template -class TrieDB: public GenericTrieDB +template +class SpecificTrieDB: public Generic { public: - TrieDB(DB* _db): GenericTrieDB(_db) {} - TrieDB(DB* _db, h256 _root): GenericTrieDB(_db, _root) {} + using DB = typename Generic::DB; + using KeyType = _KeyType; + + SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } - bool contains(KeyType _k) const { return GenericTrieDB::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return GenericTrieDB::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { GenericTrieDB::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + bool contains(KeyType _k) const { return Generic::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Generic::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Generic::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { GenericTrieDB::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void remove(KeyType _k) { Generic::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - class iterator: public GenericTrieDB::iterator + class iterator: public Generic::iterator { public: - using Super = typename GenericTrieDB::iterator; + using Super = typename Generic::iterator; using value_type = std::pair; iterator() {} - iterator(TrieDB const* _db): Super(_db) {} - iterator(TrieDB const* _db, bytesConstRef _k): Super(_db, _k) {} + iterator(Generic const* _db): Super(_db) {} + iterator(Generic const* _db, bytesConstRef _k): Super(_db, _k) {} value_type operator*() const { return at(); } value_type operator->() const { return at(); } @@ -317,27 +326,28 @@ public: iterator lower_bound(KeyType _k) const { return iterator(this, bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template -std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) +template +std::ostream& operator<<(std::ostream& _out, SpecificTrieDB const& _db) { for (auto const& i: _db) _out << i.first << ": " << escaped(i.second.toString(), false) << std::endl; return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -350,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... @@ -641,7 +685,7 @@ template void GenericTrieDB::iterator::next() } } -template typename TrieDB::iterator::value_type TrieDB::iterator::at() const +template typename SpecificTrieDB::iterator::value_type SpecificTrieDB::iterator::at() const { auto p = Super::at(); value_type ret; @@ -651,13 +695,6 @@ template typename TrieDB::iterator::value return ret; } -template void GenericTrieDB::init() -{ - m_root = insertNode(&RLPNull); -// std::cout << "Initialised root to " << m_root << std::endl; - assert(node(m_root).size()); -} - template void GenericTrieDB::insert(bytesConstRef _key, bytesConstRef _value) { #if ETH_PARANOIA diff --git a/test/trie.cpp b/test/trie.cpp index 39a3a59a5..4b676fb9a 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -48,6 +48,8 @@ static unsigned fac(unsigned _i) } } +using dev::operator <<; + BOOST_AUTO_TEST_SUITE(TrieTests) BOOST_AUTO_TEST_CASE(trie_test_anyorder) @@ -79,15 +81,35 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) next_permutation(ss.begin(), ss.end()); MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); for (auto const& k: ss) { t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } } } @@ -139,15 +161,33 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) { if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); + t.remove(k.first), ht.remove(k.first), ft.remove(k.first); else - t.insert(k.first, k.second); + t.insert(k.first, k.second), ht.insert(k.first, k.second), ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); From 96dda9d47f565f37862619d29613a045f63541ed Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 094/313] FatDB integrated. --- CMakeLists.txt | 7 ++++++- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/CommonEth.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cd7a80c4..156d0e5c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ function(createDefaultCacheConfig) set(PARANOIA OFF CACHE BOOL "Additional run-time checks") set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") + set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") endfunction() @@ -44,6 +45,10 @@ function(configureProject) add_definitions(-DETH_EVMJIT) endif() + if (FATDB) + add_definitions(-DETH_FATDB) + endif() + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() @@ -110,7 +115,7 @@ cmake_policy(SET CMP0015 NEW) createDefaultCacheConfig() configureProject() message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") -message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}") +message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}; FATDB: ${FATDB}") # Default TARGET_PLATFORM to "linux". diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 676193112..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 8facdf0f1..eba10e321 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 917239351..6aedc4c24 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -179,11 +179,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,10 +344,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -941,10 +939,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1180,9 +1177,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From 60b11697266d021b452626ef80f0f060ca1c2abf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 095/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 47 ++++++++++++++++------------ libdevcore/FixedHash.h | 6 ++-- libdevcore/vector_ref.h | 2 +- libdevcrypto/MemoryDB.h | 8 +++-- libdevcrypto/OverlayDB.cpp | 13 ++++++++ libdevcrypto/OverlayDB.h | 2 ++ libdevcrypto/TrieDB.h | 2 +- libethcore/CommonEth.cpp | 2 +- libethereum/Account.h | 36 ++++++++++++++++------ libethereum/BlockChain.cpp | 15 ++++++--- libethereum/State.cpp | 8 ++--- libethereum/State.h | 63 ++++++++++++++++++++------------------ test/CMakeLists.txt | 2 +- test/stateOriginal.cpp | 36 ++++++++++++++++------ test/trie.cpp | 20 ++++++++++++ 15 files changed, 177 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 156d0e5c5..ba25e74ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() @@ -153,8 +154,11 @@ if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) endif () add_subdirectory(libsolidity) -add_subdirectory(lllc) -add_subdirectory(solc) + +if (NOT JUSTTESTS) + add_subdirectory(lllc) + add_subdirectory(solc) +endif() if (JSONRPC) add_subdirectory(libweb3jsonrpc) @@ -171,25 +175,30 @@ add_subdirectory(libethereum) add_subdirectory(libwebthree) add_subdirectory(test) -add_subdirectory(eth) -if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") - add_subdirectory(exp) -endif () +if (NOT JUSTTESTS) -# TODO check msvc -if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) - add_subdirectory(neth) -endif () + add_subdirectory(eth) + + if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") + add_subdirectory(exp) + endif () + + # TODO check msvc + if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) + add_subdirectory(neth) + endif () + + if (NOT HEADLESS) + + add_subdirectory(libnatspec) + add_subdirectory(libjsqrc) + add_subdirectory(alethzero) + add_subdirectory(third) + add_subdirectory(mix) + + endif() -if (NOT HEADLESS) - - add_subdirectory(libnatspec) - add_subdirectory(libjsqrc) - add_subdirectory(alethzero) - add_subdirectory(third) - add_subdirectory(mix) - endif() enable_testing() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 24fac9c0a..3113b5427 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,16 +65,16 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } /// Explicitly construct, copying from a string. - explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s)) {} + explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s), _ht) {} /// Convert to arithmetic type. operator Arith() const { return fromBigEndian(m_data); } diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index 42633f6f1..2c5f07e51 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -23,7 +23,7 @@ public: vector_ref(typename std::conditional::value, std::vector::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} vector_ref(typename std::conditional::value, std::string const&, std::string&>::type _data): m_data((_T*)_data.data()), m_count(_data.size() / sizeof(_T)) {} #ifdef STORAGE_LEVELDB_INCLUDE_DB_H_ - vector_ref(leveldb::Slice const& _s): m_data(_s.data()), m_count(_s.size() / sizeof(_T)) {} + vector_ref(leveldb::Slice const& _s): m_data(reinterpret_cast<_T*>(_s.data())), m_count(_s.size() / sizeof(_T)) {} #endif explicit operator bool() const { return m_data && m_count; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 816e393a3..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,14 +51,18 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; protected: + static h256 aux(h256 _k) { return h256(sha3(_k).ref().cropped(0, 24), h256::AlignLeft); } + std::map m_over; std::map m_refCount; + h256 m_auxKey; + std::map m_aux; mutable bool m_enforceRefs = false; }; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 9e110bb84..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -19,6 +19,7 @@ * @date 2014 */ +#include #include #include "OverlayDB.h" using namespace std; @@ -51,11 +52,23 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } } +bytes OverlayDB::lookupAux(h256 _h) const +{ + bytes ret = MemoryDB::lookupAux(_h); + if (!ret.empty()) + return ret; + std::string v; + m_db->Get(m_readOptions, _h.ref(), &v); + return asBytes(v); +} + void OverlayDB::rollback() { m_over.clear(); diff --git a/libdevcrypto/OverlayDB.h b/libdevcrypto/OverlayDB.h index e9bd53343..d027afbd4 100644 --- a/libdevcrypto/OverlayDB.h +++ b/libdevcrypto/OverlayDB.h @@ -51,6 +51,8 @@ public: bool exists(h256 _h) const; void kill(h256 _h); + bytes lookupAux(h256 _h) const; + private: using MemoryDB::clear; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..348cab59e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index eba10e321..ad41780e9 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/Account.h b/libethereum/Account.h index 3f3a5d548..2cc962baa 100644 --- a/libethereum/Account.h +++ b/libethereum/Account.h @@ -76,28 +76,40 @@ public: ContractConception }; + /// Changedness of account to create. + enum Changedness + { + /// Account starts as though it has been changed. + Changed, + /// Account starts as though it has not been changed. + Unchanged + }; + /// Construct a dead Account. Account() {} /// Construct an alive Account, with given endowment, for either a normal (non-contract) account or for a /// contract account in the /// conception phase, where the code is not yet known. - Account(u256 _balance, NewAccountType _t): m_isAlive(true), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} + Account(u256 _balance, NewAccountType _t, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} /// Explicit constructor for wierd cases of construction of a normal account. - Account(u256 _nonce, u256 _balance): m_isAlive(true), m_nonce(_nonce), m_balance(_balance) {} + Account(u256 _nonce, u256 _balance, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance) {} /// Explicit constructor for wierd cases of construction or a contract account. - Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash): m_isAlive(true), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } + Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash, Changedness _c): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } /// Kill this account. Useful for the suicide opcode. Following this call, isAlive() returns false. - void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; } + void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; changed(); } /// @returns true iff this object represents an account in the state. Returns false if this object /// represents an account that should no longer exist in the trie (an account that never existed or was /// suicided). bool isAlive() const { return m_isAlive; } + /// @returns true if the account is unchanged from creation. + bool isDirty() const { return !m_isUnchanged; } + /// @returns the balance of this account. Can be altered in place. u256& balance() { return m_balance; } @@ -106,7 +118,7 @@ public: u256 const& balance() const { return m_balance; } /// Increments the balance of this account by the given amount. It's a bigint, so can be negative. - void addBalance(bigint _i) { m_balance = (u256)((bigint)m_balance + _i); } + void addBalance(bigint _i) { if (!_i) return; m_balance = (u256)((bigint)m_balance + _i); changed(); } /// @returns the nonce of the account. Can be altered in place. u256& nonce() { return m_nonce; } @@ -115,7 +127,7 @@ public: u256 const& nonce() const { return m_nonce; } /// Increment the nonce of the account by one. - void incNonce() { m_nonce++; } + void incNonce() { m_nonce++; changed(); } /// @returns the root of the trie (whose nodes are stored in the state db externally to this class) @@ -127,7 +139,7 @@ public: /// Set a key/value pair in the account's storage. This actually goes into the overlay, for committing /// to the trie later. - void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; } + void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; changed(); } /// @returns true if we are in the contract-conception state and setCode is valid to call. bool isFreshCode() const { return m_codeHash == c_contractConceptionCodeHash; } @@ -140,8 +152,8 @@ public: h256 codeHash() const { assert(!isFreshCode()); return m_codeHash; } /// Sets the code of the account. Must only be called when isFreshCode() returns true. - void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; } - void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; } + void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } + void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } /// @returns true if the account's code is available through code(). bool codeCacheValid() const { return m_codeHash == EmptySHA3 || m_codeHash == c_contractConceptionCodeHash || m_codeCache.size(); } @@ -154,9 +166,15 @@ public: bytes const& code() const { assert(codeCacheValid()); return m_codeCache; } private: + /// Note that we've altered the account. + void changed() { m_isUnchanged = false; } + /// Is this account existant? If not, it represents a deleted account. bool m_isAlive = false; + /// True if we've not made any alteration to the account having been given it's properties directly. + bool m_isUnchanged = false; + /// Account's nonce. u256 m_nonce = 0; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index c7c55758b..d5c5e710c 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -19,6 +19,8 @@ * @date 2014 */ +#include + #include "BlockChain.h" #include @@ -43,14 +45,17 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_extrasDB->NewIterator(_bc.m_readOptions); + auto it = _bc.m_db->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { - string rlpString = it->value().ToString(); - RLP r(rlpString); - BlockDetails d(r); - _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parent << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + try { + BlockInfo d(bytesConstRef(it->value())); + _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parentHash << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + } + catch (...) { + cwarn << "Invalid DB entry:" << toHex(it->key().ToString()) << " -> " << toHex(bytesConstRef(it->value())); + } } delete it; return _out; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 6aedc4c24..014d0f91e 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -224,7 +224,7 @@ void State::ensureCached(std::map& _cache, Address _a, bool _r if (state.isNull()) s = Account(0, Account::NormalCreation); else - s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash()); + s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash(), Account::Unchanged); bool ok; tie(it, ok) = _cache.insert(make_pair(_a, s)); } @@ -625,7 +625,7 @@ void State::uncommitToMine() if (!m_transactions.size()) m_state.setRoot(m_previousBlock.stateRoot); else - m_state.setRoot(m_receipts[m_receipts.size() - 1].stateRoot()); + m_state.setRoot(m_receipts.back().stateRoot()); m_db = m_lastTx; paranoia("Uncommited to mine", true); m_currentBlock.sha3Uncles = h256(); @@ -890,7 +890,7 @@ Address State::newContract(u256 _balance, bytes const& _code) auto it = m_cache.find(ret); if (it == m_cache.end()) { - m_cache[ret] = Account(0, _balance, EmptyTrie, h); + m_cache[ret] = Account(0, _balance, EmptyTrie, h, Account::Changed); return ret; } } @@ -1144,7 +1144,7 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) _out << "--- " << _s.rootHash() << std::endl; std::set
d; std::set
dtr; - auto trie = TrieDB(const_cast(&_s.m_db), _s.rootHash()); + auto trie = SecureTrieDB(const_cast(&_s.m_db), _s.rootHash()); for (auto i: trie) d.insert(i.first), dtr.insert(i.first); for (auto i: _s.m_cache) diff --git a/libethereum/State.h b/libethereum/State.h index 37af0cf0e..a496a4a03 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -328,40 +328,43 @@ template void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) - if (!i.second.isAlive()) - _state.remove(i.first); - else + if (i.second.isDirty()) { - RLPStream s(4); - s << i.second.nonce() << i.second.balance(); - - if (i.second.storageOverlay().empty()) - { - assert(i.second.baseRoot()); - s.append(i.second.baseRoot()); - } + if (!i.second.isAlive()) + _state.remove(i.first); else { - SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7ddfdb40d..292f62a03 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) target_link_libraries(testeth solidity) -if (NOT HEADLESS) +if (NOT HEADLESS AND NOT JUSTTESTS) target_link_libraries(testeth webthree) target_link_libraries(testeth natspec) endif() diff --git a/test/stateOriginal.cpp b/test/stateOriginal.cpp index 65ff5084f..5b7b0415e 100644 --- a/test/stateOriginal.cpp +++ b/test/stateOriginal.cpp @@ -20,6 +20,7 @@ * State test functions. */ +#include #include #include #include @@ -29,7 +30,21 @@ using namespace std; using namespace dev; using namespace dev::eth; -int stateTest() +namespace dev +{ +namespace test +{ + +int stateTest(); + +BOOST_AUTO_TEST_SUITE(StateIntegration) + +BOOST_AUTO_TEST_CASE(Basic) +{ + State s; +} + +BOOST_AUTO_TEST_CASE(Complex) { cnote << "Testing State..."; @@ -37,14 +52,15 @@ int stateTest() KeyPair myMiner = sha3("Gav's Miner"); // KeyPair you = sha3("123"); - Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); + Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count())); OverlayDB stateDB = State::openDB(); CanonBlockChain bc; - State s(myMiner.address(), stateDB); - cout << bc; + State s(myMiner.address(), stateDB); + cout << s; + // Sync up - this won't do much until we use the last state. s.sync(bc); @@ -52,7 +68,7 @@ int stateTest() // Mine to get some ether! s.commitToMine(bc); - while (!s.mine(100).completed) {} + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -65,7 +81,7 @@ int stateTest() // Inject a transaction to transfer funds from miner to me. bytes tx; { - Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); + Transaction t(1000, 10000, 10000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); assert(t.sender() == myMiner.address()); tx = t.rlp(); } @@ -76,7 +92,7 @@ int stateTest() // Mine to get some ether and set in stone. s.commitToMine(bc); s.commitToMine(bc); - while (!s.mine(50).completed) { s.commitToMine(bc); } + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -85,7 +101,9 @@ int stateTest() s.sync(bc); cout << s; - - return 0; } +BOOST_AUTO_TEST_SUITE_END() + +} +} diff --git a/test/trie.cpp b/test/trie.cpp index 4b676fb9a..aa453925d 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -52,6 +52,26 @@ using dev::operator <<; BOOST_AUTO_TEST_SUITE(TrieTests) +BOOST_AUTO_TEST_CASE(fat_trie) +{ + h256 r; + MemoryDB fm; + { + FatGenericTrieDB ft(&fm); + ft.init(); + ft.insert(h256("69", h256::FromHex, h256::AlignRight).ref(), h256("414243", h256::FromHex, h256::AlignRight).ref()); + for (auto i: ft) + cnote << i.first << i.second; + r = ft.root(); + } + { + FatGenericTrieDB ft(&fm); + ft.setRoot(r); + for (auto i: ft) + cnote << i.first << i.second; + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From d40f1c376d657090c7d2c7387f04d6a2de5a9eb6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 096/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 348cab59e..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From 40c8ec7cb6f9bba65db0e9e903f5fa0d840cbc41 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 097/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 3 + libevm/ExtVMFace.h | 3 + libevm/FeeStructure.cpp | 59 +++++--- libevm/FeeStructure.h | 50 ++++--- libevm/VM.cpp | 197 ++++++--------------------- libevmcore/Instruction.cpp | 267 ++++++++++++++++++------------------- libevmcore/Instruction.h | 14 ++ 7 files changed, 259 insertions(+), 334 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 30cbf1a5a..40ff62175 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -69,6 +69,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } + /// Does the account exist? + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final { diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 13e8712b8..1bca3e2b2 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -142,6 +142,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address) { return 0; } + /// Does the account exist? + virtual bool exists(Address) { return false; } + /// Suicide the associated contract and give proceeds to the given address. virtual void suicide(Address) { sub.suicides.insert(myAddress); } diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 94eb956af..1c1bf8a9e 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -25,24 +25,41 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 const dev::eth::c_stepGas = 1; -u256 const dev::eth::c_balanceGas = 20; -u256 const dev::eth::c_sha3Gas = 10; -u256 const dev::eth::c_sha3WordGas = 10; -u256 const dev::eth::c_sloadGas = 20; -u256 const dev::eth::c_sstoreSetGas = 300; -u256 const dev::eth::c_sstoreResetGas = 100; -u256 const dev::eth::c_sstoreRefundGas = 100; -u256 const dev::eth::c_createGas = 100; -u256 const dev::eth::c_createDataGas = 5; -u256 const dev::eth::c_callGas = 20; -u256 const dev::eth::c_expGas = 1; -u256 const dev::eth::c_expByteGas = 1; -u256 const dev::eth::c_memoryGas = 1; -u256 const dev::eth::c_txDataZeroGas = 1; -u256 const dev::eth::c_txDataNonZeroGas = 5; -u256 const dev::eth::c_txGas = 500; -u256 const dev::eth::c_logGas = 32; -u256 const dev::eth::c_logDataGas = 1; -u256 const dev::eth::c_logTopicGas = 32; -u256 const dev::eth::c_copyGas = 1; +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + + diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 8ef384265..1b58c80e9 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,27 +28,37 @@ namespace dev namespace eth { -extern u256 const c_stepGas; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. -extern u256 const c_balanceGas; ///< Once per BALANCE operation. -extern u256 const c_sha3Gas; ///< Once per SHA3 operation. -extern u256 const c_sha3WordGas; -extern u256 const c_sloadGas; ///< Once per SLOAD operation. -extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. -extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. -extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. -extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. +extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. +extern u256 const c_expGas; ///< Once per EXP instuction. +extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + +extern u256 const c_sha3Gas; ///< Once per SHA3 operation. +extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + +extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + +extern u256 const c_sloadGas; ///< Once per SLOAD operation. +extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. +extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. +extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + +extern u256 const c_logGas; ///< Per LOG* operation. +extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. +extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. +extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; -extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_expGas; ///< Once per EXP instuction. -extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. -extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. -extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. -extern u256 const c_logGas; ///< Per LOG* operation. -extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. -extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. -extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. +extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. +extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. +extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + +extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. +extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. +extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2ba18eda6..a52b0ec3e 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -21,7 +21,7 @@ #include "VM.h" #include - +using namespace std; using namespace dev; using namespace dev::eth; @@ -32,13 +32,33 @@ void VM::reset(u256 _gas) noexcept m_jumpDests.clear(); } +struct InstructionMetric +{ + int gasPriceTier; + int args; +}; + +static array metrics() +{ + array s_ret; + for (unsigned i = 0; i < 256; ++i) + { + InstructionInfo inst = instructionInfo((Instruction)i); + s_ret[i].gasPriceTier = inst.gasPriceTier; + s_ret[i].args = inst.args; + } + return s_ret; +} + bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { + static const array c_metrics = metrics(); + auto memNeed = [](u256 _offset, dev::u256 _size) { return _size ? (bigint)_offset + _size : (bigint)0; }; auto gasForMem = [](bigint _size) -> bigint { bigint s = _size / 32; - return (bigint)c_memoryGas * (s + s * s / 1024); + return (bigint)c_memoryGas * s + s * s / c_quadCoeffDiv; }; if (m_jumpDests.empty()) @@ -57,36 +77,35 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) Instruction inst = (Instruction)_ext.getCode(m_curPC); // FEES... - bigint runGas = c_stepGas; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; + // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. + //m_onFail = std::function(onOperation); + + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; + require(metric.args); + auto onOperation = [&]() { if (_onOp) _onOp(osteps - _steps - 1, inst, newTempSize > m_temp.size() ? (newTempSize - m_temp.size()) / 32 : bigint(0), runGas, this, &_ext); }; - // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. - //m_onFail = std::function(onOperation); switch (inst) { - case Instruction::STOP: - runGas = 0; - break; - - case Instruction::SUICIDE: - require(1); - runGas = 0; - break; - case Instruction::SSTORE: - require(2); if (!_ext.store(m_stack.back()) && m_stack[m_stack.size() - 2]) runGas = c_sstoreSetGas; else if (_ext.store(m_stack.back()) && !m_stack[m_stack.size() - 2]) { - runGas = 0; + runGas = c_sstoreClearGas; _ext.sub.refunds += c_sstoreRefundGas; } else @@ -94,52 +113,39 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::SLOAD: - require(1); runGas = c_sloadGas; break; // These all operate on memory and therefore potentially expand it: case Instruction::MSTORE: - require(2); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::MSTORE8: - require(2); newTempSize = (bigint)m_stack.back() + 1; break; case Instruction::MLOAD: - require(1); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::RETURN: - require(2); newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::SHA3: - require(2); runGas = c_sha3Gas + (m_stack[m_stack.size() - 2] + 31) / 32 * c_sha3WordGas; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::CALLDATACOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::CODECOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::EXTCODECOPY: - require(4); copySize = m_stack[m_stack.size() - 4]; newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::BALANCE: - require(1); - runGas = c_balanceGas; - break; case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -147,7 +153,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::LOG4: { unsigned n = (unsigned)inst - (unsigned)Instruction::LOG0; - require(n + 2); runGas = c_logGas + c_logTopicGas * n + (bigint)c_logDataGas * m_stack[m_stack.size() - 2]; newTempSize = memNeed(m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]); break; @@ -155,149 +160,27 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: - require(7); runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + runGas += c_callNewAccountGas; + if (m_stack[m_stack.size() - 3] > 0) + runGas += c_callValueTransferGas; newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); break; case Instruction::CREATE: { - require(3); newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]); runGas = c_createGas; break; } case Instruction::EXP: { - require(2); auto expon = m_stack[m_stack.size() - 2]; runGas = c_expGas + c_expByteGas * (32 - (h256(expon).firstBitSet() / 8)); break; } - - case Instruction::BLOCKHASH: - require(1); - break; - - case Instruction::PC: - case Instruction::MSIZE: - case Instruction::GAS: - case Instruction::JUMPDEST: - case Instruction::ADDRESS: - case Instruction::ORIGIN: - case Instruction::CALLER: - case Instruction::CALLVALUE: - case Instruction::CALLDATASIZE: - case Instruction::CODESIZE: - case Instruction::GASPRICE: - case Instruction::COINBASE: - case Instruction::TIMESTAMP: - case Instruction::NUMBER: - case Instruction::DIFFICULTY: - case Instruction::GASLIMIT: - case Instruction::PUSH1: - case Instruction::PUSH2: - case Instruction::PUSH3: - case Instruction::PUSH4: - case Instruction::PUSH5: - case Instruction::PUSH6: - case Instruction::PUSH7: - case Instruction::PUSH8: - case Instruction::PUSH9: - case Instruction::PUSH10: - case Instruction::PUSH11: - case Instruction::PUSH12: - case Instruction::PUSH13: - case Instruction::PUSH14: - case Instruction::PUSH15: - case Instruction::PUSH16: - case Instruction::PUSH17: - case Instruction::PUSH18: - case Instruction::PUSH19: - case Instruction::PUSH20: - case Instruction::PUSH21: - case Instruction::PUSH22: - case Instruction::PUSH23: - case Instruction::PUSH24: - case Instruction::PUSH25: - case Instruction::PUSH26: - case Instruction::PUSH27: - case Instruction::PUSH28: - case Instruction::PUSH29: - case Instruction::PUSH30: - case Instruction::PUSH31: - case Instruction::PUSH32: - break; - case Instruction::NOT: - case Instruction::ISZERO: - case Instruction::CALLDATALOAD: - case Instruction::EXTCODESIZE: - case Instruction::POP: - case Instruction::JUMP: - require(1); - break; - case Instruction::ADD: - case Instruction::MUL: - case Instruction::SUB: - case Instruction::DIV: - case Instruction::SDIV: - case Instruction::MOD: - case Instruction::SMOD: - case Instruction::LT: - case Instruction::GT: - case Instruction::SLT: - case Instruction::SGT: - case Instruction::EQ: - case Instruction::AND: - case Instruction::OR: - case Instruction::XOR: - case Instruction::BYTE: - case Instruction::JUMPI: - case Instruction::SIGNEXTEND: - require(2); - break; - case Instruction::ADDMOD: - case Instruction::MULMOD: - require(3); - break; - case Instruction::DUP1: - case Instruction::DUP2: - case Instruction::DUP3: - case Instruction::DUP4: - case Instruction::DUP5: - case Instruction::DUP6: - case Instruction::DUP7: - case Instruction::DUP8: - case Instruction::DUP9: - case Instruction::DUP10: - case Instruction::DUP11: - case Instruction::DUP12: - case Instruction::DUP13: - case Instruction::DUP14: - case Instruction::DUP15: - case Instruction::DUP16: - require(1 + (int)inst - (int)Instruction::DUP1); - break; - case Instruction::SWAP1: - case Instruction::SWAP2: - case Instruction::SWAP3: - case Instruction::SWAP4: - case Instruction::SWAP5: - case Instruction::SWAP6: - case Instruction::SWAP7: - case Instruction::SWAP8: - case Instruction::SWAP9: - case Instruction::SWAP10: - case Instruction::SWAP11: - case Instruction::SWAP12: - case Instruction::SWAP13: - case Instruction::SWAP14: - case Instruction::SWAP15: - case Instruction::SWAP16: - require((int)inst - (int)Instruction::SWAP1 + 2); - break; - default: - BOOST_THROW_EXCEPTION(BadInstruction()); + default:; } newTempSize = (newTempSize + 31) / 32 * 32; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index bba3d7745..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -162,136 +162,136 @@ const std::map dev::eth::c_instructions = }; static const std::map c_instructionInfo = -{ // Add, Args, Ret, SideEffects - { Instruction::STOP, { "STOP", 0, 0, 0, true } }, - { Instruction::ADD, { "ADD", 0, 2, 1, false } }, - { Instruction::SUB, { "SUB", 0, 2, 1, false } }, - { Instruction::MUL, { "MUL", 0, 2, 1, false } }, - { Instruction::DIV, { "DIV", 0, 2, 1, false } }, - { Instruction::SDIV, { "SDIV", 0, 2, 1, false } }, - { Instruction::MOD, { "MOD", 0, 2, 1, false } }, - { Instruction::SMOD, { "SMOD", 0, 2, 1, false } }, - { Instruction::EXP, { "EXP", 0, 2, 1, false } }, - { Instruction::NOT, { "NOT", 0, 1, 1, false } }, - { Instruction::LT, { "LT", 0, 2, 1, false } }, - { Instruction::GT, { "GT", 0, 2, 1, false } }, - { Instruction::SLT, { "SLT", 0, 2, 1, false } }, - { Instruction::SGT, { "SGT", 0, 2, 1, false } }, - { Instruction::EQ, { "EQ", 0, 2, 1, false } }, - { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false } }, - { Instruction::AND, { "AND", 0, 2, 1, false } }, - { Instruction::OR, { "OR", 0, 2, 1, false } }, - { Instruction::XOR, { "XOR", 0, 2, 1, false } }, - { Instruction::BYTE, { "BYTE", 0, 2, 1, false } }, - { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false } }, - { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false } }, - { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false } }, - { Instruction::SHA3, { "SHA3", 0, 2, 1, false } }, - { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false } }, - { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false } }, - { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false } }, - { Instruction::CALLER, { "CALLER", 0, 0, 1, false } }, - { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false } }, - { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false } }, - { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false } }, - { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true } }, - { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false } }, - { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true } }, - { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } }, - { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } }, - { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true } }, - { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false } }, - { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false } }, - { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } }, - { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } }, - { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false } }, - { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false } }, - { Instruction::POP, { "POP", 0, 1, 0, false } }, - { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false } }, - { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true } }, - { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true } }, - { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false } }, - { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true } }, - { Instruction::JUMP, { "JUMP", 0, 1, 0, true } }, - { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true } }, - { Instruction::PC, { "PC", 0, 0, 1, false } }, - { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false } }, - { Instruction::GAS, { "GAS", 0, 0, 1, false } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true } }, - { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false } }, - { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false } }, - { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false } }, - { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false } }, - { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false } }, - { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false } }, - { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false } }, - { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false } }, - { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false } }, - { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false } }, - { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false } }, - { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false } }, - { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false } }, - { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false } }, - { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false } }, - { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false } }, - { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false } }, - { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false } }, - { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false } }, - { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false } }, - { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false } }, - { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false } }, - { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false } }, - { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false } }, - { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false } }, - { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false } }, - { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false } }, - { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false } }, - { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false } }, - { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false } }, - { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false } }, - { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false } }, - { Instruction::DUP1, { "DUP1", 0, 1, 2, false } }, - { Instruction::DUP2, { "DUP2", 0, 2, 3, false } }, - { Instruction::DUP3, { "DUP3", 0, 3, 4, false } }, - { Instruction::DUP4, { "DUP4", 0, 4, 5, false } }, - { Instruction::DUP5, { "DUP5", 0, 5, 6, false } }, - { Instruction::DUP6, { "DUP6", 0, 6, 7, false } }, - { Instruction::DUP7, { "DUP7", 0, 7, 8, false } }, - { Instruction::DUP8, { "DUP8", 0, 8, 9, false } }, - { Instruction::DUP9, { "DUP9", 0, 9, 10, false } }, - { Instruction::DUP10, { "DUP10", 0, 10, 11, false } }, - { Instruction::DUP11, { "DUP11", 0, 11, 12, false } }, - { Instruction::DUP12, { "DUP12", 0, 12, 13, false } }, - { Instruction::DUP13, { "DUP13", 0, 13, 14, false } }, - { Instruction::DUP14, { "DUP14", 0, 14, 15, false } }, - { Instruction::DUP15, { "DUP15", 0, 15, 16, false } }, - { Instruction::DUP16, { "DUP16", 0, 16, 17, false } }, - { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false } }, - { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false } }, - { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false } }, - { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false } }, - { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false } }, - { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false } }, - { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false } }, - { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false } }, - { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false } }, - { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false } }, - { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false } }, - { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false } }, - { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false } }, - { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false } }, - { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false } }, - { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false } }, - { Instruction::LOG0, { "LOG0", 0, 2, 0, true } }, - { Instruction::LOG1, { "LOG1", 0, 3, 0, true } }, - { Instruction::LOG2, { "LOG2", 0, 4, 0, true } }, - { Instruction::LOG3, { "LOG3", 0, 5, 0, true } }, - { Instruction::LOG4, { "LOG4", 0, 6, 0, true } }, - { Instruction::CREATE, { "CREATE", 0, 3, 1, true } }, - { Instruction::CALL, { "CALL", 0, 7, 1, true } }, - { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true } }, - { Instruction::RETURN, { "RETURN", 0, 2, 0, true } }, - { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true } } +{ // Add, Args, Ret, SideEffects, GasPriceTier + { Instruction::STOP, { "STOP", 0, 0, 0, true, ZeroTier } }, + { Instruction::ADD, { "ADD", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SUB, { "SUB", 0, 2, 1, false, VeryLowTier } }, + { Instruction::MUL, { "MUL", 0, 2, 1, false, LowTier } }, + { Instruction::DIV, { "DIV", 0, 2, 1, false, LowTier } }, + { Instruction::SDIV, { "SDIV", 0, 2, 1, false, LowTier } }, + { Instruction::MOD, { "MOD", 0, 2, 1, false, LowTier } }, + { Instruction::SMOD, { "SMOD", 0, 2, 1, false, LowTier } }, + { Instruction::EXP, { "EXP", 0, 2, 1, false, SpecialTier } }, + { Instruction::NOT, { "NOT", 0, 1, 1, false, VeryLowTier } }, + { Instruction::LT, { "LT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::GT, { "GT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SLT, { "SLT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SGT, { "SGT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::EQ, { "EQ", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false, VeryLowTier } }, + { Instruction::AND, { "AND", 0, 2, 1, false, VeryLowTier } }, + { Instruction::OR, { "OR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::XOR, { "XOR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::BYTE, { "BYTE", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, MidTier } }, + { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, MidTier } }, + { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, LowTier } }, + { Instruction::SHA3, { "SHA3", 0, 2, 1, false, SpecialTier } }, + { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, BaseTier } }, + { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, ExtTier } }, + { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLER, { "CALLER", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false, BaseTier } }, + { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false, ExtTier } }, + { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, ExtTier } }, + { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, ExtTier } }, + { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, BaseTier } }, + { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, BaseTier } }, + { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false, BaseTier } }, + { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false, BaseTier } }, + { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false, BaseTier } }, + { Instruction::POP, { "POP", 0, 1, 0, false, BaseTier } }, + { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true, VeryLowTier } }, + { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true, VeryLowTier } }, + { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false, SpecialTier } }, + { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true, SpecialTier } }, + { Instruction::JUMP, { "JUMP", 0, 1, 0, true, MidTier } }, + { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, HighTier } }, + { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, + { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false, VeryLowTier } }, + { Instruction::DUP1, { "DUP1", 0, 1, 2, false, VeryLowTier } }, + { Instruction::DUP2, { "DUP2", 0, 2, 3, false, VeryLowTier } }, + { Instruction::DUP3, { "DUP3", 0, 3, 4, false, VeryLowTier } }, + { Instruction::DUP4, { "DUP4", 0, 4, 5, false, VeryLowTier } }, + { Instruction::DUP5, { "DUP5", 0, 5, 6, false, VeryLowTier } }, + { Instruction::DUP6, { "DUP6", 0, 6, 7, false, VeryLowTier } }, + { Instruction::DUP7, { "DUP7", 0, 7, 8, false, VeryLowTier } }, + { Instruction::DUP8, { "DUP8", 0, 8, 9, false, VeryLowTier } }, + { Instruction::DUP9, { "DUP9", 0, 9, 10, false, VeryLowTier } }, + { Instruction::DUP10, { "DUP10", 0, 10, 11, false, VeryLowTier } }, + { Instruction::DUP11, { "DUP11", 0, 11, 12, false, VeryLowTier } }, + { Instruction::DUP12, { "DUP12", 0, 12, 13, false, VeryLowTier } }, + { Instruction::DUP13, { "DUP13", 0, 13, 14, false, VeryLowTier } }, + { Instruction::DUP14, { "DUP14", 0, 14, 15, false, VeryLowTier } }, + { Instruction::DUP15, { "DUP15", 0, 15, 16, false, VeryLowTier } }, + { Instruction::DUP16, { "DUP16", 0, 16, 17, false, VeryLowTier } }, + { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false, VeryLowTier } }, + { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false, VeryLowTier } }, + { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false, VeryLowTier } }, + { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false, VeryLowTier } }, + { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false, VeryLowTier } }, + { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false, VeryLowTier } }, + { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false, VeryLowTier } }, + { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false, VeryLowTier } }, + { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false, VeryLowTier } }, + { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false, VeryLowTier } }, + { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false, VeryLowTier } }, + { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false, VeryLowTier } }, + { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false, VeryLowTier } }, + { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false, VeryLowTier } }, + { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false, VeryLowTier } }, + { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false, VeryLowTier } }, + { Instruction::LOG0, { "LOG0", 0, 2, 0, true, SpecialTier } }, + { Instruction::LOG1, { "LOG1", 0, 3, 0, true, SpecialTier } }, + { Instruction::LOG2, { "LOG2", 0, 4, 0, true, SpecialTier } }, + { Instruction::LOG3, { "LOG3", 0, 5, 0, true, SpecialTier } }, + { Instruction::LOG4, { "LOG4", 0, 6, 0, true, SpecialTier } }, + { Instruction::CREATE, { "CREATE", 0, 3, 1, true, SpecialTier } }, + { Instruction::CALL, { "CALL", 0, 7, 1, true, SpecialTier } }, + { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, SpecialTier } }, + { Instruction::RETURN, { "RETURN", 0, 2, 0, true, ZeroTier } }, + { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true, ZeroTier } } }; string dev::eth::disassemble(bytes const& _mem) @@ -326,12 +326,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } catch (...) { -#ifndef BOOST_NO_EXCEPTIONS - cwarn << "\n" << boost::current_exception_diagnostic_information(); -#else - cwarn << "\n"; -#endif - return InstructionInfo({"", 0, 0, 0, false}); + return InstructionInfo({"", 0, 0, 0, false, InvalidTier}); } } diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h index 5cf002c4c..9eab92713 100644 --- a/libevmcore/Instruction.h +++ b/libevmcore/Instruction.h @@ -223,6 +223,19 @@ inline Instruction logInstruction(unsigned _number) return Instruction(unsigned(Instruction::LOG0) + _number); } +enum Tier +{ + ZeroTier = 0, // 0, Zero + BaseTier, // 2, Quick + VeryLowTier, // 3, Fastest + LowTier, // 5, Fast + MidTier, // 8, Mid + HighTier, // 10, Slow + ExtTier, // 20, Ext + SpecialTier, // multiparam or otherwise special + InvalidTier // Invalid. +}; + /// Information structure for a particular instruction. struct InstructionInfo { @@ -231,6 +244,7 @@ struct InstructionInfo int args; ///< Number of items required on the stack for this instruction (and, for the purposes of ret, the number taken from the stack). int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed. bool sideEffects; ///< false if the only effect on the execution environment (apart from gas usage) is a change to a topmost segment of the stack + int gasPriceTier; ///< Tier for gas pricing. }; /// Information on all the instructions. From 314b82a1cde169c53f5e682d7664062f8cd7a043 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 098/313] Gas fixes. Trie fixes. --- libdevcore/Exceptions.h | 1 + libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 8 ++++++-- libethereum/Client.cpp | 8 ++------ libevm/VM.cpp | 15 +++++++-------- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index f3f9b1bf0..3861c69fe 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -40,6 +40,7 @@ struct BadRLP: virtual RLPException {}; struct NoNetworking: virtual Exception {}; struct NoUPnPDevice: virtual Exception {}; struct RootNotFound: virtual Exception {}; +struct BadRoot: virtual Exception {}; struct FileError: virtual Exception {}; struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): m_f("Interface " + _f + " not supported.") {} virtual const char* what() const noexcept { return m_f.c_str(); } private: std::string m_f; }; diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -93,7 +93,7 @@ public: /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). bool isEmpty() const { return m_root == c_shaNull && node(m_root).size(); } - h256 root() const { assert(node(m_root).size()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. + h256 root() const { if (!node(m_root).size()) BOOST_THROW_EXCEPTION(BadRoot()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. void debugPrint() {} @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 5ea513f0a..42ff1f25d 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -277,13 +277,9 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -#if ETH_DEBUG - cdebug << "checkWatch" << _watchId; -#endif +// cdebug << "checkWatch" << _watchId; auto& w = m_watches.at(_watchId); -#if ETH_DEBUG - cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); -#endif +// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index a52b0ec3e..6a6937f89 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -75,21 +75,20 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { // INSTRUCTION... Instruction inst = (Instruction)_ext.getCode(m_curPC); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -186,7 +185,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = (newTempSize + 31) / 32 * 32; if (newTempSize > m_temp.size()) runGas += gasForMem(newTempSize) - gasForMem(m_temp.size()); - runGas += c_copyGas * (copySize + 31) / 32; + runGas += c_copyGas * ((copySize + 31) / 32); onOperation(); // if (_onOp) From 8cdbb18419b65e9f099cf320791ae2eff030ea8a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 099/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 6a6937f89..2243da2e7 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From de180530672ca701c328a61e576ecb3750c93ff8 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 100/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- test/vm.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 40ff62175..2ff270de5 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/test/vm.h b/test/vm.h index 0a5b5fb45..c13a97276 100644 --- a/test/vm.h +++ b/test/vm.h @@ -50,6 +50,7 @@ public: virtual u256 store(u256 _n) override { return std::get<2>(addresses[myAddress])[_n]; } virtual void setStore(u256 _n, u256 _v) override { std::get<2>(addresses[myAddress])[_n] = _v; } + virtual bool exists(Address _a) override { return !!addresses.count(_a); } virtual u256 balance(Address _a) override { return std::get<0>(addresses[_a]); } virtual void subBalance(u256 _a) override { std::get<0>(addresses[myAddress]) -= _a; } virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); } From 9bed576fe856b5098d67921d9d429ba09d4a350a Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 101/313] only check rootHash of state if FATDB is off --- test/state.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/state.cpp b/test/state.cpp index 1581e4055..37ffa7f8e 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -71,7 +71,13 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } if (_fillin) + { +#if ETH_FATDB importer.exportTest(output, theState); +#else + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off")); +#endif + } else { BOOST_REQUIRE(o.count("post") > 0); @@ -84,6 +90,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); // check addresses +#if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -102,6 +110,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } } checkAddresses >(expectedAddrs, resultAddrs); +#endif + BOOST_CHECK_MESSAGE(theState.rootHash() == h256(o["postStateRoot"].get_str()), "wrong post state root"); } } } From 9a2d9684e3c36211a8fd2917dfeefe4ce5f8f1ab Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 102/313] add memory tests --- test/TestHelper.cpp | 2 ++ test/stMemoryTestFiller.json | 4 +-- test/state.cpp | 68 ++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index ea44111c9..1d544304c 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -203,6 +203,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost) } m_TestObject["post"] = json_spirit::mValue(postState); + m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes()); + // export pre state json_spirit::mObject preState; diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json index e2b3b95a0..eac2d5875 100644 --- a/test/stMemoryTestFiller.json +++ b/test/stMemoryTestFiller.json @@ -1459,7 +1459,5 @@ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "0xff55883355001144bbccddffeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } - }, - - + } } diff --git a/test/state.cpp b/test/state.cpp index 37ffa7f8e..85bc75300 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -91,7 +91,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -171,50 +170,51 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) { - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } BOOST_AUTO_TEST_CASE(stMemoryStressTest) { - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); -} + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } BOOST_AUTO_TEST_CASE(stMemoryTest) { - dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From dd60595e6f0fe3deb789b0bd047e3c021625b158 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 103/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From d04a94ca37c72d1422c6e392f25785f35751f3f2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:18:00 +0100 Subject: [PATCH 104/313] Avoid invalid paranoia tests. --- libethereum/State.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 014d0f91e..6b594e7a5 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -133,7 +133,7 @@ State::State(State const& _s): void State::paranoia(std::string const& _when, bool _enforceRefs) const { -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB // TODO: variable on context; just need to work out when there should be no leftovers // [in general this is hard since contract alteration will result in nodes in the DB that are no directly part of the state DB]. if (!isTrieGood(_enforceRefs, false)) @@ -1084,7 +1084,7 @@ u256 State::execute(LastHashes const& _lh, bytesConstRef _rlp, bytes* o_output, commit(); -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB ctrace << "Executed; now" << rootHash(); ctrace << old.diff(*this); From a94fed2df4e62b4490b4b9edf4a1da87f515dc5e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 105/313] update gas costs --- libevm/FeeStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..58d756bae 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From 790df992523595e03db4db85a73e2dc1c774c47a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 106/313] Log/bloom alterations. --- libdevcore/FixedHash.h | 2 ++ libethcore/BlockInfo.cpp | 2 +- libethcore/CommonEth.h | 7 +++++-- libethereum/BlockDetails.h | 4 ++-- libevm/FeeStructure.cpp | 7 ++++--- libevm/FeeStructure.h | 1 + libevm/VM.cpp | 17 ++--------------- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 3113b5427..eec988d76 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -240,6 +240,8 @@ inline std::ostream& operator<<(std::ostream& _out, FixedHash const& _h) } // Common types of FixedHash. +using h2048 = FixedHash<256>; +using h1024 = FixedHash<128>; using h520 = FixedHash<65>; using h512 = FixedHash<64>; using h256 = FixedHash<32>; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ce158c3cc..ce4407317 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -101,7 +101,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) stateRoot = _header[field = 3].toHash(); transactionsRoot = _header[field = 4].toHash(); receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + logBloom = _header[field = 6].toHash(); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 79525082f..89ca0aa06 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -44,8 +44,11 @@ std::string formatBalance(bigint const& _b); /// Get information concerning the currency denominations. std::vector> const& units(); -/// The log bloom's size (512 bit). -using LogBloom = h512; +/// The log bloom's size (2048-bit). +using LogBloom = h2048; + +/// Many log blooms. +using LogBlooms = std::vector; template inline u256 exp10() { diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 61b9667c4..9a3ac9ff1 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -55,10 +55,10 @@ struct BlockDetails struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } bytes rlp() const { RLPStream s; s << blooms; return s.out(); } - h512s blooms; + LogBlooms blooms; }; struct BlockReceipts diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 58d756bae..03dd14850 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 1b58c80e9..120034b0e 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2243da2e7..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -563,21 +563,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::JUMPDEST: break; -/* case Instruction::LOG0: - _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); - break; - case Instruction::LOG1: - _ext.log({m_stack[m_stack.size() - 1]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 2], (unsigned)m_stack[m_stack.size() - 3])); - break; - case Instruction::LOG2: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 3], (unsigned)m_stack[m_stack.size() - 4])); - break; - case Instruction::LOG3: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 4], (unsigned)m_stack[m_stack.size() - 5])); - break; - case Instruction::LOG4: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3], m_stack[m_stack.size() - 4]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 5], (unsigned)m_stack[m_stack.size() - 6])); - break;*/ case Instruction::LOG0: _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); m_stack.pop_back(); @@ -635,6 +620,8 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALLCODE: { u256 gas = m_stack.back(); + if (m_stack[m_stack.size() - 3] > 0) + gas += c_callStipend; m_stack.pop_back(); Address receiveAddress = asAddress(m_stack.back()); m_stack.pop_back(); From 5256c22848b012fc5a82f29bf6540003e4ce426a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 107/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba25e74ce..43ee58eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 732782d3f..97e9a220b 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -82,10 +82,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)500; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)1 + (i.size() + 31) / 32 * 1; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index aa453925d..bdb188651 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -72,6 +72,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 3b2c24d45f3ab3a0a8517f6303f034647bb5e438 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 108/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 38 +++++++++++++++++++++++++++++++++++++ libethereum/GenesisInfo.cpp | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 feeStructure.json diff --git a/feeStructure.json b/feeStructure.json new file mode 100644 index 000000000..f09464a5a --- /dev/null +++ b/feeStructure.json @@ -0,0 +1,38 @@ +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, + + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index b9b45d4b4..d7224b7cc 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -24,6 +24,10 @@ std::string const dev::eth::c_genesisInfo = R"ETHEREUM( { + "0000000000000000000000000000000000000001": { "wei": "1" }, + "0000000000000000000000000000000000000002": { "wei": "1" }, + "0000000000000000000000000000000000000003": { "wei": "1" }, + "0000000000000000000000000000000000000004": { "wei": "1" }, "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e6716f9544a56c530d868e4bfbacb172315bdead": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "b9c015918bdaba24b4ff057a92a3873d6eb201be": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, From 32ae6b974fc31ccff7b931547aab3a114d1956ee Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 109/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethereum/GenesisInfo.cpp | 4 -- libethereum/Precompiled.cpp | 9 ++-- libevm/FeeStructure.cpp | 85 ++++++++++++++++++----------------- libevm/FeeStructure.h | 8 ++++ 5 files changed, 109 insertions(+), 85 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index d7224b7cc..4e6a48284 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -36,9 +36,5 @@ R"ETHEREUM( "cd2a3d9f938e13cd947ec05abc7fe734df8dd826": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "6c386a4b26f73c802f34673f7248bb118f97424a": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e4157b34ea9615cfbde6b4fda419828124b70c78": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, - "b0afc46d9ce366d06ab4952ca27db1d9557ae9fd": { "finney": "154162184" }, - "f6b1e9dc460d4d62cc22ec5f987d726929c0f9f0": { "finney": "102774789" }, - "cc45122d8b7fa0b1eaa6b29e0fb561422a9239d0": { "finney": "51387394" }, - "b7576e9d314df41ec5506494293afb1bd5d3f65d": { "finney": "69423399" }, } )ETHEREUM"; diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 97e9a220b..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace std; using namespace dev; using namespace dev::eth; @@ -82,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 03dd14850..78c6ebfb2 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,45 +22,48 @@ #include "FeeStructure.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 120034b0e..9d60ac1bd 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } From 9e947797bec9660805c25b145e2c1d3523078cec Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 110/313] VM CALLCODE fix. --- libevm/FeeStructure.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9d60ac1bd..9109347dc 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From da1a85e71b9bfbe7c11c3ba1506a7a544add7f5c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:03:47 +0100 Subject: [PATCH 111/313] Lenient gas limit. Two uncles only. Min 2048 difficulty & assoc adjustment. --- libethcore/BlockInfo.cpp | 9 ++++++--- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 3 ++- libethereum/State.cpp | 21 +++++++++++---------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ce4407317..49ed1578b 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -191,16 +191,19 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(1024, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty >> 10) : (_parent.difficulty + (_parent.difficulty >> 10))); + return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } +template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } + void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (gasLimit != calculateGasLimit(_parent)) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent))); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + // Check timestamp is after previous timestamp. if (parentHash) diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index 9b07743c5..c4628f4aa 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " valid:" + toString(valid) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 3fd62afbd..4679c1961 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -47,6 +47,7 @@ struct InvalidSignature: virtual dev::Exception {}; class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d): m_f(_f), m_d(_d.toBytes()) {} int m_f; bytes m_d; virtual const char* what() const noexcept; }; struct InvalidUnclesHash: virtual dev::Exception {}; struct InvalidUncle: virtual dev::Exception {}; +struct TooManyUncles: virtual dev::Exception {}; struct UncleTooOld: virtual dev::Exception {}; class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block): m_uncles(_uncles), m_block(_block) {} h256Set m_uncles; h256 m_block; virtual const char* what() const noexcept; }; struct DuplicateUncleNonce: virtual dev::Exception {}; @@ -55,7 +56,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0): provided(_provided), valid(_valid) {} u256 provided; u256 valid; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 6b594e7a5..a9837d118 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -486,10 +486,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) receiptsTrie.init(); LastHashes lh = getLastHashes(_bc, (unsigned)m_previousBlock.number); + RLP rlp(_block); // All ok with the block generally. Play back the transactions now... unsigned i = 0; - for (auto const& tr: RLP(_block)[1]) + for (auto const& tr: rlp[1]) { RLPStream k; k << i; @@ -503,17 +504,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) ++i; } - if (transactionsTrie.root() != m_currentBlock.transactionsRoot) - { - cwarn << "Bad transactions state root!"; - BOOST_THROW_EXCEPTION(InvalidTransactionsStateRoot()); - } - if (receiptsTrie.root() != m_currentBlock.receiptsRoot) { cwarn << "Bad receipts state root."; cwarn << "Block:" << toHex(_block); - cwarn << "Block RLP:" << RLP(_block); + cwarn << "Block RLP:" << rlp; cwarn << "Calculated: " << receiptsTrie.root(); for (unsigned j = 0; j < i; ++j) { @@ -548,10 +543,14 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) u256 tdIncrease = m_currentBlock.difficulty; // Check uncles & apply their rewards to state. + if (rlp[2].itemCount() > 2) + BOOST_THROW_EXCEPTION(TooManyUncles()); + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); - for (auto const& i: RLP(_block)[2]) + + for (auto const& i: rlp[2]) { if (knownUncles.count(sha3(i.data()))) BOOST_THROW_EXCEPTION(UncleInChain(knownUncles, sha3(i.data()) )); @@ -699,7 +698,7 @@ void State::commitToMine(BlockChain const& _bc) // cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); auto p = m_previousBlock.parentHash; - for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash(); ++gen, p = _bc.details(p).parent) + for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash() && unclesCount < 2; ++gen, p = _bc.details(p).parent) { auto us = _bc.details(p).children; assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent! @@ -710,6 +709,8 @@ void State::commitToMine(BlockChain const& _bc) ubi.streamRLP(unclesData, WithNonce); ++unclesCount; uncleAddresses.push_back(ubi.coinbaseAddress); + if (unclesCount == 2) + break; } } } From c16e3262b105930b1e7c43f1b84c2fca5d2828bf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 112/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 92 ++++++++-------------------------------- libethcore/CommonEth.cpp | 8 +--- libethereum/State.cpp | 28 ++++++------ libethereum/State.h | 38 ++++------------- 4 files changed, 43 insertions(+), 123 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 1abf2d8c0..79852304c 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -334,20 +334,19 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class HashedGenericTrieDB: private SpecificTrieDB, h256> +template +class SecureGenericTrieDB: private TrieDB { - using Super = SpecificTrieDB, h256>; + using Super = TrieDB; public: - using DB = _DB; - - HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} - HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; + using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -360,84 +359,29 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - - // empty from the PoV of the iterator interface; still need a basic iterator impl though. - class iterator - { - public: - using value_type = std::pair; - - iterator() {} - iterator(HashedGenericTrieDB const*) {} - iterator(HashedGenericTrieDB const*, bytesConstRef) {} - - iterator& operator++() { return *this; } - value_type operator*() const { return value_type(); } - value_type operator->() const { return value_type(); } - - bool operator==(iterator const&) const { return true; } - bool operator!=(iterator const&) const { return false; } - - value_type at() const { return value_type(); } - }; - iterator begin() const { return iterator(); } - iterator end() const { return iterator(); } - iterator lower_bound(bytesConstRef) const { return iterator(); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } }; -// Hashed & Basic -template -class FatGenericTrieDB: public GenericTrieDB +template +class SecureTrieDB: public SecureGenericTrieDB { - using Super = GenericTrieDB; + using Super = SecureGenericTrieDB; public: - FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} - FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} - void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - - void init() { Super::init(); m_secure.init(); syncRoot(); } - - void setRoot(h256 _root) - { - if (!m_secure.isNull()) - Super::db()->removeAux(m_secure.root()); - m_secure.setRoot(_root); - auto rb = Super::db()->lookupAux(m_secure.root()); - auto r = h256(rb); - Super::setRoot(r); - } - - h256 root() const { return m_secure.root(); } - - void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } - void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } - - std::set leftOvers(std::ostream* = nullptr) const { return {}; } - bool check(bool) const { return m_secure.check(false) && Super::check(false); } - -private: - void syncRoot() - { - // Root changed. Need to record the mapping so we can determine on setRoot. - Super::db()->insertAux(m_secure.root(), Super::root().ref()); - } + std::string operator[](KeyType _k) const { return at(_k); } - HashedGenericTrieDB m_secure; + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template using TrieDB = SpecificTrieDB, KeyType>; - -#if ETH_FATDB -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#else -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#endif - } // Template implementations... diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index ad41780e9..8facdf0f1 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,13 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 6 + -#if ETH_FATDB - 1000 -#else - 0 -#endif -; +const unsigned c_databaseVersion = 5; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index a9837d118..676ad104f 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -179,10 +179,11 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -344,9 +345,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -940,9 +942,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1178,8 +1181,9 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index a496a4a03..7c3cec2a6 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,36 +334,14 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; - } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); } } } From dde71c4f9da9ff2e3873e3b97a92c62cadad947f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 113/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 5 ++- libdevcrypto/TrieDB.h | 75 ++++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index eec988d76..dceb1d70a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 7d39ba73b..2f4233f01 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,9 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } - void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } std::set keys() const; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 79852304c..91a39b3cc 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db = nullptr): m_db(_db) {} + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} + SpecificTrieDB(DB* _db): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -334,19 +334,20 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -359,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... From dfd18f714b12eb9c88c09144bb945dea66254d05 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 114/313] FatDB integrated. --- CMakeLists.txt | 8 +------- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/CommonEth.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ee58eaa..e86ded470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,6 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") - set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") - set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -51,11 +49,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (SOLIDITY) - add_definitions(-DETH_SOLIDITY) - endif() - - if (HEADLESS OR JUSTTESTS) + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 91a39b3cc..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 8facdf0f1..eba10e321 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 676ad104f..a9837d118 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -179,11 +179,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,10 +344,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -942,10 +940,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1181,9 +1178,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From 72fb51d63ef97a74c5a11edd7b742bc27692a337 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 115/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 3 +- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 6 ++-- libdevcrypto/OverlayDB.cpp | 16 ++-------- libdevcrypto/TrieDB.h | 2 +- libethcore/CommonEth.cpp | 2 +- libethereum/State.h | 38 ++++++++++++++++++----- test/trie.cpp | 62 -------------------------------------- 8 files changed, 42 insertions(+), 91 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e86ded470..ba25e74ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index dceb1d70a..eec988d76 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 2f4233f01..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,8 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; @@ -61,7 +61,7 @@ protected: std::map m_over; std::map m_refCount; - std::set m_auxActive; + h256 m_auxKey; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,16 +52,8 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - for (auto const& i: m_auxActive) - if (m_aux.count(i)) - { - m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; - m_aux.erase(i); - } - cdebug << "Discarding " << keysOf(m_aux); - m_auxActive.clear(); - m_aux.clear(); + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } @@ -73,9 +65,7 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, aux(_h).ref(), &v); - if (v.empty()) - cwarn << "Aux not found: " << _h; + m_db->Get(m_readOptions, _h.ref(), &v); return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..f32170cd4 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index eba10e321..ad41780e9 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/State.h b/libethereum/State.h index 7c3cec2a6..a496a4a03 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,14 +334,36 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } } } diff --git a/test/trie.cpp b/test/trie.cpp index bdb188651..aa453925d 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -72,68 +72,6 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } -BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Secure Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - GenericTrieDB t(&m); - MemoryDB hm; - HashedGenericTrieDB ht(&hm); - MemoryDB fm; - FatGenericTrieDB ft(&fm); - t.init(); - ht.init(); - ft.init(); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - ht.insert(k.first, k.second); - ft.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) - { - BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); - BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); - BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); - } - BOOST_CHECK_EQUAL(ht.root(), ft.root()); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 1b9dd297ae1fb57b552eeb6c21644a62aeab36ee Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 116/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f32170cd4..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From 71aefc516ac7b24983cb244b681beeab73fe828f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 117/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 2 +- libevm/FeeStructure.cpp | 84 ++++++++++++++++++-------------------- libevm/FeeStructure.h | 14 +++---- libevm/VM.cpp | 14 ++++--- libevmcore/Instruction.cpp | 2 +- 5 files changed, 55 insertions(+), 61 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 2ff270de5..40ff62175 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 78c6ebfb2..1c1bf8a9e 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,48 +22,44 @@ #include "FeeStructure.h" using namespace std; -namespace dev -{ -namespace eth -{ - -//--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; -u256 const c_expGas = 10; -u256 const c_expByteGas = 10; -u256 const c_sha3Gas = 30; -u256 const c_sha3WordGas = 6; -u256 const c_sloadGas = 50; -u256 const c_sstoreSetGas = 20000; -u256 const c_sstoreResetGas = 5000; -u256 const c_sstoreClearGas = 5000; -u256 const c_sstoreRefundGas = 15000; -u256 const c_jumpdestGas = 1; -u256 const c_logGas = 375; -u256 const c_logDataGas = 8; -u256 const c_logTopicGas = 375; -u256 const c_createGas = 32000; -u256 const c_callGas = 40; -u256 const c_callStipend = 2300; -u256 const c_callValueTransferGas = 9000; -u256 const c_callNewAccountGas = 25000; -u256 const c_suicideRefundGas = 24000; -u256 const c_memoryGas = 3; -u256 const c_quadCoeffDiv = 512; -u256 const c_createDataGas = 200; -u256 const c_txGas = 21000; -u256 const c_txDataZeroGas = 4; -u256 const c_txDataNonZeroGas = 68; -u256 const c_copyGas = 3; -u256 const c_ecrecoverGas = 3000; -u256 const c_sha256Gas = 60; -u256 const c_sha256WordGas = 12; -u256 const c_ripemd160Gas = 600; -u256 const c_ripemd160WordGas = 120; -u256 const c_identityGas = 15; -u256 const c_identityWordGas = 3; -//--- END: AUTOGENERATED FROM /feeStructure.json - -} -} +using namespace dev; +using namespace dev::eth; + +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9109347dc..1b58c80e9 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,41 +28,37 @@ namespace dev namespace eth { -//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_ecrecoverGas; -extern u256 const c_sha256Gas; -extern u256 const c_sha256WordGas; -extern u256 const c_ripemd160Gas; -extern u256 const c_ripemd160WordGas; -extern u256 const c_identityGas; -extern u256 const c_identityWordGas; } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index e0b487c9b..9f2fa6874 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,13 +82,19 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas = c_tierStepGas[metric.gasPriceTier]; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -145,10 +151,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::JUMPDEST: - runGas = 1; - break; - case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -164,7 +166,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index 23f19ac94..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From c5c35e62046df1d1cc20946f7a133f7506b72268 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 118/313] Gas fixes. Trie fixes. --- libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 6 +++++- libethereum/Client.cpp | 9 +++++++-- libevm/VM.cpp | 8 +------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 42ff1f25d..73e1092af 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -277,9 +277,14 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -// cdebug << "checkWatch" << _watchId; +#if ETH_DEBUG && 0 + cdebug << "checkWatch" << _watchId; +#endif + auto& w = m_watches.at(_watchId); +#if ETH_DEBUG && 0 + cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); +#endif auto& w = m_watches.at(_watchId); -// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 9f2fa6874..f4e904e3f 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,19 +82,13 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() From c863a7d0864d4c57db05df1bf085daa8d9532bef Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 119/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index f4e904e3f..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From dcf7686c6f1c7640c07ed80a7367a0b12a74f4eb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 120/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 40ff62175..2ff270de5 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final From 8917d43fd40ed77c76f4f4a2a580d59388931400 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 121/313] only check rootHash of state if FATDB is off --- test/state.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/state.cpp b/test/state.cpp index 85bc75300..1d1284e22 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -91,6 +91,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) From ecc6d2dd21da458d721bc90cf908df8dd70e354e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 122/313] add memory tests --- test/state.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 1d1284e22..7744727c9 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -91,7 +91,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -205,16 +204,46 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) } } - BOOST_AUTO_TEST_CASE(stSolidityTest) - { - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); - } +BOOST_AUTO_TEST_CASE(stSolidityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryTest) { dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } +BOOST_AUTO_TEST_CASE(stMemoryStressTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stCreateTest) { From d3e8f87a2d047418730fe6e45dbc50c8ea92b1cd Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 123/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From bf253240897f8bcf9f57cd68dc560425f649d1ce Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 124/313] update gas costs --- libevm/FeeStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..58d756bae 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From 54bbd1a8e25d2f52ff7cce9cf336070a08d1fd51 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 125/313] Log/bloom alterations. --- libevm/FeeStructure.cpp | 7 ++++--- libevm/FeeStructure.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 58d756bae..03dd14850 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 1b58c80e9..120034b0e 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. From 72b269cb40c7141b6ca65b2cfc081bba7cd7ba0a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 126/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba25e74ce..43ee58eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..121af1b59 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index aa453925d..bdb188651 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -72,6 +72,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From fb4e2cc1864d3ad9c8968e2c43fcfa54dd74d2dd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 127/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 88 +++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f5acf0f0b..f09464a5a 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,54 +1,38 @@ -var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} From 845699fa0f714433c5b4237df261e375ada48d4f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 128/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethereum/Precompiled.cpp | 8 ++-- libevm/FeeStructure.cpp | 85 ++++++++++++++++++----------------- libevm/FeeStructure.h | 8 ++++ 4 files changed, 108 insertions(+), 81 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 121af1b59..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 03dd14850..78c6ebfb2 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,45 +22,48 @@ #include "FeeStructure.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 120034b0e..9d60ac1bd 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } From a3ea387fa687ca10046ca66d48be8e8e163ee7d1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 129/313] VM CALLCODE fix. --- libevm/FeeStructure.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9d60ac1bd..9109347dc 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From 36b8a2788da4a3b85ac14649bacc6e4dae72f485 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:12:27 +0100 Subject: [PATCH 130/313] state rebase. --- test/state.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 7744727c9..f69260a84 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -227,24 +227,6 @@ BOOST_AUTO_TEST_CASE(stMemoryTest) dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stMemoryStressTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From 182cc1fc41d818046410f733a8564e92b168e5bf Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 17:36:09 +0100 Subject: [PATCH 131/313] remove genesis state from state tests Conflicts: test/state.cpp --- test/TestHelper.cpp | 10 +-------- test/TestHelper.h | 3 +-- test/state.cpp | 53 ++++++++++++++++++--------------------------- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 1d544304c..6d5a91cdd 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -67,7 +67,7 @@ namespace test struct ValueTooLarge: virtual Exception {}; bigint const c_max256plus1 = bigint(1) << 256; -ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o) +ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller) : m_statePre(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) { importEnv(_o["env"].get_obj()); importState(_o["pre"].get_obj(), m_statePre); @@ -181,13 +181,8 @@ void ImportTest::exportTest(bytes _output, State& _statePost) // export post state json_spirit::mObject postState; - std::map genesis = genesisState(); - for (auto const& a: _statePost.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(_statePost.balance(a.first)); o["nonce"] = toString(_statePost.transactionsFrom(a.first)); @@ -210,9 +205,6 @@ void ImportTest::exportTest(bytes _output, State& _statePost) for (auto const& a: m_statePre.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(m_statePre.balance(a.first)); o["nonce"] = toString(m_statePre.transactionsFrom(a.first)); diff --git a/test/TestHelper.h b/test/TestHelper.h index c4dde1a60..75edcbf31 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -45,9 +45,8 @@ namespace test class ImportTest { public: - ImportTest(json_spirit::mObject& _o) : m_TestObject(_o) {} + ImportTest(json_spirit::mObject& _o) : m_statePre(Address(), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) {} ImportTest(json_spirit::mObject& _o, bool isFiller); - // imports void importEnv(json_spirit::mObject& _o); void importState(json_spirit::mObject& _o, eth::State& _state); diff --git a/test/state.cpp b/test/state.cpp index f69260a84..8db082d0c 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -64,6 +64,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) catch (Exception const& _e) { cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); } catch (std::exception const& _e) { @@ -168,23 +169,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); +//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--quadratic" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); +// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { @@ -204,29 +205,17 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) } } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } BOOST_AUTO_TEST_CASE(stMemoryTest) { dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From c82d63b909b7fb79a5603deb50c5e35c83a97fae Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 11:55:22 +0100 Subject: [PATCH 132/313] New Proof-of-Work. --- CMakeLists.txt | 3 +- alethzero/MainWin.cpp | 2 +- eth/CMakeLists.txt | 2 +- libdevcore/Common.h | 1 + libdevcore/CommonData.h | 5 +- libdevcore/CommonIO.cpp | 23 +++ libdevcore/CommonIO.h | 4 + libdevcore/FixedHash.h | 1 + libethcore/BlockInfo.cpp | 20 ++- libethcore/BlockInfo.h | 8 +- libethcore/CMakeLists.txt | 1 + libethcore/CommonEth.cpp | 2 +- libethcore/CommonEth.h | 2 + libethcore/Exceptions.h | 3 +- libethcore/ProofOfWork.cpp | 182 ++++++++++++++------ libethcore/ProofOfWork.h | 67 ++++--- libethereum/CanonBlockChain.cpp | 4 +- libethereum/Client.cpp | 4 +- libethereum/Client.h | 6 +- libethereum/Interface.h | 2 +- libethereum/State.cpp | 21 ++- libethereum/State.h | 2 +- libweb3jsonrpc/WebThreeStubServerBase.cpp | 4 +- libweb3jsonrpc/WebThreeStubServerBase.h | 2 +- libweb3jsonrpc/abstractwebthreestubserver.h | 6 +- libweb3jsonrpc/spec.json | 2 +- mix/MixClient.h | 2 +- test/block.cpp | 56 +++--- test/dagger.cpp | 2 + test/webthreestubclient.h | 3 +- 30 files changed, 301 insertions(+), 141 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ee58eaa..dffdd9027 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ function(configureProject) endif() endfunction() - +set(CPPETHEREUM 1) function(createBuildInfo) # Set build platform; to be written to BuildInfo.h @@ -174,6 +174,7 @@ add_subdirectory(libp2p) add_subdirectory(libdevcrypto) add_subdirectory(libwhisper) +add_subdirectory(libethash) add_subdirectory(libethcore) add_subdirectory(libevm) add_subdirectory(libethereum) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index a4c8a7b60..08117e596 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1362,7 +1362,7 @@ void Main::on_blocks_currentItemChanged() s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info.headerHash(WithoutNonce), info.nonce) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index bc458a50f..64cee3e12 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -26,7 +26,7 @@ if (JSONRPC) endif() target_link_libraries(${EXECUTABLE} webthree) -target_link_libraries(${EXECUTABLE} secp256k1) +target_link_libraries(${EXECUTABLE} ethash) if (WIN32) add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 9edeacccb..764b3454e 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -65,6 +65,7 @@ using bytesConstRef = vector_ref; // Numeric types. using bigint = boost::multiprecision::number>; +using u64 = boost::multiprecision::number>; using u128 = boost::multiprecision::number>; using u256 = boost::multiprecision::number>; using s256 = boost::multiprecision::number>; diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 3cdf3b449..2c9fd30ef 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -96,7 +96,10 @@ template inline void toBigEndian(_T _val, _Out& o_out) { for (auto i = o_out.size(); i-- != 0; _val >>= 8) - o_out[i] = (typename _Out::value_type)(uint8_t)_val; + { + _T v = _val & (_T)0xff; + o_out[i] = (typename _Out::value_type)(uint8_t)v; + } } /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index feb4121cb..288dbd1ff 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -57,6 +57,24 @@ string dev::memDump(bytes const& _bytes, unsigned _width, bool _html) return ret.str(); } +// Don't forget to delete[] later. +bytesRef dev::contentsNew(std::string const& _file) +{ + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return bytesRef(); + // get length of file: + is.seekg (0, is.end); + streamoff length = is.tellg(); + if (length == 0) // return early, MSVC does not like reading 0 bytes + return bytesRef(); + is.seekg (0, is.beg); + bytesRef ret(new byte[length], length); + is.read((char*)ret.data(), length); + is.close(); + return ret; +} + bytes dev::contents(std::string const& _file) { std::ifstream is(_file, std::ifstream::binary); @@ -79,3 +97,8 @@ void dev::writeFile(std::string const& _file, bytes const& _data) ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); } +void dev::writeFile(std::string const& _file, bytesConstRef _data) +{ + ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); +} + diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 23092b702..5769b6c64 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -42,9 +42,13 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +/// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. +bytesRef contentsNew(std::string const& _file); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytes const& _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +void writeFile(std::string const& _file, bytesConstRef _data); /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index eec988d76..7fa5b411a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -247,6 +247,7 @@ using h512 = FixedHash<64>; using h256 = FixedHash<32>; using h160 = FixedHash<20>; using h128 = FixedHash<16>; +using h64 = FixedHash<8>; using h512s = std::vector; using h256s = std::vector; using h160s = std::vector; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 49ed1578b..6c645372e 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -30,7 +30,7 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 17; +u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; BlockInfo::BlockInfo(): timestamp(Invalid256) { @@ -56,7 +56,9 @@ void BlockInfo::setEmpty() gasUsed = 0; timestamp = 0; extraData.clear(); - nonce = h256(); + seedHash = h256(); + mixBytes = h256(); + nonce = Nonce(); hash = headerHash(WithNonce); } @@ -76,11 +78,11 @@ h256 BlockInfo::headerHash(IncludeNonce _n) const void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const { - _s.appendList(_n == WithNonce ? 14 : 13) + _s.appendList(_n == WithNonce ? 16 : 14) << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom - << difficulty << number << gasLimit << gasUsed << timestamp << extraData; + << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << nonce; + _s << mixBytes << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -108,7 +110,9 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - nonce = _header[field = 13].toHash(); + seedHash = _header[field = 13].toHash(); + mixBytes = _header[field = 14].toHash(); + nonce = _header[field = 15].toHash(); } catch (Exception const& _e) @@ -118,7 +122,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) } // check it hashes according to proof of work or that it's the genesis block. - if (_checkNonce && parentHash && !ProofOfWork::verify(headerHash(WithoutNonce), nonce, difficulty)) + if (_checkNonce && parentHash && !ProofOfWork::verify(*this)) BOOST_THROW_EXCEPTION(InvalidBlockNonce(headerHash(WithoutNonce), nonce, difficulty)); if (gasUsed > gasLimit) @@ -176,6 +180,7 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); + seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -204,7 +209,6 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); - // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 99efc6a17..fbc459b76 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -76,7 +76,9 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 nonce; + h256 mixBytes; + h256 seedHash; + Nonce nonce; BlockInfo(); explicit BlockInfo(bytes const& _block): BlockInfo(&_block) {} @@ -104,6 +106,8 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && + mixBytes == _cmp.mixBytes && + seedHash == _cmp.seedHash && nonce == _cmp.nonce; } bool operator!=(BlockInfo const& _cmp) const { return !operator==(_cmp); } @@ -129,7 +133,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 920f9f652..88308b630 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -22,6 +22,7 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() +target_link_libraries(${EXECUTABLE} ethash) target_link_libraries(${EXECUTABLE} devcrypto) target_link_libraries(${EXECUTABLE} devcore) diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index ad41780e9..822ede5aa 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 55; +const unsigned c_protocolVersion = 56; const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 89ca0aa06..edefda380 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -66,5 +66,7 @@ static const u256 finney = exp10<15>(); static const u256 szabo = exp10<12>(); static const u256 wei = exp10<0>(); +using Nonce = h64; + } } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 4679c1961..5a8a2d055 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,6 +22,7 @@ #pragma once #include +#include "CommonEth.h" namespace dev { @@ -64,7 +65,7 @@ struct InvalidReceiptsStateRoot: virtual dev::Exception {}; struct InvalidTimestamp: virtual dev::Exception {}; struct InvalidLogBloom: virtual dev::Exception {}; class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; }; -class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; h256 n; u256 d; virtual const char* what() const noexcept; }; +class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), Nonce _n = Nonce(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; Nonce n; u256 d; virtual const char* what() const noexcept; }; struct InvalidParentHash: virtual dev::Exception {}; struct InvalidNumber: virtual dev::Exception {}; struct InvalidContractAddress: virtual public dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 181e379b5..084225a38 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -20,12 +20,18 @@ */ #include +#include #include #include #include #include +#include +#include #include +#include #include +#include +#include "BlockInfo.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -35,72 +41,144 @@ namespace dev namespace eth { -template -static inline void update(_T& _sha, u256 const& _value) +class Ethasher { - int i = 0; - for (u256 v = _value; v; ++i, v >>= 8) {} - byte buf[32]; - bytesRef bufRef(buf, i); - toBigEndian(_value, bufRef); - _sha.Update(buf, i); -} +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; + } + + byte const* full(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash].data(); + } + + static ethash_params params(BlockInfo const& _header) + { + return params((unsigned)_header.number); + } + + static ethash_params params(unsigned _n) + { + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; + } + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; -template -static inline void update(_T& _sha, h256 const& _value) +Ethasher* Ethasher::s_this = nullptr; + +bool Ethash::verify(BlockInfo const& _header) { - int i = 0; - byte const* data = _value.data(); - for (; i != 32 && data[i] == 0; ++i); - _sha.Update(data + i, 32 - i); + bigint boundary = (bigint(1) << 256) / _header.difficulty; + u256 e(eval(_header, _header.nonce)); + return e <= boundary; } -template -static inline h256 get(_T& _sha) +h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { - h256 ret; - _sha.TruncatedFinal(&ret[0], 32); - return ret; + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return h256(r.result, h256::ConstructFromPointer); } -h256 DaggerEvaluator::node(h256 const& _root, h256 const& _xn, uint_fast32_t _L, uint_fast32_t _i) +std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - if (_L == _i) - return _root; - u256 m = (_L == 9) ? 16 : 3; - CryptoPP::SHA3_256 bsha; - for (uint_fast32_t k = 0; k < m; ++k) + auto h = _header.headerHash(WithoutNonce); + auto p = Ethasher::params(_header); + auto d = Ethasher::get()->full(_header); + + std::pair ret; + static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); + uint64_t tryNonce = (uint64_t)(u64)(m_last = Nonce::random(s_eng)); + + bigint boundary = (bigint(1) << 256) / _header.difficulty; + ret.first.requirement = log2((double)boundary); + + // 2^ 0 32 64 128 256 + // [--------*-------------------------] + // + // evaluate until we run out of time + auto startTime = std::chrono::steady_clock::now(); + if (!_turbo) + std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); + double best = 1e99; // high enough to be effectively infinity :) + Proof result; + ethash_return_value ethashReturn; + unsigned hashCount = 0; + for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - CryptoPP::SHA3_256 sha; - update(sha, _root); - update(sha, _xn); - update(sha, (u256)_L); - update(sha, (u256)_i); - update(sha, (u256)k); - uint_fast32_t pk = (uint_fast32_t)(u256)get(sha) & ((1 << ((_L - 1) * 3)) - 1); - auto u = node(_root, _xn, _L - 1, pk); - update(bsha, u); + ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); + u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + best = std::min(best, log2((double)val)); + if (val <= boundary) + { + ret.first.completed = true; + result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.nonce = u64(tryNonce); + break; + } } - return get(bsha); -} + ret.first.hashes = hashCount; + ret.first.best = best; + ret.second = result; -h256 DaggerEvaluator::eval(h256 const& _root, h256 const& _nonce) -{ - h256 extranonce = (u256)_nonce >> 26; // with xn = floor(n / 2^26) -> assuming this is with xn = floor(N / 2^26) - CryptoPP::SHA3_256 bsha; - for (uint_fast32_t k = 0; k < 4; ++k) + if (ret.first.completed) { - //sha256(D || xn || i || k) -> sha256(D || xn || k) - there's no 'i' here! - CryptoPP::SHA3_256 sha; - update(sha, _root); - update(sha, extranonce); - update(sha, _nonce); - update(sha, (u256)k); - uint_fast32_t pk = (uint_fast32_t)(u256)get(sha) & 0x1ffffff; // mod 8^8 * 2 [ == mod 2^25 ?! ] [ == & ((1 << 25) - 1) ] [ == & 0x1ffffff ] - auto u = node(_root, extranonce, 9, pk); - update(bsha, u); + BlockInfo test = _header; + assignResult(result, test); + assert(verify(test)); } - return get(bsha); + + return ret; } } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index c3c3f192b..7b9787f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -28,6 +28,7 @@ #include #include #include "CommonEth.h" +#include "BlockInfo.h" #define FAKE_DAGGER 1 @@ -45,47 +46,63 @@ struct MineInfo bool completed = false; }; -template -class ProofOfWorkEngine: public Evaluator +class Ethash { public: - static bool verify(h256 const& _root, h256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)Evaluator::eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; } + // bit-compatible with ethash_return_value + struct Proof + { + Nonce nonce; + h256 mixHash; + }; - inline std::pair mine(h256 const& _root, u256 const& _difficulty, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static bool verify(BlockInfo const& _header); + std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } protected: - h256 m_last; + Nonce m_last; }; -class SHA3Evaluator +template +class ProofOfWorkEngine: public Evaluator { public: - static h256 eval(h256 const& _root, h256 const& _nonce) { h256 b[2] = { _root, _nonce }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } -}; + using Proof = Nonce; + + static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } + + inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); -// TODO: class ARPoWEvaluator + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } -class DaggerEvaluator +protected: + Nonce m_last; +}; + +class SHA3Evaluator { public: - static h256 eval(h256 const& _root, h256 const& _nonce); - -private: - static h256 node(h256 const& _root, h256 const& _xn, uint_fast32_t _L, uint_fast32_t _i); + static h256 eval(h256 const& _root, Nonce const& _nonce) { h256 b[2] = { _root, h256(_nonce) }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } }; using SHA3ProofOfWork = ProofOfWorkEngine; -using ProofOfWork = SHA3ProofOfWork; +using ProofOfWork = Ethash; template -std::pair ProofOfWorkEngine::mine(h256 const& _root, u256 const& _difficulty, unsigned _msTimeout, bool _continue, bool _turbo) +std::pair::Proof> ProofOfWorkEngine::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - std::pair ret; + auto headerHashWithoutNonce = _header.headerHash(WithoutNonce); + auto difficulty = _header.difficulty; + + std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); - u256 s = (m_last = h256::random(s_eng)); + Nonce::Arith s = (m_last = Nonce::random(s_eng)); - bigint d = (bigint(1) << 256) / _difficulty; + bigint d = (bigint(1) << 256) / difficulty; ret.first.requirement = log2((double)d); // 2^ 0 32 64 128 256 @@ -96,12 +113,12 @@ std::pair ProofOfWorkEngine::mine(h256 const& _root, if (!_turbo) std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) - h256 solution; + ProofOfWorkEngine::Proof solution; unsigned h = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; s++, h++) { - solution = (h256)s; - auto e = (bigint)(u256)Evaluator::eval(_root, solution); + solution = (ProofOfWorkEngine::Proof)s; + auto e = (bigint)(u256)Evaluator::eval(headerHashWithoutNonce, solution); best = std::min(best, log2((double)e)); if (e <= d) { @@ -114,7 +131,11 @@ std::pair ProofOfWorkEngine::mine(h256 const& _root, ret.second = solution; if (ret.first.completed) - assert(verify(_root, solution, _difficulty)); + { + BlockInfo test = _header; + assignResult(solution, test); + assert(verify(test)); + } return ret; } diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index 29fdc9acc..418373745 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -82,8 +82,8 @@ bytes CanonBlockChain::createGenesisBlock() stateRoot = state.root(); } - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); + block.appendList(16) + << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << h256() << h256() << Nonce(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 73e1092af..e27be90e0 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -500,10 +500,10 @@ pair Client::getWork() return make_pair(m_remoteMiner.workHash(), m_remoteMiner.difficulty()); } -bool Client::submitNonce(h256 const&_nonce) +bool Client::submitWork(ProofOfWork::Proof const& _proof) { Guard l(x_remoteMiner); - return m_remoteMiner.submitWork(_nonce); + return m_remoteMiner.submitWork(_proof); } void Client::doWork() diff --git a/libethereum/Client.h b/libethereum/Client.h index 7cd520ab6..03debb750 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -145,7 +145,7 @@ public: h256 workHash() const { return m_state.info().headerHash(IncludeNonce::WithoutNonce); } u256 const& difficulty() const { return m_state.info().difficulty; } - bool submitWork(h256 const& _nonce) { return (m_isComplete = m_state.completeMine(_nonce)); } + bool submitWork(ProofOfWork::Proof const& _result) { return (m_isComplete = m_state.completeMine(_result)); } virtual bool isComplete() const override { return m_isComplete; } virtual bytes const& blockData() const { return m_state.blockData(); } @@ -294,8 +294,8 @@ public: /// 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::pair getWork() override; - /// Submit the nonce for the proof-of-work. - virtual bool submitNonce(h256 const&_nonce) override; + /// Submit the proof for the proof-of-work. + virtual bool submitWork(ProofOfWork::Proof const& _proof) override; // Debug stuff: diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 847c181e0..2a9de14d1 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -154,7 +154,7 @@ public: /// Get hash of the current block to be mined minus the nonce (the 'work hash'). virtual std::pair getWork() = 0; /// Submit the nonce for the proof-of-work. - virtual bool submitNonce(h256 const&) = 0; + virtual bool submitWork(ProofOfWork::Proof const& _proof) = 0; /// Check the progress of the mining. virtual MineProgress miningProgress() const = 0; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index a9837d118..fcb84821b 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -255,7 +255,7 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi) { auto b = _bc.block(_block); bi.populate(b); - // bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. +// bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. break; } catch (Exception const& _e) @@ -546,7 +546,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) if (rlp[2].itemCount() > 2) BOOST_THROW_EXCEPTION(TooManyUncles()); - set nonces = { m_currentBlock.nonce }; + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); @@ -773,23 +773,28 @@ MineInfo State::mine(unsigned _msTimeout, bool _turbo) MineInfo ret; // TODO: Miner class that keeps dagger between mine calls (or just non-polling mining). - tie(ret, m_currentBlock.nonce) = m_pow.mine(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.difficulty, _msTimeout, true, _turbo); + ProofOfWork::Proof r; + tie(ret, r) = m_pow.mine(m_currentBlock, _msTimeout, true, _turbo); if (!ret.completed) m_currentBytes.clear(); else - cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.nonce, m_currentBlock.difficulty); + { + ProofOfWork::assignResult(r, m_currentBlock); + cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); + } return ret; } -bool State::completeMine(h256 const& _nonce) +bool State::completeMine(ProofOfWork::Proof const& _nonce) { - if (!m_pow.verify(m_currentBlock.headerHash(WithoutNonce), _nonce, m_currentBlock.difficulty)) + ProofOfWork::assignResult(_nonce, m_currentBlock); + + if (!m_pow.verify(m_currentBlock)) return false; - m_currentBlock.nonce = _nonce; - cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.nonce, m_currentBlock.difficulty); + cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); completeMine(); diff --git a/libethereum/State.h b/libethereum/State.h index a496a4a03..33843c65c 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -112,7 +112,7 @@ public: /// Pass in a solution to the proof-of-work. /// @returns true iff the given nonce is a proof-of-work for this State's block. - bool completeMine(h256 const& _nonce); + bool completeMine(ProofOfWork::Proof const& _result); /// Attempt to find valid nonce for block that this state represents. /// This function is thread-safe. You can safely have other interactions with this object while it is happening. diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index dbf3b2ec9..382115ba2 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -457,9 +457,9 @@ Json::Value WebThreeStubServerBase::eth_getWork() return ret; } -bool WebThreeStubServerBase::eth_submitWork(std::string const& _nonce) +bool WebThreeStubServerBase::eth_submitWork(std::string const& _nonce, std::string const& _mixHash) { - return client()->submitNonce(jsToFixed<32>(_nonce)); + return client()->submitWork(ProofOfWork::Proof{jsToFixed(_nonce), jsToFixed<32>(_mixHash)}); } int WebThreeStubServerBase::eth_register(std::string const& _address) diff --git a/libweb3jsonrpc/WebThreeStubServerBase.h b/libweb3jsonrpc/WebThreeStubServerBase.h index 9535c33a0..993c82c5c 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.h +++ b/libweb3jsonrpc/WebThreeStubServerBase.h @@ -110,7 +110,7 @@ public: virtual bool eth_uninstallFilter(int _id); virtual Json::Value eth_getWork(); - virtual bool eth_submitWork(std::string const& _nonce); + virtual bool eth_submitWork(std::string const& _nonce, std::string const& _mixHash); virtual int eth_register(std::string const& _address); virtual bool eth_unregister(int _id); diff --git a/libweb3jsonrpc/abstractwebthreestubserver.h b/libweb3jsonrpc/abstractwebthreestubserver.h index e40c68acd..bb84afc9b 100644 --- a/libweb3jsonrpc/abstractwebthreestubserver.h +++ b/libweb3jsonrpc/abstractwebthreestubserver.h @@ -54,7 +54,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServerbindAndAddMethod(jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI); - this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); + this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); this->bindAndAddMethod(jsonrpc::Procedure("eth_register", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_registerI); this->bindAndAddMethod(jsonrpc::Procedure("eth_unregister", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_unregisterI); this->bindAndAddMethod(jsonrpc::Procedure("eth_queuedTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_queuedTransactionsI); @@ -254,7 +254,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServereth_submitWork(request[0u].asString()); + response = this->eth_submitWork(request[0u].asString(), request[1u].asString()); } inline virtual void eth_registerI(const Json::Value &request, Json::Value &response) { @@ -363,7 +363,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer getWork() override { return std::pair(); } - bool submitNonce(h256 const&) override { return false; } + bool submitWork(eth::ProofOfWork::Proof const&) override { return false; } /// @returns the last mined block information eth::BlockInfo blockInfo() const; diff --git a/test/block.cpp b/test/block.cpp index fdf65affa..4441da299 100644 --- a/test/block.cpp +++ b/test/block.cpp @@ -131,8 +131,12 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // find new valid nonce ProofOfWork pow; MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + ProofOfWork::Proof proof; + while (!ProofOfWork::verify(blockFromFields)) + { + tie(ret, proof) = pow.mine(blockFromFields, 1000, true, true); + ProofOfWork::assignResult(proof, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); @@ -211,7 +215,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) o["transactions"] = txArray; o["rlp"] = "0x" + toHex(state.blockData()); - BlockInfo current_BlockHeader = state.info(); + BlockInfo currentBlockHeader = state.info(); // overwrite blockheader with (possible wrong) data from "blockheader" in filler; @@ -220,7 +224,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) if (o["blockHeader"].get_obj().size() != 14) { - BlockInfo tmp = current_BlockHeader; + BlockInfo tmp = currentBlockHeader; if (o["blockHeader"].get_obj().count("parentHash")) tmp.parentHash = h256(o["blockHeader"].get_obj()["parentHash"].get_str()); @@ -263,14 +267,18 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // find new valid nonce - if (tmp != current_BlockHeader) + if (tmp != currentBlockHeader) { - current_BlockHeader = tmp; + currentBlockHeader = tmp; cout << "new header!\n"; ProofOfWork pow; MineInfo ret; - while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) - tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + ProofOfWork::Proof proof; + while (!ProofOfWork::verify(currentBlockHeader)) + { + tie(ret, proof) = pow.mine(currentBlockHeader, 10000, true, true); + ProofOfWork::assignResult(proof, currentBlockHeader); + } } } else @@ -278,27 +286,27 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // take the blockheader as is const bytes c_blockRLP = createBlockRLPFromFields(o["blockHeader"].get_obj()); const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); + currentBlockHeader.populateFromHeader(c_bRLP, false); } } // write block header mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["parentHash"] = toString(currentBlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(currentBlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(currentBlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(currentBlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(currentBlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(currentBlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(currentBlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(currentBlockHeader.difficulty); + oBlockHeader["number"] = toString(currentBlockHeader.number); + oBlockHeader["gasLimit"] = toString(currentBlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(currentBlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(currentBlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(currentBlockHeader.extraData); + oBlockHeader["nonce"] = toString(currentBlockHeader.nonce); o["blockHeader"] = oBlockHeader; @@ -318,7 +326,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) } RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + currentBlockHeader.streamRLP(rlpStream2, WithNonce); RLPStream block2(3); block2.appendRaw(rlpStream2.out()); diff --git a/test/dagger.cpp b/test/dagger.cpp index 9422b6a96..87c49bd7d 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -30,6 +30,7 @@ using namespace dev::eth; int daggerTest() { +#if 0 cnote << "Testing ProofOfWork..."; // Test dagger { @@ -46,6 +47,7 @@ int daggerTest() cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; } +#endif return 0; } diff --git a/test/webthreestubclient.h b/test/webthreestubclient.h index 70aa9db99..6d97ea67a 100644 --- a/test/webthreestubclient.h +++ b/test/webthreestubclient.h @@ -437,10 +437,11 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } - bool eth_submitWork(const std::string& param1) throw (jsonrpc::JsonRpcException) + bool eth_submitWork(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) { Json::Value p; p.append(param1); + p.append(param2); Json::Value result = this->CallMethod("eth_submitWork",p); if (result.isBool()) return result.asBool(); From 3bcd6dfda09e7e1b4da2005a6bac1120122b5e1b Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 12:04:15 +0100 Subject: [PATCH 133/313] blockchain tests Conflicts: test/block.cpp --- test/bcBlockChainTestFiller.json | 45 +++ test/block.cpp | 527 ------------------------------ test/blockchain.cpp | 537 +++++++++++++++++++++++++++++++ test/vm.cpp | 54 ++-- 4 files changed, 609 insertions(+), 554 deletions(-) create mode 100644 test/bcBlockChainTestFiller.json delete mode 100644 test/block.cpp create mode 100644 test/blockchain.cpp diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json new file mode 100644 index 000000000..050def25b --- /dev/null +++ b/test/bcBlockChainTestFiller.json @@ -0,0 +1,45 @@ +{ + "minDifficulty" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + } + ] + } +} diff --git a/test/block.cpp b/test/block.cpp deleted file mode 100644 index 4441da299..000000000 --- a/test/block.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . -*/ -/** @file block.cpp - * @author Christoph Jentzsch - * @date 2015 - * block test functions. - */ - -#include -#include -#include "TestHelper.h" - -using namespace std; -using namespace json_spirit; -using namespace dev; -using namespace dev::eth; - -namespace dev { namespace test { - -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - - return rlpStream.out(); -} - -void doBlockTests(json_spirit::mValue& _v, bool _fillin) -{ - for (auto& i: _v.get_obj()) - { - cerr << i.first << endl; - mObject& o = i.second.get_obj(); - - BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } - - BOOST_REQUIRE(o.count("pre")); - - ImportTest importer(o["pre"].get_obj()); - State state(Address(), OverlayDB(), BaseState::Empty); - importer.importState(o["pre"].get_obj(), state); - state.commit(); - - if (_fillin) - blockFromFields.stateRoot = state.rootHash(); - else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); - - if (_fillin) - { - // find new valid nonce - ProofOfWork pow; - MineInfo ret; - ProofOfWork::Proof proof; - while (!ProofOfWork::verify(blockFromFields)) - { - tie(ret, proof) = pow.mine(blockFromFields, 1000, true, true); - ProofOfWork::assignResult(proof, blockFromFields); - } - - //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - } - - // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); - - // construct blockchain - BlockChain bc(block.out(), string(), true); - - if (_fillin) - { - BOOST_REQUIRE(o.count("transactions")); - - TransactionQueue txs; - - for (auto const& txObj: o["transactions"].get_array()) - { - mObject tx = txObj.get_obj(); - importer.importTransaction(tx); - if (!txs.attemptImport(importer.m_transaction.rlp())) - cnote << "failed importing transaction\n"; - } - - try - { - state.sync(bc); - state.sync(bc,txs); - state.commitToMine(bc); - MineInfo info; - for (info.completed = false; !info.completed; info = state.mine()) {} - state.completeMine(); - } - catch (Exception const& _e) - { - cnote << "state sync or mining did throw an exception: " << diagnostic_information(_e); - return; - } - catch (std::exception const& _e) - { - cnote << "state sync or mining did throw an exception: " << _e.what(); - return; - } - - // write valid txs - mArray txArray; - Transactions txList; - for (auto const& txi: txs.transactions()) - { - Transaction tx(txi.second, CheckSignature::Sender); - txList.push_back(tx); - mObject txObject; - txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); - txObject["gasLimit"] = toString(tx.gas()); - txObject["gasPrice"] = toString(tx.gasPrice()); - txObject["r"] = "0x" + toString(tx.signature().r); - txObject["s"] = "0x" + toString(tx.signature().s); - txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); - txObject["value"] = toString(tx.value()); - - txArray.push_back(txObject); - } - - o["transactions"] = txArray; - o["rlp"] = "0x" + toHex(state.blockData()); - - BlockInfo currentBlockHeader = state.info(); - - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - - if (o.count("blockHeader")) - { - if (o["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = currentBlockHeader; - - if (o["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(o["blockHeader"].get_obj()["parentHash"].get_str()); - - if (o["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(o["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (o["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(o["blockHeader"].get_obj()["coinbase"].get_str()); - - if (o["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(o["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (o["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(o["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (o["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(o["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (o["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(o["blockHeader"].get_obj()["bloom"].get_str()); - - if (o["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(o["blockHeader"].get_obj()["difficulty"]); - - if (o["blockHeader"].get_obj().count("number")) - tmp.number = toInt(o["blockHeader"].get_obj()["number"]); - - if (o["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(o["blockHeader"].get_obj()["gasLimit"]); - - if (o["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(o["blockHeader"].get_obj()["gasUsed"]); - - if (o["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(o["blockHeader"].get_obj()["timestamp"]); - - if (o["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(o["blockHeader"].get_obj()["extraData"].get_str()); - - // find new valid nonce - - if (tmp != currentBlockHeader) - { - currentBlockHeader = tmp; - cout << "new header!\n"; - ProofOfWork pow; - MineInfo ret; - ProofOfWork::Proof proof; - while (!ProofOfWork::verify(currentBlockHeader)) - { - tie(ret, proof) = pow.mine(currentBlockHeader, 10000, true, true); - ProofOfWork::assignResult(proof, currentBlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(o["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - currentBlockHeader.populateFromHeader(c_bRLP, false); - } - } - - // write block header - - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(currentBlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(currentBlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(currentBlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(currentBlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(currentBlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(currentBlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(currentBlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(currentBlockHeader.difficulty); - oBlockHeader["number"] = toString(currentBlockHeader.number); - oBlockHeader["gasLimit"] = toString(currentBlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(currentBlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(currentBlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(currentBlockHeader.extraData); - oBlockHeader["nonce"] = toString(currentBlockHeader.nonce); - - o["blockHeader"] = oBlockHeader; - - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - o["uncleHeaders"] = aUncleList; - - //txs: - - RLPStream txStream; - txStream.appendList(txList.size()); - for (unsigned i = 0; i < txList.size(); ++i) - { - RLPStream txrlp; - txList[i].streamRLP(txrlp); - txStream.appendRaw(txrlp.out()); - } - - RLPStream rlpStream2; - currentBlockHeader.streamRLP(rlpStream2, WithNonce); - - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); - - o["rlp"] = "0x" + toHex(block2.out()); - - if (sha3(RLP(state.blockData())[0].data()) != sha3(RLP(block2.out())[0].data())) - cnote << "block header mismatch\n"; - - if (sha3(RLP(state.blockData())[1].data()) != sha3(RLP(block2.out())[1].data())) - cnote << "txs mismatch\n"; - - if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; - - try - { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); - } - // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given - catch (...) - { - cnote << "block is invalid!\n"; - o.erase(o.find("blockHeader")); - o.erase(o.find("uncleHeaders")); - o.erase(o.find("transactions")); - } - } - - else - { - bytes blockRLP; - try - { - state.sync(bc); - blockRLP = importByteArray(o["rlp"].get_str()); - bc.import(blockRLP, state.db()); - state.sync(bc); - } - // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given - catch (Exception const& _e) - { - cnote << "state sync or block import did throw an exception: " << diagnostic_information(_e); - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - catch (std::exception const& _e) - { - cnote << "state sync or block import did throw an exception: " << _e.what(); - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - catch(...) - { - cnote << "state sync or block import did throw an exception\n"; - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - - BOOST_REQUIRE(o.count("blockHeader")); - - mObject tObj = o["blockHeader"].get_obj(); - BlockInfo blockHeaderFromFields; - const bytes c_rlpBytesBlockHeader = createBlockRLPFromFields(tObj); - const RLP c_blockHeaderRLP(c_rlpBytesBlockHeader); - blockHeaderFromFields.populateFromHeader(c_blockHeaderRLP, false); - - BlockInfo blockFromRlp = bc.info(); - - //Check the fields restored from RLP to original fields - BOOST_CHECK_MESSAGE(blockHeaderFromFields.headerHash(WithNonce) == blockFromRlp.headerHash(WithNonce), "hash in given RLP not matching the block hash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.parentHash == blockFromRlp.parentHash, "parentHash in given RLP not matching the block parentHash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.sha3Uncles == blockFromRlp.sha3Uncles, "sha3Uncles in given RLP not matching the block sha3Uncles!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.coinbaseAddress == blockFromRlp.coinbaseAddress,"coinbaseAddress in given RLP not matching the block coinbaseAddress!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.stateRoot == blockFromRlp.stateRoot, "stateRoot in given RLP not matching the block stateRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.transactionsRoot == blockFromRlp.transactionsRoot, "transactionsRoot in given RLP not matching the block transactionsRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.receiptsRoot == blockFromRlp.receiptsRoot, "receiptsRoot in given RLP not matching the block receiptsRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.logBloom == blockFromRlp.logBloom, "logBloom in given RLP not matching the block logBloom!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.difficulty == blockFromRlp.difficulty, "difficulty in given RLP not matching the block difficulty!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.number == blockFromRlp.number, "number in given RLP not matching the block number!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasLimit == blockFromRlp.gasLimit,"gasLimit in given RLP not matching the block gasLimit!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); - - BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); - - //Check transaction list - - Transactions txsFromField; - - for (auto const& txObj: o["transactions"].get_array()) - { - mObject tx = txObj.get_obj(); - - BOOST_REQUIRE(tx.count("nonce")); - BOOST_REQUIRE(tx.count("gasPrice")); - BOOST_REQUIRE(tx.count("gasLimit")); - BOOST_REQUIRE(tx.count("to")); - BOOST_REQUIRE(tx.count("value")); - BOOST_REQUIRE(tx.count("v")); - BOOST_REQUIRE(tx.count("r")); - BOOST_REQUIRE(tx.count("s")); - BOOST_REQUIRE(tx.count("data")); - - try - { - Transaction t(createRLPStreamFromTransactionFields(tx).out(), CheckSignature::Sender); - txsFromField.push_back(t); - } - catch (Exception const& _e) - { - BOOST_ERROR("Failed transaction constructor with Exception: " << diagnostic_information(_e)); - } - catch (exception const& _e) - { - cnote << _e.what(); - } - } - - Transactions txsFromRlp; - RLP root(blockRLP); - for (auto const& tr: root[1]) - { - Transaction tx(tr.data(), CheckSignature::Sender); - txsFromRlp.push_back(tx); - } - - BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), "transaction list size does not match"); - - for (size_t i = 0; i < txsFromField.size(); ++i) - { - BOOST_CHECK_MESSAGE(txsFromField[i].data() == txsFromRlp[i].data(), "transaction data in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].gas() == txsFromRlp[i].gas(), "transaction gasLimit in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].gasPrice() == txsFromRlp[i].gasPrice(), "transaction gasPrice in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].nonce() == txsFromRlp[i].nonce(), "transaction nonce in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().r == txsFromRlp[i].signature().r, "transaction r in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().s == txsFromRlp[i].signature().s, "transaction s in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().v == txsFromRlp[i].signature().v, "transaction v in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); - } - - // check uncle list - BOOST_CHECK_MESSAGE((o["uncleList"].type() == json_spirit::null_type ? 0 : o["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); - } - } -} - -} }// Namespace Close - - -BOOST_AUTO_TEST_SUITE(BlockTests) - -BOOST_AUTO_TEST_CASE(blValidBlockTest) -{ - dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -{ - dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -{ - dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blForkBlocks) -{ - dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(userDefinedFileBl) -{ - dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/test/blockchain.cpp b/test/blockchain.cpp new file mode 100644 index 000000000..7dad5b4f2 --- /dev/null +++ b/test/blockchain.cpp @@ -0,0 +1,537 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file block.cpp + * @author Christoph Jentzsch + * @date 2015 + * block test functions. + */ + +#include +#include +#include "TestHelper.h" + +using namespace std; +using namespace json_spirit; +using namespace dev; +using namespace dev::eth; + +namespace dev { namespace test { + +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << importByteArray(_tObj["extraData"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void doBlockTests(json_spirit::mValue& _v, bool _fillin) +{ + for (auto& i: _v.get_obj()) + { + cerr << i.first << endl; + mObject& o = i.second.get_obj(); + + BOOST_REQUIRE(o.count("genesisBlockHeader")); + BlockInfo blockFromFields; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + blockFromFields.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch(...) + { + cnote << "block population did throw an unknown exception\n"; + continue; + } + + BOOST_REQUIRE(o.count("pre")); + + ImportTest importer(o["pre"].get_obj()); + State state(Address(), OverlayDB(), BaseState::Empty); + importer.importState(o["pre"].get_obj(), state); + state.commit(); + + if (_fillin) + blockFromFields.stateRoot = state.rootHash(); + else + BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + + if (_fillin) + { + // find new valid nonce + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) + tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + + //update genesis block in json file + o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); + o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + } + + // create new "genesis" block + RLPStream rlpStream; + blockFromFields.streamRLP(rlpStream, WithNonce); + + RLPStream block(3); + block.appendRaw(rlpStream.out()); + block.appendRaw(RLPEmptyList); + block.appendRaw(RLPEmptyList); + + blockFromFields.verifyInternals(&block.out()); + + // construct blockchain + BlockChain bc(block.out(), string(), true); + + if (_fillin) + { + BOOST_REQUIRE(o.count("blocks")); + mArray blArray; + for (auto const& bl: o["blocks"].get_array()) + { + mObject blObj = bl.get_obj(); + BOOST_REQUIRE(blObj.count("transactions")); + + TransactionQueue txs; + + for (auto const& txObj: blObj["transactions"].get_array()) + { + mObject tx = txObj.get_obj(); + importer.importTransaction(tx); + if (!txs.attemptImport(importer.m_transaction.rlp())) + cnote << "failed importing transaction\n"; + } + + try + { + state.sync(bc); + state.sync(bc,txs); + state.commitToMine(bc); + MineInfo info; + for (info.completed = false; !info.completed; info = state.mine()) {} + state.completeMine(); + } + catch (Exception const& _e) + { + cnote << "state sync or mining did throw an exception: " << diagnostic_information(_e); + return; + } + catch (std::exception const& _e) + { + cnote << "state sync or mining did throw an exception: " << _e.what(); + return; + } + + // write valid txs + mArray txArray; + Transactions txList; + for (auto const& txi: txs.transactions()) + { + Transaction tx(txi.second, CheckSignature::Sender); + txList.push_back(tx); + mObject txObject; + txObject["nonce"] = toString(tx.nonce()); + txObject["data"] = toHex(tx.data()); + txObject["gasLimit"] = toString(tx.gas()); + txObject["gasPrice"] = toString(tx.gasPrice()); + txObject["r"] = "0x" + toString(tx.signature().r); + txObject["s"] = "0x" + toString(tx.signature().s); + txObject["v"] = to_string(tx.signature().v + 27); + txObject["to"] = toString(tx.receiveAddress()); + txObject["value"] = toString(tx.value()); + + txArray.push_back(txObject); + } + + blObj["transactions"] = txArray; + blObj["rlp"] = "0x" + toHex(state.blockData()); + + BlockInfo current_BlockHeader = state.info(); + + // overwrite blockheader with (possible wrong) data from "blockheader" in filler; + + if (blObj.count("blockHeader")) + { + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + cout << "new header!\n"; + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) + tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } + } + + // write block header + + mObject oBlockHeader; + oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); + oBlockHeader["number"] = toString(current_BlockHeader.number); + oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + + blObj["blockHeader"] = oBlockHeader; + + // write uncle list + mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. + blObj["uncleHeaders"] = aUncleList; + + //txs: + + RLPStream txStream; + txStream.appendList(txList.size()); + for (unsigned i = 0; i < txList.size(); ++i) + { + RLPStream txrlp; + txList[i].streamRLP(txrlp); + txStream.appendRaw(txrlp.out()); + } + + RLPStream rlpStream2; + current_BlockHeader.streamRLP(rlpStream2, WithNonce); + + RLPStream block2(3); + block2.appendRaw(rlpStream2.out()); + block2.appendRaw(txStream.out()); + block2.appendRaw(RLPEmptyList); + + blObj["rlp"] = "0x" + toHex(block2.out()); + + if (sha3(RLP(state.blockData())[0].data()) != sha3(RLP(block2.out())[0].data())) + cnote << "block header mismatch\n"; + + if (sha3(RLP(state.blockData())[1].data()) != sha3(RLP(block2.out())[1].data())) + cnote << "txs mismatch\n"; + + if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) + cnote << "uncle list mismatch\n"; + + try + { + ImportTest importerTmp(o["pre"].get_obj()); + State stateTmp(Address(), OverlayDB(), BaseState::Empty); + importerTmp.importState(o["pre"].get_obj(), stateTmp); + stateTmp.commit(); + BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); + stateTmp.sync(bcTmp); + bc.import(block2.out(), stateTmp.db()); + stateTmp.sync(bcTmp); + } + // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given + catch (...) + { + cnote << "block is invalid!\n"; + blObj.erase(blObj.find("blockHeader")); + blObj.erase(blObj.find("uncleHeaders")); + blObj.erase(blObj.find("transactions")); + } + blArray.push_back(blObj); + } + o["blocks"] = blArray; + } + + else + { + for (auto const& bl: o["blocks"].get_array()) + { + mObject blObj = bl.get_obj(); + bytes blockRLP; + try + { + state.sync(bc); + blockRLP = importByteArray(blObj["rlp"].get_str()); + bc.import(blockRLP, state.db()); + state.sync(bc); + } + // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given + catch (Exception const& _e) + { + cnote << "state sync or block import did throw an exception: " << diagnostic_information(_e); + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + catch (std::exception const& _e) + { + cnote << "state sync or block import did throw an exception: " << _e.what(); + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + catch(...) + { + cnote << "state sync or block import did throw an exception\n"; + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + + BOOST_REQUIRE(blObj.count("blockHeader")); + + mObject tObj = blObj["blockHeader"].get_obj(); + BlockInfo blockHeaderFromFields; + const bytes c_rlpBytesBlockHeader = createBlockRLPFromFields(tObj); + const RLP c_blockHeaderRLP(c_rlpBytesBlockHeader); + blockHeaderFromFields.populateFromHeader(c_blockHeaderRLP, false); + + BlockInfo blockFromRlp = bc.info(); + + //Check the fields restored from RLP to original fields + BOOST_CHECK_MESSAGE(blockHeaderFromFields.headerHash(WithNonce) == blockFromRlp.headerHash(WithNonce), "hash in given RLP not matching the block hash!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.parentHash == blockFromRlp.parentHash, "parentHash in given RLP not matching the block parentHash!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.sha3Uncles == blockFromRlp.sha3Uncles, "sha3Uncles in given RLP not matching the block sha3Uncles!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.coinbaseAddress == blockFromRlp.coinbaseAddress,"coinbaseAddress in given RLP not matching the block coinbaseAddress!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.stateRoot == blockFromRlp.stateRoot, "stateRoot in given RLP not matching the block stateRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.transactionsRoot == blockFromRlp.transactionsRoot, "transactionsRoot in given RLP not matching the block transactionsRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.receiptsRoot == blockFromRlp.receiptsRoot, "receiptsRoot in given RLP not matching the block receiptsRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.logBloom == blockFromRlp.logBloom, "logBloom in given RLP not matching the block logBloom!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.difficulty == blockFromRlp.difficulty, "difficulty in given RLP not matching the block difficulty!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.number == blockFromRlp.number, "number in given RLP not matching the block number!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasLimit == blockFromRlp.gasLimit,"gasLimit in given RLP not matching the block gasLimit!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); + + BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); + + //Check transaction list + + Transactions txsFromField; + + for (auto const& txObj: blObj["transactions"].get_array()) + { + mObject tx = txObj.get_obj(); + + BOOST_REQUIRE(tx.count("nonce")); + BOOST_REQUIRE(tx.count("gasPrice")); + BOOST_REQUIRE(tx.count("gasLimit")); + BOOST_REQUIRE(tx.count("to")); + BOOST_REQUIRE(tx.count("value")); + BOOST_REQUIRE(tx.count("v")); + BOOST_REQUIRE(tx.count("r")); + BOOST_REQUIRE(tx.count("s")); + BOOST_REQUIRE(tx.count("data")); + + try + { + Transaction t(createRLPStreamFromTransactionFields(tx).out(), CheckSignature::Sender); + txsFromField.push_back(t); + } + catch (Exception const& _e) + { + BOOST_ERROR("Failed transaction constructor with Exception: " << diagnostic_information(_e)); + } + catch (exception const& _e) + { + cnote << _e.what(); + } + } + + Transactions txsFromRlp; + RLP root(blockRLP); + for (auto const& tr: root[1]) + { + Transaction tx(tr.data(), CheckSignature::Sender); + txsFromRlp.push_back(tx); + } + + BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), "transaction list size does not match"); + + for (size_t i = 0; i < txsFromField.size(); ++i) + { + BOOST_CHECK_MESSAGE(txsFromField[i].data() == txsFromRlp[i].data(), "transaction data in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].gas() == txsFromRlp[i].gas(), "transaction gasLimit in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].gasPrice() == txsFromRlp[i].gasPrice(), "transaction gasPrice in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].nonce() == txsFromRlp[i].nonce(), "transaction nonce in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().r == txsFromRlp[i].signature().r, "transaction r in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().s == txsFromRlp[i].signature().s, "transaction s in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().v == txsFromRlp[i].signature().v, "transaction v in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); + + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + } + + // check uncle list + BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + } + } + } +} + +} }// Namespace Close + + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); +} + +//BOOST_AUTO_TEST_CASE(blValidBlockTest) +//{ +// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) +//{ +// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) +//{ +// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blForkBlocks) +//{ +// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); +//} + +BOOST_AUTO_TEST_CASE(userDefinedFileBl) +{ + dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); +} + +BOOST_AUTO_TEST_SUITE_END() + diff --git a/test/vm.cpp b/test/vm.cpp index 21bea0650..959edae73 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -531,33 +531,33 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest) } } -BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--inputlimits" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - -BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--inputlimits" || arg == "--all") - dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests); - } -} +//BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--inputlimits" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); + +// dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); + +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} + +//BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--inputlimits" || arg == "--all") +// dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests); +// } +//} BOOST_AUTO_TEST_CASE(vmRandom) { From 2c2026e559646583ac5180a12cf3bc4aa9cc8211 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:24:06 +0100 Subject: [PATCH 134/313] more block tests + bugfix for longer chains --- test/bcBlockChainTestFiller.json | 15 + ...er.json => bcInvalidHeaderTestFiller.json} | 427 ++++++++++-------- ...iller.json => bcValidBlockTestFiller.json} | 320 +++++++------ test/blockchain.cpp | 45 +- 4 files changed, 431 insertions(+), 376 deletions(-) rename test/{blInvalidHeaderTestFiller.json => bcInvalidHeaderTestFiller.json} (69%) rename test/{blValidBlockTestFiller.json => bcValidBlockTestFiller.json} (60%) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 050def25b..75ed62943 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -39,6 +39,21 @@ ], "uncleHeaders" : [ ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } ] } diff --git a/test/blInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json similarity index 69% rename from test/blInvalidHeaderTestFiller.json rename to test/bcInvalidHeaderTestFiller.json index 482eafc56..bba00834b 100644 --- a/test/blInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,8 +1,5 @@ { "log1_wrongBlockNumber" : { - "blockHeader" : { - "number" : "2" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -33,25 +30,30 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "number" : "2" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "log1_wrongBloom" : { - "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - }, + "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -68,6 +70,7 @@ "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, + "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10000000000", @@ -82,25 +85,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongCoinbase" : { - "blockHeader" : { - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -131,25 +138,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongDifficulty" : { - "blockHeader" : { - "difficulty" : "10000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -180,25 +191,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "difficulty" : "10000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "DifferentExtraData" : { - "blockHeader" : { - "extraData" : "42" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -229,25 +244,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "extraData" : "42" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongGasLimit" : { - "blockHeader" : { - "gasLimit" : "100000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -278,25 +297,30 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "gasLimit" : "100000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ + ] }, "wrongGasUsed" : { - "blockHeader" : { - "gasUsed" : "0" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -327,25 +351,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "gasUsed" : "0" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongNumber" : { - "blockHeader" : { - "number" : "0" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -376,25 +404,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "number" : "0" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongParentHash" : { - "blockHeader" : { - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -425,25 +457,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, - "wrongReceiptTrie" : { - "blockHeader" : { - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }, + "wrongReceiptTrie" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -474,25 +510,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongStateRoot" : { - "blockHeader" : { - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -523,25 +563,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongTimestamp" : { - "blockHeader" : { - "timestamp" : "0x54c98c80" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -572,25 +616,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "timestamp" : "0x54c98c80" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, - "wrongTransactionsTrie" : { - "blockHeader" : { - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }, + "wrongTransactionsTrie" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -621,25 +669,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "transactionsTrie" : "0x55e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongUncleHash" : { - "blockHeader" : { - "uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -670,18 +722,25 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] } } diff --git a/test/blValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json similarity index 60% rename from test/blValidBlockTestFiller.json rename to test/bcValidBlockTestFiller.json index 8099c0dd6..3ce79cf4d 100644 --- a/test/blValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -1,43 +1,4 @@ { - "diffTooLowToChange" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "42", - "gasLimit" : "100000", - "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, "diff1024" : { "genesisBlockHeader" : { @@ -64,19 +25,24 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] + }, "gasPrice0" : { @@ -104,18 +70,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "0", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "85000", + "gasPrice" : "0", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -144,18 +114,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "0", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "1000001", + "gasPrice" : "0", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -184,18 +158,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "500", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -224,27 +202,31 @@ "storage": {} } }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "7000000000" - }, + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "8000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "7000000000" + }, + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "8000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -273,27 +255,31 @@ "storage": {} } }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" - }, + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "9", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + }, + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "9", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -328,54 +314,64 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ - ], - - "firstBlockTest" : { - "block" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", - "extraData" : "42", - "gasLimit" : "0x0dddb6", - "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", - "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - }, - "transactions" : [ - { - "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", - "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", - "to" : "", - "v" : "0x1b", - "value" : "" - } - ], - } + ] + }, + "dataTx" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "023101", + "extraData" : "42", + "gasLimit" : "0x0dddb6", + "gasUsed" : "100", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "62", + "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", + "gasLimit" : "0x0f3e6f", + "gasPrice" : "0x09184e72a000", + "nonce" : "0", + "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", + "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "to" : "", + "v" : "0x1b", + "value" : "" + } + ], + "uncleHeaders" : [ + ] + } + ] } } + diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 7dad5b4f2..69ea8fa2b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -81,7 +81,7 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void doBlockTests(json_spirit::mValue& _v, bool _fillin) +void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { for (auto& i: _v.get_obj()) { @@ -271,7 +271,6 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) if (tmp != current_BlockHeader) { current_BlockHeader = tmp; - cout << "new header!\n"; ProofOfWork pow; MineInfo ret; while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) @@ -343,14 +342,9 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) try { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); + state.sync(bc); + bc.import(block2.out(), state.db()); + state.sync(bc); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -505,32 +499,23 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcBlockChainTest) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); } -//BOOST_AUTO_TEST_CASE(blValidBlockTest) -//{ -// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -//} - -//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -//{ -// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -//{ -// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blForkBlocks) -//{ -// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -//} -BOOST_AUTO_TEST_CASE(userDefinedFileBl) +BOOST_AUTO_TEST_CASE(userDefinedFileBc) { - dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); + dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_SUITE_END() From 678fed4877debbbe90116a8d514f8a88f7a18db5 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:44:41 +0100 Subject: [PATCH 135/313] fix blockGasLimit bug : 1024 -> 2048 --- libethcore/BlockInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 6c645372e..71cd0d110 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -206,8 +206,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); // Check timestamp is after previous timestamp. if (parentHash) From 62a2ed4996551eeb853d44f00882e599fe0f78c6 Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 4 Mar 2015 16:01:13 +0300 Subject: [PATCH 136/313] Transaction Test Fillers POC9 gas fees increased, most tests are incorrect now need to review (wip) --- test/stPreCompiledContractsFiller.json | 6 +- test/stTransactionTestFiller.json | 144 ++++++++++++------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/test/stPreCompiledContractsFiller.json b/test/stPreCompiledContractsFiller.json index 7c7fd8e4b..d571dfccc 100644 --- a/test/stPreCompiledContractsFiller.json +++ b/test/stPreCompiledContractsFiller.json @@ -378,16 +378,16 @@ "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "currentNumber" : "0", - "currentGasLimit" : "10000000", + "currentGasLimit" : "100000000", "currentDifficulty" : "256", "currentTimestamp" : 1, "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" }, "pre" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "20000000", + "balance" : "200000000", "nonce" : "0", - "code" : "{ [[ 2 ]] (CALL 500 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", + "code" : "{ [[ 2 ]] (CALL 20000000 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { diff --git a/test/stTransactionTestFiller.json b/test/stTransactionTestFiller.json index 6b50774eb..1299e6d94 100644 --- a/test/stTransactionTestFiller.json +++ b/test/stTransactionTestFiller.json @@ -52,7 +52,7 @@ "transaction" : { "data" : "", - "gasLimit" : "500", + "gasLimit" : "21000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -84,7 +84,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -116,7 +116,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -138,7 +138,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1101", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -148,12 +148,12 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21600", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "502" + "value" : "5000" } }, @@ -170,7 +170,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -180,20 +180,20 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21600", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "502" + "value" : "5000" } }, "InternalCallHittingGasLimit" : { "env" : { - "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentCoinbase" : "2adf5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "22000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -227,7 +227,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1100", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -240,7 +240,7 @@ "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "21100", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -258,7 +258,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1100", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -271,7 +271,7 @@ "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "21100", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -289,7 +289,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1101", + "gasLimit" : "21101", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -302,7 +302,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -310,7 +310,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "140000", "code" : "", "nonce" : "0", "storage" : { @@ -339,7 +339,7 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "130000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -352,7 +352,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "100000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -360,7 +360,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "30000", "code" : "", "nonce" : "0", "storage" : { @@ -389,7 +389,7 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -402,7 +402,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -410,7 +410,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -449,7 +449,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -462,7 +462,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -470,7 +470,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "500000", "code" : "", "nonce" : "0", "storage" : { @@ -514,7 +514,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -527,7 +527,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -535,7 +535,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -544,7 +544,7 @@ "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10", - "code" : "{(CALL 0 0 1 0 0 0 0) (SUICIDE 0)}", + "code" : "{(CALL 20000 0x0000000000000000000000000000000000000000 1 0 0 0 0) (SUICIDE 0)}", "nonce" : "0", "storage" : { } @@ -552,7 +552,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "0", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -563,7 +563,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "50000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -576,7 +576,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -584,7 +584,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -592,8 +592,8 @@ }, "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10", - "code" : "{(CALL 20 0 1 0 0 0 0) (SUICIDE 0)}", + "balance" : "1000", + "code" : "{(CALL 22000 0x0000000000000000000000000000000000000000 1 0 0 0 0) (SUICIDE 0)}", "nonce" : "0", "storage" : { } @@ -601,7 +601,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "0", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -612,7 +612,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "50000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -633,7 +633,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "122000", "code" : "", "nonce" : "0", "storage" : { @@ -642,7 +642,7 @@ "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10000", - "code" : "{(SUICIDE 0) (CALL 0 2000 0 0 0 0 0) }", + "code" : "{(SUICIDE 0) (CALL 2000 0x0000000000000000000000000000000000000000 0 0 0 0 0) }", "nonce" : "0", "storage" : { } @@ -650,7 +650,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "1110", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -660,7 +660,7 @@ "transaction" : { "data" : "", - "gasLimit" : "3700", + "gasLimit" : "33700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -673,7 +673,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -681,7 +681,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "122000", "code" : "", "nonce" : "0", "storage" : { @@ -700,7 +700,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1700", + "gasLimit" : "31700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -713,7 +713,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -721,7 +721,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -740,7 +740,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1700", + "gasLimit" : "21700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -771,7 +771,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -784,7 +784,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -802,7 +802,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -815,7 +815,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -833,7 +833,7 @@ "transaction" : { "data" : "0x00000000000000000000112233445566778f32", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -846,7 +846,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -854,7 +854,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "43000", "code" : "", "nonce" : "0", "storage" : { @@ -864,7 +864,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5100", + "gasLimit" : "35100", "gasPrice" : "0", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -877,7 +877,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -885,7 +885,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "33000", "code" : "", "nonce" : "0", "storage" : { @@ -908,7 +908,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -916,7 +916,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "33000", "code" : "", "nonce" : "0", "storage" : { @@ -926,8 +926,8 @@ "transaction" : { "data" : "0x3240349548983454", - "gasLimit" : "500", - "gasPrice" : "0", + "gasLimit" : "32600", + "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", @@ -999,7 +999,7 @@ "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "900" + "value" : "" } }, @@ -1048,7 +1048,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "100000", + "balance" : "1000000", "code" : "", "nonce" : "0", "storage" : { @@ -1058,7 +1058,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1079,7 +1079,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "132000", "code" : "", "nonce" : "0", "storage" : { @@ -1089,7 +1089,7 @@ "transaction" : { "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", - "gasLimit" : "882", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1110,7 +1110,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -1120,7 +1120,7 @@ "transaction" : { "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", - "gasLimit" : "883", + "gasLimit" : "70000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1141,7 +1141,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "30000", "code" : "", "nonce" : "0", "storage" : { @@ -1159,7 +1159,7 @@ "transaction" : { "data" : "", - "gasLimit" : "882", + "gasLimit" : "21882", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From 8221ebaffdec9c430017ddf640c94014437e0e17 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:48:01 +0100 Subject: [PATCH 137/313] update block tests to latest changes PoW changes --- libethcore/ProofOfWork.cpp | 2 +- test/bcBlockChainTestFiller.json | 4 ++- test/bcInvalidHeaderTestFiller.json | 56 +++++++++++++++++++++-------- test/bcValidBlockTestFiller.json | 52 ++++++++++++++++++--------- test/blockchain.cpp | 36 +++++++++++++++---- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 084225a38..04e4249b6 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -162,7 +162,7 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign if (val <= boundary) { ret.first.completed = true; - result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); result.nonce = u64(tryNonce); break; } diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 75ed62943..827f49c58 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -7,12 +7,14 @@ "extraData" : "42", "gasLimit" : "100000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index bba00834b..5665a3418 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -7,7 +7,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -61,7 +63,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,7 +119,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -168,7 +174,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -221,7 +229,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -274,7 +284,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -328,7 +340,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -381,7 +395,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -434,7 +450,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -487,7 +505,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -540,7 +560,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -593,7 +615,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -646,7 +670,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -699,7 +725,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 3ce79cf4d..abb8afdf5 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -8,7 +8,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -30,7 +32,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "850", + "gasLimit" : "85000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -53,7 +55,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,7 +101,9 @@ "extraData" : "42", "gasLimit" : "1000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -141,7 +147,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -163,7 +171,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "500", + "gasLimit" : "50000", "gasPrice" : "10", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -185,7 +193,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -238,7 +248,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -291,7 +303,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -341,8 +355,10 @@ "extraData" : "42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "number" : "0", "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", @@ -351,19 +367,23 @@ "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } }, "blocks" : [ { "transactions" : [ { "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", + "gasLimit" : "50000", + "gasPrice" : "50", "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "", - "v" : "0x1b", "value" : "" } ], diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 69ea8fa2b..ccfd57722 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -75,6 +75,12 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("extraData")) rlpStream << importByteArray(_tObj["extraData"].get_str()); + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixBytes")) + rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -130,13 +136,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { // find new valid nonce ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + std::pair ret; + while (!ProofOfWork::verify(blockFromFields)) + { + ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); } // create new "genesis" block @@ -266,15 +276,25 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixBytes")) + tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + // find new valid nonce if (tmp != current_BlockHeader) { current_BlockHeader = tmp; + ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) - tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } } } else @@ -302,6 +322,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); blObj["blockHeader"] = oBlockHeader; @@ -423,6 +445,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); From 431cace13fc71a8901e45975fd967952fb797094 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 15:17:34 +0100 Subject: [PATCH 138/313] More info in AZ. --- alethzero/MainWin.cpp | 22 ++++++++++++++++++---- libethcore/BlockInfo.cpp | 18 +++++++++++++----- libethcore/BlockInfo.h | 7 ++++--- libethcore/Exceptions.h | 1 + libethcore/ProofOfWork.cpp | 8 ++++---- libethcore/ProofOfWork.h | 11 ++++++++--- 6 files changed, 48 insertions(+), 19 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 08117e596..e6f380e47 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1358,11 +1358,16 @@ void Main::on_blocks_currentItemChanged() s << "   Children: " << details.children.size() << ""; s << "
Gas used/limit: " << info.gasUsed << "/" << info.gasLimit << ""; s << "
Coinbase: " << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << " " << info.coinbaseAddress; + s << "
Seed hash: " << info.seedHash << ""; + s << "
Mix hash: " << info.mixHash << ""; s << "
Nonce: " << info.nonce << ""; s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + { + auto e = ProofOfWork::eval(info); + s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; + } else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; @@ -1374,9 +1379,18 @@ void Main::on_blocks_currentItemChanged() for (auto u: block[2]) { BlockInfo uncle = BlockInfo::fromHeader(u.data()); - s << "
 Hash: " << uncle.hash << ""; - s << "
 Parent: " << uncle.parentHash << ""; - s << "
 Number: " << uncle.number << ""; + char const* line = "
 "; + s << line << "Hash: " << uncle.hash << ""; + s << line << "Parent: " << uncle.parentHash << ""; + s << line << "Number: " << uncle.number << ""; + s << line << "Coinbase: " << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << " " << uncle.coinbaseAddress; + s << line << "Seed hash: " << uncle.seedHash << ""; + s << line << "Mix hash: " << uncle.mixHash << ""; + s << line << "Nonce: " << uncle.nonce << ""; + s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; + s << line << "Difficulty: " << uncle.difficulty << ""; + auto e = ProofOfWork::eval(uncle); + s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) s << "
Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << ""; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 71cd0d110..c04f6fc29 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -57,7 +57,7 @@ void BlockInfo::setEmpty() timestamp = 0; extraData.clear(); seedHash = h256(); - mixBytes = h256(); + mixHash = h256(); nonce = Nonce(); hash = headerHash(WithNonce); } @@ -82,7 +82,7 @@ void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << mixBytes << nonce; + _s << mixHash << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -111,7 +111,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); seedHash = _header[field = 13].toHash(); - mixBytes = _header[field = 14].toHash(); + mixHash = _header[field = 14].toHash(); nonce = _header[field = 15].toHash(); } @@ -180,7 +180,12 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); - seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; + seedHash = calculateSeedHash(_parent); +} + +h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const +{ + return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -196,7 +201,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -209,6 +214,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (seedHash != calculateSeedHash(_parent)) + BOOST_THROW_EXCEPTION(InvalidSeedHash()); + // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index fbc459b76..d2072046d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -76,7 +76,7 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 mixBytes; + h256 mixHash; h256 seedHash; Nonce nonce; @@ -106,7 +106,7 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && - mixBytes == _cmp.mixBytes && + mixHash == _cmp.mixHash && seedHash == _cmp.seedHash && nonce == _cmp.nonce; } @@ -123,6 +123,7 @@ public: u256 calculateDifficulty(BlockInfo const& _parent) const; u256 calculateGasLimit(BlockInfo const& _parent) const; + h256 calculateSeedHash(BlockInfo const& _parent) const; /// sha3 of the header only. h256 headerHash(IncludeNonce _n) const; @@ -133,7 +134,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixHash << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 5a8a2d055..833bc2b04 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -57,6 +57,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real): m_head(_head), m_real(_real) {} h256 m_head; h256 m_real; virtual const char* what() const noexcept; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; +struct InvalidSeedHash: virtual dev::Exception {}; class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 04e4249b6..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -118,16 +118,16 @@ Ethasher* Ethasher::s_this = nullptr; bool Ethash::verify(BlockInfo const& _header) { bigint boundary = (bigint(1) << 256) / _header.difficulty; - u256 e(eval(_header, _header.nonce)); - return e <= boundary; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; } -h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) +Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { auto p = Ethasher::params(_header); ethash_return_value r; ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return h256(r.result, h256::ConstructFromPointer); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7b9787f61..fdf51f0d4 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -55,12 +55,17 @@ public: Nonce nonce; h256 mixHash; }; + struct Result + { + h256 value; + h256 mixHash; + }; - static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } protected: Nonce m_last; From df90502691e614cc1fb92d01934163195adcedc2 Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 4 Mar 2015 19:01:37 +0300 Subject: [PATCH 139/313] Gas Fee Test Changes (1) State Tests --- test/stBlockHashTestFiller.json | 6 +- test/stExampleFiller.json | 2 +- test/stInitCodeTestFiller.json | 34 +++++----- test/stLogTestsFiller.json | 92 +++++++++++++------------- test/stMemoryTestFiller.json | 2 +- test/stRefundTestFiller.json | 32 ++++----- test/stSolidityTestFiller.json | 14 ++-- test/stSpecialTestFiller.json | 4 +- test/stSystemOperationsTestFiller.json | 58 ++++++++-------- 9 files changed, 122 insertions(+), 122 deletions(-) diff --git a/test/stBlockHashTestFiller.json b/test/stBlockHashTestFiller.json index af2234976..5ecc5b1c7 100644 --- a/test/stBlockHashTestFiller.json +++ b/test/stBlockHashTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -59,7 +59,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -93,7 +93,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stExampleFiller.json b/test/stExampleFiller.json index 7acf695ed..9daefbd54 100644 --- a/test/stExampleFiller.json +++ b/test/stExampleFiller.json @@ -26,7 +26,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "10000", + "gasLimit" : "400000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stInitCodeTestFiller.json b/test/stInitCodeTestFiller.json index ea5467df8..902290121 100644 --- a/test/stInitCodeTestFiller.json +++ b/test/stInitCodeTestFiller.json @@ -21,7 +21,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "599", + "gasLimit" : "32599", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -43,7 +43,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "2", + "balance" : "22177", "code" : "", "nonce" : "0", "storage" : { @@ -53,7 +53,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "599", + "gasLimit" : "22176", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -74,7 +74,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "70000", "code" : "", "nonce" : "0", "storage" : { @@ -84,7 +84,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "590", + "gasLimit" : "21590", "gasPrice" : "3", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -104,7 +104,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "50000", "code" : "", "nonce" : "0", "storage" : { @@ -114,7 +114,7 @@ "transaction" : { "data" : "0x6000f1", - "gasLimit" : "1000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -135,7 +135,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -145,7 +145,7 @@ "transaction" : { "data" : "0x600a80600c6000396000fff2ffff600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -166,7 +166,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -176,7 +176,7 @@ "transaction" : { "data" : "0x600a80600c600039600000f20000600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -207,7 +207,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200ff600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -245,7 +245,7 @@ "transaction" : { "data" : "0x00", - "gasLimit" : "10000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -283,7 +283,7 @@ "transaction" : { "data" : "0x00", - "gasLimit" : "10000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -521,7 +521,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "41000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -560,7 +560,7 @@ "transaction" : { "data" : "", - "gasLimit" : "15000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stLogTestsFiller.json b/test/stLogTestsFiller.json index 0f31c4c63..3b13698cf 100644 --- a/test/stLogTestsFiller.json +++ b/test/stLogTestsFiller.json @@ -32,7 +32,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -73,7 +73,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -114,9 +114,9 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "100000", + "value" : "2100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "" } @@ -156,7 +156,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -238,7 +238,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -279,7 +279,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -320,7 +320,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -361,7 +361,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -402,7 +402,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -444,7 +444,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -485,7 +485,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -526,7 +526,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -567,7 +567,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -608,7 +608,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -649,7 +649,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -690,7 +690,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -731,7 +731,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -772,7 +772,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -814,7 +814,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -855,7 +855,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -896,7 +896,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -937,7 +937,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -978,7 +978,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1019,7 +1019,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1060,7 +1060,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1101,7 +1101,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1142,7 +1142,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1184,7 +1184,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1225,7 +1225,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1266,7 +1266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1307,7 +1307,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1348,7 +1348,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1389,7 +1389,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1430,7 +1430,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1471,7 +1471,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1512,7 +1512,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1553,7 +1553,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1595,7 +1595,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1636,7 +1636,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1677,7 +1677,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1718,7 +1718,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1759,7 +1759,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1800,7 +1800,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1841,7 +1841,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json index eac2d5875..f34307443 100644 --- a/test/stMemoryTestFiller.json +++ b/test/stMemoryTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "1000", + "gasLimit" : "22000", "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stRefundTestFiller.json b/test/stRefundTestFiller.json index 4809c0987..9e867a508 100644 --- a/test/stRefundTestFiller.json +++ b/test/stRefundTestFiller.json @@ -18,7 +18,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -27,7 +27,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -54,7 +54,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -63,7 +63,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -90,7 +90,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -99,7 +99,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "500", + "gasLimit" : "21000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -126,7 +126,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "502", + "balance" : "50200", "nonce" : "0", "code" : "", "storage": {} @@ -135,7 +135,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "502", + "gasLimit" : "21002", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -166,7 +166,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -175,7 +175,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -206,7 +206,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -215,7 +215,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -247,7 +247,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -256,7 +256,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -288,7 +288,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -297,7 +297,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSolidityTestFiller.json b/test/stSolidityTestFiller.json index 549c5f226..948dc5f7a 100644 --- a/test/stSolidityTestFiller.json +++ b/test/stSolidityTestFiller.json @@ -278,7 +278,7 @@ { "//" : "run()", "data" : "0xc0406226", - "gasLimit" : "15000", + "gasLimit" : "35000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -333,7 +333,7 @@ { "//" : "testRecursiveMethods()", "data" : "0x981a3165", - "gasLimit" : "2000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -378,7 +378,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -388,7 +388,7 @@ { "//" : "testInfiniteLoop()", "data" : "0x296df0df", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -463,7 +463,7 @@ { "//" : "run(uint256)", "data" : "0xa444f5e900000000000000000000000000000000000000000000000000000000000204", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -508,7 +508,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -518,7 +518,7 @@ { "//" : "run()", "data" : "0xc0406226", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSpecialTestFiller.json b/test/stSpecialTestFiller.json index d01072b46..223d9f75f 100644 --- a/test/stSpecialTestFiller.json +++ b/test/stSpecialTestFiller.json @@ -22,7 +22,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -31,7 +31,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSystemOperationsTestFiller.json b/test/stSystemOperationsTestFiller.json index 3b08ca67b..7460ca94e 100644 --- a/test/stSystemOperationsTestFiller.json +++ b/test/stSystemOperationsTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -60,7 +60,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -95,7 +95,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -129,7 +129,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -163,7 +163,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -232,7 +232,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -257,7 +257,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -266,7 +266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -300,7 +300,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -334,7 +334,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -368,7 +368,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -410,7 +410,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -452,7 +452,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -494,7 +494,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -536,7 +536,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -578,7 +578,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -619,7 +619,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -660,7 +660,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -701,7 +701,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -743,7 +743,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -785,7 +785,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -827,7 +827,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -870,7 +870,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -911,7 +911,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -952,7 +952,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -993,7 +993,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1035,7 +1035,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1076,7 +1076,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From 2719aaf83087ef3c59167d1e90b896413d8a94c6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 17:35:23 +0100 Subject: [PATCH 140/313] Add date/time language to solidity. --- libdevcore/FixedHash.h | 4 ++-- libsolidity/AST.h | 8 +++++++- libsolidity/ExpressionCompiler.cpp | 3 +++ libsolidity/Parser.cpp | 9 +++++++++ libsolidity/Token.h | 24 ++++++++++++++++-------- libsolidity/Types.cpp | 19 ++++++++++++++++++- mix/MixClient.cpp | 9 ++++++--- test/SolidityScanner.cpp | 17 +++++++++++++++++ test/blockchain.cpp | 14 +++++++------- 9 files changed, 85 insertions(+), 22 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 7fa5b411a..b00a80c04 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -85,8 +85,8 @@ public: // The obvious comparison operators. bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; } bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; } - bool operator<(FixedHash const& _c) const { return m_data < _c.m_data; } - bool operator>=(FixedHash const& _c) const { return m_data >= _c.m_data; } + bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; } + bool operator>=(FixedHash const& _c) const { return !operator<(_c); } // The obvious binary operators. FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; } diff --git a/libsolidity/AST.h b/libsolidity/AST.h index c91c433ed..c3c2cd8d3 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1197,7 +1197,13 @@ public: Wei = Token::SubWei, Szabo = Token::SubSzabo, Finney = Token::SubFinney, - Ether = Token::SubEther + Ether = Token::SubEther, + Second = Token::SubSecond, + Minute = Token::SubMinute, + Hour = Token::SubHour, + Day = Token::SubDay, + Week = Token::SubWeek, + Year = Token::SubYear }; Literal(SourceLocation const& _location, Token::Value _token, ASTPointer const& _value, diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 619b06738..38d9aac86 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -250,6 +250,9 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) case Token::BitNot: // ~ m_context << eth::Instruction::NOT; break; + case Token::After: // after + m_context << eth::Instruction::TIMESTAMP << eth::Instruction::ADD; + break; case Token::Delete: // delete solAssert(!!m_currentLValue, "LValue not retrieved."); m_currentLValue->setToZero(_unaryOperation.getLocation()); diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 3c88efc7c..44d111591 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -822,6 +822,15 @@ ASTPointer Parser::parsePrimaryExpression() expression = nodeFactory.createNode(token, literal, subdenomination); break; } + if (Token::isTimeSubdenomination(m_scanner->peekNextToken())) + { + ASTPointer literal = getLiteralAndAdvance(); + nodeFactory.markEndPosition(); + Literal::SubDenomination subdenomination = static_cast(m_scanner->getCurrentToken()); + m_scanner->next(); + expression = nodeFactory.createNode(token, literal, subdenomination); + break; + } // fall-through case Token::StringLiteral: nodeFactory.markEndPosition(); diff --git a/libsolidity/Token.h b/libsolidity/Token.h index 5e4a6317f..2997bb493 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -162,7 +162,7 @@ namespace solidity K(New, "new", 0) \ K(Public, "public", 0) \ K(Private, "private", 0) \ - K(Internal, "internal", 0) \ + K(Internal, "internal", 0) \ K(Return, "return", 0) \ K(Returns, "returns", 0) \ K(Struct, "struct", 0) \ @@ -171,11 +171,18 @@ namespace solidity K(While, "while", 0) \ K(Enum, "enum", 0) \ \ - /* Ether subdenominations */ \ - K(SubWei, "wei", 0) \ - K(SubSzabo, "szabo", 0) \ - K(SubFinney, "finney", 0) \ - K(SubEther, "ether", 0) \ + /* Ether subdenominations */ \ + K(SubWei, "wei", 0) \ + K(SubSzabo, "szabo", 0) \ + K(SubFinney, "finney", 0) \ + K(SubEther, "ether", 0) \ + K(SubSecond, "seconds", 0) \ + K(SubMinute, "minutes", 0) \ + K(SubHour, "hours", 0) \ + K(SubDay, "days", 0) \ + K(SubWeek, "weeks", 0) \ + K(SubYear, "years", 0) \ + K(After, "after", 0) \ /* type keywords, keep them in this order, keep int as first keyword * the implementation in Types.cpp has to be synced to this here */\ K(Int, "int", 0) \ @@ -376,12 +383,13 @@ public: } static bool isBitOp(Value op) { return (BitOr <= op && op <= SHR) || op == BitNot; } - static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub; } + static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub || op == After; } static bool isCountOp(Value op) { return op == Inc || op == Dec; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; } static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Internal; } - static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; } + static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; } + static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; } // Returns a string corresponding to the JS token string // (.e., "<" for the token LT) or NULL if the token doesn't diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 22d612cd9..2105d6299 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -195,7 +195,8 @@ TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const return TypePointer(); // for non-hash integers, we allow +, -, ++ and -- else if (_operator == Token::Add || _operator == Token::Sub || - _operator == Token::Inc || _operator == Token::Dec) + _operator == Token::Inc || _operator == Token::Dec || + _operator == Token::After) return shared_from_this(); else return TypePointer(); @@ -251,6 +252,7 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) switch (_literal.getSubDenomination()) { case Literal::SubDenomination::Wei: + case Literal::SubDenomination::Second: case Literal::SubDenomination::None: break; case Literal::SubDenomination::Szabo: @@ -262,6 +264,21 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) case Literal::SubDenomination::Ether: m_value *= bigint("1000000000000000000"); break; + case Literal::SubDenomination::Minute: + m_value *= bigint("60"); + break; + case Literal::SubDenomination::Hour: + m_value *= bigint("3600"); + break; + case Literal::SubDenomination::Day: + m_value *= bigint("86400"); + break; + case Literal::SubDenomination::Week: + m_value *= bigint("604800"); + break; + case Literal::SubDenomination::Year: + m_value *= bigint("31536000"); + break; } } diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index 04cec6344..5b446a6a4 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -46,15 +46,18 @@ const u256 c_mixGenesisDifficulty = (u256) 1 << 4; class MixBlockChain: public dev::eth::BlockChain { public: - MixBlockChain(std::string const& _path, h256 _stateRoot): BlockChain(createGenesisBlock(_stateRoot), _path, true) + MixBlockChain(std::string const& _path, h256 _stateRoot): + BlockChain(createGenesisBlock(_stateRoot), _path, true) { } static bytes createGenesisBlock(h256 _stateRoot) { RLPStream block(3); - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_mixGenesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << std::string() << sha3(bytes(1, 42)); + block.appendList(16) + << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie + << LogBloom() << c_mixGenesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 + << std::string() << h256() << h256() << h64(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); diff --git a/test/SolidityScanner.cpp b/test/SolidityScanner.cpp index 2e4e5db08..8d3e53929 100644 --- a/test/SolidityScanner.cpp +++ b/test/SolidityScanner.cpp @@ -264,6 +264,23 @@ BOOST_AUTO_TEST_CASE(ether_subdenominations) BOOST_CHECK_EQUAL(scanner.next(), Token::SubEther); } +BOOST_AUTO_TEST_CASE(time_subdenominations) +{ + Scanner scanner(CharStream("seconds minutes hours days weeks years")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::SubSecond); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubMinute); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubHour); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubDay); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubWeek); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubYear); +} + +BOOST_AUTO_TEST_CASE(time_after) +{ + Scanner scanner(CharStream("after 1")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::After); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ccfd57722..aea2bab07 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -78,8 +78,8 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("seedHash")) rlpStream << importByteArray(_tObj["seedHash"].get_str()); - if (_tObj.count("mixBytes")) - rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -146,7 +146,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); + o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); } // create new "genesis" block @@ -276,8 +276,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixBytes")) - tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); if (blObj["blockHeader"].get_obj().count("seedHash")) tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); @@ -322,7 +322,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); @@ -445,7 +445,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixHash == blockFromRlp.mixHash, "mixHash in given RLP not matching the block mixHash!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); From ef128a4bf4aedffeef8b502eb2a0fae421465a89 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 19:55:52 +0100 Subject: [PATCH 141/313] Params & JSON file. --- libdevcrypto/OverlayDB.cpp | 2 -- libethcore/BlockInfo.cpp | 19 +++++++++---------- libethcore/BlockInfo.h | 2 -- .../FeeStructure.cpp => libethcore/Params.cpp | 11 ++++++++++- libevm/FeeStructure.h => libethcore/Params.h | 10 ++++++++++ libethcore/ProofOfWork.cpp | 2 ++ libethereum/Client.h | 2 +- libethereum/Interface.h | 2 +- libethereum/Precompiled.cpp | 2 +- libethereum/State.h | 2 +- libevm/All.h | 1 - libevm/VM.h | 2 +- libsolidity/Types.cpp | 2 ++ feeStructure.json => params.json | 12 +++++++++++- 14 files changed, 49 insertions(+), 22 deletions(-) rename libevm/FeeStructure.cpp => libethcore/Params.cpp (84%) rename libevm/FeeStructure.h => libethcore/Params.h (91%) rename feeStructure.json => params.json (75%) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4bd698f57 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -56,10 +56,8 @@ void OverlayDB::commit() if (m_aux.count(i)) { m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; m_aux.erase(i); } - cdebug << "Discarding " << keysOf(m_aux); m_auxActive.clear(); m_aux.clear(); m_over.clear(); diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index c04f6fc29..ef7f7b8f0 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -25,13 +25,12 @@ #include #include "ProofOfWork.h" #include "Exceptions.h" +#include "Params.h" #include "BlockInfo.h" using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; - BlockInfo::BlockInfo(): timestamp(Invalid256) { } @@ -128,7 +127,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) if (gasUsed > gasLimit) BOOST_THROW_EXCEPTION(TooMuchGasUsed()); - if (number && extraData.size() > 1024) + if (number && extraData.size() > c_maximumExtraDataSize) BOOST_THROW_EXCEPTION(ExtraDataTooBig()); } @@ -185,23 +184,23 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const { - return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; + return number % c_epochDuration == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const { if (!parentHash) - return 1000000; + return c_genesisGasLimit; else - return max(125000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024); + return max(c_minGasLimit, (_parent.gasLimit * (c_gasLimitBoundDivisor - 1) + (_parent.gasUsed * 6 / 5)) / c_gasLimitBoundDivisor); } u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const { if (!parentHash) - return c_genesisDifficulty; + return (u256)c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -211,8 +210,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index d2072046d..bf986e3a1 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -30,8 +30,6 @@ namespace dev namespace eth { -extern u256 c_genesisDifficulty; - enum IncludeNonce { WithoutNonce = 0, diff --git a/libevm/FeeStructure.cpp b/libethcore/Params.cpp similarity index 84% rename from libevm/FeeStructure.cpp rename to libethcore/Params.cpp index 78c6ebfb2..f36af1375 100644 --- a/libevm/FeeStructure.cpp +++ b/libethcore/Params.cpp @@ -19,7 +19,7 @@ * @date 2014 */ -#include "FeeStructure.h" +#include "Params.h" using namespace std; namespace dev @@ -28,6 +28,15 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_genesisDifficulty = 2048; +u256 const c_maximumExtraDataSize = 1024; +u256 const c_epochDuration = 3000; +u256 const c_genesisGasLimit = 1000000; +u256 const c_minGasLimit = 125000; +u256 const c_gasLimitBoundDivisor = 1024; +u256 const c_minimumDifficulty = 2048; +u256 const c_difficultyBoundDivisor = 2048; +u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; u256 const c_expGas = 10; u256 const c_expByteGas = 10; diff --git a/libevm/FeeStructure.h b/libethcore/Params.h similarity index 91% rename from libevm/FeeStructure.h rename to libethcore/Params.h index 9109347dc..cab1852fa 100644 --- a/libevm/FeeStructure.h +++ b/libethcore/Params.h @@ -29,6 +29,16 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +extern u256 const c_genesisDifficulty; +extern u256 const c_maximumExtraDataSize; +extern u256 const c_epochDuration; +extern u256 const c_genesisGasLimit; +extern u256 const c_minGasLimit; +extern u256 const c_gasLimitBoundDivisor; +extern u256 const c_minimumDifficulty; +extern u256 const c_difficultyBoundDivisor; +extern u256 const c_durationLimit; + extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..332d739bb 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,6 +66,7 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } + cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -90,6 +91,7 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } + cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/libethereum/Client.h b/libethereum/Client.h index 03debb750..c4f2b3705 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include "CanonBlockChain.h" #include "TransactionQueue.h" diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 2a9de14d1..817a5e4b0 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include "LogFilter.h" #include "Transaction.h" #include "AccountDiff.h" diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..6e0d4756c 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/libethereum/State.h b/libethereum/State.h index 33843c65c..00a735291 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include "TransactionQueue.h" #include "Account.h" diff --git a/libevm/All.h b/libevm/All.h index 89c451ef4..2360d91b8 100644 --- a/libevm/All.h +++ b/libevm/All.h @@ -1,5 +1,4 @@ #pragma once #include "ExtVMFace.h" -#include "FeeStructure.h" #include "VM.h" diff --git a/libevm/VM.h b/libevm/VM.h index ecf5de292..f100badc4 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -27,7 +27,7 @@ #include #include #include -#include "FeeStructure.h" +#include #include "VMFace.h" namespace dev diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 2105d6299..865a32c3a 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -308,6 +308,8 @@ TypePointer IntegerConstantType::unaryOperatorResult(Token::Value _operator) con case Token::Sub: value = -m_value; break; + case Token::After: + return shared_from_this(); default: return TypePointer(); } diff --git a/feeStructure.json b/params.json similarity index 75% rename from feeStructure.json rename to params.json index f5acf0f0b..1b5682544 100644 --- a/feeStructure.json +++ b/params.json @@ -1,5 +1,15 @@ var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." }, + "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, + "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, + "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, + "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, + "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, + "minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." }, + "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, + "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, + + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "expGas": { "v": 10, "d": "Once per EXP instuction." }, "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, From 20517ec66c7719729872500367522e2c83b4578d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 21:32:26 +0100 Subject: [PATCH 142/313] merge --- libethcore/BlockInfo.cpp | 20 +- test/bcBlockChainTestFiller.json | 6 +- test/bcInvalidHeaderTestFiller.json | 88 ++++----- test/bcUncleTestFiller.json | 114 ++++++++++++ test/bcValidBlockTestFiller.json | 48 ++--- test/blockchain.cpp | 275 +++++++++++++++------------- 6 files changed, 341 insertions(+), 210 deletions(-) create mode 100644 test/bcUncleTestFiller.json diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ef7f7b8f0..d8a2357a1 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -96,22 +96,22 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) int field = 0; try { - parentHash = _header[field = 0].toHash(); - sha3Uncles = _header[field = 1].toHash(); - coinbaseAddress = _header[field = 2].toHash
(); - stateRoot = _header[field = 3].toHash(); - transactionsRoot = _header[field = 4].toHash(); - receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + parentHash = _header[field = 0].toHash(RLP::VeryStrict); + sha3Uncles = _header[field = 1].toHash(RLP::VeryStrict); + coinbaseAddress = _header[field = 2].toHash
(RLP::VeryStrict); + stateRoot = _header[field = 3].toHash(RLP::VeryStrict); + transactionsRoot = _header[field = 4].toHash(RLP::VeryStrict); + receiptsRoot = _header[field = 5].toHash(RLP::VeryStrict); + logBloom = _header[field = 6].toHash(RLP::VeryStrict); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - seedHash = _header[field = 13].toHash(); - mixHash = _header[field = 14].toHash(); - nonce = _header[field = 15].toHash(); + seedHash = _header[field = 13].toHash(RLP::VeryStrict); + mixHash = _header[field = 14].toHash(RLP::VeryStrict); + nonce = _header[field = 15].toHash(RLP::VeryStrict); } catch (Exception const& _e) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 827f49c58..8a0bf89fe 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -1,10 +1,10 @@ { "minDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1023", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", "number" : "0", @@ -12,7 +12,7 @@ "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index 5665a3418..aa32dfbab 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,13 +1,13 @@ { "log1_wrongBlockNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -57,13 +57,13 @@ "log1_wrongBloom" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -92,7 +92,7 @@ "blocks" : [ { "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, "transactions" : [ { @@ -113,13 +113,13 @@ "wrongCoinbase" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -168,13 +168,13 @@ "wrongDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -223,13 +223,13 @@ "DifferentExtraData" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -257,7 +257,7 @@ "blocks" : [ { "blockHeader" : { - "extraData" : "42" + "extraData" : "0x42" }, "transactions" : [ { @@ -278,13 +278,13 @@ "wrongGasLimit" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -334,13 +334,13 @@ "wrongGasUsed" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -389,13 +389,13 @@ "wrongNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -444,13 +444,13 @@ "wrongParentHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -499,13 +499,13 @@ "wrongReceiptTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -554,13 +554,13 @@ "wrongStateRoot" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -609,13 +609,13 @@ "wrongTimestamp" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -664,13 +664,13 @@ "wrongTransactionsTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -719,13 +719,13 @@ "wrongUncleHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json new file mode 100644 index 000000000..839e3ba46 --- /dev/null +++ b/test/bcUncleTestFiller.json @@ -0,0 +1,114 @@ +{ + "minDifficulty" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "2049", + "extraData" : "0x", + "gasLimit" : "99804806", + "gasUsed" : "21000", + "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", + "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", + "nonce" : "17ed77999bef2e4b", + "number" : "2", + "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", + "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", + "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", + "timestamp" : "1425490151", + "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "1", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + } +} diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index abb8afdf5..29b2e978e 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -2,13 +2,13 @@ "diff1024" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1024", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -49,13 +49,13 @@ "gasPrice0" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -95,13 +95,13 @@ "gasLimitTooHigh" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "1000000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -141,13 +141,13 @@ "SimpleTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -187,13 +187,13 @@ "txOrder" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -242,13 +242,13 @@ "txEqualValue" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -297,13 +297,13 @@ "log1_correct" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -349,13 +349,13 @@ "dataTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "023101", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index aea2bab07..55c39f56b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -31,61 +31,10 @@ using namespace dev::eth; namespace dev { namespace test { -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("seedHash")) - rlpStream << importByteArray(_tObj["seedHash"].get_str()); - - if (_tObj.count("mixHash")) - rlpStream << importByteArray(_tObj["mixHash"].get_str()); +bytes createBlockRLPFromFields(mObject& _tObj); +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - return rlpStream.out(); -} void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -147,6 +96,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); + o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); } // create new "genesis" block @@ -211,13 +161,13 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txList.push_back(tx); mObject txObject; txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); + txObject["data"] = "0x" + toHex(tx.data()); txObject["gasLimit"] = toString(tx.gas()); txObject["gasPrice"] = toString(tx.gasPrice()); txObject["r"] = "0x" + toString(tx.signature().r); txObject["s"] = "0x" + toString(tx.signature().s); txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); + txObject["to"] = tx.isCreation() ? "" : toString(tx.receiveAddress()); txObject["value"] = toString(tx.value()); txArray.push_back(txObject); @@ -232,78 +182,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj.count("blockHeader")) { - if (blObj["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = current_BlockHeader; - - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); - - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); - - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); - - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); - - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); - - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); - - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); - - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); - - // find new valid nonce - - if (tmp != current_BlockHeader) - { - current_BlockHeader = tmp; - - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) - { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); - } + overwriteBlockHeader(current_BlockHeader, blObj); } // write block header @@ -321,10 +200,11 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["hash"] = toString(current_BlockHeader.hash); blObj["blockHeader"] = oBlockHeader; @@ -506,7 +386,9 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions from rlp and transaction from field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].rlp() == txsFromRlp[i].rlp(), "transactions rlp do not match"); + } // check uncle list @@ -516,6 +398,137 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } } +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.count("hash") > 0 ? (_tObj.size() - 1) : _tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << fromHex(_tObj["extraData"].get_str()); + + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +{ + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } +} } }// Namespace Close @@ -536,6 +549,10 @@ BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); } +//BOOST_AUTO_TEST_CASE(bcUncleTest) +//{ +// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +//} BOOST_AUTO_TEST_CASE(userDefinedFileBc) { From e938bbc8c671db7b76cd98b00acb99f09c41d6d5 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 22:38:05 +0100 Subject: [PATCH 143/313] fix evmjit build --- evmjit/libevmjit-cpp/Env.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmjit/libevmjit-cpp/Env.cpp b/evmjit/libevmjit-cpp/Env.cpp index 11882d79d..874993c84 100644 --- a/evmjit/libevmjit-cpp/Env.cpp +++ b/evmjit/libevmjit-cpp/Env.cpp @@ -1,7 +1,7 @@ #pragma GCC diagnostic ignored "-Wconversion" #include -#include +#include #include #include "Utils.h" From 8def53064b981da9bfd68eae403bf44c8c13a898 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:24:01 +0100 Subject: [PATCH 144/313] RLP tool. --- CMakeLists.txt | 1 + eth/main.cpp | 43 +++--- libdevcore/CommonIO.cpp | 19 ++- libdevcore/CommonIO.h | 6 +- libethcore/Params.cpp | 4 +- libethcore/ProofOfWork.cpp | 2 - params.json | 8 +- rlp/CMakeLists.txt | 16 +++ rlp/base64.cpp | 128 +++++++++++++++++ rlp/base64.h | 40 ++++++ rlp/main.cpp | 279 +++++++++++++++++++++++++++++++++++++ 11 files changed, 511 insertions(+), 35 deletions(-) create mode 100644 rlp/CMakeLists.txt create mode 100644 rlp/base64.cpp create mode 100644 rlp/base64.h create mode 100644 rlp/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dffdd9027..59cfe4ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ if (EVMJIT) endif() add_subdirectory(libdevcore) +add_subdirectory(rlp) add_subdirectory(libevmcore) add_subdirectory(liblll) diff --git a/eth/main.cpp b/eth/main.cpp index 5051580a5..dff97f7fa 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -97,38 +97,38 @@ void interactiveHelp() void help() { cout - << "Usage eth [OPTIONS] " << endl - << "Options:" << endl - << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl + << "Usage eth [OPTIONS] " << endl + << "Options:" << endl + << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl << " -b,--bootstrap Connect to the default Ethereum peerserver." << endl - << " -c,--client-name Add a name to your client's version string (default: blank)." << endl - << " -d,--db-path Load database from path (default: ~/.ethereum " << endl - << " /Etherum or Library/Application Support/Ethereum)." << endl + << " -c,--client-name Add a name to your client's version string (default: blank)." << endl + << " -d,--db-path Load database from path (default: ~/.ethereum " << endl + << " /Etherum or Library/Application Support/Ethereum)." << endl << " -f,--force-mining Mine even when there are no transaction to mine (Default: off)" << endl << " -h,--help Show this help message and exit." << endl - << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl + << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl #if ETH_JSONRPC << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl #endif - << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl + << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl << " -m,--mining Enable mining, optionally for a specified number of blocks (Default: off)" << endl << " -n,--upnp Use upnp for NAT (default: on)." << endl << " -L,--local-networking Use peers whose addresses are local." << endl << " -o,--mode Start a full node or a peer node (Default: full)." << endl - << " -p,--port Connect to remote port (default: 30303)." << endl - << " -r,--remote Connect to remote host (default: none)." << endl - << " -s,--secret Set the secret key for use with send command (default: auto)." << endl + << " -p,--port Connect to remote port (default: 30303)." << endl + << " -r,--remote Connect to remote host (default: none)." << endl + << " -s,--secret Set the secret key for use with send command (default: auto)." << endl << " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl - << " -u,--public-ip Force public ip to given (default; auto)." << endl - << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl - << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl - << " -V,--version Show the version and exit." << endl + << " -u,--public-ip Force public ip to given (default; auto)." << endl + << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl + << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl + << " -V,--version Show the version and exit." << endl #if ETH_EVMJIT << " --jit Use EVM JIT (default: off)." << endl #endif ; - exit(0); + exit(0); } string credits(bool _interactive = false) @@ -136,15 +136,14 @@ string credits(bool _interactive = false) std::ostringstream cout; cout << "Ethereum (++) " << dev::Version << endl - << " Code by Gav Wood, (c) 2013, 2014." << endl + << " Code by Gav Wood et al, (c) 2013, 2014, 2015." << endl << " Based on a design by Vitalik Buterin." << endl << endl; if (_interactive) - { - cout << "Type 'netstart 30303' to start networking" << endl; - cout << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl; - cout << "Type 'exit' to quit" << endl << endl; - } + cout + << "Type 'netstart 30303' to start networking" << endl + << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl + << "Type 'exit' to quit" << endl << endl; return cout.str(); } diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 288dbd1ff..4fa132073 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -84,7 +84,7 @@ bytes dev::contents(std::string const& _file) is.seekg (0, is.end); streamoff length = is.tellg(); if (length == 0) // return early, MSVC does not like reading 0 bytes - return {}; + return bytes(); is.seekg (0, is.beg); bytes ret(length); is.read((char*)ret.data(), length); @@ -92,9 +92,22 @@ bytes dev::contents(std::string const& _file) return ret; } -void dev::writeFile(std::string const& _file, bytes const& _data) +string dev::contentsString(std::string const& _file) { - ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return string(); + // get length of file: + is.seekg (0, is.end); + streamoff length = is.tellg(); + if (length == 0) // return early, MSVC does not like reading 0 bytes + return string(); + is.seekg (0, is.beg); + string ret; + ret.resize(length); + is.read((char*)ret.data(), length); + is.close(); + return ret; } void dev::writeFile(std::string const& _file, bytesConstRef _data) diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 5769b6c64..1fc8a65e4 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -42,13 +42,15 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +std::string contentsString(std::string const& _file); /// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. bytesRef contentsNew(std::string const& _file); -/// Write the given binary data into the given file, replacing the file if it pre-exists. -void writeFile(std::string const& _file, bytes const& _data); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytesConstRef _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +inline void writeFile(std::string const& _file, bytes const& _data) { writeFile(_file, bytesConstRef(&_data)); } +inline void writeFile(std::string const& _file, std::string const& _data) { writeFile(_file, bytesConstRef(_data)); } /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index f36af1375..d1154abcc 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -28,13 +28,13 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_genesisDifficulty = 2048; +u256 const c_genesisDifficulty = 131072; u256 const c_maximumExtraDataSize = 1024; u256 const c_epochDuration = 3000; u256 const c_genesisGasLimit = 1000000; u256 const c_minGasLimit = 125000; u256 const c_gasLimitBoundDivisor = 1024; -u256 const c_minimumDifficulty = 2048; +u256 const c_minimumDifficulty = 131072; u256 const c_difficultyBoundDivisor = 2048; u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 332d739bb..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,7 +66,6 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } - cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -91,7 +90,6 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } - cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/params.json b/params.json index 1b5682544..744f92154 100644 --- a/params.json +++ b/params.json @@ -1,13 +1,13 @@ var x = { - "genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." }, + "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, + "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, + "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, + "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "expGas": { "v": 10, "d": "Once per EXP instuction." }, diff --git a/rlp/CMakeLists.txt b/rlp/CMakeLists.txt new file mode 100644 index 000000000..0e2b5f57b --- /dev/null +++ b/rlp/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_policy(SET CMP0015 NEW) +set(CMAKE_AUTOMOC OFF) + +aux_source_directory(. SRC_LIST) + +include_directories(BEFORE ..) +include_directories(${LEVELDB_INCLUDE_DIRS}) + +set(EXECUTABLE rlp) + +add_executable(${EXECUTABLE} ${SRC_LIST}) + +target_link_libraries(${EXECUTABLE} devcrypto) + +install( TARGETS ${EXECUTABLE} DESTINATION bin) + diff --git a/rlp/base64.cpp b/rlp/base64.cpp new file mode 100644 index 000000000..5e2b32000 --- /dev/null +++ b/rlp/base64.cpp @@ -0,0 +1,128 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. + +#include "base64.h" + +#include + +using namespace std; +using namespace dev; + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +static inline bool is_base64(byte c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +std::string dev::base64_encode(bytesConstRef _in) { + std::string ret; + int i = 0; + int j = 0; + byte char_array_3[3]; + byte char_array_4[4]; + + auto buf = _in.data(); + auto bufLen = _in.size(); + + while (bufLen--) { + char_array_3[i++] = *(buf++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + } + + return ret; +} + +bytes dev::base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + byte char_array_4[4], char_array_3[3]; + bytes ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret.push_back(char_array_3[i]); + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); + } + + return ret; +} diff --git a/rlp/base64.h b/rlp/base64.h new file mode 100644 index 000000000..53ba282c8 --- /dev/null +++ b/rlp/base64.h @@ -0,0 +1,40 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +#pragma once + +#include +#include +#include + +namespace dev +{ + +std::string base64_encode(bytesConstRef _in); +bytes base64_decode(std::string const& _in); + +} diff --git a/rlp/main.cpp b/rlp/main.cpp new file mode 100644 index 000000000..9bd51cdfc --- /dev/null +++ b/rlp/main.cpp @@ -0,0 +1,279 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file main.cpp + * @author Gav Wood + * @date 2014 + * RLP tool. + */ +#include +#include +#include +#include +#include +#include +#include +#include "base64.h" +using namespace std; +using namespace dev; + +void help() +{ + cout + << "Usage rlp [OPTIONS] [ | -- ]" << endl + << "Options:" << endl + << " -V,--version Show the version and exit." << endl + ; + exit(0); +} + +void version() +{ + cout << "rlp version " << dev::Version << endl; + exit(0); +} + +enum class Mode { + ListArchive, + ExtractArchive, + Render, +}; + +enum class Encoding { + Auto, + Hex, + Base64, + Binary, +}; + +bool isAscii(string const& _s) +{ + for (char c: _s) + if (c < 32) + return false; + return true; +} + +class RLPStreamer +{ +public: + struct Prefs + { + string indent = " "; + bool hexInts = false; + bool forceString = false; + bool escapeAll = false; + bool forceHex = false; + }; + + RLPStreamer(ostream& _out, Prefs _p): m_out(_out), m_prefs(_p) {} + + void output(RLP const& _d, unsigned _level = 0) + { + if (_d.isNull()) + m_out << "null"; + else if (_d.isInt()) + if (m_prefs.hexInts) + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + else + m_out << _d.toInt(RLP::LaisezFaire); + else if (_d.isData()) + if (m_prefs.forceString || (!m_prefs.forceHex && isAscii(_d.toString()))) + m_out << escaped(_d.toString(), m_prefs.escapeAll); + else + m_out << toHex(_d.data()); + else if (_d.isList()) + { + m_out << "["; + string newline = "\n"; + for (unsigned i = 0; i < _level + 1; ++i) + newline += m_prefs.indent; + int j = 0; + for (auto i: _d) + { + m_out << (j++ ? + (m_prefs.indent.empty() ? ", " : ("," + newline)) : + (m_prefs.indent.empty() ? " " : newline)); + output(i, _level + 1); + } + newline = newline.substr(0, newline.size() - m_prefs.indent.size()); + m_out << (m_prefs.indent.empty() ? (j ? " ]" : "]") : (j ? newline + "]" : "]")); + } + } + +private: + std::ostream& m_out; + Prefs m_prefs; +}; + +int main(int argc, char** argv) +{ + Encoding encoding = Encoding::Auto; + Mode mode = Mode::Render; + string inputFile = "--"; + bool lenience = false; + RLPStreamer::Prefs prefs; + + for (int i = 1; i < argc; ++i) + { + string arg = argv[i]; + if (arg == "-h" || arg == "--help") + help(); + else if (arg == "-r" || arg == "--render") + mode = Mode::Render; + else if ((arg == "-i" || arg == "--indent") && argc > i) + prefs.indent = argv[++i]; + else if (arg == "--hex-ints") + prefs.hexInts = true; + else if (arg == "--force-string") + prefs.forceString = true; + else if (arg == "--force-hex") + prefs.forceHex = true; + else if (arg == "--force-escape") + prefs.escapeAll = true; + else if (arg == "-l" || arg == "--list-archive") + mode = Mode::ListArchive; + else if (arg == "-e" || arg == "--extract-archive") + mode = Mode::ExtractArchive; + else if (arg == "-L" || arg == "--lenience") + lenience = true; + else if (arg == "-V" || arg == "--version") + version(); + else if (arg == "-x" || arg == "--hex" || arg == "--base-16") + encoding = Encoding::Hex; + else if (arg == "--64" || arg == "--base-64") + encoding = Encoding::Base64; + else if (arg == "-b" || arg == "--bin" || arg == "--base-256") + encoding = Encoding::Binary; + else + inputFile = arg; + } + + bytes in; + if (inputFile == "--") + for (int i = cin.get(); i != -1; i = cin.get()) + in.push_back((byte)i); + else + in = contents(inputFile); + if (encoding == Encoding::Auto) + { + encoding = Encoding::Hex; + for (char b: in) + if (b != '\n' && b != ' ' && b != '\t') + { + if (encoding == Encoding::Hex && (b < '0' || b > '9' ) && (b < 'a' || b > 'f' ) && (b < 'A' || b > 'F' )) + { + cerr << "'" << b << "':" << (int)b << endl; + encoding = Encoding::Base64; + } + if (encoding == Encoding::Base64 && (b < '0' || b > '9' ) && (b < 'a' || b > 'z' ) && (b < 'A' || b > 'Z' ) && b != '+' && b != '/') + { + encoding = Encoding::Binary; + break; + } + } + } + bytes b; + switch (encoding) + { + case Encoding::Hex: + { + string s = asString(in); + boost::algorithm::replace_all(s, " ", ""); + boost::algorithm::replace_all(s, "\n", ""); + boost::algorithm::replace_all(s, "\t", ""); + b = fromHex(s); + break; + } + case Encoding::Base64: + { + string s = asString(in); + boost::algorithm::replace_all(s, " ", ""); + boost::algorithm::replace_all(s, "\n", ""); + boost::algorithm::replace_all(s, "\t", ""); + b = base64_decode(s); + break; + } + default: + swap(b, in); + break; + } + + try + { + RLP rlp(b); + switch (mode) + { + case Mode::ListArchive: + { + if (!rlp.isList()) + { + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); + } + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; + } + case Mode::ExtractArchive: + { + if (!rlp.isList()) + { + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); + } + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; + } + } + catch (...) + { + cerr << "Error: Invalid format; bad RLP." << endl; + exit(1); + } + + return 0; +} From f6502e252221c2ac69340d9e3c30e5c246d13b36 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:36:20 +0100 Subject: [PATCH 145/313] Improvements to help text of RLP. --- rlp/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 9bd51cdfc..c3c04535b 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -35,6 +35,20 @@ void help() cout << "Usage rlp [OPTIONS] [ | -- ]" << endl << "Options:" << endl + << " -r,--render Render the given RLP. Options:" << endl + << " --indent Use string as the level indentation (default ' ')." << endl + << " --hex-ints Render integers in hex." << endl + << " --force-string Force all data to be rendered as C-style strings." << endl + << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl + << " --force-hex Force all data to be rendered as raw hex." << endl + << " -l,--list-archive List the items in the RLP list by hash and size." << endl + << " -e,--extract-archive Extract all items in the RLP list, named by hash." << endl + << "General options:" << endl + << " -L,--lenience Try not to bomb out early if possible." << endl + << " -x,--hex,--base-16 Treat input RLP as hex encoded data." << endl + << " --64,--base-64 Treat input RLP as base-64 encoded data." << endl + << " -b,--bin,--base-256 Treat input RLP as raw binary data." << endl + << " -h,--help Print this help message and exit." << endl << " -V,--version Show the version and exit." << endl ; exit(0); @@ -87,7 +101,7 @@ public: m_out << "null"; else if (_d.isInt()) if (m_prefs.hexInts) - m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire), 1), 1); else m_out << _d.toInt(RLP::LaisezFaire); else if (_d.isData()) From d3f0fe098b7bd8bff535e87f548e0be2f2980e04 Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 5 Mar 2015 12:48:30 +0300 Subject: [PATCH 146/313] VMTest Fillers execution gas amount changed --- test/vmArithmeticTestFiller.json | 324 ++++++------- test/vmBitwiseLogicOperationTestFiller.json | 248 +++++----- test/vmBlockInfoTestFiller.json | 44 +- test/vmEnvironmentalInfoTestFiller.json | 92 ++-- test/vmIOandFlowOperationsTestFiller.json | 488 ++++++++++---------- test/vmLogTestFiller.json | 184 ++++---- test/vmPerformanceTestFiller.json | 16 +- test/vmPushDupSwapTestFiller.json | 282 +++++------ test/vmSha3TestFiller.json | 26 +- test/vmSystemOperationsTestFiller.json | 64 +-- test/vmtestsFiller.json | 16 +- 11 files changed, 892 insertions(+), 892 deletions(-) diff --git a/test/vmArithmeticTestFiller.json b/test/vmArithmeticTestFiller.json index 1484de19c..933df72d1 100644 --- a/test/vmArithmeticTestFiller.json +++ b/test/vmArithmeticTestFiller.json @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -221,7 +221,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -249,7 +249,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -277,7 +277,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -305,7 +305,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -333,7 +333,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -361,7 +361,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -389,7 +389,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -417,7 +417,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -445,7 +445,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -473,7 +473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -501,7 +501,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -529,7 +529,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -557,7 +557,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -585,7 +585,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -613,7 +613,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -641,7 +641,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -669,7 +669,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -697,7 +697,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -725,7 +725,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -753,7 +753,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -781,7 +781,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -809,7 +809,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -837,7 +837,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -865,7 +865,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -893,7 +893,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -921,7 +921,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1005,7 +1005,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1033,7 +1033,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1061,7 +1061,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1089,7 +1089,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1117,7 +1117,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1145,7 +1145,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1173,7 +1173,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1201,7 +1201,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1229,7 +1229,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1257,7 +1257,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1369,7 +1369,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1397,7 +1397,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1537,7 +1537,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1565,7 +1565,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1593,7 +1593,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1621,7 +1621,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1649,7 +1649,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1677,7 +1677,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1705,7 +1705,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1733,7 +1733,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1762,7 +1762,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1790,7 +1790,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1930,7 +1930,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1958,7 +1958,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1986,7 +1986,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2014,7 +2014,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2042,7 +2042,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2070,7 +2070,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2098,7 +2098,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2126,7 +2126,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2154,7 +2154,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2183,7 +2183,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2211,7 +2211,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2239,7 +2239,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2267,7 +2267,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2295,7 +2295,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2323,7 +2323,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2351,7 +2351,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2379,7 +2379,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2407,7 +2407,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2435,7 +2435,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2463,7 +2463,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2491,7 +2491,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2519,7 +2519,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2547,7 +2547,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2575,7 +2575,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2603,7 +2603,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2631,7 +2631,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2659,7 +2659,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2687,7 +2687,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2715,7 +2715,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2743,7 +2743,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2771,7 +2771,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2799,7 +2799,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2827,7 +2827,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2855,7 +2855,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2883,7 +2883,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2911,7 +2911,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2939,7 +2939,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2967,7 +2967,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2995,7 +2995,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3023,7 +3023,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3051,7 +3051,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3079,7 +3079,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3107,7 +3107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3135,7 +3135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3163,7 +3163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3191,7 +3191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3219,7 +3219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3247,7 +3247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3275,7 +3275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3303,7 +3303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3331,7 +3331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3359,7 +3359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3387,7 +3387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3415,7 +3415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3443,7 +3443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3471,7 +3471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3499,7 +3499,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3527,7 +3527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3555,7 +3555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3583,7 +3583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3611,7 +3611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3639,7 +3639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3667,7 +3667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3695,7 +3695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3723,7 +3723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3751,7 +3751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3779,7 +3779,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3807,7 +3807,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3835,7 +3835,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3863,7 +3863,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3891,7 +3891,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3919,7 +3919,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3947,7 +3947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3975,7 +3975,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4003,7 +4003,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4031,7 +4031,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4059,7 +4059,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4087,7 +4087,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4115,7 +4115,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4143,7 +4143,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4171,7 +4171,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4199,7 +4199,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4227,7 +4227,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4255,7 +4255,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4283,7 +4283,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4311,7 +4311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4339,7 +4339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4367,7 +4367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4395,7 +4395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4423,7 +4423,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4451,7 +4451,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4479,7 +4479,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4507,7 +4507,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4535,7 +4535,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4563,7 +4563,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4591,7 +4591,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4619,7 +4619,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4647,7 +4647,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4675,7 +4675,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4703,7 +4703,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4731,7 +4731,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4759,7 +4759,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4787,7 +4787,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4815,7 +4815,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4843,7 +4843,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4871,7 +4871,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4899,7 +4899,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmBitwiseLogicOperationTestFiller.json b/test/vmBitwiseLogicOperationTestFiller.json index 8954dca1e..1eb923f4f 100644 --- a/test/vmBitwiseLogicOperationTestFiller.json +++ b/test/vmBitwiseLogicOperationTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT (- 0 2) 0 )}", "storage": {} @@ -20,10 +20,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "value" : "10000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "10000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 0 (- 0 2) )}", "storage": {} @@ -48,10 +48,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "value" : "10000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "10000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -76,10 +76,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", - "data" : "", + "value" : "10000000000000000000", + "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -95,7 +95,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -108,7 +108,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -123,7 +123,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] ( GT (- 0 2) 0 )}", "storage": {} @@ -136,7 +136,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -151,7 +151,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 0 (- 0 2) )}", "storage": {} @@ -164,7 +164,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -208,7 +208,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -221,7 +221,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -236,7 +236,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT (- 0 2) 0 )}", "storage": {} @@ -249,7 +249,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -264,7 +264,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 0 (- 0 2) )}", "storage": {} @@ -277,7 +277,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -292,7 +292,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -305,7 +305,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -321,7 +321,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -334,7 +334,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -349,7 +349,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT (- 0 5) (- 0 3) )}", "storage": {} @@ -362,7 +362,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -377,7 +377,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT (- 0 2) 0 )}", "storage": {} @@ -390,7 +390,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -405,7 +405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 0 (- 0 2) )}", "storage": {} @@ -418,7 +418,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -433,7 +433,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -446,7 +446,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -462,7 +462,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -475,7 +475,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -490,7 +490,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT (- 0 5) (- 0 3) )}", "storage": {} @@ -503,7 +503,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -518,7 +518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (- 0 5) (- 0 3) )}", "storage": {} @@ -531,7 +531,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -546,7 +546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ 0 0)}", "storage": {} @@ -559,7 +559,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -574,7 +574,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ 115792089237316195423570985008687907853269984665640564039457584007913129639935 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -587,7 +587,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -602,7 +602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -615,7 +615,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -630,7 +630,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO 0 )}", "storage": {} @@ -643,7 +643,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "iszeo2": { @@ -657,7 +657,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO (- 0 2) )}", "storage": {} @@ -670,7 +670,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -685,7 +685,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 2 2) }", "storage": {} @@ -698,7 +698,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -713,7 +713,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 2 1) }", "storage": {} @@ -726,7 +726,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -741,7 +741,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 3 1) }", "storage": {} @@ -754,7 +754,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "and3": { @@ -768,7 +768,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -781,7 +781,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "and4": { @@ -795,7 +795,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -808,7 +808,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 2 2) } ", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -879,7 +879,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 2 1) } ", "storage": {} @@ -892,7 +892,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -907,7 +907,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 3 1) } ", "storage": {} @@ -920,7 +920,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "or3": { @@ -934,7 +934,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -947,7 +947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "or4": { @@ -961,7 +961,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -974,7 +974,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -989,7 +989,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1002,7 +1002,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1017,7 +1017,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 2 2) } ", "storage": {} @@ -1030,7 +1030,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1045,7 +1045,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 2 1) } ", "storage": {} @@ -1058,7 +1058,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1073,7 +1073,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 3 1) } ", "storage": {} @@ -1086,7 +1086,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "xor3": { @@ -1100,7 +1100,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -1113,7 +1113,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "xor4": { @@ -1127,7 +1127,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1140,7 +1140,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1155,7 +1155,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1168,7 +1168,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1183,7 +1183,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 0 )}", "storage": {} @@ -1196,7 +1196,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1211,7 +1211,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 2 )}", "storage": {} @@ -1224,7 +1224,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1239,7 +1239,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -1252,7 +1252,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1267,7 +1267,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 2) )}", "storage": {} @@ -1280,7 +1280,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1295,7 +1295,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 115792089237316195423570985008687907853269984665640564039457584007913129639935) )}", "storage": {} @@ -1308,7 +1308,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1323,7 +1323,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 0) )}", "storage": {} @@ -1336,7 +1336,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1351,7 +1351,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 0) 0x8040201008040201 ) } ", "storage": {} @@ -1364,7 +1364,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "byte1": { @@ -1378,7 +1378,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 1) 0x8040201008040201 ) } ", "storage": {} @@ -1391,7 +1391,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "byte2": { @@ -1405,7 +1405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 2) 0x8040201008040201 ) } ", "storage": {} @@ -1418,7 +1418,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1433,7 +1433,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 3) 0x8040201008040201 ) } ", "storage": {} @@ -1446,7 +1446,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1461,7 +1461,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 4) 0x8040201008040201 ) } ", "storage": {} @@ -1474,7 +1474,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1489,7 +1489,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 5) 0x8040201008040201 ) } ", "storage": {} @@ -1502,7 +1502,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1518,7 +1518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 6) 0x8040201008040201 ) } ", "storage": {} @@ -1531,7 +1531,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1546,7 +1546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 7) 0x8040201008040201 ) } ", "storage": {} @@ -1559,7 +1559,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1575,7 +1575,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 31) 0x8040201008040201 ) } ", "storage": {} @@ -1588,7 +1588,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1603,7 +1603,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (SDIV 31 32) 0x8040201008040201 ) } ", "storage": {} @@ -1616,7 +1616,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1631,7 +1631,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8040201008040201 ) } ", "storage": {} @@ -1644,7 +1644,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1659,7 +1659,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE 0 0x8040201008040201) } ", "storage": {} @@ -1672,7 +1672,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmBlockInfoTestFiller.json b/test/vmBlockInfoTestFiller.json index 04cbec51c..c86a9f2cb 100644 --- a/test/vmBlockInfoTestFiller.json +++ b/test/vmBlockInfoTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 2) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) }", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 0) }", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (COINBASE) }", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (TIMESTAMP) }", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NUMBER) }", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (DIFFICULTY) }", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GASLIMIT) }", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmEnvironmentalInfoTestFiller.json b/test/vmEnvironmentalInfoTestFiller.json index c63cd914c..4de871d9e 100644 --- a/test/vmEnvironmentalInfoTestFiller.json +++ b/test/vmEnvironmentalInfoTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADDRESS)}", "storage": {} @@ -38,7 +38,7 @@ }, "pre" : { "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADDRESS)}", "storage": {} @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681 )}", "storage": {} @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681aa )}", "storage": {} @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}", "storage": {} @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -207,7 +207,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6) (BALANCE (ADDRESS)))}", "storage": {} @@ -236,7 +236,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681) (BALANCE (CALLER)))}", "storage": {} @@ -264,7 +264,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ORIGIN)}", "storage": {} @@ -292,7 +292,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLER)}", "storage": {} @@ -321,7 +321,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLVALUE)}", "storage": {} @@ -350,7 +350,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 0)}", "storage": {} @@ -378,7 +378,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 1)}", "storage": {} @@ -406,7 +406,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 5)}", "storage": {} @@ -434,7 +434,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa)}", "storage": {} @@ -462,7 +462,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -490,7 +490,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -518,7 +518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -546,7 +546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 2 ) [[ 0 ]] @0}", "storage": {} @@ -574,7 +574,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0 0 ) [[ 0 ]] @0}", "storage": {} @@ -602,7 +602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 0xff ) [[ 0 ]] @0}", "storage": {} @@ -630,7 +630,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 9 ) [[ 0 ]] @0}", "storage": {} @@ -658,7 +658,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 1 ) [[ 0 ]] @0}", "storage": {} @@ -686,7 +686,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 0 ) [[ 0 ]] @0}", "storage": {} @@ -882,7 +882,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CODESIZE)}", "storage": {} @@ -910,7 +910,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}", "storage": {} @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }", "storage": {} @@ -966,7 +966,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }", "storage": {} @@ -994,7 +994,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 0 ) [[ 0 ]] @0 }", "storage": {} @@ -1022,7 +1022,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GASPRICE) }", "storage": {} @@ -1050,7 +1050,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}", "storage": {} @@ -1078,7 +1078,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -1107,13 +1107,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (EXTCODESIZE (CALLER)) (CODESIZE) ) }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (EXTCODESIZE (CALLER)) (CODESIZE) ) }", "storage": {} @@ -1140,13 +1140,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CODESIZE) }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE (CALLER) ) }", "storage": {} @@ -1174,7 +1174,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (ADDRESS) 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}", "storage": {} @@ -1202,13 +1202,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (CALLER) 0 0 0 ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1237,13 +1237,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (CALLER) 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1271,13 +1271,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY 0xaacd1722f3947def4cf144679da39c4c32bdc35681 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1305,13 +1305,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY 0xcd1722f3947def4cf144679da39c4c32bdc35681aa 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} diff --git a/test/vmIOandFlowOperationsTestFiller.json b/test/vmIOandFlowOperationsTestFiller.json index f71109e17..995b9d6da 100644 --- a/test/vmIOandFlowOperationsTestFiller.json +++ b/test/vmIOandFlowOperationsTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600360045055", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5060026003600455", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600260035155", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600260035255", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 23) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{[[ 0 ]] (MLOAD 0) } ", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 1 23) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 1 ]] (MLOAD 7489573) } ", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 (+ 2 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23 ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -318,7 +318,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23 ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -331,7 +331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -346,7 +346,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -359,7 +359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -374,7 +374,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xff) (MSTORE8 2 0xee) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -387,7 +387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -402,7 +402,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 10 0xee) [[ 20 ]] (SLOAD 0) } ", "storage": {} @@ -415,7 +415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -430,7 +430,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 10 0xee) [[ 20 ]] (SLOAD 100) } ", "storage": {} @@ -443,7 +443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -458,7 +458,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 1 0xee) (SSTORE 2 0xdd) [[ 10 ]] (SLOAD 1) [[ 20 ]] (SLOAD 2) } ", "storage": {} @@ -471,7 +471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -486,7 +486,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6009565b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b", "storage": {} @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6006560060015b6002600355", "storage": {} @@ -527,7 +527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -542,7 +542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016008570060015b6002600355", "storage": {} @@ -555,7 +555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -570,7 +570,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60055661eeff", "storage": {} @@ -583,7 +583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -598,7 +598,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600456655b6001600155", "storage": {} @@ -611,7 +611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -626,7 +626,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160075761eeff", "storage": {} @@ -639,7 +639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -654,7 +654,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600657655b6001600155", "storage": {} @@ -667,7 +667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -682,7 +682,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600056", "storage": {} @@ -695,7 +695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -710,7 +710,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x565b600056", "storage": {} @@ -723,7 +723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600401565b600360005260206000f3600656", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007566001600255", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "jump0_jumpdest0": { @@ -878,7 +878,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360075660015b600255", "storage": {} @@ -891,7 +891,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -906,7 +906,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007566001600255", "storage": {} @@ -919,7 +919,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -934,7 +934,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360085660015b600255", "storage": {} @@ -947,7 +947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -962,7 +962,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a6008505660015b600255", "storage": {} @@ -975,7 +975,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -990,7 +990,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b6008505660015b600255", "storage": {} @@ -1003,7 +1003,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1018,7 +1018,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff0156", "storage": {} @@ -1031,7 +1031,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1046,7 +1046,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360016009576001600255", "storage": {} @@ -1059,7 +1059,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1074,7 +1074,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a5760015b600255", "storage": {} @@ -1087,7 +1087,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1102,7 +1102,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360006009576001600255", "storage": {} @@ -1115,7 +1115,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1130,7 +1130,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff576002600355", "storage": {} @@ -1143,7 +1143,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1158,7 +1158,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600101560060015b6002600355", "storage": {} @@ -1171,7 +1171,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1186,7 +1186,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016008600301570060015b6002600355", "storage": {} @@ -1199,7 +1199,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1214,7 +1214,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60056003015661eeff", "storage": {} @@ -1227,7 +1227,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1242,7 +1242,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460030156655b6001600155", "storage": {} @@ -1255,7 +1255,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1270,7 +1270,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160076003015761eeff", "storage": {} @@ -1283,7 +1283,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1298,7 +1298,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600660030157655b6001600155", "storage": {} @@ -1311,7 +1311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1326,7 +1326,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b586000555960115758600052596000575b58600055", "storage": {} @@ -1339,7 +1339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1354,7 +1354,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage": {} @@ -1367,7 +1367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1382,7 +1382,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600301566001600255", "storage": {} @@ -1395,7 +1395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "DynamicJump0_jumpdest0": { @@ -1409,7 +1409,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360076003015660015b600255", "storage": {} @@ -1422,7 +1422,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1437,7 +1437,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600301566001600255", "storage": {} @@ -1450,7 +1450,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1465,7 +1465,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360086003015660015b600255", "storage": {} @@ -1478,7 +1478,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1493,7 +1493,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a6008506003015660015b600255", "storage": {} @@ -1506,7 +1506,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1521,7 +1521,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b6008506003015660015b600255", "storage": {} @@ -1534,7 +1534,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1549,7 +1549,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff0160030156", "storage": {} @@ -1562,7 +1562,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1577,7 +1577,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360016009600301576001600255", "storage": {} @@ -1590,7 +1590,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1605,7 +1605,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a6003015760015b600255", "storage": {} @@ -1618,7 +1618,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1633,7 +1633,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360006009600301576001600255", "storage": {} @@ -1646,7 +1646,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1661,7 +1661,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0600301576002600355", "storage": {} @@ -1674,7 +1674,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1689,7 +1689,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160084301570060015b6002600355", "storage": {} @@ -1702,7 +1702,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1717,7 +1717,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600543015661eeff", "storage": {} @@ -1730,7 +1730,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1745,7 +1745,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6004430156655b6001600155", "storage": {} @@ -1758,7 +1758,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1773,7 +1773,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600743015761eeff", "storage": {} @@ -1786,7 +1786,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1801,7 +1801,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016006430157655b6001600155", "storage": {} @@ -1814,7 +1814,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1829,7 +1829,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage": {} @@ -1842,7 +1842,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1857,7 +1857,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360074301566001600255", "storage": {} @@ -1870,7 +1870,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "BlockNumberDynamicJump0_jumpdest0": { @@ -1884,7 +1884,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600743015660015b600255", "storage": {} @@ -1897,7 +1897,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1912,7 +1912,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360074301566001600255", "storage": {} @@ -1925,7 +1925,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1940,7 +1940,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600843015660015b600255", "storage": {} @@ -1953,7 +1953,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1968,7 +1968,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a60085043015660015b600255", "storage": {} @@ -1981,7 +1981,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1996,7 +1996,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b60085043015660015b600255", "storage": {} @@ -2009,7 +2009,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2024,7 +2024,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff01430156", "storage": {} @@ -2037,7 +2037,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2052,7 +2052,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600160094301576001600255", "storage": {} @@ -2065,7 +2065,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2080,7 +2080,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a43015760015b600255", "storage": {} @@ -2093,7 +2093,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2108,7 +2108,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600060094301576001600255", "storage": {} @@ -2121,7 +2121,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2136,7 +2136,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04301576002600355", "storage": {} @@ -2149,7 +2149,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2165,7 +2165,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PUSH1 3 JUMP", "code" : "0x6009436006575b566001", @@ -2179,7 +2179,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2194,7 +2194,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a436006575b5660015b6001600155", "storage": {} @@ -2207,7 +2207,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2222,7 +2222,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435660615b4343025660615b60615b5b5b6001600155", "storage": {} @@ -2235,7 +2235,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2250,7 +2250,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435660615b4343025660615b60615b605b6001600155", "storage": {} @@ -2263,7 +2263,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2278,7 +2278,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2291,7 +2291,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2306,7 +2306,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2319,7 +2319,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2334,7 +2334,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2347,7 +2347,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2362,7 +2362,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600860005401570060015b6002600355", "storage" : { @@ -2377,7 +2377,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2392,7 +2392,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600054015661eeff", "storage" : { @@ -2407,7 +2407,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2422,7 +2422,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60046000540156655b6001600155", "storage" : { @@ -2437,7 +2437,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2452,7 +2452,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016007600054015761eeff", "storage" : { @@ -2467,7 +2467,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2482,7 +2482,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160066000540157655b6001600155", "storage" : { @@ -2497,7 +2497,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2512,7 +2512,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage" : { @@ -2527,7 +2527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2542,7 +2542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600760005401566001600255", "storage" : { @@ -2558,7 +2558,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "JDfromStorageDynamicJump0_jumpdest0": { @@ -2572,7 +2572,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600054015660015b600255", "storage" : { @@ -2587,7 +2587,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2602,7 +2602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600760005401566001600255", "storage" : { @@ -2618,7 +2618,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2633,7 +2633,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236008600054015660015b600255", "storage" : { @@ -2648,7 +2648,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2663,7 +2663,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a600850600054015660015b600255", "storage" : { @@ -2679,7 +2679,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2694,7 +2694,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b600850600054015660015b600255", "storage" : { @@ -2709,7 +2709,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2724,7 +2724,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff016000540156", "storage" : { @@ -2740,7 +2740,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2755,7 +2755,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600960005401576001600255", "storage" : { @@ -2770,7 +2770,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2785,7 +2785,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a600054015760015b600255", "storage" : { @@ -2801,7 +2801,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2816,7 +2816,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236000600960005401576001600255", "storage" : { @@ -2831,7 +2831,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2846,7 +2846,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff060005401576002600355", "storage" : { @@ -2861,7 +2861,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2877,7 +2877,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (PC)}", "storage": {} @@ -2890,7 +2890,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2905,7 +2905,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(SSTORE 0 0xff) [[ 0 ]] (PC)}", "storage": {} @@ -2918,7 +2918,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2933,7 +2933,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xff) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2946,7 +2946,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2961,7 +2961,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2974,7 +2974,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2989,7 +2989,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 32 0xeeee) [[ 0 ]] (MSIZE)}", "storage": {} @@ -3002,7 +3002,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3017,7 +3017,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 90 0xeeee) [[ 0 ]] (MSIZE)}", "storage": {} @@ -3030,7 +3030,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3045,7 +3045,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 90 0xeeee) [[ 0 ]] (GAS)}", "storage": {} @@ -3058,7 +3058,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3073,7 +3073,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{[[ 0 ]] (GAS)}", "storage": {} @@ -3086,7 +3086,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3101,7 +3101,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0x112233445566778899001122334455667788990011223344556677889900aabb 0 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 1 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 2 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 3 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 4 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 5 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 6 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 7 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 8 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 9 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 10 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 11 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 12 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 13 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 14 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 15 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 16 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 17 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 18 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 19 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 20 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 21 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 22 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 23 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 24 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 25 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 26 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 27 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 28 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 29 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 30 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 31 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 32 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 2014 BYTE 0 0 SSTORE)", "storage": {} @@ -3114,7 +3114,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3129,7 +3129,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 2 0 MSTORE8 3 1 MSTORE8 0 MLOAD 1 MLOAD ADD 2 MSTORE 64 0 RETURN)", "storage": {} @@ -3142,7 +3142,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3157,7 +3157,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 1000000 RETURN)", "storage": {} @@ -3170,7 +3170,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3185,7 +3185,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [i] 1 ( if (> @i 0) { (return 39) [i] 2 } (return 1) ) }", "storage": {} @@ -3198,7 +3198,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3213,7 +3213,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0x4 0x6 0x9 0x14 JUMP JUMPDEST 0xa SUB 0x0 MSTORE MSIZE 0x0 RETURN JUMPDEST 0x0 MSTORE ADD 0x9 JUMP)", "storage": {} @@ -3226,7 +3226,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3241,7 +3241,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[69]] (caller) (return 0 (lll (when (= (caller) @@69) (for {} (< @i (calldatasize)) [i](+ @i 64) [[ (calldataload @i) ]] (calldataload (+ @i 32)) ) ) 0))}", "storage": {} @@ -3254,7 +3254,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3279,7 +3279,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "code" : "(asm 10 0 MSTORE JUMPDEST 0 MLOAD 1 SWAP1 SUB DUP1 0 MSTORE 5 JUMPI)", "nonce" : "0", "storage" : {} @@ -3298,7 +3298,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 27 37 MUL JUMP JUMPDEST)", "storage": {} @@ -3311,7 +3311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3326,7 +3326,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 3 3 MUL JUMPI 0 0 JUMP)", "storage": {} @@ -3339,7 +3339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3354,7 +3354,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(for [i]:10 (> @i 0) [i](- @i 1) [j](+ @i @j))", "storage": {} @@ -3367,7 +3367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3382,7 +3382,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(for [i]:0 (< @i 10) [i](+ @i 1) [j](+ @i @j))", "storage": {} @@ -3395,7 +3395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3410,7 +3410,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 4 3 ADD JUMP STOP JUMPDEST 1 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3423,7 +3423,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3438,7 +3438,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 8 6 ADD JUMP STOP JUMPDEST 1 0 MSTORE STOP JUMPDEST 2 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3451,7 +3451,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3466,7 +3466,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 4 5 ADD JUMPI STOP JUMPDEST 1 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3479,7 +3479,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3494,7 +3494,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0 7 5 ADD JUMPI 1 0 MSTORE STOP JUMPDEST)", "storage": {} @@ -3507,7 +3507,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3522,7 +3522,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 10 JUMPDEST 1 DUP2 SUB DUP1 2 JUMPI 0 MSTORE8 1 MSTORE8 2 MSTORE8 3 MSTORE8 4 MSTORE8 5 MSTORE8 6 MSTORE8 7 MSTORE8 8 MSTORE8 9 MSTORE8 MSIZE 0 RETURN)", "storage": {} @@ -3535,7 +3535,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3550,7 +3550,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(when (> 1 0) [i] 13)", "storage": {} @@ -3563,7 +3563,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmLogTestFiller.json b/test/vmLogTestFiller.json index 5b63957c5..fea69a4a9 100644 --- a/test/vmLogTestFiller.json +++ b/test/vmLogTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG0 0 0) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) (LOG0 2 16) }", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 0 1) }", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -123,7 +123,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 31 1) }", "storage": {} @@ -136,7 +136,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -151,7 +151,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1) }", "storage": {} @@ -164,7 +164,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -207,7 +207,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 1 0) }", "storage": {} @@ -220,7 +220,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -235,7 +235,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG1 0 0 0) }", "storage": {} @@ -248,7 +248,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -263,7 +263,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG1 0 32 0) }", "storage": {} @@ -276,7 +276,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -291,7 +291,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0 1 0) }", "storage": {} @@ -304,7 +304,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -320,7 +320,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 31 1 0) }", "storage": {} @@ -333,7 +333,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -348,7 +348,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0) }", "storage": {} @@ -361,7 +361,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -376,7 +376,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0) }", "storage": {} @@ -389,7 +389,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -404,7 +404,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 1 0 0) }", "storage": {} @@ -417,7 +417,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -432,7 +432,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -445,7 +445,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -460,7 +460,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG1 0 32 (CALLER)) }", "storage": {} @@ -473,7 +473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -488,7 +488,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG2 0 0 0 0) }", "storage": {} @@ -501,7 +501,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -516,7 +516,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG2 0 32 0 0) }", "storage": {} @@ -529,7 +529,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -544,7 +544,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0 1 0 0) }", "storage": {} @@ -557,7 +557,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -573,7 +573,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 31 1 0 0) }", "storage": {} @@ -586,7 +586,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -601,7 +601,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0) }", "storage": {} @@ -614,7 +614,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -629,7 +629,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0) }", "storage": {} @@ -642,7 +642,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -657,7 +657,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 1 0 0 0) }", "storage": {} @@ -670,7 +670,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -685,7 +685,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -698,7 +698,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -713,7 +713,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG2 0 32 0 (CALLER) ) }", "storage": {} @@ -726,7 +726,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -741,7 +741,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG3 0 0 0 0 0) }", "storage": {} @@ -754,7 +754,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -769,7 +769,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG3 0 32 0 0 0) }", "storage": {} @@ -782,7 +782,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -797,7 +797,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0 1 0 0 0) }", "storage": {} @@ -810,7 +810,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -826,7 +826,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 31 1 0 0 0) }", "storage": {} @@ -839,7 +839,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -854,7 +854,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0 0) }", "storage": {} @@ -867,7 +867,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -882,7 +882,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0 0) }", "storage": {} @@ -895,7 +895,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -910,7 +910,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 1 0 0 0 0) }", "storage": {} @@ -923,7 +923,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -951,7 +951,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -966,7 +966,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 0 0 (CALLER) ) }", "storage": {} @@ -979,7 +979,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -994,7 +994,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 (PC) (PC) (PC) ) }", "storage": {} @@ -1007,7 +1007,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1022,7 +1022,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG4 0 0 0 0 0 0) }", "storage": {} @@ -1035,7 +1035,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1050,7 +1050,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG4 0 32 0 0 0 0) }", "storage": {} @@ -1063,7 +1063,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1078,7 +1078,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0 1 0 0 0 0) }", "storage": {} @@ -1091,7 +1091,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1107,7 +1107,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 31 1 0 0 0 0) }", "storage": {} @@ -1120,7 +1120,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1135,7 +1135,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0 0 0) }", "storage": {} @@ -1148,7 +1148,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1163,7 +1163,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0 0 0) }", "storage": {} @@ -1176,7 +1176,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1191,7 +1191,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 1 0 0 0 0 0) }", "storage": {} @@ -1204,7 +1204,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1219,7 +1219,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -1232,7 +1232,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1247,7 +1247,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 0 0 0 (CALLER) ) }", "storage": {} @@ -1260,7 +1260,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1275,7 +1275,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 (PC) (PC) (PC) (PC) ) }", "storage": {} @@ -1288,7 +1288,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmPerformanceTestFiller.json b/test/vmPerformanceTestFiller.json index e33bd1955..e9cb4806d 100644 --- a/test/vmPerformanceTestFiller.json +++ b/test/vmPerformanceTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "ManyFunctions.sol", "code" : "0x60e060020a60003504806301f99ad7146108c3578063023a624a146108d857806303bdecf5146108ed57806305fe035f14610902578063082d8f4914610917578063090bf3b71461092c5780630bd9c534146109415780630c4bfa94146109565780630e20ebe21461096b5780630f76de0d1461098057806310cfcc191461099557806313ce15a9146109aa578063140dcec4146109bf57806314d07a3e146109d45780631687f112146109e957806316eb6603146109fe578063172cf71714610a135780631bd6f59614610a285780631cdb857114610a3d5780631cf74ece14610a525780631d09ba2c14610a675780631f69aa5114610a7c578063223dcc7414610a9157806325e524d314610aa6578063261de7c414610abb5780632632924d14610ad05780632909cc5d14610ae55780632981699814610afa5780632a85a45d14610b0f5780632ca36da014610b245780632cbf1f0d14610b395780632d0f557314610b4e5780632d97867814610b6357806331db9efd14610b7857806332064db714610b8d57806332931fbb14610ba2578063355f51a014610bb7578063361bb34014610bcc578063364ddb0e14610be15780633792a01814610bf657806338c68f8f14610c0b57806338e586fd14610c20578063392d42ae14610c3557806339a87bd914610c4a5780633a95a33214610c5f5780633b8ecdf914610c745780633cf0659a14610c895780633eaf992314610c9e5780633fe97ead14610cb35780633ff11c8b14610cc8578063404efc5314610cdd578063407fce7b14610cf257806340c3b18714610d07578063440208c314610d1c57806344e86b2f14610d31578063455df57914610d465780634689ab4d14610d5b57806346be2e0c14610d70578063487cd86f14610d8557806348e6178214610d9a57806349d4a34414610daf5780634a0f597414610dc45780634bc24ec514610dd95780634c2fe45614610dee5780634cc885d414610e035780634eaaad7b14610e185780634eb166af14610e2d5780635050093414610e42578063506bff1114610e57578063508762c114610e6c578063526938f814610e8157806354400c6014610e96578063559510d814610eab57806355a5f70214610ec057806356ca528f14610ed5578063570a2a1614610eea5780635dab2e0f14610eff5780635dca53d314610f1457806362017ebc14610f29578063621a25f814610f3e578063626d4a3614610f5357806362b6a28214610f6857806364faf22c14610f7d57806366d7ffde14610f9257806367b886e814610fa757806367e902c714610fbc57806369d7774014610fd15780636b7ae8e614610fe65780636c3b659114610ffb5780636e54181e146110105780636e978d91146110255780636f63d2ec1461103a578063706332d11461104f57806370ac4bb9146110645780637138ef521461107957806371dd46a91461108e57806372a7c229146110a35780637376fc8d146110b8578063738a2679146110cd57806374552650146110e2578063746fc8d0146110f757806379254bb81461110c5780637adaa3f8146111215780637e4eb35b14611136578063885ec18e1461114b5780638b9ff6b6146111605780638ce113dc146111755780638defbc5e1461118a5780638f4613d51461119f5780638fdc24ba146111b45780639002dba4146111c957806391d15735146111de57806391d43b23146111f357806393b14daa1461120857806394d63afd1461121d57806395805dad1461123257806396f68782146112475780639740e4a21461125c578063981290131461127157806399a3f0e8146112865780639acb1ad41461129b5780639be07908146112b05780639c15be0b146112c55780639d451c4d146112da5780639d8ee943146112ef5780639ef6ca0f14611304578063a0db0a2214611319578063a18e2eb91461132e578063a408384914611343578063a57544da14611358578063a5a83e4d1461136d578063a6843f3414611382578063a6dacdd714611397578063a8c4c8bc146113ac578063aa058a73146113c1578063aad62da2146113d6578063aaf3e4f4146113eb578063ab81e77314611400578063abc93aee14611415578063abde33f71461142a578063b114b96c1461143f578063b3df873714611454578063b4174cb014611469578063b5d02a561461147e578063b731e84814611493578063b7b96723146114a8578063bbcded7a146114bd578063bbececa9146114d2578063beca7440146114e7578063bf8981c0146114fc578063c028c67414611511578063c2385fa614611526578063c319a02c1461153b578063c569bae014611550578063c6715f8114611565578063c7b98dec1461157a578063c9acab841461158f578063ca9efc73146115a4578063cad80024146115b9578063cdadb0fa146115ce578063cdbdf391146115e3578063cf460fa5146115f8578063cf69318a1461160d578063d1835b8c14611622578063d353a1cb14611637578063d3e141e01461164c578063d5ec7e1d14611661578063d7ead1de14611676578063d90b02aa1461168b578063d959e244146116a0578063d9e68b44146116b5578063daacb24f146116ca578063dc12a805146116df578063dd946033146116f4578063dda5142414611709578063de6612171461171e578063dfb9560c14611733578063e03827d214611748578063e21720001461175d578063e2c718d814611772578063e3da539914611787578063e48e603f1461179c578063e5f9ec29146117b1578063e6c0459a146117c6578063e70addec146117db578063e7a01215146117f0578063ea7f4d2714611805578063ebb6c59f1461181a578063ed6302be1461182f578063ed64b36b14611844578063eecd278914611859578063f0ed14e01461186e578063f0f2134414611883578063f1e328f914611898578063f1e6f4cd146118ad578063f32fe995146118c2578063f75165c6146118d7578063f7ed71d0146118ec578063f80f44f314611901578063f8bc050514611916578063fbd3c51a1461192b578063fd72009014611940578063fed3a3001461195557005b6108ce600435612edf565b8060005260206000f35b6108e3600435612fb5565b8060005260206000f35b6108f8600435613f47565b8060005260206000f35b61090d600435612a11565b8060005260206000f35b6109226004356127ec565b8060005260206000f35b61093760043561215c565b8060005260206000f35b61094c6004356128c2565b8060005260206000f35b61096160043561310f565b8060005260206000f35b610976600435614e0b565b8060005260206000f35b61098b600435613269565b8060005260206000f35b6109a0600435611a82565b8060005260206000f35b6109b5600435613e71565b8060005260206000f35b6109ca600435611dd2565b8060005260206000f35b6109df6004356120d0565b8060005260206000f35b6109f4600435613755565b8060005260206000f35b610a096004356134e3565b8060005260206000f35b610a1e6004356137e1565b8060005260206000f35b610a3360043561382b565b8060005260206000f35b610a48600435612b0b565b8060005260206000f35b610a5d60043561386d565b8060005260206000f35b610a726004356131e5565b8060005260206000f35b610a876004356143e9565b8060005260206000f35b610a9c60043561319b565b8060005260206000f35b610ab1600435612e11565b8060005260206000f35b610ac660043561234a565b8060005260206000f35b610adb6004356121e8565b8060005260206000f35b610af06004356119f6565b8060005260206000f35b610b05600435613bff565b8060005260206000f35b610b1a600435612606565b8060005260206000f35b610b2f6004356126d4565b8060005260206000f35b610b44600435613bb5565b8060005260206000f35b610b59600435612462565b8060005260206000f35b610b6e600435611e14565b8060005260206000f35b610b836004356149ab565b8060005260206000f35b610b98600435611c26565b8060005260206000f35b610bad600435612a7f565b8060005260206000f35b610bc2600435613457565b8060005260206000f35b610bd760043561340d565b8060005260206000f35b610bec60043561363d565b8060005260206000f35b610c01600435612e53565b8060005260206000f35b610c1660043561477b565b8060005260206000f35b610c2b600435612c6d565b8060005260206000f35b610c40600435612648565b8060005260206000f35b610c55600435612274565b8060005260206000f35b610c6a6004356138f9565b8060005260206000f35b610c7f600435612b55565b8060005260206000f35b610c94600435611eea565b8060005260206000f35b610ca9600435613ebb565b8060005260206000f35b610cbe600435613499565b8060005260206000f35b610cd3600435614807565b8060005260206000f35b610ce8600435611fb8565b8060005260206000f35b610cfd600435613083565b8060005260206000f35b610d126004356125bc565b8060005260206000f35b610d27600435613041565b8060005260206000f35b610d3c6004356140a1565b8060005260206000f35b610d516004356147bd565b8060005260206000f35b610d66600435611c70565b8060005260206000f35b610d7b600435612300565b8060005260206000f35b610d906004356123d6565b8060005260206000f35b610da5600435612c23565b8060005260206000f35b610dba600435614faf565b8060005260206000f35b610dcf600435612044565b8060005260206000f35b610de4600435613ae7565b8060005260206000f35b610df9600435614cf3565b8060005260206000f35b610e0e600435613d17565b8060005260206000f35b610e2360043561412d565b8060005260206000f35b610e38600435614177565b8060005260206000f35b610e4d60043561208e565b8060005260206000f35b610e62600435612dc7565b8060005260206000f35b610e77600435612f29565b8060005260206000f35b610e8c6004356124a4565b8060005260206000f35b610ea1600435611b58565b8060005260206000f35b610eb66004356136c9565b8060005260206000f35b610ecb600435613227565b8060005260206000f35b610ee0600435611acc565b8060005260206000f35b610ef5600435613687565b8060005260206000f35b610f0a6004356146a5565b8060005260206000f35b610f1f6004356121a6565b8060005260206000f35b610f346004356132f5565b8060005260206000f35b610f49600435613da3565b8060005260206000f35b610f5e60043561379f565b8060005260206000f35b610f73600435612878565b8060005260206000f35b610f88600435611b0e565b8060005260206000f35b610f9d600435611ea0565b8060005260206000f35b610fb2600435614ed9565b8060005260206000f35b610fc7600435614bdb565b8060005260206000f35b610fdc600435614c1d565b8060005260206000f35b610ff1600435614245565b8060005260206000f35b6110066004356146ef565b8060005260206000f35b61101b60043561428f565b8060005260206000f35b611030600435614ac3565b8060005260206000f35b611045600435613de5565b8060005260206000f35b61105a6004356132b3565b8060005260206000f35b61106f6004356122be565b8060005260206000f35b611084600435612e9d565b8060005260206000f35b611099600435611b9a565b8060005260206000f35b6110ae6004356127aa565b8060005260206000f35b6110c3600435613e2f565b8060005260206000f35b6110d8600435614849565b8060005260206000f35b6110ed600435614dc1565b8060005260206000f35b61110260043561333f565b8060005260206000f35b61111760043561211a565b8060005260206000f35b61112c600435612692565b8060005260206000f35b611141600435612904565b8060005260206000f35b611156600435612d3b565b8060005260206000f35b61116b600435614b91565b8060005260206000f35b611180600435613a5b565b8060005260206000f35b611195600435612232565b8060005260206000f35b6111aa600435612f6b565b8060005260206000f35b6111bf600435614d35565b8060005260206000f35b6111d4600435611a40565b8060005260206000f35b6111e9600435612ff7565b8060005260206000f35b6111fe60043561431b565b8060005260206000f35b611213600435613159565b8060005260206000f35b611228600435612b97565b8060005260206000f35b61123d600435612990565b8060005260206000f35b611252600435613b73565b8060005260206000f35b611267600435614961565b8060005260206000f35b61127c600435613381565b8060005260206000f35b611291600435613fd3565b8060005260206000f35b6112a660043561257a565b8060005260206000f35b6112bb600435614501565b8060005260206000f35b6112d0600435613d59565b8060005260206000f35b6112e56004356143a7565b8060005260206000f35b6112fa60043561405f565b8060005260206000f35b61130f60043561238c565b8060005260206000f35b611324600435612be1565b8060005260206000f35b611339600435613f89565b8060005260206000f35b61134e60043561294e565b8060005260206000f35b6113636004356124ee565b8060005260206000f35b611378600435614b4f565b8060005260206000f35b61138d6004356133cb565b8060005260206000f35b6113a26004356139cf565b8060005260206000f35b6113b7600435613c8b565b8060005260206000f35b6113cc600435612cf9565b8060005260206000f35b6113e1600435614a79565b8060005260206000f35b6113f66004356149ed565b8060005260206000f35b61140b600435613b29565b8060005260206000f35b611420600435613ccd565b8060005260206000f35b611435600435611f76565b8060005260206000f35b61144a600435614ff1565b8060005260206000f35b61145f600435613525565b8060005260206000f35b61147460043561356f565b8060005260206000f35b6114896004356129dc565b8060005260206000f35b61149e600435614ca9565b8060005260206000f35b6114b3600435612d85565b8060005260206000f35b6114c86004356141b9565b8060005260206000f35b6114dd600435614475565b8060005260206000f35b6114f26004356135fb565b8060005260206000f35b611507600435612530565b8060005260206000f35b61151c600435614663565b8060005260206000f35b611531600435614433565b8060005260206000f35b611546600435614f23565b8060005260206000f35b61155b600435614c67565b8060005260206000f35b611570600435611d3e565b8060005260206000f35b611585600435612a3d565b8060005260206000f35b61159a600435613a11565b8060005260206000f35b6115af600435614619565b8060005260206000f35b6115c4600435613985565b8060005260206000f35b6115d9600435613943565b8060005260206000f35b6115ee600435612418565b8060005260206000f35b6116036004356119b4565b8060005260206000f35b611618600435613a9d565b8060005260206000f35b61162d600435611cb2565b8060005260206000f35b6116426004356129d2565b8060005260206000f35b611657600435612caf565b8060005260206000f35b61166c600435611d88565b8060005260206000f35b611681600435614203565b8060005260206000f35b61169660043561458d565b8060005260206000f35b6116ab600435611f2c565b8060005260206000f35b6116c0600435612a23565b8060005260206000f35b6116d5600435612836565b8060005260206000f35b6116ea6004356138b7565b8060005260206000f35b6116ff6004356145d7565b8060005260206000f35b61171460043561454b565b8060005260206000f35b6117296004356142d1565b8060005260206000f35b61173e600435611e5e565b8060005260206000f35b611753600435614015565b8060005260206000f35b611768600435613c41565b8060005260206000f35b61177d600435611be4565b8060005260206000f35b611792600435614b05565b8060005260206000f35b6117a7600435613713565b8060005260206000f35b6117bc6004356135b1565b8060005260206000f35b6117d16004356144bf565b8060005260206000f35b6117e660043561491f565b8060005260206000f35b6117fb600435612ac9565b8060005260206000f35b6118106004356130cd565b8060005260206000f35b6118256004356140eb565b8060005260206000f35b61183a600435614f65565b8060005260206000f35b61184f60043561196a565b8060005260206000f35b6118646004356148d5565b8060005260206000f35b611879600435614d7f565b8060005260206000f35b61188e600435612002565b8060005260206000f35b6118a3600435613efd565b8060005260206000f35b6118b860043561271e565b8060005260206000f35b6118cd600435614e4d565b8060005260206000f35b6118e2600435611cfc565b8060005260206000f35b6118f7600435612760565b8060005260206000f35b61190c600435614e97565b8060005260206000f35b61192160043561435d565b8060005260206000f35b611936600435614731565b8060005260206000f35b61194b600435614893565b8060005260206000f35b611960600435614a37565b8060005260206000f35b6000600061197f61197a846129dc565b6129dc565b9050605d60020a811015611992576119a2565b61199b816119f6565b91506119ae565b6119ab816119b4565b91505b50919050565b600060006119c1836129dc565b9050605e60020a8110156119d4576119e4565b6119dd81611a40565b91506119f0565b6119ed81611a82565b91505b50919050565b60006000611a0b611a06846129dc565b6129dc565b9050605e60020a811015611a1e57611a2e565b611a2781611a82565b9150611a3a565b611a3781611a40565b91505b50919050565b60006000611a4d836129dc565b9050605f60020a811015611a6057611a70565b611a6981611acc565b9150611a7c565b611a7981611b0e565b91505b50919050565b60006000611a97611a92846129dc565b6129dc565b9050605f60020a811015611aaa57611aba565b611ab381611b0e565b9150611ac6565b611ac381611acc565b91505b50919050565b60006000611ad9836129dc565b9050606060020a811015611aec57611afc565b611af581611b58565b9150611b08565b611b0581611b9a565b91505b50919050565b60006000611b23611b1e846129dc565b6129dc565b9050606060020a811015611b3657611b46565b611b3f81611b9a565b9150611b52565b611b4f81611b58565b91505b50919050565b60006000611b65836129dc565b9050606160020a811015611b7857611b88565b611b8181611be4565b9150611b94565b611b9181611c26565b91505b50919050565b60006000611baf611baa846129dc565b6129dc565b9050606160020a811015611bc257611bd2565b611bcb81611c26565b9150611bde565b611bdb81611be4565b91505b50919050565b60006000611bf1836129dc565b9050606260020a811015611c0457611c14565b611c0d81611c70565b9150611c20565b611c1d81611cb2565b91505b50919050565b60006000611c3b611c36846129dc565b6129dc565b9050606260020a811015611c4e57611c5e565b611c5781611cb2565b9150611c6a565b611c6781611c70565b91505b50919050565b60006000611c7d836129dc565b9050606360020a811015611c9057611ca0565b611c9981611cfc565b9150611cac565b611ca981611d88565b91505b50919050565b60006000611cc7611cc2846129dc565b6129dc565b9050606360020a811015611cda57611cea565b611ce381611d88565b9150611cf6565b611cf381611cfc565b91505b50919050565b60006000611d09836129dc565b9050606460020a811015611d1c57611d2c565b611d2581611dd2565b9150611d38565b611d3581611e14565b91505b50919050565b60006000611d53611d4e846129dc565b6129dc565b9050607a60020a811015611d6657611d76565b611d6f81613269565b9150611d82565b611d7f81613227565b91505b50919050565b60006000611d9d611d98846129dc565b6129dc565b9050606460020a811015611db057611dc0565b611db981611e14565b9150611dcc565b611dc981611dd2565b91505b50919050565b60006000611ddf836129dc565b9050606560020a811015611df257611e02565b611dfb81611e5e565b9150611e0e565b611e0b81611ea0565b91505b50919050565b60006000611e29611e24846129dc565b6129dc565b9050606560020a811015611e3c57611e4c565b611e4581611ea0565b9150611e58565b611e5581611e5e565b91505b50919050565b60006000611e6b836129dc565b9050606660020a811015611e7e57611e8e565b611e8781611eea565b9150611e9a565b611e9781611f2c565b91505b50919050565b60006000611eb5611eb0846129dc565b6129dc565b9050606660020a811015611ec857611ed8565b611ed181611f2c565b9150611ee4565b611ee181611eea565b91505b50919050565b60006000611ef7836129dc565b9050606760020a811015611f0a57611f1a565b611f1381611f76565b9150611f26565b611f2381611fb8565b91505b50919050565b60006000611f41611f3c846129dc565b6129dc565b9050606760020a811015611f5457611f64565b611f5d81611fb8565b9150611f70565b611f6d81611f76565b91505b50919050565b60006000611f83836129dc565b9050606860020a811015611f9657611fa6565b611f9f81612002565b9150611fb2565b611faf81612044565b91505b50919050565b60006000611fcd611fc8846129dc565b6129dc565b9050606860020a811015611fe057611ff0565b611fe981612044565b9150611ffc565b611ff981612002565b91505b50919050565b6000600061200f836129dc565b9050606960020a81101561202257612032565b61202b8161208e565b915061203e565b61203b816120d0565b91505b50919050565b60006000612059612054846129dc565b6129dc565b9050606960020a81101561206c5761207c565b612075816120d0565b9150612088565b6120858161208e565b91505b50919050565b6000600061209b836129dc565b9050606a60020a8110156120ae576120be565b6120b78161211a565b91506120ca565b6120c78161215c565b91505b50919050565b600060006120e56120e0846129dc565b6129dc565b9050606a60020a8110156120f857612108565b6121018161215c565b9150612114565b6121118161211a565b91505b50919050565b60006000612127836129dc565b9050606b60020a81101561213a5761214a565b612143816121a6565b9150612156565b612153816121e8565b91505b50919050565b6000600061217161216c846129dc565b6129dc565b9050606b60020a81101561218457612194565b61218d816121e8565b91506121a0565b61219d816121a6565b91505b50919050565b600060006121b3836129dc565b9050606c60020a8110156121c6576121d6565b6121cf81612232565b91506121e2565b6121df81612274565b91505b50919050565b600060006121fd6121f8846129dc565b6129dc565b9050606c60020a81101561221057612220565b61221981612274565b915061222c565b61222981612232565b91505b50919050565b6000600061223f836129dc565b9050606d60020a81101561225257612262565b61225b816122be565b915061226e565b61226b81612300565b91505b50919050565b60006000612289612284846129dc565b6129dc565b9050606d60020a81101561229c576122ac565b6122a581612300565b91506122b8565b6122b5816122be565b91505b50919050565b600060006122cb836129dc565b9050606e60020a8110156122de576122ee565b6122e78161234a565b91506122fa565b6122f78161238c565b91505b50919050565b60006000612315612310846129dc565b6129dc565b9050606e60020a81101561232857612338565b6123318161238c565b9150612344565b6123418161234a565b91505b50919050565b60006000612357836129dc565b9050606f60020a81101561236a5761237a565b612373816123d6565b9150612386565b61238381612418565b91505b50919050565b600060006123a161239c846129dc565b6129dc565b9050606f60020a8110156123b4576123c4565b6123bd81612418565b91506123d0565b6123cd816123d6565b91505b50919050565b600060006123e3836129dc565b9050607060020a8110156123f657612406565b6123ff81612462565b9150612412565b61240f816124a4565b91505b50919050565b6000600061242d612428846129dc565b6129dc565b9050607060020a81101561244057612450565b612449816124a4565b915061245c565b61245981612462565b91505b50919050565b6000600061246f836129dc565b9050607160020a81101561248257612492565b61248b816124ee565b915061249e565b61249b81612530565b91505b50919050565b600060006124b96124b4846129dc565b6129dc565b9050607160020a8110156124cc576124dc565b6124d581612530565b91506124e8565b6124e5816124ee565b91505b50919050565b600060006124fb836129dc565b9050607260020a81101561250e5761251e565b6125178161257a565b915061252a565b612527816125bc565b91505b50919050565b60006000612545612540846129dc565b6129dc565b9050607260020a81101561255857612568565b612561816125bc565b9150612574565b6125718161257a565b91505b50919050565b60006000612587836129dc565b9050607360020a81101561259a576125aa565b6125a381612606565b91506125b6565b6125b381612648565b91505b50919050565b600060006125d16125cc846129dc565b6129dc565b9050607360020a8110156125e4576125f4565b6125ed81612648565b9150612600565b6125fd81612606565b91505b50919050565b60006000612613836129dc565b9050607460020a81101561262657612636565b61262f81612692565b9150612642565b61263f816126d4565b91505b50919050565b6000600061265d612658846129dc565b6129dc565b9050607460020a81101561267057612680565b612679816126d4565b915061268c565b61268981612692565b91505b50919050565b6000600061269f836129dc565b9050607560020a8110156126b2576126c2565b6126bb8161271e565b91506126ce565b6126cb81612760565b91505b50919050565b600060006126e96126e4846129dc565b6129dc565b9050607560020a8110156126fc5761270c565b61270581612760565b9150612718565b6127158161271e565b91505b50919050565b6000600061272b836129dc565b9050607660020a81101561273e5761274e565b612747816127aa565b915061275a565b612757816127ec565b91505b50919050565b60006000612775612770846129dc565b6129dc565b9050607660020a81101561278857612798565b612791816127ec565b91506127a4565b6127a1816127aa565b91505b50919050565b600060006127b7836129dc565b9050607760020a8110156127ca576127da565b6127d381612836565b91506127e6565b6127e381612878565b91505b50919050565b600060006128016127fc846129dc565b6129dc565b9050607760020a81101561281457612824565b61281d81612878565b9150612830565b61282d81612836565b91505b50919050565b60006000612843836129dc565b9050607860020a81101561285657612866565b61285f816128c2565b9150612872565b61286f81612904565b91505b50919050565b6000600061288d612888846129dc565b6129dc565b9050607860020a8110156128a0576128b0565b6128a981612904565b91506128bc565b6128b9816128c2565b91505b50919050565b600060006128cf836129dc565b9050607960020a8110156128e2576128f2565b6128eb8161294e565b91506128fe565b6128fb81611d3e565b91505b50919050565b60006000612919612914846129dc565b6129dc565b9050607960020a81101561292c5761293c565b61293581611d3e565b9150612948565b6129458161294e565b91505b50919050565b6000600061295b836129dc565b9050607a60020a81101561296e5761297e565b61297781613227565b915061298a565b61298781613269565b91505b50919050565b6000600061299d836129dc565b9050604e60020a8110156129b0576129c0565b6129b981612a7f565b91506129cc565b6129c981612a3d565b91505b50919050565b6000819050919050565b600060007f5851f42d4c957f2c0000000000000000000000000000000000000000000000019050828102600101915050919050565b6000612a1c826129d2565b9050919050565b6000612a36612a31836129dc565b6129d2565b9050919050565b60006000612a4a836129dc565b9050604f60020a811015612a5d57612a6d565b612a6681612ac9565b9150612a79565b612a7681612b0b565b91505b50919050565b60006000612a94612a8f846129dc565b6129dc565b9050604f60020a811015612aa757612ab7565b612ab081612b0b565b9150612ac3565b612ac081612ac9565b91505b50919050565b60006000612ad6836129dc565b9050605060020a811015612ae957612af9565b612af281612b55565b9150612b05565b612b0281612b97565b91505b50919050565b60006000612b20612b1b846129dc565b6129dc565b9050605060020a811015612b3357612b43565b612b3c81612b97565b9150612b4f565b612b4c81612b55565b91505b50919050565b60006000612b62836129dc565b9050605160020a811015612b7557612b85565b612b7e81612be1565b9150612b91565b612b8e81612c23565b91505b50919050565b60006000612bac612ba7846129dc565b6129dc565b9050605160020a811015612bbf57612bcf565b612bc881612c23565b9150612bdb565b612bd881612be1565b91505b50919050565b60006000612bee836129dc565b9050605260020a811015612c0157612c11565b612c0a81612c6d565b9150612c1d565b612c1a81612caf565b91505b50919050565b60006000612c38612c33846129dc565b6129dc565b9050605260020a811015612c4b57612c5b565b612c5481612caf565b9150612c67565b612c6481612c6d565b91505b50919050565b60006000612c7a836129dc565b9050605360020a811015612c8d57612c9d565b612c9681612cf9565b9150612ca9565b612ca681612d3b565b91505b50919050565b60006000612cc4612cbf846129dc565b6129dc565b9050605360020a811015612cd757612ce7565b612ce081612d3b565b9150612cf3565b612cf081612cf9565b91505b50919050565b60006000612d06836129dc565b9050605460020a811015612d1957612d29565b612d2281612d85565b9150612d35565b612d3281612dc7565b91505b50919050565b60006000612d50612d4b846129dc565b6129dc565b9050605460020a811015612d6357612d73565b612d6c81612dc7565b9150612d7f565b612d7c81612d85565b91505b50919050565b60006000612d92836129dc565b9050605560020a811015612da557612db5565b612dae81612e11565b9150612dc1565b612dbe81612e53565b91505b50919050565b60006000612ddc612dd7846129dc565b6129dc565b9050605560020a811015612def57612dff565b612df881612e53565b9150612e0b565b612e0881612e11565b91505b50919050565b60006000612e1e836129dc565b9050605660020a811015612e3157612e41565b612e3a81612e9d565b9150612e4d565b612e4a81612edf565b91505b50919050565b60006000612e68612e63846129dc565b6129dc565b9050605660020a811015612e7b57612e8b565b612e8481612edf565b9150612e97565b612e9481612e9d565b91505b50919050565b60006000612eaa836129dc565b9050605760020a811015612ebd57612ecd565b612ec681612f29565b9150612ed9565b612ed681612f6b565b91505b50919050565b60006000612ef4612eef846129dc565b6129dc565b9050605760020a811015612f0757612f17565b612f1081612f6b565b9150612f23565b612f2081612f29565b91505b50919050565b60006000612f36836129dc565b9050605860020a811015612f4957612f59565b612f5281612fb5565b9150612f65565b612f6281612ff7565b91505b50919050565b60006000612f80612f7b846129dc565b6129dc565b9050605860020a811015612f9357612fa3565b612f9c81612ff7565b9150612faf565b612fac81612fb5565b91505b50919050565b60006000612fc2836129dc565b9050605960020a811015612fd557612fe5565b612fde81613041565b9150612ff1565b612fee81613083565b91505b50919050565b6000600061300c613007846129dc565b6129dc565b9050605960020a81101561301f5761302f565b61302881613083565b915061303b565b61303881613041565b91505b50919050565b6000600061304e836129dc565b9050605a60020a81101561306157613071565b61306a816130cd565b915061307d565b61307a8161310f565b91505b50919050565b60006000613098613093846129dc565b6129dc565b9050605a60020a8110156130ab576130bb565b6130b48161310f565b91506130c7565b6130c4816130cd565b91505b50919050565b600060006130da836129dc565b9050605b60020a8110156130ed576130fd565b6130f681613159565b9150613109565b6131068161319b565b91505b50919050565b6000600061312461311f846129dc565b6129dc565b9050605b60020a81101561313757613147565b6131408161319b565b9150613153565b61315081613159565b91505b50919050565b60006000613166836129dc565b9050605c60020a81101561317957613189565b613182816131e5565b9150613195565b6131928161196a565b91505b50919050565b600060006131b06131ab846129dc565b6129dc565b9050605c60020a8110156131c3576131d3565b6131cc8161196a565b91506131df565b6131dc816131e5565b91505b50919050565b600060006131f2836129dc565b9050605d60020a81101561320557613215565b61320e816119b4565b9150613221565b61321e816119f6565b91505b50919050565b60006000613234836129dc565b9050607b60020a81101561324757613257565b613250816132b3565b9150613263565b613260816132f5565b91505b50919050565b6000600061327e613279846129dc565b6129dc565b9050607b60020a811015613291576132a1565b61329a816132f5565b91506132ad565b6132aa816132b3565b91505b50919050565b600060006132c0836129dc565b9050607c60020a8110156132d3576132e3565b6132dc8161333f565b91506132ef565b6132ec81613381565b91505b50919050565b6000600061330a613305846129dc565b6129dc565b9050607c60020a81101561331d5761332d565b61332681613381565b9150613339565b6133368161333f565b91505b50919050565b6000600061334c836129dc565b9050607d60020a81101561335f5761336f565b613368816133cb565b915061337b565b6133788161340d565b91505b50919050565b60006000613396613391846129dc565b6129dc565b9050607d60020a8110156133a9576133b9565b6133b28161340d565b91506133c5565b6133c2816133cb565b91505b50919050565b600060006133d8836129dc565b9050607e60020a8110156133eb576133fb565b6133f481613457565b9150613407565b61340481613499565b91505b50919050565b6000600061342261341d846129dc565b6129dc565b9050607e60020a81101561343557613445565b61343e81613499565b9150613451565b61344e81613457565b91505b50919050565b60006000613464836129dc565b9050607f60020a81101561347757613487565b613480816134e3565b9150613493565b61349081613525565b91505b50919050565b600060006134ae6134a9846129dc565b6129dc565b9050607f60020a8110156134c1576134d1565b6134ca81613525565b91506134dd565b6134da816134e3565b91505b50919050565b600060006134f0836129dc565b9050608060020a81101561350357613513565b61350c8161356f565b915061351f565b61351c816135b1565b91505b50919050565b6000600061353a613535846129dc565b6129dc565b9050608060020a81101561354d5761355d565b613556816135b1565b9150613569565b6135668161356f565b91505b50919050565b6000600061357c836129dc565b9050608160020a81101561358f5761359f565b613598816135fb565b91506135ab565b6135a88161363d565b91505b50919050565b600060006135c66135c1846129dc565b6129dc565b9050608160020a8110156135d9576135e9565b6135e28161363d565b91506135f5565b6135f2816135fb565b91505b50919050565b60006000613608836129dc565b9050608260020a81101561361b5761362b565b61362481613687565b9150613637565b613634816136c9565b91505b50919050565b6000600061365261364d846129dc565b6129dc565b9050608260020a81101561366557613675565b61366e816136c9565b9150613681565b61367e81613687565b91505b50919050565b60006000613694836129dc565b9050608360020a8110156136a7576136b7565b6136b081613713565b91506136c3565b6136c081613755565b91505b50919050565b600060006136de6136d9846129dc565b6129dc565b9050608360020a8110156136f157613701565b6136fa81613755565b915061370d565b61370a81613713565b91505b50919050565b60006000613720836129dc565b9050608460020a81101561373357613743565b61373c8161379f565b915061374f565b61374c816137e1565b91505b50919050565b6000600061376a613765846129dc565b6129dc565b9050608460020a81101561377d5761378d565b613786816137e1565b9150613799565b6137968161379f565b91505b50919050565b600060006137ac836129dc565b9050608560020a8110156137bf576137cf565b6137c88161382b565b91506137db565b6137d88161386d565b91505b50919050565b600060006137f66137f1846129dc565b6129dc565b9050608560020a81101561380957613819565b6138128161386d565b9150613825565b6138228161382b565b91505b50919050565b60006000613838836129dc565b9050608660020a81101561384b5761385b565b613854816138b7565b9150613867565b613864816138f9565b91505b50919050565b6000600061388261387d846129dc565b6129dc565b9050608660020a811015613895576138a5565b61389e816138f9565b91506138b1565b6138ae816138b7565b91505b50919050565b600060006138c4836129dc565b9050608760020a8110156138d7576138e7565b6138e081613943565b91506138f3565b6138f081613985565b91505b50919050565b6000600061390e613909846129dc565b6129dc565b9050608760020a81101561392157613931565b61392a81613985565b915061393d565b61393a81613943565b91505b50919050565b60006000613950836129dc565b9050608860020a81101561396357613973565b61396c816139cf565b915061397f565b61397c81613a11565b91505b50919050565b6000600061399a613995846129dc565b6129dc565b9050608860020a8110156139ad576139bd565b6139b681613a11565b91506139c9565b6139c6816139cf565b91505b50919050565b600060006139dc836129dc565b9050608960020a8110156139ef576139ff565b6139f881613a5b565b9150613a0b565b613a0881613a9d565b91505b50919050565b60006000613a26613a21846129dc565b6129dc565b9050608960020a811015613a3957613a49565b613a4281613a9d565b9150613a55565b613a5281613a5b565b91505b50919050565b60006000613a68836129dc565b9050608a60020a811015613a7b57613a8b565b613a8481613ae7565b9150613a97565b613a9481613b29565b91505b50919050565b60006000613ab2613aad846129dc565b6129dc565b9050608a60020a811015613ac557613ad5565b613ace81613b29565b9150613ae1565b613ade81613ae7565b91505b50919050565b60006000613af4836129dc565b9050608b60020a811015613b0757613b17565b613b1081613b73565b9150613b23565b613b2081613bb5565b91505b50919050565b60006000613b3e613b39846129dc565b6129dc565b9050608b60020a811015613b5157613b61565b613b5a81613bb5565b9150613b6d565b613b6a81613b73565b91505b50919050565b60006000613b80836129dc565b9050608c60020a811015613b9357613ba3565b613b9c81613bff565b9150613baf565b613bac81613c41565b91505b50919050565b60006000613bca613bc5846129dc565b6129dc565b9050608c60020a811015613bdd57613bed565b613be681613c41565b9150613bf9565b613bf681613bff565b91505b50919050565b60006000613c0c836129dc565b9050608d60020a811015613c1f57613c2f565b613c2881613c8b565b9150613c3b565b613c3881613ccd565b91505b50919050565b60006000613c56613c51846129dc565b6129dc565b9050608d60020a811015613c6957613c79565b613c7281613ccd565b9150613c85565b613c8281613c8b565b91505b50919050565b60006000613c98836129dc565b9050608e60020a811015613cab57613cbb565b613cb481613d17565b9150613cc7565b613cc481613d59565b91505b50919050565b60006000613ce2613cdd846129dc565b6129dc565b9050608e60020a811015613cf557613d05565b613cfe81613d59565b9150613d11565b613d0e81613d17565b91505b50919050565b60006000613d24836129dc565b9050608f60020a811015613d3757613d47565b613d4081613da3565b9150613d53565b613d5081613de5565b91505b50919050565b60006000613d6e613d69846129dc565b6129dc565b9050608f60020a811015613d8157613d91565b613d8a81613de5565b9150613d9d565b613d9a81613da3565b91505b50919050565b60006000613db0836129dc565b9050609060020a811015613dc357613dd3565b613dcc81613e2f565b9150613ddf565b613ddc81613e71565b91505b50919050565b60006000613dfa613df5846129dc565b6129dc565b9050609060020a811015613e0d57613e1d565b613e1681613e71565b9150613e29565b613e2681613e2f565b91505b50919050565b60006000613e3c836129dc565b9050609160020a811015613e4f57613e5f565b613e5881613ebb565b9150613e6b565b613e6881613efd565b91505b50919050565b60006000613e86613e81846129dc565b6129dc565b9050609160020a811015613e9957613ea9565b613ea281613efd565b9150613eb5565b613eb281613ebb565b91505b50919050565b60006000613ec8836129dc565b9050609260020a811015613edb57613eeb565b613ee481613f47565b9150613ef7565b613ef481613f89565b91505b50919050565b60006000613f12613f0d846129dc565b6129dc565b9050609260020a811015613f2557613f35565b613f2e81613f89565b9150613f41565b613f3e81613f47565b91505b50919050565b60006000613f54836129dc565b9050609360020a811015613f6757613f77565b613f7081613fd3565b9150613f83565b613f8081614015565b91505b50919050565b60006000613f9e613f99846129dc565b6129dc565b9050609360020a811015613fb157613fc1565b613fba81614015565b9150613fcd565b613fca81613fd3565b91505b50919050565b60006000613fe0836129dc565b9050609460020a811015613ff357614003565b613ffc8161405f565b915061400f565b61400c816140a1565b91505b50919050565b6000600061402a614025846129dc565b6129dc565b9050609460020a81101561403d5761404d565b614046816140a1565b9150614059565b6140568161405f565b91505b50919050565b6000600061406c836129dc565b9050609560020a81101561407f5761408f565b614088816140eb565b915061409b565b6140988161412d565b91505b50919050565b600060006140b66140b1846129dc565b6129dc565b9050609560020a8110156140c9576140d9565b6140d28161412d565b91506140e5565b6140e2816140eb565b91505b50919050565b600060006140f8836129dc565b9050609660020a81101561410b5761411b565b61411481614177565b9150614127565b614124816141b9565b91505b50919050565b6000600061414261413d846129dc565b6129dc565b9050609660020a81101561415557614165565b61415e816141b9565b9150614171565b61416e81614177565b91505b50919050565b60006000614184836129dc565b9050609760020a811015614197576141a7565b6141a081614203565b91506141b3565b6141b081614245565b91505b50919050565b600060006141ce6141c9846129dc565b6129dc565b9050609760020a8110156141e1576141f1565b6141ea81614245565b91506141fd565b6141fa81614203565b91505b50919050565b60006000614210836129dc565b9050609860020a81101561422357614233565b61422c8161428f565b915061423f565b61423c816142d1565b91505b50919050565b6000600061425a614255846129dc565b6129dc565b9050609860020a81101561426d5761427d565b614276816142d1565b9150614289565b6142868161428f565b91505b50919050565b6000600061429c836129dc565b9050609960020a8110156142af576142bf565b6142b88161431b565b91506142cb565b6142c88161435d565b91505b50919050565b600060006142e66142e1846129dc565b6129dc565b9050609960020a8110156142f957614309565b6143028161435d565b9150614315565b6143128161431b565b91505b50919050565b60006000614328836129dc565b9050609a60020a81101561433b5761434b565b614344816143a7565b9150614357565b614354816143e9565b91505b50919050565b6000600061437261436d846129dc565b6129dc565b9050609a60020a81101561438557614395565b61438e816143e9565b91506143a1565b61439e816143a7565b91505b50919050565b600060006143b4836129dc565b9050609b60020a8110156143c7576143d7565b6143d081614433565b91506143e3565b6143e081614475565b91505b50919050565b600060006143fe6143f9846129dc565b6129dc565b9050609b60020a81101561441157614421565b61441a81614475565b915061442d565b61442a81614433565b91505b50919050565b60006000614440836129dc565b9050609c60020a81101561445357614463565b61445c816144bf565b915061446f565b61446c81614501565b91505b50919050565b6000600061448a614485846129dc565b6129dc565b9050609c60020a81101561449d576144ad565b6144a681614501565b91506144b9565b6144b6816144bf565b91505b50919050565b600060006144cc836129dc565b9050609d60020a8110156144df576144ef565b6144e88161454b565b91506144fb565b6144f88161458d565b91505b50919050565b60006000614516614511846129dc565b6129dc565b9050609d60020a81101561452957614539565b6145328161458d565b9150614545565b6145428161454b565b91505b50919050565b60006000614558836129dc565b9050609e60020a81101561456b5761457b565b614574816145d7565b9150614587565b61458481614619565b91505b50919050565b600060006145a261459d846129dc565b6129dc565b9050609e60020a8110156145b5576145c5565b6145be81614619565b91506145d1565b6145ce816145d7565b91505b50919050565b600060006145e4836129dc565b9050609f60020a8110156145f757614607565b61460081614663565b9150614613565b614610816146a5565b91505b50919050565b6000600061462e614629846129dc565b6129dc565b9050609f60020a81101561464157614651565b61464a816146a5565b915061465d565b61465a81614663565b91505b50919050565b60006000614670836129dc565b905060a060020a81101561468357614693565b61468c816146ef565b915061469f565b61469c81614731565b91505b50919050565b600060006146ba6146b5846129dc565b6129dc565b905060a060020a8110156146cd576146dd565b6146d681614731565b91506146e9565b6146e6816146ef565b91505b50919050565b600060006146fc836129dc565b905060a160020a81101561470f5761471f565b6147188161477b565b915061472b565b614728816147bd565b91505b50919050565b60006000614746614741846129dc565b6129dc565b905060a160020a81101561475957614769565b614762816147bd565b9150614775565b6147728161477b565b91505b50919050565b60006000614788836129dc565b905060a260020a81101561479b576147ab565b6147a481614807565b91506147b7565b6147b481614849565b91505b50919050565b600060006147d26147cd846129dc565b6129dc565b905060a260020a8110156147e5576147f5565b6147ee81614849565b9150614801565b6147fe81614807565b91505b50919050565b60006000614814836129dc565b905060a360020a81101561482757614837565b61483081614893565b9150614843565b614840816148d5565b91505b50919050565b6000600061485e614859846129dc565b6129dc565b905060a360020a81101561487157614881565b61487a816148d5565b915061488d565b61488a81614893565b91505b50919050565b600060006148a0836129dc565b905060a460020a8110156148b3576148c3565b6148bc8161491f565b91506148cf565b6148cc81614961565b91505b50919050565b600060006148ea6148e5846129dc565b6129dc565b905060a460020a8110156148fd5761490d565b61490681614961565b9150614919565b6149168161491f565b91505b50919050565b6000600061492c836129dc565b905060a560020a81101561493f5761494f565b614948816149ab565b915061495b565b614958816149ed565b91505b50919050565b60006000614976614971846129dc565b6129dc565b905060a560020a81101561498957614999565b614992816149ed565b91506149a5565b6149a2816149ab565b91505b50919050565b600060006149b8836129dc565b905060a660020a8110156149cb576149db565b6149d481614a37565b91506149e7565b6149e481614a79565b91505b50919050565b60006000614a026149fd846129dc565b6129dc565b905060a660020a811015614a1557614a25565b614a1e81614a79565b9150614a31565b614a2e81614a37565b91505b50919050565b60006000614a44836129dc565b905060a760020a811015614a5757614a67565b614a6081614ac3565b9150614a73565b614a7081614b05565b91505b50919050565b60006000614a8e614a89846129dc565b6129dc565b905060a760020a811015614aa157614ab1565b614aaa81614b05565b9150614abd565b614aba81614ac3565b91505b50919050565b60006000614ad0836129dc565b905060a860020a811015614ae357614af3565b614aec81614b4f565b9150614aff565b614afc81614b91565b91505b50919050565b60006000614b1a614b15846129dc565b6129dc565b905060a860020a811015614b2d57614b3d565b614b3681614b91565b9150614b49565b614b4681614b4f565b91505b50919050565b60006000614b5c836129dc565b905060a960020a811015614b6f57614b7f565b614b7881614bdb565b9150614b8b565b614b8881614c1d565b91505b50919050565b60006000614ba6614ba1846129dc565b6129dc565b905060a960020a811015614bb957614bc9565b614bc281614c1d565b9150614bd5565b614bd281614bdb565b91505b50919050565b60006000614be8836129dc565b905060aa60020a811015614bfb57614c0b565b614c0481614c67565b9150614c17565b614c1481614ca9565b91505b50919050565b60006000614c32614c2d846129dc565b6129dc565b905060aa60020a811015614c4557614c55565b614c4e81614ca9565b9150614c61565b614c5e81614c67565b91505b50919050565b60006000614c74836129dc565b905060ab60020a811015614c8757614c97565b614c9081614cf3565b9150614ca3565b614ca081614d35565b91505b50919050565b60006000614cbe614cb9846129dc565b6129dc565b905060ab60020a811015614cd157614ce1565b614cda81614d35565b9150614ced565b614cea81614cf3565b91505b50919050565b60006000614d00836129dc565b905060ac60020a811015614d1357614d23565b614d1c81614d7f565b9150614d2f565b614d2c81614dc1565b91505b50919050565b60006000614d4a614d45846129dc565b6129dc565b905060ac60020a811015614d5d57614d6d565b614d6681614dc1565b9150614d79565b614d7681614d7f565b91505b50919050565b60006000614d8c836129dc565b905060ad60020a811015614d9f57614daf565b614da881614e0b565b9150614dbb565b614db881614e4d565b91505b50919050565b60006000614dd6614dd1846129dc565b6129dc565b905060ad60020a811015614de957614df9565b614df281614e4d565b9150614e05565b614e0281614e0b565b91505b50919050565b60006000614e18836129dc565b905060ae60020a811015614e2b57614e3b565b614e3481614e97565b9150614e47565b614e4481614ed9565b91505b50919050565b60006000614e62614e5d846129dc565b6129dc565b905060ae60020a811015614e7557614e85565b614e7e81614ed9565b9150614e91565b614e8e81614e97565b91505b50919050565b60006000614ea4836129dc565b905060af60020a811015614eb757614ec7565b614ec081614f23565b9150614ed3565b614ed081614f65565b91505b50919050565b60006000614eee614ee9846129dc565b6129dc565b905060af60020a811015614f0157614f11565b614f0a81614f65565b9150614f1d565b614f1a81614f23565b91505b50919050565b60006000614f30836129dc565b905060b060020a811015614f4357614f53565b614f4c81614faf565b9150614f5f565b614f5c81614ff1565b91505b50919050565b60006000614f7a614f75846129dc565b6129dc565b905060b060020a811015614f8d57614f9d565b614f9681614ff1565b9150614fa9565b614fa681614faf565b91505b50919050565b60006000614fbc836129dc565b905060b160020a811015614fcf57614fdf565b614fd881612a11565b9150614feb565b614fe881612a23565b91505b50919050565b60006000615006615001846129dc565b6129dc565b905060b160020a81101561501957615029565b61502281612a23565b9150615035565b61503281612a11565b91505b5091905056", @@ -25,7 +25,7 @@ "//" : "ManyFunctions.start(1)", "data" : "0x95805DAD0000000000000000000000000000000000000000000000000000000000000001", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "ackermann31": { @@ -39,7 +39,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -54,7 +54,7 @@ "//" : "ackermann(3, 1)", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "ackermann32": { @@ -68,7 +68,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -97,7 +97,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -126,7 +126,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -155,7 +155,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", diff --git a/test/vmPushDupSwapTestFiller.json b/test/vmPushDupSwapTestFiller.json index 1aca47922..9b8930e01 100644 --- a/test/vmPushDupSwapTestFiller.json +++ b/test/vmPushDupSwapTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60ff600355", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x61eeff600355", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x62ddeeff600355", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x63ccddeeff600355", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x64bbccddeeff600355", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x65aabbccddeeff600355", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6699aabbccddeeff600355", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x678899aabbccddeeff600355", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x68778899aabbccddeeff600355", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6966778899aabbccddeeff600355", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -318,7 +318,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6a5566778899aabbccddeeff600355", "storage": {} @@ -331,7 +331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -346,7 +346,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6b445566778899aabbccddeeff600355", "storage": {} @@ -359,7 +359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -374,7 +374,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6c33445566778899aabbccddeeff600355", "storage": {} @@ -387,7 +387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -402,7 +402,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6d2233445566778899aabbccddeeff600355", "storage": {} @@ -415,7 +415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -430,7 +430,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6e112233445566778899aabbccddeeff600355", "storage": {} @@ -443,7 +443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -458,7 +458,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6f10112233445566778899aabbccddeeff600355", "storage": {} @@ -471,7 +471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -486,7 +486,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x70ff00112233445566778899aabbccddeeff600355", "storage": {} @@ -499,7 +499,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x71eeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -527,7 +527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -542,7 +542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x72ddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -555,7 +555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -570,7 +570,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x73ccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -583,7 +583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -598,7 +598,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x74bbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -611,7 +611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -626,7 +626,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x75aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -639,7 +639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -654,7 +654,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7699aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -667,7 +667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -682,7 +682,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -695,7 +695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -710,7 +710,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x78778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -723,7 +723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -738,7 +738,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7966778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -751,7 +751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -767,7 +767,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7a5566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -780,7 +780,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -795,7 +795,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7b445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -808,7 +808,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7c33445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7d2233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -879,7 +879,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7e112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -892,7 +892,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -907,7 +907,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -920,7 +920,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -935,7 +935,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7fff10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -948,7 +948,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -964,7 +964,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7fff10112233445566778899aabbccddeeff00112233445566778899aabbccdd", "storage": {} @@ -977,7 +977,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -992,7 +992,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 101 2002 303303 40444404 50555555505 60666666666606 7777777777777777 888888888888888888 99999999999999999999 10000000000000000000001 10111111111111111111111101 2022222222222222222222222202 303333333333333333333333333303 4044444444444444444444444444444404 505555555555555555555555555555555505 60666666666666666666666666666666666606 7077777777777777777777777777777777777707 808888888888888888888888888888888888888808 90999999999999999999999999999999999999999909 100000000000000000000000000000000000000000000001 10111111111111111111111111111111111111111111111101 2022222222222222222222222222222222222222222222222202 303333333333333333333333333333333333333333333333333303 40444444444444444444444444444444444444444444444444444404 50555555555555555555555555555555555555555555555555555555505 6066666666666666666666666666666666666666666666666666666666606 707777777777777777777777777777777777777777777777777777777777707 808888888888888888888888888888888888888888888888888888888888888808 90999999999999999999999999999999999999999999999999999999999999999909 100000000000000000000000000000000000000000000000000000000000000000000001 10111111111111111111111111111111111111111111111111111111111111111111111101 2022222222222222222222222222222222222222222222222222222222222222222222222202)", "storage": {} @@ -1020,7 +1020,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff80600355", "storage": {} @@ -1033,7 +1033,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1048,7 +1048,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff81600355", "storage": {} @@ -1061,7 +1061,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1076,7 +1076,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600181600355", "storage": {} @@ -1089,7 +1089,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1104,7 +1104,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60036002600182600355", "storage": {} @@ -1117,7 +1117,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1132,7 +1132,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460036002600183600355", "storage": {} @@ -1145,7 +1145,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1160,7 +1160,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600460036002600184600355", "storage": {} @@ -1173,7 +1173,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1188,7 +1188,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60066005600460036002600185600355", "storage": {} @@ -1201,7 +1201,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1216,7 +1216,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600760066005600460036002600186600355", "storage": {} @@ -1229,7 +1229,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1244,7 +1244,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600760066005600460036002600187600355", "storage": {} @@ -1257,7 +1257,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1272,7 +1272,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60096008600760066005600460036002600188600355", "storage": {} @@ -1285,7 +1285,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1300,7 +1300,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a60096008600760066005600460036002600189600355", "storage": {} @@ -1313,7 +1313,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1328,7 +1328,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600b600a6009600860076006600560046003600260018a600355", "storage": {} @@ -1341,7 +1341,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1356,7 +1356,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600c600b600a6009600860076006600560046003600260018b600355", "storage": {} @@ -1369,7 +1369,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1384,7 +1384,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600d600c600b600a6009600860076006600560046003600260018c600355", "storage": {} @@ -1397,7 +1397,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1412,7 +1412,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600e600d600c600b600a6009600860076006600560046003600260018d600355", "storage": {} @@ -1425,7 +1425,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1440,7 +1440,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600f600e600d600c600b600a6009600860076006600560046003600260018e600355", "storage": {} @@ -1453,7 +1453,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1468,7 +1468,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6010600f600e600d600c600b600a6009600860076006600560046003600260018f600355", "storage": {} @@ -1481,7 +1481,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1496,7 +1496,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff60039055", "storage": {} @@ -1509,7 +1509,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1524,7 +1524,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff60039155", "storage": {} @@ -1537,7 +1537,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1552,7 +1552,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600160039155", "storage": {} @@ -1565,7 +1565,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1580,7 +1580,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60036002600160039255", "storage": {} @@ -1593,7 +1593,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1608,7 +1608,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460036002600160039355", "storage": {} @@ -1621,7 +1621,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1636,7 +1636,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600460036002600160039455", "storage": {} @@ -1649,7 +1649,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1664,7 +1664,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60066005600460036002600160039555", "storage": {} @@ -1677,7 +1677,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1692,7 +1692,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600760066005600460036002600160039655", "storage": {} @@ -1705,7 +1705,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1720,7 +1720,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600760066005600460036002600160039755", "storage": {} @@ -1733,7 +1733,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1748,7 +1748,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60096008600760066005600460036002600160039855", "storage": {} @@ -1761,7 +1761,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1776,7 +1776,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a60096008600760066005600460036002600160039955", "storage": {} @@ -1789,7 +1789,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1804,7 +1804,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600b600a60096008600760066005600460036002600160039a55", "storage": {} @@ -1817,7 +1817,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1832,7 +1832,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600c600b600a60096008600760066005600460036002600160039b55", "storage": {} @@ -1845,7 +1845,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1860,7 +1860,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600d600c600b600a60096008600760066005600460036002600160039c55", "storage": {} @@ -1873,7 +1873,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1888,7 +1888,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600e600d600c600b600a60096008600760066005600460036002600160039d55", "storage": {} @@ -1901,7 +1901,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1916,7 +1916,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600f600e600d600c600b600a60096008600760066005600460036002600160039e55", "storage": {} @@ -1929,7 +1929,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1944,7 +1944,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6010600f600e600d600c600b600a60096008600760066005600460036002600160039f55", "storage": {} @@ -1957,7 +1957,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1972,7 +1972,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 5 2 1 12 JUMPI POP POP STOP JUMPDEST SWAP1 1 22 JUMPI POP POP STOP JUMPDEST SUB 0 MSTORE 1 31 RETURN)", "storage": {} @@ -1985,7 +1985,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmSha3TestFiller.json b/test/vmSha3TestFiller.json index 142af79d0..f10601f00 100644 --- a/test/vmSha3TestFiller.json +++ b/test/vmSha3TestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0 0)}", "storage": {} @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 4 5)}", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 10 10)}", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 1000 0xfffff)}", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0xfffffffff 100)}", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 10000 0xfffffffff )}", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)}", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, diff --git a/test/vmSystemOperationsTestFiller.json b/test/vmSystemOperationsTestFiller.json index 709af7079..bdbbdc29b 100644 --- a/test/vmSystemOperationsTestFiller.json +++ b/test/vmSystemOperationsTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 3 29) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -51,7 +51,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -79,7 +79,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -107,7 +107,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -161,14 +161,14 @@ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "code" : "0x4243434242434243f14555", "data" : "0x", - "gas" : "10000", + "gas" : "100000", "gasPrice" : "100000000000000", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "code" : "0x4243434242434243f14555", "nonce" : "0", "storage" : { @@ -188,7 +188,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2) }", "storage": {} @@ -224,7 +224,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) (POST 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 ) }", "storage": {} @@ -260,7 +260,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLSTATELESS 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2 ) }", "storage": {} @@ -296,7 +296,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2 ) }", "storage": {} @@ -333,7 +333,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 100 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -369,7 +369,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 987654321 64 64 0) }", "storage": {} @@ -405,7 +405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 9865432 64 0) }", "storage": {} @@ -441,7 +441,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 987654 1) }", "storage": {} @@ -478,7 +478,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 987654 0) }", "storage": {} @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 987654 0 64 0) }", "storage": {} @@ -556,7 +556,7 @@ "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (+ (SLOAD 0) 1) [[ 1 ]] (CALL (- (GAS) 224) (ADDRESS) 0 0 0 0 0) } ", "storage": {} @@ -668,7 +668,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE (CALLER))}", "storage": {} @@ -704,7 +704,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE 0xaa1722f3947def4cf144679da39c4c32bdc35681 )}", "storage": {} @@ -740,7 +740,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE (ADDRESS) )}", "storage": {} @@ -866,7 +866,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) (POST 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 ) }", "storage": {} @@ -902,7 +902,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLSTATELESS 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -974,7 +974,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6000355415600957005b60203560003555", "storage": {} @@ -987,7 +987,7 @@ "value" : "1000000000000000000", "data" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffafffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1002,7 +1002,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} @@ -1038,7 +1038,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} @@ -1074,7 +1074,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", "storage": {} @@ -1146,7 +1146,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) (SUICIDE 0x945304eb96065b2a98b57a48a06ae28d285a71b5) }", "storage": {} @@ -1182,7 +1182,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} diff --git a/test/vmtestsFiller.json b/test/vmtestsFiller.json index 75bf1da8f..c9f157f11 100644 --- a/test/vmtestsFiller.json +++ b/test/vmtestsFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(suicide (caller))", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (call (- (gas) 200) (caller) (+ 2 2 (* 4 4 4) (/ 2 2) (% 3 2) (- 8 2 2)) 0 0 0 0) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(seq (when (and 1 1) (call (- (gas) 200) (caller) 2 0 0 0 0)) (when (and 1 0) (call (- (gas) 200) (caller) 3 0 0 0 0)) (when (and 0 1) (call (- (gas) 200) (caller) 4 0 0 0 0)) (when (and 0 0) (call (- (gas) 200) (caller) 5 0 0 0 0)) (when (or 1 1) (call (- (gas) 200) (caller) 12 0 0 0 0)) (when (or 1 0) (call (- (gas) 200) (caller) 13 0 0 0 0)) (when (or 0 1) (call (- (gas) 200) (caller) 14 0 0 0 0)) (when (or 0 0) (call (- (gas) 200) (caller) 15 0 0 0 0)) )", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(call (- (gas) 200) (caller) 500000000000000000 0 0 0 0)", "storage": {} @@ -107,7 +107,7 @@ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000", "gasPrice" : "100000000000000", - "gas" : "10000", + "gas" : "100000", "data" : "" } } From 9385ee2533626ff9bc1213a1376088ca6322b47e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 11:09:34 +0100 Subject: [PATCH 147/313] Bunch of repotting/curating. [10:59:28] Vitalik Buterin: block.parent.gas_limit * 1023 / 1024 <= block.gas_limit <= block.parent.gas_limit * 1025/1024 --- alethzero/Context.cpp | 2 +- alethzero/Context.h | 2 +- alethzero/Debugger.h | 2 +- alethzero/MainWin.h | 2 +- alethzero/Transact.h | 2 +- rlp/base64.cpp => libdevcore/Base64.cpp | 12 +-- rlp/base64.h => libdevcore/Base64.h | 9 +- libdevcore/Common.h | 6 ++ libdevcore/CommonIO.h | 1 + libdevcore/CommonJS.cpp | 101 ++++++++++++++++++++ libdevcore/CommonJS.h | 116 +++++++++++++++++++++++ libethcore/BlockInfo.cpp | 12 +-- libethcore/BlockInfo.h | 2 +- libethcore/{CommonEth.cpp => Common.cpp} | 4 +- libethcore/{CommonEth.h => Common.h} | 2 +- libethcore/CommonJS.cpp | 79 +-------------- libethcore/CommonJS.h | 114 +++------------------- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 4 +- libethcore/ProofOfWork.h | 2 +- libethereum/Account.cpp | 2 +- libethereum/AccountDiff.h | 2 +- libethereum/BlockChain.h | 2 +- libethereum/BlockQueue.h | 2 +- libethereum/CanonBlockChain.h | 2 +- libethereum/EthereumHost.h | 2 +- libethereum/EthereumPeer.h | 2 +- libethereum/Executive.h | 2 +- libethereum/ExtVM.h | 2 +- libethereum/LogFilter.h | 2 +- libethereum/Miner.h | 2 +- libethereum/Precompiled.cpp | 2 +- libethereum/Transaction.h | 2 +- libethereum/TransactionQueue.h | 2 +- libethereum/Utility.cpp | 2 +- libevm/ExtVMFace.h | 2 +- libevm/VM.h | 2 +- mix/QEther.h | 2 +- rlp/main.cpp | 94 +++++++++--------- test/MemTrie.cpp | 2 +- test/TrieHash.cpp | 2 +- test/commonjs.cpp | 2 +- third/MainWin.h | 2 +- 43 files changed, 339 insertions(+), 275 deletions(-) rename rlp/base64.cpp => libdevcore/Base64.cpp (91%) rename rlp/base64.h => libdevcore/Base64.h (80%) create mode 100644 libdevcore/CommonJS.cpp create mode 100644 libdevcore/CommonJS.h rename libethcore/{CommonEth.cpp => Common.cpp} (97%) rename libethcore/{CommonEth.h => Common.h} (98%) diff --git a/alethzero/Context.cpp b/alethzero/Context.cpp index d187e6d47..7a5a986d1 100644 --- a/alethzero/Context.cpp +++ b/alethzero/Context.cpp @@ -21,7 +21,7 @@ #include "Context.h" #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/alethzero/Context.h b/alethzero/Context.h index 098690455..beb368c26 100644 --- a/alethzero/Context.h +++ b/alethzero/Context.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include class QComboBox; diff --git a/alethzero/Debugger.h b/alethzero/Debugger.h index 370ad6e30..76ef6a0d3 100644 --- a/alethzero/Debugger.h +++ b/alethzero/Debugger.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 638469fbe..072911ff7 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/alethzero/Transact.h b/alethzero/Transact.h index f14005eff..8ef4f41e0 100644 --- a/alethzero/Transact.h +++ b/alethzero/Transact.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/rlp/base64.cpp b/libdevcore/Base64.cpp similarity index 91% rename from rlp/base64.cpp rename to libdevcore/Base64.cpp index 5e2b32000..684556cd5 100644 --- a/rlp/base64.cpp +++ b/libdevcore/Base64.cpp @@ -23,13 +23,11 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. - -#include "base64.h" +/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// Originally by René Nyffenegger, modified by some other guy and then devified by Gav Wood. +#include "Base64.h" #include - using namespace std; using namespace dev; @@ -42,7 +40,7 @@ static inline bool is_base64(byte c) { return (isalnum(c) || (c == '+') || (c == '/')); } -std::string dev::base64_encode(bytesConstRef _in) { +std::string dev::toBase64(bytesConstRef _in) { std::string ret; int i = 0; int j = 0; @@ -86,7 +84,7 @@ std::string dev::base64_encode(bytesConstRef _in) { return ret; } -bytes dev::base64_decode(std::string const& encoded_string) { +bytes dev::fromBase64(std::string const& encoded_string) { int in_len = encoded_string.size(); int i = 0; int j = 0; diff --git a/rlp/base64.h b/libdevcore/Base64.h similarity index 80% rename from rlp/base64.h rename to libdevcore/Base64.h index 53ba282c8..1e9c88429 100644 --- a/rlp/base64.h +++ b/libdevcore/Base64.h @@ -23,8 +23,9 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// Originally by René Nyffenegger. +/// DEVified by Gav Wood. #pragma once #include @@ -34,7 +35,7 @@ namespace dev { -std::string base64_encode(bytesConstRef _in); -bytes base64_decode(std::string const& _in); +std::string toBase64(bytesConstRef _in); +bytes fromBase64(std::string const& _in); } diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 764b3454e..b82cb827e 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -119,6 +119,12 @@ inline unsigned int toLog2(u256 _x) return ret; } +template +inline N diff(N const& _a, N const& _b) +{ + return std::max(_a, _b) - std::min(_a, _b); +} + /// RAII utility class whose destructor calls a given function. class ScopeGuard { public: diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 1fc8a65e4..03fc9cffc 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -36,6 +36,7 @@ #include #include #include "Common.h" +#include "Base64.h" namespace dev { diff --git a/libdevcore/CommonJS.cpp b/libdevcore/CommonJS.cpp new file mode 100644 index 000000000..f173e779e --- /dev/null +++ b/libdevcore/CommonJS.cpp @@ -0,0 +1,101 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CommonJS.cpp + * @authors: + * Gav Wood + * Marek Kotewicz + * @date 2014 + */ + +#include "CommonJS.h" + +namespace dev +{ + +bytes jsToBytes(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return fromHex(_s.substr(2)); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return toCompactBigEndian(bigint(_s)); + else + return bytes(); +} + +bytes padded(bytes _b, unsigned _l) +{ + while (_b.size() < _l) + _b.insert(_b.begin(), 0); + return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l))); +} + +bytes paddedRight(bytes _b, unsigned _l) +{ + _b.resize(_l); + return _b; +} + +bytes unpadded(bytes _b) +{ + auto p = asString(_b).find_last_not_of((char)0); + _b.resize(p == std::string::npos ? 0 : (p + 1)); + return _b; +} + +bytes unpadLeft(bytes _b) +{ + unsigned int i = 0; + if (_b.size() == 0) + return _b; + + while (i < _b.size() && _b[i] == byte(0)) + i++; + + if (i != 0) + _b.erase(_b.begin(), _b.begin() + i); + return _b; +} + +std::string fromRaw(h256 _n, unsigned* _inc) +{ + if (_n) + { + std::string s((char const*)_n.data(), 32); + auto l = s.find_first_of('\0'); + if (!l) + return ""; + if (l != std::string::npos) + { + auto p = s.find_first_not_of('\0', l); + if (!(p == std::string::npos || (_inc && p == 31))) + return ""; + if (_inc) + *_inc = (byte)s[31]; + s.resize(l); + } + for (auto i: s) + if (i < 32) + return ""; + return s; + } + return ""; +} + +} + diff --git a/libdevcore/CommonJS.h b/libdevcore/CommonJS.h new file mode 100644 index 000000000..d3e8e6daa --- /dev/null +++ b/libdevcore/CommonJS.h @@ -0,0 +1,116 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CommonJS.h + * @authors: + * Gav Wood + * Marek Kotewicz + * @date 2014 + */ + +#pragma once + +#include +#include "FixedHash.h" +#include "CommonData.h" +#include "CommonIO.h" + +namespace dev +{ + +template std::string toJS(FixedHash const& _h) +{ + return "0x" + toHex(_h.ref()); +} + +template std::string toJS(boost::multiprecision::number> const& _n) +{ + return "0x" + toHex(toCompactBigEndian(_n)); +} + +inline std::string toJS(dev::bytes const& _n) +{ + return "0x" + dev::toHex(_n); +} + +/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. +bytes jsToBytes(std::string const& _s); +/// Add '0' on the head of @a _b until @a _l. +bytes padded(bytes _b, unsigned _l); +/// Add '0' on the queue of @a _b until @a _l. +bytes paddedRight(bytes _b, unsigned _l); +/// Removing all trailing '0'. Returns empty array if input contains only '0' char. +bytes unpadded(bytes _s); +/// Remove all 0 byte on the head of @a _s. +bytes unpadLeft(bytes _s); +/// Convert h256 into user-readable string (by directly using std::string constructor). +std::string fromRaw(h256 _n, unsigned* _inc = nullptr); + +template FixedHash jsToFixed(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return FixedHash(_s.substr(2 + std::max(N * 2, _s.size() - 2) - N * 2)); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return (typename FixedHash::Arith)(_s); + else + // Binary + return FixedHash(); // FAIL +} + +inline std::string jsToFixed(double _s) +{ + return toJS(dev::u256(_s * (double)(dev::u256(1) << 128))); +} + +template boost::multiprecision::number> jsToInt(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return fromBigEndian>>(fromHex(_s.substr(2))); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return boost::multiprecision::number>(_s); + else + // Binary + return 0; // FAIL +} + +inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } + +inline std::string jsToDecimal(std::string const& _s) +{ + return dev::toString(jsToU256(_s)); +} + +inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32) +{ + _s.resize(std::max(_s.size(), _padding)); + return "0x" + dev::toHex(_s); +} + +inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) +{ + return jsFromBinary(asBytes(_s), _padding); +} + +inline double jsFromFixed(std::string const& _s) +{ + return (double)jsToU256(_s) / (double)(dev::u256(1) << 128); +} + +} diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index d8a2357a1..270f96b07 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "ProofOfWork.h" #include "Exceptions.h" #include "Params.h" @@ -203,15 +203,15 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } -template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } - void BlockInfo::verifyParent(BlockInfo const& _parent) const -{ // Check difficulty is correct given the two timestamps. +{ + // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); + if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || + gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index bf986e3a1..a119d92eb 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -23,7 +23,7 @@ #include #include -#include "CommonEth.h" +#include "Common.h" namespace dev { diff --git a/libethcore/CommonEth.cpp b/libethcore/Common.cpp similarity index 97% rename from libethcore/CommonEth.cpp rename to libethcore/Common.cpp index 822ede5aa..65c0b8b92 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/Common.cpp @@ -14,12 +14,12 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file CommonEth.cpp +/** @file Common.cpp * @author Gav Wood * @date 2014 */ -#include "CommonEth.h" +#include "Common.h" #include #include #include "Exceptions.h" diff --git a/libethcore/CommonEth.h b/libethcore/Common.h similarity index 98% rename from libethcore/CommonEth.h rename to libethcore/Common.h index edefda380..80a253bdd 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/Common.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file CommonEth.h +/** @file Common.h * @author Gav Wood * @date 2014 * diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index 388738528..ef9ac9f65 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -26,75 +26,12 @@ namespace dev { -bytes jsToBytes(std::string const& _s) +Address toAddress(std::string const& _sn) { - if (_s.substr(0, 2) == "0x") - // Hex - return fromHex(_s.substr(2)); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return toCompactBigEndian(bigint(_s)); + if (_sn.size() == 40) + return Address(fromHex(_sn)); else - return bytes(); -} - -bytes padded(bytes _b, unsigned _l) -{ - while (_b.size() < _l) - _b.insert(_b.begin(), 0); - return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l))); -} - -bytes paddedRight(bytes _b, unsigned _l) -{ - _b.resize(_l); - return _b; -} - -bytes unpadded(bytes _b) -{ - auto p = asString(_b).find_last_not_of((char)0); - _b.resize(p == std::string::npos ? 0 : (p + 1)); - return _b; -} - -bytes unpadLeft(bytes _b) -{ - unsigned int i = 0; - if (_b.size() == 0) - return _b; - - while (i < _b.size() && _b[i] == byte(0)) - i++; - - if (i != 0) - _b.erase(_b.begin(), _b.begin() + i); - return _b; -} - -std::string fromRaw(h256 _n, unsigned* _inc) -{ - if (_n) - { - std::string s((char const*)_n.data(), 32); - auto l = s.find_first_of('\0'); - if (!l) - return ""; - if (l != std::string::npos) - { - auto p = s.find_first_not_of('\0', l); - if (!(p == std::string::npos || (_inc && p == 31))) - return ""; - if (_inc) - *_inc = (byte)s[31]; - s.resize(l); - } - for (auto i: s) - if (i < 32) - return ""; - return s; - } - return ""; + return Address(); } std::string prettyU256(u256 _n, bool _abridged) @@ -128,13 +65,5 @@ std::string prettyU256(u256 _n, bool _abridged) return s.str(); } -Address fromString(std::string const& _sn) -{ - if (_sn.size() == 40) - return Address(fromHex(_sn)); - else - return Address(); -} - } diff --git a/libethcore/CommonJS.h b/libethcore/CommonJS.h index abe74f0af..7d3071c68 100644 --- a/libethcore/CommonJS.h +++ b/libethcore/CommonJS.h @@ -24,124 +24,38 @@ #pragma once #include -#include -#include -#include -#include -#include "CommonEth.h" +#include +#include +#include "Common.h" + +// devcrypto namespace dev { -template std::string toJS(FixedHash const& _h) -{ - return "0x" + toHex(_h.ref()); -} +/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40). +Address toAddress(std::string const& _a); -template std::string toJS(boost::multiprecision::number> const& _n) -{ - return "0x" + toHex(toCompactBigEndian(_n)); -} +/// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length. +inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } -inline std::string toJS(dev::bytes const& _n) -{ - return "0x" + dev::toHex(_n); -} +/// Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length. +inline Secret jsToSecret(std::string const& _s) { return jsToFixed(_s); } + +/// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length. +inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } -/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. -bytes jsToBytes(std::string const& _s); -/// Add '0' on the head of @a _b until @a _l. -bytes padded(bytes _b, unsigned _l); -/// Add '0' on the queue of @a _b until @a _l. -bytes paddedRight(bytes _b, unsigned _l); -/// Removing all trailing '0'. Returns empty array if input contains only '0' char. -bytes unpadded(bytes _s); -/// Remove all 0 byte on the head of @a _s. -bytes unpadLeft(bytes _s); /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. std::string prettyU256(u256 _n, bool _abridged = true); -/// Convert h256 into user-readable string (by directly using std::string constructor). -std::string fromRaw(h256 _n, unsigned* _inc = nullptr); -/// Convert string to Address (h160), returns empty address if (_a.size != 40). -Address fromString(std::string const& _a); - -template FixedHash jsToFixed(std::string const& _s) -{ - if (_s.substr(0, 2) == "0x") - // Hex - return FixedHash(_s.substr(2 + std::max(N * 2, _s.size() - 2) - N * 2)); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return (typename FixedHash::Arith)(_s); - else - // Binary - return FixedHash(); // FAIL -} - -inline std::string jsToFixed(double _s) -{ - return toJS(dev::u256(_s * (double)(dev::u256(1) << 128))); -} - -template boost::multiprecision::number> jsToInt(std::string const& _s) -{ - if (_s.substr(0, 2) == "0x") - // Hex - return fromBigEndian>>(fromHex(_s.substr(2))); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return boost::multiprecision::number>(_s); - else - // Binary - return 0; // FAIL -} - -inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } - -inline std::string jsToDecimal(std::string const& _s) -{ - return dev::toString(jsToU256(_s)); -} -inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32) -{ - _s.resize(std::max(_s.size(), _padding)); - return "0x" + dev::toHex(_s); } -inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) -{ - return jsFromBinary(asBytes(_s), _padding); -} - -inline double jsFromFixed(std::string const& _s) -{ - return (double)jsToU256(_s) / (double)(dev::u256(1) << 128); -} - -} - -// devcrypto - -#include - -namespace dev -{ - -inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } -inline Secret jsToSecret(std::string const& _s) { return jsToFixed(_s); } - -} - - // ethcore namespace dev { namespace eth { -inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } - struct TransactionSkeleton { bool creation = false; diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c4628f4aa..c489c8f4a 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 833bc2b04..2d732325b 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,7 +22,7 @@ #pragma once #include -#include "CommonEth.h" +#include "Common.h" namespace dev { @@ -58,7 +58,7 @@ class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTr struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; struct InvalidSeedHash: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index fdf51f0d4..7006f6f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -27,7 +27,7 @@ #include #include #include -#include "CommonEth.h" +#include "Common.h" #include "BlockInfo.h" #define FAKE_DAGGER 1 diff --git a/libethereum/Account.cpp b/libethereum/Account.cpp index 74b6ebe7b..13eb0a8cd 100644 --- a/libethereum/Account.cpp +++ b/libethereum/Account.cpp @@ -20,7 +20,7 @@ */ #include "Account.h" -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/libethereum/AccountDiff.h b/libethereum/AccountDiff.h index 0c0ede4ae..dd494c0a5 100644 --- a/libethereum/AccountDiff.h +++ b/libethereum/AccountDiff.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace dev { diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 0c5587d2a..dbcab2580 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "BlockDetails.h" diff --git a/libethereum/BlockQueue.h b/libethereum/BlockQueue.h index 210b9eeb0..5eefa9d8e 100644 --- a/libethereum/BlockQueue.h +++ b/libethereum/BlockQueue.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include namespace dev diff --git a/libethereum/CanonBlockChain.h b/libethereum/CanonBlockChain.h index d9739097a..7110dbc90 100644 --- a/libethereum/CanonBlockChain.h +++ b/libethereum/CanonBlockChain.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "BlockDetails.h" diff --git a/libethereum/EthereumHost.h b/libethereum/EthereumHost.h index dfa928675..16c7056ca 100644 --- a/libethereum/EthereumHost.h +++ b/libethereum/EthereumHost.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include "CommonNet.h" #include "EthereumPeer.h" diff --git a/libethereum/EthereumPeer.h b/libethereum/EthereumPeer.h index 71bfc544f..94142ef86 100644 --- a/libethereum/EthereumPeer.h +++ b/libethereum/EthereumPeer.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include "CommonNet.h" #include "DownloadMan.h" diff --git a/libethereum/Executive.h b/libethereum/Executive.h index bb5563604..2e89f0623 100644 --- a/libethereum/Executive.h +++ b/libethereum/Executive.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include "Transaction.h" diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 2ff270de5..d63cd943a 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "State.h" diff --git a/libethereum/LogFilter.h b/libethereum/LogFilter.h index 5f68cd5d0..7b8922a03 100644 --- a/libethereum/LogFilter.h +++ b/libethereum/LogFilter.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include "TransactionReceipt.h" namespace dev diff --git a/libethereum/Miner.h b/libethereum/Miner.h index fd449e995..bdd49abb9 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "State.h" namespace dev diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 6e0d4756c..62d159418 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using namespace std; using namespace dev; diff --git a/libethereum/Transaction.h b/libethereum/Transaction.h index a9044970f..7dd28f7c6 100644 --- a/libethereum/Transaction.h +++ b/libethereum/Transaction.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace dev { diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 22a420602..b58944e4f 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -23,7 +23,7 @@ #include #include -#include "libethcore/CommonEth.h" +#include "libethcore/Common.h" #include namespace dev diff --git a/libethereum/Utility.cpp b/libethereum/Utility.cpp index 31c5e278a..7b0a961b2 100644 --- a/libethereum/Utility.cpp +++ b/libethereum/Utility.cpp @@ -22,7 +22,7 @@ #include "Utility.h" #include -#include +#include #include using namespace std; using namespace dev; diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 1bca3e2b2..9a49db113 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace dev diff --git a/libevm/VM.h b/libevm/VM.h index f100badc4..f2c773e4b 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/mix/QEther.h b/mix/QEther.h index 794ba2ba1..f50c39e7c 100644 --- a/mix/QEther.h +++ b/mix/QEther.h @@ -23,7 +23,7 @@ #pragma once #include -#include +#include #include "QBigInt.h" namespace dev diff --git a/rlp/main.cpp b/rlp/main.cpp index c3c04535b..85c08e0e6 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -22,11 +22,9 @@ #include #include #include -#include #include #include #include -#include "base64.h" using namespace std; using namespace dev; @@ -218,7 +216,7 @@ int main(int argc, char** argv) boost::algorithm::replace_all(s, " ", ""); boost::algorithm::replace_all(s, "\n", ""); boost::algorithm::replace_all(s, "\t", ""); - b = base64_decode(s); + b = fromBase64(s); break; } default: @@ -228,60 +226,60 @@ int main(int argc, char** argv) try { - RLP rlp(b); - switch (mode) - { - case Mode::ListArchive: - { - if (!rlp.isList()) + RLP rlp(b); + switch (mode) { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); - } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ListArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; - } - break; - } - case Mode::ExtractArchive: - { - if (!rlp.isList()) - { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ExtractArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - ofstream fout; - fout.open(toString(sha3(i.data()))); - fout.write(reinterpret_cast(i.data().data()), i.data().size()); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; } - break; - } - case Mode::Render: - { - RLPStreamer s(cout, prefs); - s.output(rlp); - cout << endl; - break; - } - default:; - } } catch (...) { diff --git a/test/MemTrie.cpp b/test/MemTrie.cpp index c3a44e1e5..ab5a13b60 100644 --- a/test/MemTrie.cpp +++ b/test/MemTrie.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/TrieHash.cpp b/test/TrieHash.cpp index ee4f2e87d..ccf12c162 100644 --- a/test/TrieHash.cpp +++ b/test/TrieHash.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/commonjs.cpp b/test/commonjs.cpp index 041a14f68..72582c540 100644 --- a/test/commonjs.cpp +++ b/test/commonjs.cpp @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(jsToAddress) cnote << "Testing jsToPublic..."; KeyPair kp = KeyPair::create(); string string = toJS(kp.address()); - Address address = dev::eth::jsToAddress(string); + Address address = dev::jsToAddress(string); BOOST_CHECK_EQUAL(kp.address(), address); } diff --git a/third/MainWin.h b/third/MainWin.h index 513cfe96e..2f8f95f0e 100644 --- a/third/MainWin.h +++ b/third/MainWin.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace Ui { From 8bd4794b320025c36bb5e44fb708f54f663c6a7c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 12:48:28 +0100 Subject: [PATCH 148/313] Make RLP JSON compatible by default. --- rlp/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 85c08e0e6..663bbf14d 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -36,6 +36,7 @@ void help() << " -r,--render Render the given RLP. Options:" << endl << " --indent Use string as the level indentation (default ' ')." << endl << " --hex-ints Render integers in hex." << endl + << " --ascii-strings Render data as C-style strings or hex depending on content being ASCII." << endl << " --force-string Force all data to be rendered as C-style strings." << endl << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl << " --force-hex Force all data to be rendered as raw hex." << endl @@ -86,7 +87,7 @@ public: { string indent = " "; bool hexInts = false; - bool forceString = false; + bool forceString = true; bool escapeAll = false; bool forceHex = false; }; @@ -150,6 +151,8 @@ int main(int argc, char** argv) prefs.indent = argv[++i]; else if (arg == "--hex-ints") prefs.hexInts = true; + else if (arg == "--ascii-strings") + prefs.forceString = prefs.forceHex = false; else if (arg == "--force-string") prefs.forceString = true; else if (arg == "--force-hex") From e6e67e08158b8fb90fb448d4176bca5ca2aaa85b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 15:58:20 +0100 Subject: [PATCH 149/313] For Marek :) BlockChain::transaction(h256 _transactionHash) BlockChain::transactionHashes(h256 _blockHash) --- alethzero/MainWin.cpp | 5 +- libethcore/BlockInfo.h | 1 + libethcore/Ethasher.cpp | 115 +++++++++++++++++++++++++++++++++++++ libethcore/Ethasher.h | 97 +++++++++++++++++++++++++++++++ libethcore/ProofOfWork.cpp | 98 ++----------------------------- libethcore/ProofOfWork.h | 10 ---- libethereum/BlockChain.cpp | 6 ++ libethereum/BlockChain.h | 14 ++++- libethereum/BlockDetails.h | 14 +++++ test/dagger.cpp | 76 +++++++++++++++++------- 10 files changed, 308 insertions(+), 128 deletions(-) create mode 100644 libethcore/Ethasher.cpp create mode 100644 libethcore/Ethasher.h diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index e6f380e47..3c5dcf25a 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -36,6 +36,7 @@ #endif #include #include +#include #include #include #include @@ -1365,7 +1366,7 @@ void Main::on_blocks_currentItemChanged() s << "
Difficulty: " << info.difficulty << ""; if (info.number) { - auto e = ProofOfWork::eval(info); + auto e = Ethasher::eval(info); s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } else @@ -1389,7 +1390,7 @@ void Main::on_blocks_currentItemChanged() s << line << "Nonce: " << uncle.nonce << ""; s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; s << line << "Difficulty: " << uncle.difficulty << ""; - auto e = ProofOfWork::eval(uncle); + auto e = Ethasher::eval(uncle); s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index a119d92eb..95519b57d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -85,6 +85,7 @@ public: static h256 headerHash(bytes const& _block) { return headerHash(&_block); } static h256 headerHash(bytesConstRef _block); + static BlockInfo fromHeader(bytes const& _block) { return fromHeader(bytesConstRef(&_block)); } static BlockInfo fromHeader(bytesConstRef _block); explicit operator bool() const { return timestamp != Invalid256; } diff --git a/libethcore/Ethasher.cpp b/libethcore/Ethasher.cpp new file mode 100644 index 000000000..a28895a1a --- /dev/null +++ b/libethcore/Ethasher.cpp @@ -0,0 +1,115 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file Ethasher.cpp + * @author Gav Wood + * @date 2014 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "BlockInfo.h" +#include "Ethasher.h" +using namespace std; +using namespace chrono; +using namespace dev; +using namespace eth; + +Ethasher* dev::eth::Ethasher::s_this = nullptr; + +bytes const& Ethasher::cache(BlockInfo const& _header) +{ + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; +} + +bytesConstRef Ethasher::full(BlockInfo const& _header) +{ + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash]; +} + +ethash_params Ethasher::params(BlockInfo const& _header) +{ + return params((unsigned)_header.number); +} + +ethash_params Ethasher::params(unsigned _n) +{ + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; +} + +bool Ethasher::verify(BlockInfo const& _header) +{ + bigint boundary = (bigint(1) << 256) / _header.difficulty; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; +} + +Ethasher::Result Ethasher::eval(BlockInfo const& _header, Nonce const& _nonce) +{ + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; +} + diff --git a/libethcore/Ethasher.h b/libethcore/Ethasher.h new file mode 100644 index 000000000..cfe0d1c82 --- /dev/null +++ b/libethcore/Ethasher.h @@ -0,0 +1,97 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file Ethasher.h + * @author Gav Wood + * @date 2014 + * + * ProofOfWork algorithm. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include // TODO: REMOVE once everything merged into this class and an opaque API can be provided. +#include "Common.h" +#include "BlockInfo.h" + +namespace dev +{ +namespace eth +{ + +class Ethasher +{ +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header); + bytesConstRef full(BlockInfo const& _header); + static ethash_params params(BlockInfo const& _header); + static ethash_params params(unsigned _n); + + struct Result + { + h256 value; + h256 mixHash; + }; + + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); + static bool verify(BlockInfo const& _header); + + class Miner + { + public: + Miner(BlockInfo const& _header): + m_headerHash(_header.headerHash(WithoutNonce)), + m_params(Ethasher::params(_header)), + m_datasetPointer(Ethasher::get()->full(_header).data()) + {} + + inline h256 mine(uint64_t _nonce) + { + ethash_compute_full(&m_ethashReturn, m_datasetPointer, &m_params, m_headerHash.data(), _nonce); + return h256(m_ethashReturn.result, h256::ConstructFromPointer); + } + + inline h256 lastMixHash() const + { + return h256(m_ethashReturn.mix_hash, h256::ConstructFromPointer); + } + + private: + ethash_return_value m_ethashReturn; + h256 m_headerHash; + ethash_params m_params; + void const* m_datasetPointer; + }; + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; + +} +} diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..d261ccb1c 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -30,8 +30,8 @@ #include #include #include -#include #include "BlockInfo.h" +#include "Ethasher.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -41,100 +41,14 @@ namespace dev namespace eth { -class Ethasher -{ -public: - Ethasher() {} - - static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } - - bytes const& cache(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_caches.count(_header.seedHash)) - { - try { - boost::filesystem::create_directories(getDataDir() + "/ethashcache"); - } catch (...) {} - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; - m_caches[_header.seedHash] = contents(memoFile); - if (m_caches[_header.seedHash].empty()) - { - ethash_params p = params((unsigned)_header.number); - m_caches[_header.seedHash].resize(p.cache_size); - ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); - writeFile(memoFile, m_caches[_header.seedHash]); - } - } - return m_caches[_header.seedHash]; - } - - byte const* full(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_fulls.count(_header.seedHash)) - { - if (!m_fulls.empty()) - { - delete [] m_fulls.begin()->second.data(); - m_fulls.erase(m_fulls.begin()); - } - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; - m_fulls[_header.seedHash] = contentsNew(memoFile); - if (!m_fulls[_header.seedHash]) - { - ethash_params p = params((unsigned)_header.number); - m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); - auto c = cache(_header); - ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); - writeFile(memoFile, m_fulls[_header.seedHash]); - } - } - return m_fulls[_header.seedHash].data(); - } - - static ethash_params params(BlockInfo const& _header) - { - return params((unsigned)_header.number); - } - - static ethash_params params(unsigned _n) - { - ethash_params p; - p.cache_size = ethash_get_cachesize(_n); - p.full_size = ethash_get_datasize(_n); - return p; - } - -private: - static Ethasher* s_this; - RecursiveMutex x_this; - std::map m_caches; - std::map m_fulls; -}; - -Ethasher* Ethasher::s_this = nullptr; - bool Ethash::verify(BlockInfo const& _header) { - bigint boundary = (bigint(1) << 256) / _header.difficulty; - auto e = eval(_header, _header.nonce); - return (u256)e.value <= boundary && e.mixHash == _header.mixHash; -} - -Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) -{ - auto p = Ethasher::params(_header); - ethash_return_value r; - ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; + return Ethasher::verify(_header); } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - auto h = _header.headerHash(WithoutNonce); - auto p = Ethasher::params(_header); - auto d = Ethasher::get()->full(_header); + Ethasher::Miner m(_header); std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); @@ -152,17 +66,15 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) Proof result; - ethash_return_value ethashReturn; unsigned hashCount = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); - u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + u256 val(m.mine(tryNonce)); best = std::min(best, log2((double)val)); if (val <= boundary) { ret.first.completed = true; - result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); + result.mixHash = m.lastMixHash(); result.nonce = u64(tryNonce); break; } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7006f6f61..250ddb73d 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -49,20 +49,12 @@ struct MineInfo class Ethash { public: - // bit-compatible with ethash_return_value struct Proof { Nonce nonce; h256 mixHash; }; - struct Result - { - h256 value; - h256 mixHash; - }; - static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } @@ -78,9 +70,7 @@ public: using Proof = Nonce; static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } - inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } protected: diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index d5c5e710c..30e9e4204 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -307,7 +307,13 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); #if ETH_PARANOIA checkConsistency(); diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index dbcab2580..58bd7bf38 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -34,6 +34,7 @@ #include #include "BlockDetails.h" #include "Account.h" +#include "Transaction.h" #include "BlockQueue.h" namespace ldb = leveldb; @@ -61,6 +62,8 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using TransactionHashes = h256s; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -108,12 +111,19 @@ public: BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } BlockReceipts receipts() const { return receipts(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } + TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. bytes block(h256 _hash) const; bytes block() const { return block(currentHash()); } + /// Get a transaction from its hash. Thread-safe. + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. - bytes transaction(h256 _hash, unsigned _i) const { bytes b = block(_hash); return RLP(b)[1][_i].data().toBytes(); } + bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } bytes transaction(unsigned _i) const { return transaction(currentHash(), _i); } /// Get a number for the given hash (or the most recent mined if none given). Thread-safe. @@ -185,6 +195,8 @@ private: mutable BlockLogBloomsHash m_logBlooms; mutable boost::shared_mutex x_receipts; mutable BlockReceiptsHash m_receipts; + mutable boost::shared_mutex x_transactionAddresses; + mutable TransactionAddressHash m_transactionAddresses; mutable boost::shared_mutex x_cache; mutable std::map m_cache; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 9a3ac9ff1..b59d165ab 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -70,13 +70,27 @@ struct BlockReceipts TransactionReceipts receipts; }; +struct TransactionAddress +{ + TransactionAddress() {} + TransactionAddress(RLP const& _rlp) { blockHash = _rlp[0].toHash(); index = _rlp[1].toInt(); } + bytes rlp() const { RLPStream s(2); s << blockHash << index; return s.out(); } + + explicit operator bool() const { return !!blockHash; } + + h256 blockHash; + unsigned index = 0; +}; + using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; +using TransactionAddressHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; +static const TransactionAddress NullTransactionAddress; } } diff --git a/test/dagger.cpp b/test/dagger.cpp index 87c49bd7d..dec753fe7 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -17,37 +17,69 @@ /** @file dagger.cpp * @author Gav Wood * @date 2014 - * ProofOfWork test functions. + * Dashimoto test functions. */ -#include -#include +#include +#include +#include "JsonSpiritHeaders.h" +#include #include +#include +#include +#include "TestHelper.h" + using namespace std; -using namespace std::chrono; using namespace dev; using namespace dev::eth; -int daggerTest() +namespace js = json_spirit; + +using dev::operator <<; + +BOOST_AUTO_TEST_SUITE(DashimotoTests) + +BOOST_AUTO_TEST_CASE(basic_test) { -#if 0 - cnote << "Testing ProofOfWork..."; - // Test dagger - { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + string testPath = test::getTestPath(); + + testPath += "/PoWTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/ethash_tests.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'ethash_tests.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + BlockInfo header = BlockInfo::fromHeader(fromHex(o["header"].get_str())); + 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); + + unsigned cacheSize(o["cache_size"].get_int()); + h256 cacheHash(o["cache_hash"].get_str()); + BOOST_REQUIRE_EQUAL(Ethasher::get()->cache(header).size(), cacheSize); + BOOST_REQUIRE_EQUAL(sha3(Ethasher::get()->cache(header)), cacheHash); + +#if TEST_FULL + unsigned fullSize(o["full_size"].get_int()); + h256 fullHash(o["full_hash"].get_str()); + BOOST_REQUIRE_EQUAL(Ethasher::get()->full(header).size(), fullSize); + BOOST_REQUIRE_EQUAL(sha3(Ethasher::get()->full(header)), fullHash); #endif - return 0; + + h256 result(o["result"].get_str()); + Ethasher::Result r = Ethasher::eval(header); + BOOST_REQUIRE_EQUAL(r.value, result); + BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash); + } } +BOOST_AUTO_TEST_SUITE_END() + + From 768bc2d98407c8e45a00b0996439ef31c58bb9c8 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 19:38:31 +0100 Subject: [PATCH 150/313] Fast block hash from number. --- libethcore/Common.cpp | 9 +++-- libethereum/BlockChain.cpp | 79 ++++++++++++++++++++------------------ libethereum/BlockChain.h | 52 ++++++++++++++++++------- libethereum/BlockDetails.h | 11 ++++++ libethereum/Client.cpp | 11 +++++- libethereum/Client.h | 1 + libethereum/Miner.h | 3 ++ 7 files changed, 111 insertions(+), 55 deletions(-) diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 65c0b8b92..9eb622fe3 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,13 +33,14 @@ namespace eth { const unsigned c_protocolVersion = 56; -const unsigned c_databaseVersion = 6 + +const unsigned c_databaseBaseVersion = 7; #if ETH_FATDB - 1000 +const unsigned c_databaseVersionModifier = 1000; #else - 0 +const unsigned c_databaseVersionModifier = 0; #endif -; + +const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier; vector> const& units() { diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 30e9e4204..65a55880c 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -45,7 +45,7 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_db->NewIterator(_bc.m_readOptions); + auto it = _bc.m_blocksDB->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { @@ -102,9 +102,9 @@ void BlockChain::open(std::string _path, bool _killExisting) ldb::Options o; o.create_if_missing = true; - ldb::DB::Open(o, _path + "/blocks", &m_db); + ldb::DB::Open(o, _path + "/blocks", &m_blocksDB); ldb::DB::Open(o, _path + "/details", &m_extrasDB); - if (!m_db) + if (!m_blocksDB) BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); if (!m_extrasDB) BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); @@ -132,10 +132,10 @@ void BlockChain::close() { cnote << "Closing blockchain DB"; delete m_extrasDB; - delete m_db; + delete m_blocksDB; m_lastBlockHash = m_genesisHash; m_details.clear(); - m_cache.clear(); + m_blocks.clear(); } template @@ -294,6 +294,23 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_details[newHash] = BlockDetails((unsigned)pd.number + 1, td, bi.parentHash, {}); m_details[bi.parentHash].children.push_back(newHash); } + { + WriteGuard l(x_blockHashes); + m_blockHashes[h256(bi.number)].value = newHash; + } + // Collate transaction hashes and remember who they were. + h256s tas; + { + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + WriteGuard l(x_transactionAddresses); + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + { + tas.push_back(sha3(blockRLP[1][ta.index].data())); + m_transactionAddresses[tas.back()] = ta; + } + } { WriteGuard l(x_logBlooms); m_logBlooms[newHash] = blb; @@ -303,17 +320,14 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_receipts[newHash] = br; } - m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)dev::ref(m_details[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); - RLP blockRLP(_block); - TransactionAddress ta; - ta.blockHash = newHash; - for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) - m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); + m_blocksDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(h256(bi.number), ExtraBlockHash), (ldb::Slice)dev::ref(m_blockHashes[h256(bi.number)].rlp())); + for (auto const& h: tas) + m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraTransactionAddress), (ldb::Slice)dev::ref(m_transactionAddresses[h].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraLogBlooms), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraReceipts), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); #if ETH_PARANOIA checkConsistency(); @@ -406,7 +420,7 @@ void BlockChain::checkConsistency() WriteGuard l(x_details); m_details.clear(); } - ldb::Iterator* it = m_db->NewIterator(m_readOptions); + ldb::Iterator* it = m_blocksDB->NewIterator(m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().size() == 32) { @@ -449,12 +463,12 @@ bool BlockChain::isKnown(h256 _hash) const if (_hash == m_genesisHash) return true; { - ReadGuard l(x_cache); - if (m_cache.count(_hash)) + ReadGuard l(x_blocks); + if (m_blocks.count(_hash)) return true; } string d; - m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); + m_blocksDB->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); return !!d.size(); } @@ -464,14 +478,14 @@ bytes BlockChain::block(h256 _hash) const return m_genesisBlock; { - ReadGuard l(x_cache); - auto it = m_cache.find(_hash); - if (it != m_cache.end()) + ReadGuard l(x_blocks); + auto it = m_blocks.find(_hash); + if (it != m_blocks.end()) return it->second; } string d; - m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); + m_blocksDB->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); if (!d.size()) { @@ -479,18 +493,9 @@ bytes BlockChain::block(h256 _hash) const return bytes(); } - WriteGuard l(x_cache); - m_cache[_hash].resize(d.size()); - memcpy(m_cache[_hash].data(), d.data(), d.size()); - - return m_cache[_hash]; -} + WriteGuard l(x_blocks); + m_blocks[_hash].resize(d.size()); + memcpy(m_blocks[_hash].data(), d.data(), d.size()); -h256 BlockChain::numberHash(unsigned _n) const -{ - if (!_n) - return genesisHash(); - h256 ret = currentHash(); - for (; _n < details().number; ++_n, ret = details(ret).parent) {} - return ret; + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 58bd7bf38..62a5bf792 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -62,8 +62,17 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using BlocksHash = std::map; using TransactionHashes = h256s; +enum { + ExtraDetails = 0, + ExtraBlockHash, + ExtraTransactionAddress, + ExtraLogBlooms, + ExtraReceipts +}; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -99,28 +108,31 @@ public: BlockInfo info(h256 _hash) const { return BlockInfo(block(_hash)); } BlockInfo info() const { return BlockInfo(block()); } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. + bytes block(h256 _hash) const; + bytes block() const { return block(currentHash()); } + /// Get the familial details concerning a block (or the most recent mined if none given). Thread-safe. - BlockDetails details(h256 _hash) const { return queryExtras(_hash, m_details, x_details, NullBlockDetails); } + BlockDetails details(h256 _hash) const { return queryExtras(_hash, m_details, x_details, NullBlockDetails); } BlockDetails details() const { return details(currentHash()); } /// Get the transactions' log blooms of a block (or the most recent mined if none given). Thread-safe. - BlockLogBlooms logBlooms(h256 _hash) const { return queryExtras(_hash, m_logBlooms, x_logBlooms, NullBlockLogBlooms); } + BlockLogBlooms logBlooms(h256 _hash) const { return queryExtras(_hash, m_logBlooms, x_logBlooms, NullBlockLogBlooms); } BlockLogBlooms logBlooms() const { return logBlooms(currentHash()); } /// Get the transactions' receipts of a block (or the most recent mined if none given). Thread-safe. - BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } + BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } BlockReceipts receipts() const { return receipts(currentHash()); } /// Get a list of transaction hashes for a given block. Thread-safe. TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } - /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. - bytes block(h256 _hash) const; - bytes block() const { return block(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + h256 numberHash(u256 _index) const { if (!_index) return genesisHash(); return queryExtras(h256(_index), m_blockHashes, x_blockHashes, NullBlockHash).value; } /// Get a transaction from its hash. Thread-safe. - bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } @@ -136,9 +148,6 @@ public: /// Get the hash of the genesis block. Thread-safe. h256 genesisHash() const { return m_genesisHash; } - /// Get the hash of a block of a given number. Slow; try not to use it too much. - h256 numberHash(unsigned _n) const; - /// Get all blocks not allowed as uncles given a parent (i.e. featured as uncles/main in parent, parent + 1, ... parent + 5). /// @returns set including the header-hash of every parent (including @a _parent) up to and including generation +5 /// togther with all their quoted uncles. @@ -160,6 +169,21 @@ public: */ h256s treeRoute(h256 _from, h256 _to, h256* o_common = nullptr, bool _pre = true, bool _post = true) const; + struct Statistics + { + unsigned memDetails; + unsigned memLogBlooms; + unsigned memReceipts; + unsigned memTransactionAddresses; + unsigned memCache; + }; + + /// @returns statistics about memory usage. + Statistics usage() const; + + /// Deallocate unused data. + void garbageCollect(); + private: void open(std::string _path, bool _killExisting = false); void close(); @@ -189,6 +213,8 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. + mutable boost::shared_mutex x_blocks; + mutable BlocksHash m_blocks; mutable boost::shared_mutex x_details; mutable BlockDetailsHash m_details; mutable boost::shared_mutex x_logBlooms; @@ -197,11 +223,11 @@ private: mutable BlockReceiptsHash m_receipts; mutable boost::shared_mutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_cache; - mutable std::map m_cache; + mutable boost::shared_mutex x_blockHashes; + mutable BlockHashHash m_blockHashes; /// The disk DBs. Thread-safe, so no need for locks. - ldb::DB* m_db; + ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; /// Hash of the last (valid) block on the longest chain. diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index b59d165ab..f9bccea1e 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -70,6 +70,15 @@ struct BlockReceipts TransactionReceipts receipts; }; +struct BlockHash +{ + BlockHash() {} + BlockHash(RLP const& _r) { value = _r.toHash(); } + bytes rlp() const { return dev::rlp(value); } + + h256 value; +}; + struct TransactionAddress { TransactionAddress() {} @@ -86,11 +95,13 @@ using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; using TransactionAddressHash = std::map; +using BlockHashHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; static const TransactionAddress NullTransactionAddress; +static const BlockHash NullBlockHash; } } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index e27be90e0..570f5fc41 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -517,9 +517,18 @@ void Client::doWork() { if (m.isComplete()) { - cwork << "CHAIN <== postSTATE"; + // TODO: enable a short-circuit option since we mined it. will need to get the end state from the miner. + auto lm = dynamic_cast(&m); h256s hs; + if (false && lm && !m_verifyOwnBlocks) { + // TODO: implement + //m_bc.attemptImport(m_blockData(), m_stateDB, lm->state()); + // TODO: derive hs from lm->state() + } + else + { + cwork << "CHAIN <== postSTATE"; WriteGuard l(x_stateDB); hs = m_bc.attemptImport(m.blockData(), m_stateDB); } diff --git a/libethereum/Client.h b/libethereum/Client.h index c4f2b3705..02fc8b91b 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -359,6 +359,7 @@ private: bool m_paranoia = false; ///< Should we be paranoid about our state? bool m_turboMining = false; ///< Don't squander all of our time mining actually just sleeping. bool m_forceMining = false; ///< Mine even when there are no transactions pending? + bool m_verifyOwnBlocks = true; ///< Shoudl be verify blocks that we mined? mutable Mutex m_filterLock; std::map m_filters; diff --git a/libethereum/Miner.h b/libethereum/Miner.h index bdd49abb9..45cf9944b 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -130,6 +130,9 @@ public: /// Get and clear the mining history. std::list miningHistory() { Guard l(x_mineInfo); auto ret = m_mineHistory; m_mineHistory.clear(); return ret; } + /// @returns the state on which we mined. + State const& state() const { return m_mineState; } + private: /// Do some work on the mining. virtual void doWork(); From b132c44ab05c6c646a0dc69233676c77986ee2cf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 21:19:21 +0100 Subject: [PATCH 151/313] Caching. --- alethzero/Main.ui | 7 ++ alethzero/MainWin.cpp | 8 +++ alethzero/MainWin.h | 1 + libethereum/BlockChain.cpp | 124 +++++++++++++++++++++++++++++++++++ libethereum/BlockChain.h | 34 +++++++--- libethereum/BlockDetails.cpp | 5 +- libethereum/BlockDetails.h | 17 +++-- libethereum/Client.cpp | 1 + 8 files changed, 181 insertions(+), 16 deletions(-) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index 9025aa846..8f6597ca5 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -38,6 +38,13 @@ + + + + 0 bytes used + + + diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 3c5dcf25a..978676795 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -137,6 +137,7 @@ Main::Main(QWidget *parent) : ui->configDock->close(); on_verbosity_valueChanged(); + statusBar()->addPermanentWidget(ui->cacheUsage); statusBar()->addPermanentWidget(ui->balance); statusBar()->addPermanentWidget(ui->peerCount); statusBar()->addPermanentWidget(ui->mineStatus); @@ -1140,6 +1141,12 @@ void Main::on_refresh_triggered() refreshAll(); } +void Main::refreshCache() +{ + BlockChain::Statistics s = ethereum()->blockChain().usage(); + ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); +} + void Main::timerEvent(QTimerEvent*) { // 7/18, Alex: aggregating timers, prelude to better threading? @@ -1168,6 +1175,7 @@ void Main::timerEvent(QTimerEvent*) interval = 0; refreshNetwork(); refreshWhispers(); + refreshCache(); poll(); } else diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 072911ff7..487272a7a 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -211,6 +211,7 @@ private: void refreshNetwork(); void refreshMining(); void refreshWhispers(); + void refreshCache(); void refreshAll(); void refreshPending(); diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 65a55880c..f4a5acea9 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -75,8 +75,33 @@ ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub) #endif } +#if ETH_DEBUG +static const chrono::system_clock::duration c_collectionDuration = chrono::seconds(15); +static const unsigned c_collectionQueueSize = 2; +static const unsigned c_maxCacheSize = 1024 * 1024 * 1; +static const unsigned c_minCacheSize = 1; +#else + +/// Duration between flushes. +static const chrono::system_clock::duration c_collectionDuration = chrono::seconds(60); + +/// Length of death row (total time in cache is multiple of this and collection duration). +static const unsigned c_collectionQueueSize = 20; + +/// Max size, above which we start forcing cache reduction. +static const unsigned c_maxCacheSize = 1024 * 1024 * 64; + +/// Min size, below which we don't bother flushing it. +static const unsigned c_minCacheSize = 1024 * 1024 * 32; + +#endif + BlockChain::BlockChain(bytes const& _genesisBlock, std::string _path, bool _killExisting) { + // initialise deathrow. + m_cacheUsage.resize(c_collectionQueueSize); + m_lastCollection = chrono::system_clock::now(); + // Initialise with the genesis as the last block on the longest chain. m_genesisBlock = _genesisBlock; m_genesisHash = sha3(RLP(m_genesisBlock)[0].data()); @@ -414,6 +439,103 @@ h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, boo return ret; } +void BlockChain::noteUsed(h256 const& _h, unsigned _extra) const +{ + auto id = CacheID(_h, _extra); + Guard l(x_cacheUsage); + m_cacheUsage[0].insert(id); + if (m_cacheUsage[1].count(id)) + m_cacheUsage[1].erase(id); + else + m_inUse.insert(id); +} + +template static unsigned getHashSize(map const& _map) +{ + unsigned ret = 0; + for (auto const& i: _map) + ret += i.second.size + 64; + return ret; +} + +void BlockChain::updateStats() const +{ + { + ReadGuard l1(x_blocks); + m_lastStats.memBlocks = 0; + for (auto const& i: m_blocks) + m_lastStats.memBlocks += i.second.size() + 64; + } + { + ReadGuard l2(x_details); + m_lastStats.memDetails = getHashSize(m_details); + } + { + ReadGuard l5(x_logBlooms); + m_lastStats.memLogBlooms = getHashSize(m_logBlooms); + } + { + ReadGuard l4(x_receipts); + m_lastStats.memReceipts = getHashSize(m_receipts); + } + { + ReadGuard l3(x_blockHashes); + m_lastStats.memBlockHashes = getHashSize(m_blockHashes); + } + { + ReadGuard l6(x_transactionAddresses); + m_lastStats.memTransactionAddresses = getHashSize(m_transactionAddresses); + } +} + +void BlockChain::garbageCollect(bool _force) +{ + updateStats(); + + if (!_force && chrono::system_clock::now() < m_lastCollection + c_collectionDuration && m_lastStats.memTotal() < c_maxCacheSize) + return; + if (m_lastStats.memTotal() < c_minCacheSize) + return; + + m_lastCollection = chrono::system_clock::now(); + + Guard l(x_cacheUsage); + WriteGuard l1(x_blocks); + WriteGuard l2(x_details); + WriteGuard l3(x_blockHashes); + WriteGuard l4(x_receipts); + WriteGuard l5(x_logBlooms); + WriteGuard l6(x_transactionAddresses); + for (CacheID const& id: m_cacheUsage.back()) + { + m_inUse.erase(id); + // kill i from cache. + switch (id.second) + { + case (unsigned)-1: + m_blocks.erase(id.first); + break; + case ExtraDetails: + m_details.erase(id.first); + break; + case ExtraBlockHash: + m_blockHashes.erase(id.first); + break; + case ExtraReceipts: + m_receipts.erase(id.first); + break; + case ExtraLogBlooms: + m_logBlooms.erase(id.first); + break; + case ExtraTransactionAddress: + m_transactionAddresses.erase(id.first); + break; + } + } + m_cacheUsage.pop_back(); + m_cacheUsage.push_front({}); +} + void BlockChain::checkConsistency() { { @@ -497,5 +619,7 @@ bytes BlockChain::block(h256 _hash) const m_blocks[_hash].resize(d.size()); memcpy(m_blocks[_hash].data(), d.data(), d.size()); + noteUsed(_hash); + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 62a5bf792..20c41b553 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -26,7 +26,7 @@ #include #pragma warning(pop) -#include +#include #include #include #include @@ -171,18 +171,20 @@ public: struct Statistics { + unsigned memBlocks; unsigned memDetails; unsigned memLogBlooms; unsigned memReceipts; unsigned memTransactionAddresses; - unsigned memCache; + unsigned memBlockHashes; + unsigned memTotal() const { return memBlocks + memDetails + memLogBlooms + memReceipts + memTransactionAddresses + memBlockHashes; } }; /// @returns statistics about memory usage. - Statistics usage() const; + Statistics usage(bool _freshen = false) const { if (_freshen) updateStats(); return m_lastStats; } /// Deallocate unused data. - void garbageCollect(); + void garbageCollect(bool _force = false); private: void open(std::string _path, bool _killExisting = false); @@ -205,6 +207,8 @@ private: return _n; } + noteUsed(_h, N); + WriteGuard l(_x); auto ret = _m.insert(std::make_pair(_h, T(RLP(s)))); return ret.first->second; @@ -213,19 +217,29 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. - mutable boost::shared_mutex x_blocks; + mutable SharedMutex x_blocks; mutable BlocksHash m_blocks; - mutable boost::shared_mutex x_details; + mutable SharedMutex x_details; mutable BlockDetailsHash m_details; - mutable boost::shared_mutex x_logBlooms; + mutable SharedMutex x_logBlooms; mutable BlockLogBloomsHash m_logBlooms; - mutable boost::shared_mutex x_receipts; + mutable SharedMutex x_receipts; mutable BlockReceiptsHash m_receipts; - mutable boost::shared_mutex x_transactionAddresses; + mutable SharedMutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_blockHashes; + mutable SharedMutex x_blockHashes; mutable BlockHashHash m_blockHashes; + using CacheID = std::pair; + mutable Mutex x_cacheUsage; + mutable std::deque> m_cacheUsage; + mutable std::set m_inUse; + void noteUsed(h256 const& _h, unsigned _extra = (unsigned)-1) const; + std::chrono::system_clock::time_point m_lastCollection; + + void updateStats() const; + mutable Statistics m_lastStats; + /// The disk DBs. Thread-safe, so no need for locks. ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; diff --git a/libethereum/BlockDetails.cpp b/libethereum/BlockDetails.cpp index 58f37b7aa..c15939fdb 100644 --- a/libethereum/BlockDetails.cpp +++ b/libethereum/BlockDetails.cpp @@ -32,9 +32,12 @@ BlockDetails::BlockDetails(RLP const& _r) totalDifficulty = _r[1].toInt(); parent = _r[2].toHash(); children = _r[3].toVector(); + size = _r.size(); } bytes BlockDetails::rlp() const { - return rlpList(number, totalDifficulty, parent, children); + auto ret = rlpList(number, totalDifficulty, parent, children); + size = ret.size(); + return ret; } diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index f9bccea1e..ed478568d 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -46,28 +46,32 @@ struct BlockDetails bool isNull() const { return !totalDifficulty; } explicit operator bool() const { return !isNull(); } - unsigned number; // TODO: remove? + unsigned number; u256 totalDifficulty; h256 parent; h256s children; + + mutable unsigned size; }; struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } - bytes rlp() const { RLPStream s; s << blooms; return s.out(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); size = _r.data().size(); } + bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } LogBlooms blooms; + mutable unsigned size; }; struct BlockReceipts { BlockReceipts() {} - BlockReceipts(RLP const& _r) { for (auto const& i: _r) receipts.emplace_back(i.data()); } - bytes rlp() const { RLPStream s(receipts.size()); for (TransactionReceipt const& i: receipts) i.streamRLP(s); return s.out(); } + BlockReceipts(RLP const& _r) { for (auto const& i: _r) receipts.emplace_back(i.data()); size = _r.data().size(); } + bytes rlp() const { RLPStream s(receipts.size()); for (TransactionReceipt const& i: receipts) i.streamRLP(s); size = s.out().size(); return s.out(); } TransactionReceipts receipts; + mutable unsigned size; }; struct BlockHash @@ -77,6 +81,7 @@ struct BlockHash bytes rlp() const { return dev::rlp(value); } h256 value; + static const unsigned size = 65; }; struct TransactionAddress @@ -89,6 +94,8 @@ struct TransactionAddress h256 blockHash; unsigned index = 0; + + static const unsigned size = 67; }; using BlockDetailsHash = std::map; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 570f5fc41..ca0b60375 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -630,6 +630,7 @@ void Client::doWork() uninstallWatch(i); m_lastGarbageCollection = chrono::system_clock::now(); } + m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From ee10c2afaf0d5e0422cf401c4b630d2b6f2a179e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 22:42:34 +0100 Subject: [PATCH 152/313] Cache reporting in AZ. --- alethzero/MainWin.cpp | 34 +++++++++++++++++++++++++++++++++- libethereum/Client.cpp | 7 +++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 978676795..a155207ba 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1141,10 +1141,42 @@ void Main::on_refresh_triggered() refreshAll(); } +static std::string niceUsed(unsigned _n) +{ + static const vector c_units = { "bytes", "KB", "MB", "GB", "TB", "PB" }; + unsigned u = 0; + while (_n > 10240) + { + _n /= 1024; + u++; + } + if (_n > 1000) + return toString(_n / 1000) + "." + toString((min(949, _n % 1000) + 50) / 100) + " " + c_units[u + 1]; + else + return toString(_n) + " " + c_units[u]; +} + void Main::refreshCache() { BlockChain::Statistics s = ethereum()->blockChain().usage(); - ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); + QString t; + auto f = [&](unsigned n, QString l) + { + t += ("%1 " + l).arg(QString::fromStdString(niceUsed(n))); + }; + f(s.memTotal(), "total"); + t += " ("; + f(s.memBlocks, "blocks"); + t += ", "; + f(s.memReceipts, "receipts"); + t += ", "; + f(s.memLogBlooms, "blooms"); + t += ", "; + f(s.memBlockHashes + s.memTransactionAddresses, "hashes"); + t += ", "; + f(s.memDetails, "family"); + t += ")"; + ui->cacheUsage->setText(t); } void Main::timerEvent(QTimerEvent*) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index ca0b60375..4c6bd2d58 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -615,7 +615,7 @@ void Client::doWork() this_thread::sleep_for(chrono::milliseconds(100)); if (chrono::system_clock::now() - m_lastGarbageCollection > chrono::seconds(5)) { - // garbage collect on watches + // watches garbage collection vector toUninstall; { Guard l(m_filterLock); @@ -628,9 +628,12 @@ void Client::doWork() } for (auto i: toUninstall) uninstallWatch(i); + + // blockchain GC + m_bc.garbageCollect(); + m_lastGarbageCollection = chrono::system_clock::now(); } - m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From 689d13e0acea57c9370145f375acf20aba7ba798 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:11:24 +0100 Subject: [PATCH 153/313] add quadratic complexity tests --- test/state.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 8db082d0c..b18705148 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -169,23 +169,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -//{ -// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) -// { -// string arg = boost::unit_test::framework::master_test_suite().argv[i]; -// if (arg == "--quadratic" || arg == "--all") -// { -// auto start = chrono::steady_clock::now(); - -// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - -// auto end = chrono::steady_clock::now(); -// auto duration(chrono::duration_cast(end - start)); -// cnote << "test duration: " << duration.count() << " milliseconds.\n"; -// } -// } -//} +BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { From 112fb2dc971d57972a622212f8ec4af0757df174 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:12:51 +0100 Subject: [PATCH 154/313] add uncle header feature for fillers --- test/blockchain.cpp | 282 ++++++++++++++++++++++++++++---------------- 1 file changed, 182 insertions(+), 100 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 55c39f56b..a23a756b1 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -33,8 +33,10 @@ namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - - +BlockInfo constructBlock(mObject& _o); +void updatePoW(BlockInfo& _bi); +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); +RLPStream createFullBlockFromHeader(const BlockInfo& _bi, const bytes& _txs = RLPEmptyList, const bytes& _uncles = RLPEmptyList); void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -44,86 +46,47 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } + BlockInfo biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj()); BOOST_REQUIRE(o.count("pre")); - ImportTest importer(o["pre"].get_obj()); State state(Address(), OverlayDB(), BaseState::Empty); importer.importState(o["pre"].get_obj(), state); state.commit(); if (_fillin) - blockFromFields.stateRoot = state.rootHash(); + biGenesisBlock.stateRoot = state.rootHash(); else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + BOOST_CHECK_MESSAGE(biGenesisBlock.stateRoot == state.rootHash(), "root hash does not match"); if (_fillin) { // find new valid nonce - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(blockFromFields)) - { - ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, blockFromFields); - } + updatePoW(biGenesisBlock); //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); - o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); + writeBlockHeaderToJson(o["genesisBlockHeader"].get_obj(), biGenesisBlock); } // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); + RLPStream rlpGenesisBlock = createFullBlockFromHeader(biGenesisBlock); + biGenesisBlock.verifyInternals(&rlpGenesisBlock.out()); // construct blockchain - BlockChain bc(block.out(), string(), true); + BlockChain bc(rlpGenesisBlock.out(), string(), true); if (_fillin) { BOOST_REQUIRE(o.count("blocks")); mArray blArray; + vector vBiBlocks; for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); - BOOST_REQUIRE(blObj.count("transactions")); + // get txs TransactionQueue txs; - + BOOST_REQUIRE(blObj.count("transactions")); for (auto const& txObj: blObj["transactions"].get_array()) { mObject tx = txObj.get_obj(); @@ -132,6 +95,35 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "failed importing transaction\n"; } + // write uncle list + BlockQueue uncleBlockQueue; + mArray aUncleList; + vector vBiUncles; + + for (auto const& uHObj: blObj["uncleHeaders"].get_array()) + { + mObject uncleHeaderObj = uHObj.get_obj(); + BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); + + // make uncle header valid + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + uncleBlockFromFields.timestamp = (u256)time(0); + + updatePoW(uncleBlockFromFields); + writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); + + aUncleList.push_back(uncleHeaderObj); + vBiUncles.push_back(uncleBlockFromFields); + + cnote << "import uncle in blockQueue"; + RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields); + uncleBlockQueue.import(&uncle.out(), bc); + } + + blObj["uncleHeaders"] = aUncleList; + bc.sync(uncleBlockQueue, state.db(), 4); + state.commitToMine(bc); + try { state.sync(bc); @@ -152,6 +144,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) return; } + blObj["rlp"] = "0x" + toHex(state.blockData()); + // write valid txs mArray txArray; Transactions txList; @@ -174,46 +168,19 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } blObj["transactions"] = txArray; - blObj["rlp"] = "0x" + toHex(state.blockData()); BlockInfo current_BlockHeader = state.info(); - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - if (blObj.count("blockHeader")) - { overwriteBlockHeader(current_BlockHeader, blObj); - } // write block header - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); - oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); - oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); - oBlockHeader["hash"] = toString(current_BlockHeader.hash); - + writeBlockHeaderToJson(oBlockHeader, current_BlockHeader); blObj["blockHeader"] = oBlockHeader; + vBiBlocks.push_back(current_BlockHeader); - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - blObj["uncleHeaders"] = aUncleList; - - //txs: - + // compare blocks from state and from rlp RLPStream txStream; txStream.appendList(txList.size()); for (unsigned i = 0; i < txList.size(); ++i) @@ -223,13 +190,16 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txStream.appendRaw(txrlp.out()); } - RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + RLPStream uncleStream; + uncleStream.appendList(vBiUncles.size()); + for (unsigned i = 0; i < vBiUncles.size(); ++i) + { + RLPStream uncleRlp; + vBiUncles[i].streamRLP(uncleRlp, WithNonce); + uncleStream.appendRaw(uncleRlp.out()); + } - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); + RLPStream block2 = createFullBlockFromHeader(current_BlockHeader, txStream.out(), uncleStream.out()); blObj["rlp"] = "0x" + toHex(block2.out()); @@ -240,13 +210,14 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "txs mismatch\n"; if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; + cnote << "uncle list mismatch\n" << RLP(state.blockData())[2].data() << "\n" << RLP(block2.out())[2].data(); try { state.sync(bc); bc.import(block2.out(), state.db()); state.sync(bc); + state.commit(); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -392,12 +363,51 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } // check uncle list - BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + + // uncles from uncle list field + vector uBlHsFromField; + if (blObj["uncleHeaders"].type() != json_spirit::null_type) + { + for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) + { + mObject uBlH = uBlHeaderObj.get_obj(); + cout << "uBlH.size(): " << uBlH.size() << endl; + BOOST_REQUIRE(uBlH.size() == 17); + bytes uncleRLP = createBlockRLPFromFields(uBlH); + const RLP c_uRLP(uncleRLP); + BlockInfo uncleBlockHeader; + try + { + uncleBlockHeader.populateFromHeader(c_uRLP, true); + } + catch(...) + { + BOOST_ERROR("invalid uncle header"); + } + uBlHsFromField.push_back(uncleBlockHeader); + } + } + + // uncles from block RLP + vector uBlHsFromRlp; + for (auto const& uRLP: root[2]) + { + BlockInfo uBl; + uBl.populateFromHeader(uRLP, true); + uBlHsFromRlp.push_back(uBl); + } + + BOOST_REQUIRE_EQUAL(uBlHsFromField.size(), uBlHsFromRlp.size()); + + for (size_t i = 0; i < uBlHsFromField.size(); ++i) + BOOST_CHECK_MESSAGE(uBlHsFromField[i] == uBlHsFromRlp[i], "block header in rlp and in field do not match"); } } } } +// helping functions + bytes createBlockRLPFromFields(mObject& _tObj) { RLPStream rlpStream; @@ -529,31 +539,103 @@ void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) current_BlockHeader.populateFromHeader(c_bRLP, false); } } -} }// Namespace Close +BlockInfo constructBlock(mObject& _o) +{ -BOOST_AUTO_TEST_SUITE(BlockChainTests) + BlockInfo ret; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(_o); + const RLP c_bRLP(c_blockRLP); + ret.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch(...) + { + BOOST_ERROR("block population did throw an unknown exception\n"); + } + return ret; +} -BOOST_AUTO_TEST_CASE(bcBlockChainTest) +void updatePoW(BlockInfo& _bi) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(_bi)) + { + ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _bi); + } } -BOOST_AUTO_TEST_CASE(bcValidBlockTest) +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi) { - dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); + _o["parentHash"] = toString(_bi.parentHash); + _o["uncleHash"] = toString(_bi.sha3Uncles); + _o["coinbase"] = toString(_bi.coinbaseAddress); + _o["stateRoot"] = toString(_bi.stateRoot); + _o["transactionsTrie"] = toString(_bi.transactionsRoot); + _o["receiptTrie"] = toString(_bi.receiptsRoot); + _o["bloom"] = toString(_bi.logBloom); + _o["difficulty"] = toString(_bi.difficulty); + _o["number"] = toString(_bi.number); + _o["gasLimit"] = toString(_bi.gasLimit); + _o["gasUsed"] = toString(_bi.gasUsed); + _o["timestamp"] = toString(_bi.timestamp); + _o["extraData"] ="0x" + toHex(_bi.extraData); + _o["mixHash"] = toString(_bi.mixHash); + _o["seedHash"] = toString(_bi.seedHash); + _o["nonce"] = toString(_bi.nonce); + _o["hash"] = toString(_bi.hash); } -BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, const bytes& _uncles ) { - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); + RLPStream rlpStream; + _bi.streamRLP(rlpStream, WithNonce); + + RLPStream ret(3); + ret.appendRaw(rlpStream.out()); + ret.appendRaw(_txs); + ret.appendRaw(_uncles); + + return ret; } +} }// Namespace Close -//BOOST_AUTO_TEST_CASE(bcUncleTest) + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +//BOOST_AUTO_TEST_CASE(bcBlockChainTest) +//{ +// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcValidBlockTest) +//{ +// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) //{ -// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); //} +BOOST_AUTO_TEST_CASE(bcUncleTest) +{ + dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +} + BOOST_AUTO_TEST_CASE(userDefinedFileBc) { dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); From 1651deb65e42564c559349224eb252881c3c8b75 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:14:42 +0100 Subject: [PATCH 155/313] update blockchain test filler to new min diff and min gasLimit --- test/bcBlockChainTestFiller.json | 2 +- test/bcInvalidHeaderTestFiller.json | 56 ++++++++++++++--------------- test/bcValidBlockTestFiller.json | 32 ++++++++--------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 8a0bf89fe..b149f5938 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -3,7 +3,7 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index aa32dfbab..39a91a583 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -3,9 +3,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -59,9 +59,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,9 +115,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -170,9 +170,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -225,9 +225,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -280,9 +280,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -336,9 +336,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -391,9 +391,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -446,9 +446,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -501,9 +501,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -556,9 +556,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -611,9 +611,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -666,9 +666,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -721,9 +721,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 29b2e978e..14d4cfb2c 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -4,9 +4,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1024", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -51,9 +51,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,9 +97,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "1000000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -143,9 +143,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -189,9 +189,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -244,9 +244,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -299,9 +299,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -351,9 +351,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "0x0dddb6", + "gasLimit" : "125000", "gasUsed" : "100", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", From ca7bcdb242fc29c41ad572d7115a23bc00886574 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:16:17 +0100 Subject: [PATCH 156/313] add first uncle test --- test/bcUncleTestFiller.json | 73 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index 839e3ba46..d866b887c 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,9 +1,9 @@ { - "minDifficulty" : { + "oneUncle" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", @@ -54,24 +54,39 @@ "value" : "10" } ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], "uncleHeaders" : [ { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "2049", + "difficulty" : "131072", "extraData" : "0x", - "gasLimit" : "99804806", - "gasUsed" : "21000", - "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", - "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", - "nonce" : "17ed77999bef2e4b", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", "number" : "2", - "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", - "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", - "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", - "timestamp" : "1425490151", - "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] @@ -80,35 +95,19 @@ "transactions" : [ { "data" : "", - "gasLimit" : "8000000", - "gasPrice" : "0", - "nonce" : "2", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "3", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" } ], "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "1", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } ] - } + }, ] } + + } From 6b74f144fc2d680ac05c539b2bb2291e0fd282b2 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:19:48 +0100 Subject: [PATCH 157/313] style --- test/blockchain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index a23a756b1..ec9f7b68d 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -367,7 +367,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // uncles from uncle list field vector uBlHsFromField; if (blObj["uncleHeaders"].type() != json_spirit::null_type) - { for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) { mObject uBlH = uBlHeaderObj.get_obj(); @@ -386,7 +385,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } uBlHsFromField.push_back(uncleBlockHeader); } - } // uncles from block RLP vector uBlHsFromRlp; From 94557bfaed23e90ebed8964f9f79cec229ddfdb7 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:32 +0100 Subject: [PATCH 158/313] style + add test cases --- test/blockchain.cpp | 108 ++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ec9f7b68d..e453e32ab 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -32,7 +32,7 @@ using namespace dev::eth; namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj); BlockInfo constructBlock(mObject& _o); void updatePoW(BlockInfo& _bi); void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); @@ -106,8 +106,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); // make uncle header valid - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); uncleBlockFromFields.timestamp = (u256)time(0); + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); @@ -462,79 +462,79 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj) { - if (blObj["blockHeader"].get_obj().size() != 14) + if (_blObj["blockHeader"].get_obj().size() != 14) { - BlockInfo tmp = current_BlockHeader; + BlockInfo tmp = _current_BlockHeader; - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(_blObj["blockHeader"].get_obj()["parentHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(_blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + if (_blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(_blObj["blockHeader"].get_obj()["coinbase"].get_str()); - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + if (_blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(_blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(_blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(_blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + if (_blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(_blObj["blockHeader"].get_obj()["bloom"].get_str()); - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + if (_blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(_blObj["blockHeader"].get_obj()["difficulty"]); - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + if (_blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(_blObj["blockHeader"].get_obj()["number"]); - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + if (_blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(_blObj["blockHeader"].get_obj()["gasLimit"]); - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + if (_blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(_blObj["blockHeader"].get_obj()["gasUsed"]); - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + if (_blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(_blObj["blockHeader"].get_obj()["timestamp"]); - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (_blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(_blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(_blObj["blockHeader"].get_obj()["mixHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(_blObj["blockHeader"].get_obj()["seedHash"].get_str()); // find new valid nonce - if (tmp != current_BlockHeader) + if (tmp != _current_BlockHeader) { - current_BlockHeader = tmp; + _current_BlockHeader = tmp; ProofOfWork pow; std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) + while (!ProofOfWork::verify(_current_BlockHeader)) { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); + ret = pow.mine(_current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _current_BlockHeader); } } } else { // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const bytes c_blockRLP = createBlockRLPFromFields(_blObj["blockHeader"].get_obj()); const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); + _current_BlockHeader.populateFromHeader(c_bRLP, false); } } @@ -614,20 +614,20 @@ RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, cons BOOST_AUTO_TEST_SUITE(BlockChainTests) -//BOOST_AUTO_TEST_CASE(bcBlockChainTest) -//{ -// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcValidBlockTest) -//{ -// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) -//{ -// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} BOOST_AUTO_TEST_CASE(bcUncleTest) { From e064237651a17d3706eca3f91910d1d3f0c9b46c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:49 +0100 Subject: [PATCH 159/313] add uncle tests --- test/bcUncleTestFiller.json | 348 +++++++++++++++++++++++++++++++++++- 1 file changed, 347 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index d866b887c..c0233ff91 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -90,6 +90,181 @@ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] + } + ] + }, + + "twoEqualUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "twoUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] }, { "transactions" : [ @@ -97,7 +272,91 @@ "data" : "", "gasLimit" : "80000050", "gasPrice" : "1", - "nonce" : "3", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "threeUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" @@ -106,6 +365,93 @@ "uncleHeaders" : [ ] }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "a55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } ] } From bad66fea5ce0cab6b6ca3da8b0a18090ee2f71fd Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 14:34:45 +0100 Subject: [PATCH 160/313] add secure trie tests --- test/trie.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/test/trie.cpp b/test/trie.cpp index bdb188651..8a2598211 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -196,6 +196,48 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } +BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -277,6 +319,69 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } +BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trietest_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + vector keysToBeDeleted; + for (auto& i: o["in"].get_array()) + { + vector values; + for (auto& s: i.get_array()) + { + if (s.type() == json_spirit::str_type) + values.push_back(s.get_str()); + else if (s.type() == json_spirit::null_type) + { + // mark entry for deletion + values.push_back(""); + if (!values[0].find("0x")) + values[0] = asString(fromHex(values[0].substr(2))); + keysToBeDeleted.push_back(values[0]); + } + else + BOOST_FAIL("Bad type (expected string)"); + } + + BOOST_REQUIRE(values.size() == 2); + ss.push_back(make_pair(values[0], values[1])); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) + t.remove(k.first); + else + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } +} + inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From 86862ba0e44d915ebdc9cc3799ed4593bc9b4e5f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:13:45 +0100 Subject: [PATCH 161/313] merge --- test/trie.cpp | 105 -------------------------------------------------- 1 file changed, 105 deletions(-) diff --git a/test/trie.cpp b/test/trie.cpp index 8a2598211..bdb188651 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -196,48 +196,6 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } -BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -319,69 +277,6 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } -BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trietest_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - vector keysToBeDeleted; - for (auto& i: o["in"].get_array()) - { - vector values; - for (auto& s: i.get_array()) - { - if (s.type() == json_spirit::str_type) - values.push_back(s.get_str()); - else if (s.type() == json_spirit::null_type) - { - // mark entry for deletion - values.push_back(""); - if (!values[0].find("0x")) - values[0] = asString(fromHex(values[0].substr(2))); - keysToBeDeleted.push_back(values[0]); - } - else - BOOST_FAIL("Bad type (expected string)"); - } - - BOOST_REQUIRE(values.size() == 2); - ss.push_back(make_pair(values[0], values[1])); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); - else - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } -} - inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From 8bc00bb74cb0df5219b5e26660f2353faadfb339 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:15:12 +0100 Subject: [PATCH 162/313] check for minGasLimit and minDifficulty when constructing block --- libethcore/BlockInfo.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 270f96b07..3b4878a7d 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -125,10 +125,16 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) BOOST_THROW_EXCEPTION(InvalidBlockNonce(headerHash(WithoutNonce), nonce, difficulty)); if (gasUsed > gasLimit) - BOOST_THROW_EXCEPTION(TooMuchGasUsed()); + BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(gasLimit), bigint(gasUsed)) ); + + if (difficulty < c_minimumDifficulty) + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); + + if (gasLimit < c_minGasLimit) + BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); if (number && extraData.size() > c_maximumExtraDataSize) - BOOST_THROW_EXCEPTION(ExtraDataTooBig()); + BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); } void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) @@ -207,7 +213,7 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) - BOOST_THROW_EXCEPTION(InvalidDifficulty()); + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError((bigint)calculateDifficulty(_parent), (bigint)difficulty)); if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) From 3e1ef9bd83afa92aa1c3f4c2c915cfc4a03b90c8 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:14:45 +0100 Subject: [PATCH 163/313] try to have a uncle with block number = 1 --- test/bcUncleTestFiller.json | 80 +++++++++++++++++++++++++++++++++++++ test/blockchain.cpp | 6 ++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index c0233ff91..e70f25bb4 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,4 +1,84 @@ { + "uncleHeaderAtBlock2" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + "oneUncle" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index e453e32ab..7f840bc76 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -80,6 +80,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_REQUIRE(o.count("blocks")); mArray blArray; vector vBiBlocks; + vBiBlocks.push_back(biGenesisBlock); for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); @@ -107,7 +108,10 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // make uncle header valid uncleBlockFromFields.timestamp = (u256)time(0); - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + if (vBiBlocks.size() > 2) + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + else + continue; updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); From 1ec262952a3927faf7c037f3bf51d0d271d0be8d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:16:11 +0100 Subject: [PATCH 164/313] fix --- test/bcUncleTestFiller.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index e70f25bb4..639051f2b 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -65,7 +65,7 @@ "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", "nonce" : "18a524c1790fa83b", - "number" : "2", + "number" : "1", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", From 2be4551a360f84c065a0f55e868539fa7d585f97 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 11:17:26 +0100 Subject: [PATCH 165/313] Don't use flawed way of generating random keys. --- libdevcore/FixedHash.cpp | 2 +- libdevcore/FixedHash.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdevcore/FixedHash.cpp b/libdevcore/FixedHash.cpp index 0369ea854..ae2d77c85 100644 --- a/libdevcore/FixedHash.cpp +++ b/libdevcore/FixedHash.cpp @@ -25,4 +25,4 @@ using namespace std; using namespace dev; -std::mt19937_64 dev::s_fixedHashEngine(time(0)); +std::random_device dev::s_fixedHashEngine; diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index b00a80c04..49c6ed2bf 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -31,7 +31,7 @@ namespace dev { -extern std::mt19937_64 s_fixedHashEngine; +extern std::random_device s_fixedHashEngine; /// Fixed-size raw-byte array container type, with an API optimised for storing hashes. /// Transparently converts to/from the corresponding arithmetic type; this will From 727fac4a3110322e979766bfd0b9769c5fe9ecba Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 11:57:07 +0100 Subject: [PATCH 166/313] Add the library until we figure out git subtree/submodule --- libethash/CMakeLists.txt | 39 +++++ libethash/compiler.h | 33 ++++ libethash/data_sizes.h | 247 ++++++++++++++++++++++++++++++ libethash/endian.h | 74 +++++++++ libethash/ethash.h | 93 +++++++++++ libethash/fnv.h | 38 +++++ libethash/internal.c | 298 ++++++++++++++++++++++++++++++++++++ libethash/internal.h | 48 ++++++ libethash/sha3.c | 151 ++++++++++++++++++ libethash/sha3.h | 27 ++++ libethash/sha3_cryptopp.cpp | 34 ++++ libethash/sha3_cryptopp.h | 15 ++ libethash/util.c | 41 +++++ libethash/util.h | 47 ++++++ 14 files changed, 1185 insertions(+) create mode 100644 libethash/CMakeLists.txt create mode 100644 libethash/compiler.h create mode 100644 libethash/data_sizes.h create mode 100644 libethash/endian.h create mode 100644 libethash/ethash.h create mode 100644 libethash/fnv.h create mode 100644 libethash/internal.c create mode 100644 libethash/internal.h create mode 100644 libethash/sha3.c create mode 100644 libethash/sha3.h create mode 100644 libethash/sha3_cryptopp.cpp create mode 100644 libethash/sha3_cryptopp.h create mode 100644 libethash/util.c create mode 100644 libethash/util.h diff --git a/libethash/CMakeLists.txt b/libethash/CMakeLists.txt new file mode 100644 index 000000000..7bc147af7 --- /dev/null +++ b/libethash/CMakeLists.txt @@ -0,0 +1,39 @@ +set(LIBRARY ethash) + +if (CPPETHEREUM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +#else () +endif () + +set(CMAKE_BUILD_TYPE Release) + +if (NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +endif() + +set(FILES util.c + util.h + internal.c + ethash.h + endian.h + compiler.h + fnv.h + data_sizes.h) + +if (NOT CRYPTOPP_FOUND) + find_package(CryptoPP 5.6.2) +endif() + +if (CRYPTOPP_FOUND) + add_definitions(-DWITH_CRYPTOPP) + include_directories( ${CRYPTOPP_INCLUDE_DIRS} ) + list(APPEND FILES sha3_cryptopp.cpp sha3_cryptopp.h) +else() + list(APPEND FILES sha3.c sha3.h) +endif() + +add_library(${LIBRARY} ${FILES}) + +if (CRYPTOPP_FOUND) + TARGET_LINK_LIBRARIES(${LIBRARY} ${CRYPTOPP_LIBRARIES}) +endif() diff --git a/libethash/compiler.h b/libethash/compiler.h new file mode 100644 index 000000000..9695871cd --- /dev/null +++ b/libethash/compiler.h @@ -0,0 +1,33 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file compiler.h + * @date 2014 + */ +#pragma once + +// Visual Studio doesn't support the inline keyword in C mode +#if defined(_MSC_VER) && !defined(__cplusplus) +#define inline __inline +#endif + +// pretend restrict is a standard keyword +#if defined(_MSC_VER) +#define restrict __restrict +#else +#define restrict __restrict__ +#endif + diff --git a/libethash/data_sizes.h b/libethash/data_sizes.h new file mode 100644 index 000000000..ccdf554a8 --- /dev/null +++ b/libethash/data_sizes.h @@ -0,0 +1,247 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software FoundationUUU,either version 3 of the LicenseUUU,or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be usefulU, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If notUUU,see . +*/ + +/** @file data_sizes.h +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +// TODO: Update this after ~3.5 years + +#pragma once + +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +// 500 Epochs worth of tabulated DAG sizes (~3.5 Years) + +// Generated with the following Mathematica Code: +// GetDataSizes[n_] := Module[{ +// DAGSizeBytesInit = 2^30, +// MixBytes = 128, +// DAGGrowth = 113000000, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = +// Floor[(DAGSizeBytesInit + DAGGrowth * j) / MixBytes]}, +// While[! PrimeQ[i], i--]; +// Sow[i*MixBytes]; j++]]]][[2]][[1]] + +static const size_t dag_sizes[] = { + 1073739904U, 1186739584U, 1299741568U, 1412741248U, 1525741696U, + 1638736768U, 1751741312U, 1864740736U, 1977740672U, 2090740864U, + 2203740544U, 2316741248U, 2429739392U, 2542740352U, 2655741824U, + 2768739712U, 2881740416U, 2994741632U, 3107740544U, 3220741504U, + 3333738112U, 3446741632U, 3559741312U, 3672740224U, 3785740928U, + 3898738304U, 4011741824U, 4124739712U, 4237735808U, 4350740864U, + 4463741824U, 4576741504U, 4689741184U, 4802739328U, 4915741568U, + 5028740224U, 5141740672U, 5254738304U, 5367741824U, 5480737664U, + 5593738112U, 5706741632U, 5819740544U, 5932734592U, 6045739904U, + 6158740096U, 6271740032U, 6384731776U, 6497732992U, 6610740352U, + 6723741056U, 6836741504U, 6949740416U, 7062740096U, 7175741824U, + 7288740224U, 7401741184U, 7514741632U, 7627741568U, 7740739712U, + 7853739136U, 7966740352U, 8079741568U, 8192739712U, 8305738624U, + 8418740864U, 8531740288U, 8644740736U, 8757735808U, 8870738816U, + 8983739264U, 9096740992U, 9209740928U, 9322739584U, 9435741824U, + 9548741504U, 9661739392U, 9774738304U, 9887741312U, 10000738688U, + 10113739136U, 10226741632U, 10339739776U, 10452741248U, 10565740928U, + 10678736512U, 10791734656U, 10904741248U, 11017738112U, 11130741632U, + 11243741312U, 11356739456U, 11469740416U, 11582734976U, 11695739008U, + 11808741248U, 11921734784U, 12034739072U, 12147741568U, 12260737408U, + 12373741696U, 12486738304U, 12599740544U, 12712740224U, 12825741184U, + 12938736256U, 13051741312U, 13164737408U, 13277738368U, 13390738048U, + 13503741824U, 13616741504U, 13729737088U, 13842740096U, 13955741312U, + 14068741504U, 14181740416U, 14294741632U, 14407739776U, 14520740224U, + 14633740928U, 14746736512U, 14859741824U, 14972740736U, 15085740928U, + 15198738304U, 15311732096U, 15424740736U, 15537739904U, 15650741632U, + 15763741568U, 15876737152U, 15989741696U, 16102740608U, 16215741056U, + 16328741248U, 16441740416U, 16554737792U, 16667740288U, 16780740992U, + 16893738112U, 17006741632U, 17119739008U, 17232735616U, 17345739392U, + 17458740352U, 17571736192U, 17684739712U, 17797739392U, 17910740096U, + 18023741312U, 18136740736U, 18249738112U, 18362738816U, 18475735424U, + 18588740224U, 18701738368U, 18814736768U, 18927737216U, 19040739968U, + 19153739648U, 19266736768U, 19379737984U, 19492739456U, 19605738368U, + 19718740352U, 19831741312U, 19944736384U, 20057741696U, 20170741376U, + 20283741824U, 20396737408U, 20509741696U, 20622741376U, 20735739008U, + 20848741504U, 20961740672U, 21074739328U, 21187740032U, 21300739456U, + 21413741696U, 21526740608U, 21639741824U, 21752737408U, 21865741696U, + 21978741376U, 22091741824U, 22204738432U, 22317740672U, 22430740096U, + 22543736704U, 22656741248U, 22769739904U, 22882739584U, 22995740288U, + 23108740736U, 23221740928U, 23334741376U, 23447737216U, 23560740992U, + 23673741184U, 23786740864U, 23899737728U, 24012741248U, 24125734784U, + 24238736512U, 24351741824U, 24464740736U, 24577737088U, 24690741632U, + 24803739776U, 24916740736U, 25029740416U, 25142740864U, 25255741568U, + 25368741248U, 25481740672U, 25594741376U, 25707741568U, 25820741504U, + 25933730432U, 26046739072U, 26159741824U, 26272741504U, 26385740672U, + 26498740096U, 26611741568U, 26724740992U, 26837739904U, 26950735232U, + 27063738496U, 27176741248U, 27289741184U, 27402740864U, 27515740544U, + 27628737152U, 27741740672U, 27854741632U, 27967740544U, 28080739712U, + 28193738368U, 28306741376U, 28419737728U, 28532739968U, 28645739648U, + 28758740096U, 28871741312U, 28984739456U, 29097740416U, 29210740864U, + 29323741312U, 29436740224U, 29549741696U, 29662738304U, 29775741568U, + 29888741504U, 30001740928U, 30114737024U, 30227735168U, 30340737664U, + 30453738368U, 30566737024U, 30679733632U, 30792740224U, 30905740928U, + 31018740352U, 31131740032U, 31244738944U, 31357737344U, 31470741376U, + 31583740544U, 31696740224U, 31809738112U, 31922739328U, 32035737472U, + 32148740992U, 32261741696U, 32374740352U, 32487741824U, 32600740736U, + 32713739648U, 32826740608U, 32939729792U, 33052740992U, 33165740672U, + 33278739584U, 33391741312U, 33504739712U, 33617740928U, 33730740608U, + 33843738496U, 33956739968U, 34069741696U, 34182739328U, 34295741824U, + 34408739968U, 34521740672U, 34634736512U, 34747741568U, 34860741248U, + 34973739392U, 35086738304U, 35199741056U, 35312736896U, 35425741184U, + 35538741376U, 35651740288U, 35764737152U, 35877741184U, 35990739584U, + 36103740544U, 36216740992U, 36329739392U, 36442737536U, 36555741568U, + 36668740736U, 36781741184U, 36894737024U, 37007741312U, 37120739456U, + 37233741184U, 37346736256U, 37459736192U, 37572734336U, 37685739904U, + 37798740352U, 37911737728U, 38024741504U, 38137739648U, 38250740608U, + 38363741824U, 38476740992U, 38589741184U, 38702740096U, 38815741312U, + 38928741248U, 39041738368U, 39154739584U, 39267741824U, 39380739712U, + 39493735808U, 39606741632U, 39719741312U, 39832741504U, 39945739648U, + 40058740352U, 40171740032U, 40284740992U, 40397740672U, 40510740352U, + 40623740288U, 40736738176U, 40849737856U, 40962741376U, 41075739776U, + 41188737664U, 41301735808U, 41414738048U, 41527741312U, 41640740992U, + 41753739904U, 41866739072U, 41979738496U, 42092740736U, 42205739648U, + 42318740608U, 42431741312U, 42544738688U, 42657741184U, 42770738048U, + 42883741568U, 42996741248U, 43109740928U, 43222736512U, 43335741056U, + 43448730496U, 43561740416U, 43674741632U, 43787740544U, 43900741504U, + 44013739648U, 44126740864U, 44239740544U, 44352741248U, 44465738368U, + 44578735232U, 44691739264U, 44804741504U, 44917741696U, 45030741376U, + 45143741824U, 45256740992U, 45369739136U, 45482740096U, 45595739776U, + 45708739712U, 45821740672U, 45934741376U, 46047741056U, 46160741248U, + 46273737088U, 46386740864U, 46499739008U, 46612739968U, 46725735296U, + 46838740864U, 46951741568U, 47064737152U, 47177741696U, 47290741376U, + 47403738752U, 47516741248U, 47629739648U, 47742741632U, 47855737984U, + 47968740224U, 48081738368U, 48194741632U, 48307739264U, 48420739712U, + 48533739136U, 48646738304U, 48759741824U, 48872741504U, 48985739392U, + 49098741376U, 49211741056U, 49324740992U, 49437738368U, 49550740864U, + 49663735424U, 49776737408U, 49889740672U, 50002738816U, 50115738752U, + 50228739712U, 50341741696U, 50454736768U, 50567738752U, 50680739968U, + 50793736832U, 50906734976U, 51019741568U, 51132739456U, 51245741696U, + 51358741376U, 51471741056U, 51584738944U, 51697734272U, 51810739072U, + 51923736448U, 52036740736U, 52149741184U, 52262737024U, 52375738496U, + 52488740992U, 52601739136U, 52714740352U, 52827736448U, 52940738176U, + 53053741696U, 53166740864U, 53279741824U, 53392741504U, 53505739136U, + 53618739584U, 53731741312U, 53844741248U, 53957741696U, 54070741376U, + 54183740288U, 54296741504U, 54409741696U, 54522739072U, 54635737472U, + 54748741504U, 54861736064U, 54974740096U, 55087741568U, 55200733568U, + 55313741696U, 55426734464U, 55539741056U, 55652741504U, 55765741184U, + 55878741376U, 55991730304U, 56104740992U, 56217740672U, 56330731648U, + 56443737472U, 56556724352U, 56669740672U, 56782739072U, 56895740032U, + 57008741248U, 57121741696U, 57234740096U, 57347741312U, 57460741504U +}; + +// 500 Epochs worth of tabulated DAG sizes (~3.5 Years) + +// Generated with the following Mathematica Code: +// GetCacheSizes[n_] := Module[{ +// DAGSizeBytesInit = 2^30, +// MixBytes = 128, +// DAGGrowth = 113000000, +// HashBytes = 64, +// DAGParents = 1024, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = Floor[(DAGSizeBytesInit + DAGGrowth * j) / (DAGParents * HashBytes)]}, +// While[! PrimeQ[i], i--]; +// Sow[i*HashBytes]; j++]]]][[2]][[1]] + +const size_t cache_sizes[] = { + 1048384U, 1158208U, 1268416U, 1377856U, 1489856U, 1599296U, 1710656U, + 1820608U, 1930816U, 2041024U, 2151872U, 2261696U, 2371904U, 2482624U, + 2593216U, 2703296U, 2814016U, 2924224U, 3034816U, 3144896U, 3255488U, + 3365312U, 3475904U, 3586624U, 3696064U, 3806272U, 3917504U, 4027456U, + 4138304U, 4248512U, 4359104U, 4469312U, 4579264U, 4689728U, 4797376U, + 4909888U, 5020096U, 5131328U, 5241664U, 5351744U, 5461312U, 5572544U, + 5683264U, 5793472U, 5903552U, 6014144U, 6121664U, 6235072U, 6344896U, + 6454592U, 6565952U, 6675904U, 6786112U, 6896704U, 7006784U, 7117888U, + 7228096U, 7338304U, 7448768U, 7557952U, 7669184U, 7779776U, 7889216U, + 8000192U, 8110912U, 8220736U, 8331712U, 8441536U, 8552384U, 8662592U, + 8772928U, 8883136U, 8993728U, 9103168U, 9214528U, 9323968U, 9434816U, + 9545152U, 9655616U, 9766336U, 9876544U, 9986624U, 10097344U, 10207424U, + 10316864U, 10427968U, 10538432U, 10649152U, 10758976U, 10869568U, 10979776U, + 11089472U, 11200832U, 11309632U, 11420608U, 11531584U, 11641792U, 11751104U, + 11862976U, 11973184U, 12083264U, 12193856U, 12304064U, 12414656U, 12524608U, + 12635072U, 12745792U, 12855616U, 12965824U, 13076416U, 13187008U, 13297216U, + 13407808U, 13518016U, 13627072U, 13738688U, 13848256U, 13959488U, 14069696U, + 14180288U, 14290624U, 14399552U, 14511424U, 14621504U, 14732096U, 14841664U, + 14951744U, 15062336U, 15172672U, 15283264U, 15393088U, 15504448U, 15614272U, + 15723712U, 15834944U, 15945152U, 16055744U, 16165696U, 16277056U, 16387136U, + 16494784U, 16607936U, 16718272U, 16828736U, 16938176U, 17048384U, 17159872U, + 17266624U, 17380544U, 17490496U, 17600192U, 17711296U, 17821376U, 17931968U, + 18041152U, 18152896U, 18261952U, 18373568U, 18483392U, 18594112U, 18703936U, + 18814912U, 18924992U, 19034944U, 19145408U, 19256128U, 19366208U, 19477184U, + 19587136U, 19696576U, 19808192U, 19916992U, 20028352U, 20137664U, 20249024U, + 20358848U, 20470336U, 20580544U, 20689472U, 20801344U, 20911424U, 21020096U, + 21130688U, 21242176U, 21352384U, 21462208U, 21573824U, 21683392U, 21794624U, + 21904448U, 22013632U, 22125248U, 22235968U, 22344512U, 22456768U, 22566848U, + 22677056U, 22786496U, 22897984U, 23008064U, 23118272U, 23228992U, 23338816U, + 23449408U, 23560256U, 23670464U, 23780672U, 23891264U, 24001216U, 24110656U, + 24221888U, 24332608U, 24442688U, 24552512U, 24662464U, 24773696U, 24884032U, + 24994496U, 25105216U, 25215296U, 25324864U, 25435712U, 25546432U, 25655744U, + 25767232U, 25876672U, 25986368U, 26098112U, 26207936U, 26318912U, 26428736U, + 26539712U, 26650048U, 26760256U, 26869184U, 26979776U, 27091136U, 27201728U, + 27311552U, 27422272U, 27532352U, 27642304U, 27752896U, 27863744U, 27973952U, + 28082752U, 28194752U, 28305344U, 28415168U, 28524992U, 28636352U, 28746304U, + 28857152U, 28967104U, 29077184U, 29187904U, 29298496U, 29408576U, 29518912U, + 29628992U, 29739968U, 29850176U, 29960512U, 30070336U, 30180544U, 30290752U, + 30398912U, 30512192U, 30622784U, 30732992U, 30842176U, 30953536U, 31063744U, + 31174336U, 31284544U, 31395136U, 31504448U, 31615552U, 31725632U, 31835072U, + 31946176U, 32057024U, 32167232U, 32277568U, 32387008U, 32497984U, 32608832U, + 32719168U, 32829376U, 32939584U, 33050048U, 33160768U, 33271232U, 33381184U, + 33491648U, 33601856U, 33712576U, 33822016U, 33932992U, 34042816U, 34153024U, + 34263104U, 34373824U, 34485056U, 34594624U, 34704832U, 34816064U, 34926272U, + 35036224U, 35146816U, 35255104U, 35367104U, 35478208U, 35588416U, 35698496U, + 35808832U, 35918656U, 36029888U, 36139456U, 36250688U, 36360512U, 36471104U, + 36581696U, 36691136U, 36802112U, 36912448U, 37022912U, 37132864U, 37242944U, + 37354048U, 37464512U, 37574848U, 37684928U, 37794752U, 37904704U, 38015552U, + 38125888U, 38236864U, 38345792U, 38457152U, 38567744U, 38678336U, 38787776U, + 38897216U, 39009088U, 39117632U, 39230144U, 39340352U, 39450304U, 39560384U, + 39671488U, 39781312U, 39891392U, 40002112U, 40112704U, 40223168U, 40332608U, + 40443968U, 40553792U, 40664768U, 40774208U, 40884416U, 40993984U, 41105984U, + 41215424U, 41326528U, 41436992U, 41546048U, 41655872U, 41768128U, 41878336U, + 41988928U, 42098752U, 42209344U, 42319168U, 42429248U, 42540352U, 42649792U, + 42761024U, 42871616U, 42981824U, 43092032U, 43201856U, 43312832U, 43423552U, + 43533632U, 43643584U, 43753792U, 43864384U, 43974976U, 44084032U, 44195392U, + 44306368U, 44415296U, 44526016U, 44637248U, 44746816U, 44858048U, 44967872U, + 45078848U, 45188288U, 45299264U, 45409216U, 45518272U, 45630272U, 45740224U, + 45850432U, 45960896U, 46069696U, 46182208U, 46292416U, 46402624U, 46512064U, + 46623296U, 46733888U, 46843712U, 46953664U, 47065024U, 47175104U, 47285696U, + 47395904U, 47506496U, 47615296U, 47726912U, 47837632U, 47947712U, 48055232U, + 48168128U, 48277952U, 48387392U, 48499648U, 48609472U, 48720064U, 48830272U, + 48940096U, 49050944U, 49160896U, 49271744U, 49381568U, 49492288U, 49602752U, + 49712576U, 49822016U, 49934272U, 50042816U, 50154304U, 50264128U, 50374336U, + 50484416U, 50596288U, 50706752U, 50816704U, 50927168U, 51035456U, 51146944U, + 51258176U, 51366976U, 51477824U, 51589568U, 51699776U, 51809728U, 51920576U, + 52030016U, 52140736U, 52251328U, 52361152U, 52470592U, 52582592U, 52691776U, + 52803136U, 52912576U, 53020736U, 53132224U, 53242688U, 53354816U, 53465536U, + 53575232U, 53685568U, 53796544U, 53906752U, 54016832U, 54126656U, 54236992U, + 54347456U, 54457408U, 54569024U, 54679232U, 54789184U, 54899776U, 55008832U, + 55119296U, 55231168U, 55341248U, 55451584U, 55562048U, 55672256U, 55782208U, + 55893184U, 56002112U, 56113216U +}; + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/endian.h b/libethash/endian.h new file mode 100644 index 000000000..9ca842e47 --- /dev/null +++ b/libethash/endian.h @@ -0,0 +1,74 @@ +#pragma once + +#include +#include "compiler.h" + +static const uint8_t BitReverseTable256[] = + { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + +static inline uint32_t bitfn_swap32(uint32_t a) { + return (BitReverseTable256[a & 0xff] << 24) | + (BitReverseTable256[(a >> 8) & 0xff] << 16) | + (BitReverseTable256[(a >> 16) & 0xff] << 8) | + (BitReverseTable256[(a >> 24) & 0xff]); +} + +static inline uint64_t bitfn_swap64(uint64_t a) { + return ((uint64_t) bitfn_swap32((uint32_t) (a >> 32))) | + (((uint64_t) bitfn_swap32((uint32_t) a)) << 32); +} + +#if defined(__MINGW32__) || defined(_WIN32) + # define LITTLE_ENDIAN 1234 + # define BYTE_ORDER LITTLE_ENDIAN +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) + # include +#elif defined(__OpenBSD__) || defined(__SVR4) + # include +#elif defined(__APPLE__) +# include +#elif defined( BSD ) && (BSD >= 199103) + # include +#elif defined( __QNXNTO__ ) && defined( __LITTLEENDIAN__ ) + # define LITTLE_ENDIAN 1234 + # define BYTE_ORDER LITTLE_ENDIAN +#elif defined( __QNXNTO__ ) && defined( __BIGENDIAN__ ) + # define BIG_ENDIAN 1234 + # define BYTE_ORDER BIG_ENDIAN +#else + +# include + +#endif + + +#if LITTLE_ENDIAN == BYTE_ORDER + +#define fix_endian32(x) (x) +#define fix_endian64(x) (x) + +#elif BIG_ENDIAN == BYTE_ORDER + +#define fix_endian32(x) bitfn_swap32(x) +#define fix_endian64(x) bitfn_swap64(x) + +#else +# error "endian not supported" +#endif // BYTE_ORDER \ No newline at end of file diff --git a/libethash/ethash.h b/libethash/ethash.h new file mode 100644 index 000000000..918a77413 --- /dev/null +++ b/libethash/ethash.h @@ -0,0 +1,93 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file ethash.h +* @date 2015 +*/ +#pragma once + +#include +#include +#include +#include +#include "compiler.h" + +#define REVISION 19 +#define DAGSIZE_BYTES_INIT 1073741824U // 2**30 +#define DAG_GROWTH 113000000U +#define EPOCH_LENGTH 30000U +#define MIX_BYTES 128 +#define DAG_PARENTS 256 +#define CACHE_ROUNDS 3 +#define ACCESSES 64 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ethash_params { + size_t full_size; // Size of full data set (in bytes, multiple of mix size (128)). + size_t cache_size; // Size of compute cache (in bytes, multiple of node size (64)). +} ethash_params; + +typedef struct ethash_return_value { + uint8_t result[32]; + uint8_t mix_hash[32]; +} ethash_return_value; + +size_t ethash_get_datasize(const uint32_t block_number); +size_t ethash_get_cachesize(const uint32_t block_number); + +// initialize the parameters +static inline void ethash_params_init(ethash_params *params, const uint32_t block_number) { + params->full_size = ethash_get_datasize(block_number); + params->cache_size = ethash_get_cachesize(block_number); +} + +typedef struct ethash_cache { + void *mem; +} ethash_cache; + +void ethash_mkcache(ethash_cache *cache, ethash_params const *params, const uint8_t seed[32]); +void ethash_compute_full_data(void *mem, ethash_params const *params, ethash_cache const *cache); +void ethash_full(ethash_return_value *ret, void const *full_mem, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce); +void ethash_light(ethash_return_value *ret, ethash_cache const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce); + +static inline void ethash_prep_light(void *cache, ethash_params const *params, const uint8_t seed[32]) { ethash_cache c; c.mem = cache; ethash_mkcache(&c, params, seed); } +static inline void ethash_compute_light(ethash_return_value *ret, void const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_cache c; c.mem = (void*)cache; ethash_light(ret, &c, params, header_hash, nonce); } +static inline void ethash_prep_full(void *full, ethash_params const *params, void const *cache) { ethash_cache c; c.mem = (void*)cache; ethash_compute_full_data(full, params, &c); } +static inline void ethash_compute_full(ethash_return_value *ret, void const *full, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_full(ret, full, params, header_hash, nonce); } + +static inline int ethash_check_difficulty( + const uint8_t hash[32], + const uint8_t difficulty[32]) { + // Difficulty is big endian + for (int i = 0; i < 32; i++) { + if (hash[i] == difficulty[i]) continue; + return hash[i] < difficulty[i]; + } + return 1; +} + +int ethash_quick_check_difficulty( + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32], + const uint8_t difficulty[32]); + +#ifdef __cplusplus +} +#endif diff --git a/libethash/fnv.h b/libethash/fnv.h new file mode 100644 index 000000000..edabeaae2 --- /dev/null +++ b/libethash/fnv.h @@ -0,0 +1,38 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file fnv.h +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +#pragma once +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define FNV_PRIME 0x01000193 + +static inline uint32_t fnv_hash(const uint32_t x, const uint32_t y) { + return x*FNV_PRIME ^ y; +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/internal.c b/libethash/internal.c new file mode 100644 index 000000000..a2b82d375 --- /dev/null +++ b/libethash/internal.c @@ -0,0 +1,298 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file dash.cpp +* @author Tim Hughes +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +#include +#include +#include +#include "ethash.h" +#include "fnv.h" +#include "endian.h" +#include "internal.h" +#include "data_sizes.h" + +#ifdef WITH_CRYPTOPP + +#include "sha3_cryptopp.h" + +#else +#include "sha3.h" +#endif // WITH_CRYPTOPP + +size_t ethash_get_datasize(const uint32_t block_number) { + assert(block_number / EPOCH_LENGTH < 500); + return dag_sizes[block_number / EPOCH_LENGTH]; +} + +size_t ethash_get_cachesize(const uint32_t block_number) { + assert(block_number / EPOCH_LENGTH < 500); + return cache_sizes[block_number / EPOCH_LENGTH]; +} + +// Follows Sergio's "STRICT MEMORY HARD HASHING FUNCTIONS" (2014) +// https://bitslog.files.wordpress.com/2013/12/memohash-v0-3.pdf +// SeqMemoHash(s, R, N) +void static ethash_compute_cache_nodes( + node *const nodes, + ethash_params const *params, + const uint8_t seed[32]) { + assert((params->cache_size % sizeof(node)) == 0); + uint32_t const num_nodes = (uint32_t)(params->cache_size / sizeof(node)); + + SHA3_512(nodes[0].bytes, seed, 32); + + for (unsigned i = 1; i != num_nodes; ++i) { + SHA3_512(nodes[i].bytes, nodes[i - 1].bytes, 64); + } + + for (unsigned j = 0; j != CACHE_ROUNDS; j++) { + for (unsigned i = 0; i != num_nodes; i++) { + uint32_t const idx = nodes[i].words[0] % num_nodes; + node data; + data = nodes[(num_nodes - 1 + i) % num_nodes]; + for (unsigned w = 0; w != NODE_WORDS; ++w) + { + data.words[w] ^= nodes[idx].words[w]; + } + SHA3_512(nodes[i].bytes, data.bytes, sizeof(data)); + } + } + + // now perform endian conversion +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != (num_nodes*NODE_WORDS); ++w) + { + nodes->words[w] = fix_endian32(nodes->words[w]); + } +#endif +} + +void ethash_mkcache( + ethash_cache *cache, + ethash_params const *params, + const uint8_t seed[32]) { + node *nodes = (node *) cache->mem; + ethash_compute_cache_nodes(nodes, params, seed); +} + +void ethash_calculate_dag_item( + node *const ret, + const unsigned node_index, + const struct ethash_params *params, + const struct ethash_cache *cache) { + + uint32_t num_parent_nodes = (uint32_t)(params->cache_size / sizeof(node)); + node const *cache_nodes = (node const *) cache->mem; + node const *init = &cache_nodes[node_index % num_parent_nodes]; + + memcpy(ret, init, sizeof(node)); + ret->words[0] ^= node_index; + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); + +#if defined(_M_X64) && ENABLE_SSE + __m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = ret->xmm[0]; + __m128i xmm1 = ret->xmm[1]; + __m128i xmm2 = ret->xmm[2]; + __m128i xmm3 = ret->xmm[3]; +#endif + + for (unsigned i = 0; i != DAG_PARENTS; ++i) + { + uint32_t parent_index = ((node_index ^ i)*FNV_PRIME ^ ret->words[i % NODE_WORDS]) % num_parent_nodes; + node const *parent = &cache_nodes[parent_index]; + + #if defined(_M_X64) && ENABLE_SSE + { + xmm0 = _mm_mullo_epi32(xmm0, fnv_prime); + xmm1 = _mm_mullo_epi32(xmm1, fnv_prime); + xmm2 = _mm_mullo_epi32(xmm2, fnv_prime); + xmm3 = _mm_mullo_epi32(xmm3, fnv_prime); + xmm0 = _mm_xor_si128(xmm0, parent->xmm[0]); + xmm1 = _mm_xor_si128(xmm1, parent->xmm[1]); + xmm2 = _mm_xor_si128(xmm2, parent->xmm[2]); + xmm3 = _mm_xor_si128(xmm3, parent->xmm[3]); + + // have to write to ret as values are used to compute index + ret->xmm[0] = xmm0; + ret->xmm[1] = xmm1; + ret->xmm[2] = xmm2; + ret->xmm[3] = xmm3; + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + ret->words[w] = fnv_hash(ret->words[w], parent->words[w]); + } + } + #endif + } + + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); +} + +void ethash_compute_full_data( + void *mem, + ethash_params const *params, + ethash_cache const *cache) { + assert((params->full_size % (sizeof(uint32_t) * MIX_WORDS)) == 0); + assert((params->full_size % sizeof(node)) == 0); + node *full_nodes = mem; + + // now compute full nodes + for (unsigned n = 0; n != (params->full_size / sizeof(node)); ++n) { + ethash_calculate_dag_item(&(full_nodes[n]), n, params, cache); + } +} + +static void ethash_hash( + ethash_return_value * ret, + node const *full_nodes, + ethash_cache const *cache, + ethash_params const *params, + const uint8_t header_hash[32], + const uint64_t nonce) { + + assert((params->full_size % MIX_WORDS) == 0); + + // pack hash and nonce together into first 40 bytes of s_mix + assert(sizeof(node)*8 == 512); + node s_mix[MIX_NODES + 1]; + memcpy(s_mix[0].bytes, header_hash, 32); + +#if BYTE_ORDER != LITTLE_ENDIAN + s_mix[0].double_words[4] = fix_endian64(nonce); +#else + s_mix[0].double_words[4] = nonce; +#endif + + // compute sha3-512 hash and replicate across mix + SHA3_512(s_mix->bytes, s_mix->bytes, 40); + +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != 16; ++w) { + s_mix[0].words[w] = fix_endian32(s_mix[0].words[w]); + } +#endif + + node* const mix = s_mix + 1; + for (unsigned w = 0; w != MIX_WORDS; ++w) { + mix->words[w] = s_mix[0].words[w % NODE_WORDS]; + } + + unsigned const + page_size = sizeof(uint32_t) * MIX_WORDS, + num_full_pages = (unsigned)(params->full_size / page_size); + + + for (unsigned i = 0; i != ACCESSES; ++i) + { + uint32_t const index = ((s_mix->words[0] ^ i)*FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages; + + for (unsigned n = 0; n != MIX_NODES; ++n) + { + const node * dag_node = &full_nodes[MIX_NODES * index + n]; + + if (!full_nodes) { + node tmp_node; + ethash_calculate_dag_item(&tmp_node, index * MIX_NODES + n, params, cache); + dag_node = &tmp_node; + } + + #if defined(_M_X64) && ENABLE_SSE + { + __m128i fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]); + __m128i xmm1 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[1]); + __m128i xmm2 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[2]); + __m128i xmm3 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[3]); + mix[n].xmm[0] = _mm_xor_si128(xmm0, dag_node->xmm[0]); + mix[n].xmm[1] = _mm_xor_si128(xmm1, dag_node->xmm[1]); + mix[n].xmm[2] = _mm_xor_si128(xmm2, dag_node->xmm[2]); + mix[n].xmm[3] = _mm_xor_si128(xmm3, dag_node->xmm[3]); + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]); + } + } + #endif + } + + } + + // compress mix + for (unsigned w = 0; w != MIX_WORDS; w += 4) + { + uint32_t reduction = mix->words[w+0]; + reduction = reduction*FNV_PRIME ^ mix->words[w+1]; + reduction = reduction*FNV_PRIME ^ mix->words[w+2]; + reduction = reduction*FNV_PRIME ^ mix->words[w+3]; + mix->words[w/4] = reduction; + } + +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != MIX_WORDS/4; ++w) { + mix->words[w] = fix_endian32(mix->words[w]); + } +#endif + + memcpy(ret->mix_hash, mix->bytes, 32); + // final Keccak hash + SHA3_256(ret->result, s_mix->bytes, 64+32); // Keccak-256(s + compressed_mix) +} + +void ethash_quick_hash( + uint8_t return_hash[32], + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32]) { + + uint8_t buf[64+32]; + memcpy(buf, header_hash, 32); +#if BYTE_ORDER != LITTLE_ENDIAN + nonce = fix_endian64(nonce); +#endif + memcpy(&(buf[32]), &nonce, 8); + SHA3_512(buf, buf, 40); + memcpy(&(buf[64]), mix_hash, 32); + SHA3_256(return_hash, buf, 64+32); +} + +int ethash_quick_check_difficulty( + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32], + const uint8_t difficulty[32]) { + + uint8_t return_hash[32]; + ethash_quick_hash(return_hash, header_hash, nonce, mix_hash); + return ethash_check_difficulty(return_hash, difficulty); +} + +void ethash_full(ethash_return_value * ret, void const *full_mem, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) { + ethash_hash(ret, (node const *) full_mem, NULL, params, previous_hash, nonce); +} + +void ethash_light(ethash_return_value * ret, ethash_cache const *cache, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) { + ethash_hash(ret, NULL, cache, params, previous_hash, nonce); +} diff --git a/libethash/internal.h b/libethash/internal.h new file mode 100644 index 000000000..bcbacdaa4 --- /dev/null +++ b/libethash/internal.h @@ -0,0 +1,48 @@ +#pragma once +#include "compiler.h" +#include "endian.h" +#include "ethash.h" + +#define ENABLE_SSE 1 + +#if defined(_M_X64) && ENABLE_SSE +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// compile time settings +#define NODE_WORDS (64/4) +#define MIX_WORDS (MIX_BYTES/4) +#define MIX_NODES (MIX_WORDS / NODE_WORDS) +#include + +typedef union node { + uint8_t bytes[NODE_WORDS * 4]; + uint32_t words[NODE_WORDS]; + uint64_t double_words[NODE_WORDS / 2]; + +#if defined(_M_X64) && ENABLE_SSE + __m128i xmm[NODE_WORDS/4]; +#endif + +} node; + +void ethash_calculate_dag_item( + node *const ret, + const unsigned node_index, + ethash_params const *params, + ethash_cache const *cache +); + +void ethash_quick_hash( + uint8_t return_hash[32], + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32]); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/sha3.c b/libethash/sha3.c new file mode 100644 index 000000000..0c28230b8 --- /dev/null +++ b/libethash/sha3.c @@ -0,0 +1,151 @@ +/** libkeccak-tiny +* +* A single-file implementation of SHA-3 and SHAKE. +* +* Implementor: David Leon Gil +* License: CC0, attribution kindly requested. Blame taken too, +* but not liability. +*/ +#include "sha3.h" + +#include +#include +#include +#include + +/******** The Keccak-f[1600] permutation ********/ + +/*** Constants. ***/ +static const uint8_t rho[24] = \ + { 1, 3, 6, 10, 15, 21, + 28, 36, 45, 55, 2, 14, + 27, 41, 56, 8, 25, 43, + 62, 18, 39, 61, 20, 44}; +static const uint8_t pi[24] = \ + {10, 7, 11, 17, 18, 3, + 5, 16, 8, 21, 24, 4, + 15, 23, 19, 13, 12, 2, + 20, 14, 22, 9, 6, 1}; +static const uint64_t RC[24] = \ + {1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, + 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, + 0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL, + 0x8000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL, 0x8000000000008003ULL, + 0x8000000000008002ULL, 0x8000000000000080ULL, 0x800aULL, 0x800000008000000aULL, + 0x8000000080008081ULL, 0x8000000000008080ULL, 0x80000001ULL, 0x8000000080008008ULL}; + +/*** Helper macros to unroll the permutation. ***/ +#define rol(x, s) (((x) << s) | ((x) >> (64 - s))) +#define REPEAT6(e) e e e e e e +#define REPEAT24(e) REPEAT6(e e e e) +#define REPEAT5(e) e e e e e +#define FOR5(v, s, e) \ + v = 0; \ + REPEAT5(e; v += s;) + +/*** Keccak-f[1600] ***/ +static inline void keccakf(void* state) { + uint64_t* a = (uint64_t*)state; + uint64_t b[5] = {0}; + uint64_t t = 0; + uint8_t x, y; + + for (int i = 0; i < 24; i++) { + // Theta + FOR5(x, 1, + b[x] = 0; + FOR5(y, 5, + b[x] ^= a[x + y]; )) + FOR5(x, 1, + FOR5(y, 5, + a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) + // Rho and pi + t = a[1]; + x = 0; + REPEAT24(b[0] = a[pi[x]]; + a[pi[x]] = rol(t, rho[x]); + t = b[0]; + x++; ) + // Chi + FOR5(y, + 5, + FOR5(x, 1, + b[x] = a[y + x];) + FOR5(x, 1, + a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) + // Iota + a[0] ^= RC[i]; + } +} + +/******** The FIPS202-defined functions. ********/ + +/*** Some helper macros. ***/ + +#define _(S) do { S } while (0) +#define FOR(i, ST, L, S) \ + _(for (size_t i = 0; i < L; i += ST) { S; }) +#define mkapply_ds(NAME, S) \ + static inline void NAME(uint8_t* dst, \ + const uint8_t* src, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } +#define mkapply_sd(NAME, S) \ + static inline void NAME(const uint8_t* src, \ + uint8_t* dst, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } + +mkapply_ds(xorin, dst[i] ^= src[i]) // xorin +mkapply_sd(setout, dst[i] = src[i]) // setout + +#define P keccakf +#define Plen 200 + +// Fold P*F over the full blocks of an input. +#define foldP(I, L, F) \ + while (L >= rate) { \ + F(a, I, rate); \ + P(a); \ + I += rate; \ + L -= rate; \ + } + +/** The sponge-based hash construction. **/ +static inline int hash(uint8_t* out, size_t outlen, + const uint8_t* in, size_t inlen, + size_t rate, uint8_t delim) { + if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) { + return -1; + } + uint8_t a[Plen] = {0}; + // Absorb input. + foldP(in, inlen, xorin); + // Xor in the DS and pad frame. + a[inlen] ^= delim; + a[rate - 1] ^= 0x80; + // Xor in the last block. + xorin(a, in, inlen); + // Apply P + P(a); + // Squeeze output. + foldP(out, outlen, setout); + setout(a, out, outlen); + memset(a, 0, 200); + return 0; +} + +#define defsha3(bits) \ + int sha3_##bits(uint8_t* out, size_t outlen, \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ + } + +/*** FIPS202 SHA3 FOFs ***/ +defsha3(256) +defsha3(512) \ No newline at end of file diff --git a/libethash/sha3.h b/libethash/sha3.h new file mode 100644 index 000000000..36a0a5301 --- /dev/null +++ b/libethash/sha3.h @@ -0,0 +1,27 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "compiler.h" +#include +#include + +#define decsha3(bits) \ + int sha3_##bits(uint8_t*, size_t, const uint8_t*, size_t); + +decsha3(256) +decsha3(512) + +static inline void SHA3_256(uint8_t * const ret, uint8_t const *data, const size_t size) { + sha3_256(ret, 32, data, size); +} + +static inline void SHA3_512(uint8_t * const ret, uint8_t const *data, const size_t size) { + sha3_512(ret, 64, data, size); +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/sha3_cryptopp.cpp b/libethash/sha3_cryptopp.cpp new file mode 100644 index 000000000..9454ce04a --- /dev/null +++ b/libethash/sha3_cryptopp.cpp @@ -0,0 +1,34 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ + +/** @file sha3.cpp +* @author Tim Hughes +* @date 2015 +*/ + +#include +#include + +extern "C" { +void SHA3_256(uint8_t *const ret, const uint8_t *data, size_t size) { + CryptoPP::SHA3_256().CalculateDigest(ret, data, size); +} + +void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size) { + CryptoPP::SHA3_512().CalculateDigest(ret, data, size); +} +} \ No newline at end of file diff --git a/libethash/sha3_cryptopp.h b/libethash/sha3_cryptopp.h new file mode 100644 index 000000000..f910960e1 --- /dev/null +++ b/libethash/sha3_cryptopp.h @@ -0,0 +1,15 @@ +#pragma once + +#include "compiler.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void SHA3_256(uint8_t *const ret, const uint8_t *data, size_t size); +void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/util.c b/libethash/util.c new file mode 100644 index 000000000..fbf268b7d --- /dev/null +++ b/libethash/util.c @@ -0,0 +1,41 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file util.c + * @author Tim Hughes + * @date 2015 + */ +#include +#include +#include "util.h" + +#ifdef _MSC_VER + +// foward declare without all of Windows.h +__declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString); + +void debugf(const char *str, ...) +{ + va_list args; + va_start(args, str); + + char buf[1<<16]; + _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); + buf[sizeof(buf)-1] = '\0'; + OutputDebugStringA(buf); +} + +#endif diff --git a/libethash/util.h b/libethash/util.h new file mode 100644 index 000000000..2f59076f6 --- /dev/null +++ b/libethash/util.h @@ -0,0 +1,47 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file util.h + * @author Tim Hughes + * @date 2015 + */ +#pragma once +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +void debugf(const char *str, ...); +#else +#define debugf printf +#endif + +static inline uint32_t min_u32(uint32_t a, uint32_t b) +{ + return a < b ? a : b; +} + +static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_) +{ + return x < min_ ? min_ : (x > max_ ? max_ : x); +} + +#ifdef __cplusplus +} +#endif From 176f9b39959c56ea8516ba890c30782b30ffe608 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 12:33:59 +0100 Subject: [PATCH 167/313] Minor fix. --- libethereum/Client.cpp | 1 - params.json | 64 ------------------------------------------ 2 files changed, 65 deletions(-) delete mode 100644 params.json diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 4c6bd2d58..9a249a645 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -284,7 +284,6 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) #if ETH_DEBUG && 0 cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); #endif - auto& w = m_watches.at(_watchId); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/params.json b/params.json deleted file mode 100644 index 744f92154..000000000 --- a/params.json +++ /dev/null @@ -1,64 +0,0 @@ -var x = { - "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, - "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, - "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, - "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, - "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, - "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, - - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} - -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ - From 3f0e502cfa6721f96875af5f4fff8380f0f36edf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 12:44:42 +0100 Subject: [PATCH 168/313] Remove params. --- params.json | 64 ----------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 params.json diff --git a/params.json b/params.json deleted file mode 100644 index 744f92154..000000000 --- a/params.json +++ /dev/null @@ -1,64 +0,0 @@ -var x = { - "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, - "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, - "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, - "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, - "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, - "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, - - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} - -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ - From bb0f5358bfa86184d7a4f4a30c04ce4bc8fde26b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 169/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 48 +++++++++++++++++++++++ libethcore/CommonEth.cpp | 2 +- libethereum/CachedAddressState.cpp | 6 +-- libethereum/CachedAddressState.h | 3 ++ libethereum/CanonBlockChain.cpp | 2 +- libethereum/State.cpp | 63 +++++++++++++----------------- libethereum/State.h | 9 ++--- mix/MixClient.cpp | 2 +- 8 files changed, 88 insertions(+), 47 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f5b7ff9c9..c08199e06 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -325,6 +325,54 @@ std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) return _out; } +template +class SecureGenericTrieDB: private TrieDB +{ + using Super = TrieDB; + +public: + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + using Super::open; + using Super::init; + using Super::setRoot; + using Super::haveRoot; + + /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). + using Super::isNull; + /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). + using Super::isEmpty; + + using Super::root; + + using Super::leftOvers; + using Super::check; + + std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } + void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } +}; + +template +class SecureTrieDB: public SecureGenericTrieDB +{ + using Super = SecureGenericTrieDB; + +public: + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + + std::string operator[](KeyType _k) const { return at(_k); } + + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } +}; + } // Template implementations... diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 2264e6ec9..8facdf0f1 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 54; +const unsigned c_protocolVersion = 55; const unsigned c_databaseVersion = 5; vector> const& units() diff --git a/libethereum/CachedAddressState.cpp b/libethereum/CachedAddressState.cpp index 5f9be6944..e2fadc8b5 100644 --- a/libethereum/CachedAddressState.cpp +++ b/libethereum/CachedAddressState.cpp @@ -56,9 +56,9 @@ std::map CachedAddressState::storage() const std::map ret; if (m_r) { - TrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - ret[j.first] = RLP(j.second).toInt(); + SecureTrieDB memdb(const_cast(m_o), m_r[2].toHash()); // promise we won't alter the overlay! :) +// for (auto const& j: memdb) +// ret[j.first] = RLP(j.second).toInt(); } if (m_s) for (auto const& j: m_s->storageOverlay()) diff --git a/libethereum/CachedAddressState.h b/libethereum/CachedAddressState.h index 301f54338..8a3c3a607 100644 --- a/libethereum/CachedAddressState.h +++ b/libethereum/CachedAddressState.h @@ -45,7 +45,10 @@ public: u256 balance() const; u256 nonce() const; bytes code() const; + + // TODO: DEPRECATE. std::map storage() const; + AccountDiff diff(CachedAddressState const& _c); private: diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index b0fe90a78..29fdc9acc 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -76,7 +76,7 @@ bytes CanonBlockChain::createGenesisBlock() h256 stateRoot; { MemoryDB db; - TrieDB state(&db); + SecureTrieDB state(&db); state.init(); dev::eth::commit(genesisState(), db, state); stateRoot = state.root(); diff --git a/libethereum/State.cpp b/libethereum/State.cpp index fad9112db..512dfd792 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -169,18 +169,6 @@ State::~State() { } -Address State::nextActiveAddress(Address _a) const -{ - auto it = m_state.lower_bound(_a); - if ((*it).first == _a) - ++it; - if (it == m_state.end()) - // exchange comments if we want to wraparound -// it = m_state.begin(); - return Address(); - return (*it).first; -} - StateDiff State::diff(State const& _c) const { StateDiff ret; @@ -189,13 +177,14 @@ StateDiff State::diff(State const& _c) const std::set
trieAds; std::set
trieAdsD; - auto trie = TrieDB(const_cast(&m_db), rootHash()); - auto trieD = TrieDB(const_cast(&_c.m_db), _c.rootHash()); + auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); + auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -357,9 +346,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -592,9 +582,10 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) { cwarn << "Bad state root!"; cnote << "Given to be:" << m_currentBlock.stateRoot; - cnote << TrieDB(&m_db, m_currentBlock.stateRoot); + // TODO: Fix +// cnote << SecureTrieDB(&m_db, m_currentBlock.stateRoot); cnote << "Calculated to be:" << rootHash(); - cnote << m_state; +// cnote << m_state; cnote << *this; // Rollback the trie. m_db.rollback(); @@ -939,7 +930,7 @@ u256 State::storage(Address _id, u256 _memory) const return mit->second; // Not in the storage cache - go to the DB. - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't change the overlay! :) string payload = memdb.at(_memory); u256 ret = payload.size() ? RLP(payload).toInt() : 0; it->second.setStorage(_memory, ret); @@ -957,9 +948,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - TrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1010,24 +1002,24 @@ bool State::isTrieGood(bool _enforceRefs, bool _requireNoLeftOvers) const cwarn << "LEFTOVERS" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << "Left:" << lo; cnote << "Keys:" << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } // TODO: Enable once fixed. - for (auto const& i: m_state) +/* for (auto const& i: m_state) { RLP r(i.second); - TrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. + SecureTrieDB storageDB(const_cast(&m_db), r[2].toHash()); // promise not to alter OverlayDB. for (auto const& j: storageDB) { (void)j; } if (!e && r[3].toHash() != EmptySHA3 && m_db.lookup(r[3].toHash()).empty()) return false; - } + }*/ } catch (InvalidTrie const&) { cwarn << "BAD TRIE" << (e ? "[enforced" : "[unenforced") << "refs]"; cnote << m_db.keys(); - m_state.debugStructure(cerr); +// m_state.debugStructure(cerr); return false; } return true; @@ -1194,9 +1186,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) std::set cached; if (r) { - TrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index 813141d17..37af0cf0e 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -94,9 +94,6 @@ public: /// @returns the set containing all addresses currently in use in Ethereum. std::map addresses() const; - /// @returns the address b such that b > @a _a . - Address nextActiveAddress(Address _a) const; - /// Get the header information on the present block. BlockInfo const& info() const { return m_currentBlock; } @@ -299,7 +296,7 @@ private: void paranoia(std::string const& _when, bool _enforceRefs = false) const; OverlayDB m_db; ///< Our overlay for the state tree. - TrieDB m_state; ///< Our state tree, as an OverlayDB DB. + SecureTrieDB m_state; ///< Our state tree, as an OverlayDB DB. Transactions m_transactions; ///< The current list of transactions that we've included in the state. TransactionReceipts m_receipts; ///< The corresponding list of transaction receipts. std::set m_transactionSet; ///< The set of transaction hashes that we've included in the state. @@ -328,7 +325,7 @@ private: std::ostream& operator<<(std::ostream& _out, State const& _s); template -void commit(std::map const& _cache, DB& _db, TrieDB& _state) +void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) if (!i.second.isAlive()) @@ -345,7 +342,7 @@ void commit(std::map const& _cache, DB& _db, TrieDB storageDB(&_db, i.second.baseRoot()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); for (auto const& j: i.second.storageOverlay()) if (j.second) storageDB.insert(j.first, rlp(j.second)); diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index aaa37a8bb..2ce9455cf 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -81,7 +81,7 @@ void MixClient::resetState(std::map _accounts) m_watches.clear(); m_stateDB = OverlayDB(); - TrieDB accountState(&m_stateDB); + SecureTrieDB accountState(&m_stateDB); accountState.init(); std::map genesisState; From c88590f0b84e2272f4f3fd97f83aa4bc5a1793c5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 170/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 6 +- libdevcrypto/MemoryDB.cpp | 2 +- libdevcrypto/MemoryDB.h | 4 ++ libdevcrypto/TrieDB.h | 123 +++++++++++++++++++++++++------------- test/trie.cpp | 44 +++++++++++++- 5 files changed, 130 insertions(+), 49 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 2b4e6bc08..24fac9c0a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -53,7 +53,7 @@ public: enum ConstructFromStringType { FromHex, FromBinary }; /// Method to convert from a string. - enum ConstructFromHashType { AlignLeft, AlignRight }; + enum ConstructFromHashType { AlignLeft, AlignRight, FailIfDifferent }; /// Construct an empty hash. FixedHash() { m_data.fill(0); } @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.cpp b/libdevcrypto/MemoryDB.cpp index 4fc4ed9ad..56b77ddee 100644 --- a/libdevcrypto/MemoryDB.cpp +++ b/libdevcrypto/MemoryDB.cpp @@ -107,7 +107,7 @@ set MemoryDB::keys() const { set ret; for (auto const& i: m_refCount) - if (i.second) + if (i.second && h128(i.first.ref().cropped(0, 16))) ret.insert(i.first); return ret; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 4b8d3b3a2..816e393a3 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -26,6 +26,7 @@ #include #include #include +#include "SHA3.h" namespace dev { @@ -50,6 +51,9 @@ public: bool kill(h256 _h); void purge(); + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + std::set keys() const; protected: diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index c08199e06..676193112 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -62,17 +62,21 @@ extern const h256 EmptyTrie; * assert(t.isEmpty()); * @endcode */ -template +template class GenericTrieDB { public: + using DB = _DB; + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} + void open(DB* _db) { m_db = _db; } void open(DB* _db, h256 _root) { m_db = _db; setRoot(_root); } - void init(); + void init() { setRoot(insertNode(&RLPNull)); assert(node(m_root).size()); } + void setRoot(h256 _root) { m_root = _root; @@ -83,7 +87,6 @@ public: if (!node(m_root).size()) BOOST_THROW_EXCEPTION(RootNotFound()); } - bool haveRoot(h256 _root, bool _enforceRefs = true) { return _root == c_shaNull ? true : m_db->lookup(_root, _enforceRefs).size(); } /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). bool isNull() const { return !node(m_root).size(); } @@ -211,6 +214,9 @@ public: iterator lower_bound(bytesConstRef _key) const { return iterator(this, _key); } +protected: + DB* db() const { return m_db; } + private: RLPStream& streamNode(RLPStream& _s, bytes const& _b); @@ -281,30 +287,33 @@ std::ostream& operator<<(std::ostream& _out, GenericTrieDB const& _db) return _out; } -template -class TrieDB: public GenericTrieDB +template +class SpecificTrieDB: public Generic { public: - TrieDB(DB* _db): GenericTrieDB(_db) {} - TrieDB(DB* _db, h256 _root): GenericTrieDB(_db, _root) {} + using DB = typename Generic::DB; + using KeyType = _KeyType; + + SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } - bool contains(KeyType _k) const { return GenericTrieDB::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return GenericTrieDB::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { GenericTrieDB::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + bool contains(KeyType _k) const { return Generic::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Generic::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Generic::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { GenericTrieDB::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void remove(KeyType _k) { Generic::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - class iterator: public GenericTrieDB::iterator + class iterator: public Generic::iterator { public: - using Super = typename GenericTrieDB::iterator; + using Super = typename Generic::iterator; using value_type = std::pair; iterator() {} - iterator(TrieDB const* _db): Super(_db) {} - iterator(TrieDB const* _db, bytesConstRef _k): Super(_db, _k) {} + iterator(Generic const* _db): Super(_db) {} + iterator(Generic const* _db, bytesConstRef _k): Super(_db, _k) {} value_type operator*() const { return at(); } value_type operator->() const { return at(); } @@ -317,27 +326,28 @@ public: iterator lower_bound(KeyType _k) const { return iterator(this, bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template -std::ostream& operator<<(std::ostream& _out, TrieDB const& _db) +template +std::ostream& operator<<(std::ostream& _out, SpecificTrieDB const& _db) { for (auto const& i: _db) _out << i.first << ": " << escaped(i.second.toString(), false) << std::endl; return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -350,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... @@ -641,7 +685,7 @@ template void GenericTrieDB::iterator::next() } } -template typename TrieDB::iterator::value_type TrieDB::iterator::at() const +template typename SpecificTrieDB::iterator::value_type SpecificTrieDB::iterator::at() const { auto p = Super::at(); value_type ret; @@ -651,13 +695,6 @@ template typename TrieDB::iterator::value return ret; } -template void GenericTrieDB::init() -{ - m_root = insertNode(&RLPNull); -// std::cout << "Initialised root to " << m_root << std::endl; - assert(node(m_root).size()); -} - template void GenericTrieDB::insert(bytesConstRef _key, bytesConstRef _value) { #if ETH_PARANOIA diff --git a/test/trie.cpp b/test/trie.cpp index dd335b4a6..18e115da0 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -50,6 +50,8 @@ static unsigned fac(unsigned _i) } } +using dev::operator <<; + BOOST_AUTO_TEST_SUITE(TrieTests) BOOST_AUTO_TEST_CASE(trie_test_anyorder) @@ -81,15 +83,35 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) next_permutation(ss.begin(), ss.end()); MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); for (auto const& k: ss) { t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } } } @@ -141,15 +163,33 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) MemoryDB m; GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); t.init(); + ht.init(); + ft.init(); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) { if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); + t.remove(k.first), ht.remove(k.first), ft.remove(k.first); else - t.insert(k.first, k.second); + t.insert(k.first, k.second), ht.insert(k.first, k.second), ft.insert(k.first, k.second); BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); } BOOST_REQUIRE(!o["root"].is_null()); From 67ed60bad68fe22bfa5a685cf77af10947c283cb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 171/313] FatDB integrated. --- CMakeLists.txt | 7 ++++++- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/CommonEth.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 51 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cd7a80c4..156d0e5c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ function(createDefaultCacheConfig) set(PARANOIA OFF CACHE BOOL "Additional run-time checks") set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") + set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") endfunction() @@ -44,6 +45,10 @@ function(configureProject) add_definitions(-DETH_EVMJIT) endif() + if (FATDB) + add_definitions(-DETH_FATDB) + endif() + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() @@ -110,7 +115,7 @@ cmake_policy(SET CMP0015 NEW) createDefaultCacheConfig() configureProject() message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") -message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}") +message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}; FATDB: ${FATDB}") # Default TARGET_PLATFORM to "linux". diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 676193112..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 8facdf0f1..eba10e321 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 512dfd792..e43796eb3 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,11 +180,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -346,10 +345,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -948,10 +946,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1187,9 +1184,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From 31f3ae66fba3fa5fe89d47b6a0a60a185f02aa0d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 172/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 47 ++++++++++++++++------------ libdevcore/FixedHash.h | 6 ++-- libdevcore/vector_ref.h | 2 +- libdevcrypto/MemoryDB.h | 8 +++-- libdevcrypto/OverlayDB.cpp | 13 ++++++++ libdevcrypto/OverlayDB.h | 2 ++ libdevcrypto/TrieDB.h | 2 +- libethcore/CommonEth.cpp | 2 +- libethereum/Account.h | 36 ++++++++++++++++------ libethereum/BlockChain.cpp | 15 ++++++--- libethereum/State.cpp | 8 ++--- libethereum/State.h | 63 ++++++++++++++++++++------------------ test/CMakeLists.txt | 2 +- test/stateOriginal.cpp | 36 ++++++++++++++++------ test/trie.cpp | 20 ++++++++++++ 15 files changed, 177 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 156d0e5c5..ba25e74ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() @@ -153,8 +154,11 @@ if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) endif () add_subdirectory(libsolidity) -add_subdirectory(lllc) -add_subdirectory(solc) + +if (NOT JUSTTESTS) + add_subdirectory(lllc) + add_subdirectory(solc) +endif() if (JSONRPC) add_subdirectory(libweb3jsonrpc) @@ -171,25 +175,30 @@ add_subdirectory(libethereum) add_subdirectory(libwebthree) add_subdirectory(test) -add_subdirectory(eth) -if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") - add_subdirectory(exp) -endif () +if (NOT JUSTTESTS) -# TODO check msvc -if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) - add_subdirectory(neth) -endif () + add_subdirectory(eth) + + if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") + add_subdirectory(exp) + endif () + + # TODO check msvc + if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")) + add_subdirectory(neth) + endif () + + if (NOT HEADLESS) + + add_subdirectory(libnatspec) + add_subdirectory(libjsqrc) + add_subdirectory(alethzero) + add_subdirectory(third) + add_subdirectory(mix) + + endif() -if (NOT HEADLESS) - - add_subdirectory(libnatspec) - add_subdirectory(libjsqrc) - add_subdirectory(alethzero) - add_subdirectory(third) - add_subdirectory(mix) - endif() enable_testing() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 24fac9c0a..3113b5427 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,16 +65,16 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } /// Explicitly construct, copying from a string. - explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s)) {} + explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s) : dev::asBytes(_s), _ht) {} /// Convert to arithmetic type. operator Arith() const { return fromBigEndian(m_data); } diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index 42633f6f1..2c5f07e51 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -23,7 +23,7 @@ public: vector_ref(typename std::conditional::value, std::vector::type> const*, std::vector<_T>*>::type _data): m_data(_data->data()), m_count(_data->size()) {} vector_ref(typename std::conditional::value, std::string const&, std::string&>::type _data): m_data((_T*)_data.data()), m_count(_data.size() / sizeof(_T)) {} #ifdef STORAGE_LEVELDB_INCLUDE_DB_H_ - vector_ref(leveldb::Slice const& _s): m_data(_s.data()), m_count(_s.size() / sizeof(_T)) {} + vector_ref(leveldb::Slice const& _s): m_data(reinterpret_cast<_T*>(_s.data())), m_count(_s.size() / sizeof(_T)) {} #endif explicit operator bool() const { return m_data && m_count; } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 816e393a3..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,14 +51,18 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; protected: + static h256 aux(h256 _k) { return h256(sha3(_k).ref().cropped(0, 24), h256::AlignLeft); } + std::map m_over; std::map m_refCount; + h256 m_auxKey; + std::map m_aux; mutable bool m_enforceRefs = false; }; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 9e110bb84..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -19,6 +19,7 @@ * @date 2014 */ +#include #include #include "OverlayDB.h" using namespace std; @@ -51,11 +52,23 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } } +bytes OverlayDB::lookupAux(h256 _h) const +{ + bytes ret = MemoryDB::lookupAux(_h); + if (!ret.empty()) + return ret; + std::string v; + m_db->Get(m_readOptions, _h.ref(), &v); + return asBytes(v); +} + void OverlayDB::rollback() { m_over.clear(); diff --git a/libdevcrypto/OverlayDB.h b/libdevcrypto/OverlayDB.h index e9bd53343..d027afbd4 100644 --- a/libdevcrypto/OverlayDB.h +++ b/libdevcrypto/OverlayDB.h @@ -51,6 +51,8 @@ public: bool exists(h256 _h) const; void kill(h256 _h); + bytes lookupAux(h256 _h) const; + private: using MemoryDB::clear; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..348cab59e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index eba10e321..ad41780e9 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/Account.h b/libethereum/Account.h index 3f3a5d548..2cc962baa 100644 --- a/libethereum/Account.h +++ b/libethereum/Account.h @@ -76,28 +76,40 @@ public: ContractConception }; + /// Changedness of account to create. + enum Changedness + { + /// Account starts as though it has been changed. + Changed, + /// Account starts as though it has not been changed. + Unchanged + }; + /// Construct a dead Account. Account() {} /// Construct an alive Account, with given endowment, for either a normal (non-contract) account or for a /// contract account in the /// conception phase, where the code is not yet known. - Account(u256 _balance, NewAccountType _t): m_isAlive(true), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} + Account(u256 _balance, NewAccountType _t, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_balance(_balance), m_codeHash(_t == NormalCreation ? EmptySHA3 : c_contractConceptionCodeHash) {} /// Explicit constructor for wierd cases of construction of a normal account. - Account(u256 _nonce, u256 _balance): m_isAlive(true), m_nonce(_nonce), m_balance(_balance) {} + Account(u256 _nonce, u256 _balance, Changedness _c = Changed): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance) {} /// Explicit constructor for wierd cases of construction or a contract account. - Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash): m_isAlive(true), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } + Account(u256 _nonce, u256 _balance, h256 _contractRoot, h256 _codeHash, Changedness _c): m_isAlive(true), m_isUnchanged(_c == Unchanged), m_nonce(_nonce), m_balance(_balance), m_storageRoot(_contractRoot), m_codeHash(_codeHash) { assert(_contractRoot); } /// Kill this account. Useful for the suicide opcode. Following this call, isAlive() returns false. - void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; } + void kill() { m_isAlive = false; m_storageOverlay.clear(); m_codeHash = EmptySHA3; m_storageRoot = EmptyTrie; m_balance = 0; m_nonce = 0; changed(); } /// @returns true iff this object represents an account in the state. Returns false if this object /// represents an account that should no longer exist in the trie (an account that never existed or was /// suicided). bool isAlive() const { return m_isAlive; } + /// @returns true if the account is unchanged from creation. + bool isDirty() const { return !m_isUnchanged; } + /// @returns the balance of this account. Can be altered in place. u256& balance() { return m_balance; } @@ -106,7 +118,7 @@ public: u256 const& balance() const { return m_balance; } /// Increments the balance of this account by the given amount. It's a bigint, so can be negative. - void addBalance(bigint _i) { m_balance = (u256)((bigint)m_balance + _i); } + void addBalance(bigint _i) { if (!_i) return; m_balance = (u256)((bigint)m_balance + _i); changed(); } /// @returns the nonce of the account. Can be altered in place. u256& nonce() { return m_nonce; } @@ -115,7 +127,7 @@ public: u256 const& nonce() const { return m_nonce; } /// Increment the nonce of the account by one. - void incNonce() { m_nonce++; } + void incNonce() { m_nonce++; changed(); } /// @returns the root of the trie (whose nodes are stored in the state db externally to this class) @@ -127,7 +139,7 @@ public: /// Set a key/value pair in the account's storage. This actually goes into the overlay, for committing /// to the trie later. - void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; } + void setStorage(u256 _p, u256 _v) { m_storageOverlay[_p] = _v; changed(); } /// @returns true if we are in the contract-conception state and setCode is valid to call. bool isFreshCode() const { return m_codeHash == c_contractConceptionCodeHash; } @@ -140,8 +152,8 @@ public: h256 codeHash() const { assert(!isFreshCode()); return m_codeHash; } /// Sets the code of the account. Must only be called when isFreshCode() returns true. - void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; } - void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; } + void setCode(bytes&& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } + void setCode(bytes const& _code) { assert(isFreshCode()); m_codeCache = _code; changed(); } /// @returns true if the account's code is available through code(). bool codeCacheValid() const { return m_codeHash == EmptySHA3 || m_codeHash == c_contractConceptionCodeHash || m_codeCache.size(); } @@ -154,9 +166,15 @@ public: bytes const& code() const { assert(codeCacheValid()); return m_codeCache; } private: + /// Note that we've altered the account. + void changed() { m_isUnchanged = false; } + /// Is this account existant? If not, it represents a deleted account. bool m_isAlive = false; + /// True if we've not made any alteration to the account having been given it's properties directly. + bool m_isUnchanged = false; + /// Account's nonce. u256 m_nonce = 0; diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index aabce4d4b..b1727ae1c 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -19,6 +19,8 @@ * @date 2014 */ +#include + #include "BlockChain.h" #include @@ -44,14 +46,17 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_extrasDB->NewIterator(_bc.m_readOptions); + auto it = _bc.m_db->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { - string rlpString = it->value().ToString(); - RLP r(rlpString); - BlockDetails d(r); - _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parent << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + try { + BlockInfo d(bytesConstRef(it->value())); + _out << toHex(it->key().ToString()) << ": " << d.number << " @ " << d.parentHash << (cmp == it->key().ToString() ? " BEST" : "") << std::endl; + } + catch (...) { + cwarn << "Invalid DB entry:" << toHex(it->key().ToString()) << " -> " << toHex(bytesConstRef(it->value())); + } } delete it; return _out; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index e43796eb3..2d1ba2e33 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -225,7 +225,7 @@ void State::ensureCached(std::map& _cache, Address _a, bool _r if (state.isNull()) s = Account(0, Account::NormalCreation); else - s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash()); + s = Account(state[0].toInt(), state[1].toInt(), state[2].toHash(), state[3].toHash(), Account::Unchanged); bool ok; tie(it, ok) = _cache.insert(make_pair(_a, s)); } @@ -626,7 +626,7 @@ void State::uncommitToMine() if (!m_transactions.size()) m_state.setRoot(m_previousBlock.stateRoot); else - m_state.setRoot(m_receipts[m_receipts.size() - 1].stateRoot()); + m_state.setRoot(m_receipts.back().stateRoot()); m_db = m_lastTx; paranoia("Uncommited to mine", true); m_currentBlock.sha3Uncles = h256(); @@ -897,7 +897,7 @@ Address State::newContract(u256 _balance, bytes const& _code) auto it = m_cache.find(ret); if (it == m_cache.end()) { - m_cache[ret] = Account(0, _balance, EmptyTrie, h); + m_cache[ret] = Account(0, _balance, EmptyTrie, h, Account::Changed); return ret; } } @@ -1151,7 +1151,7 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) _out << "--- " << _s.rootHash() << std::endl; std::set
d; std::set
dtr; - auto trie = TrieDB(const_cast(&_s.m_db), _s.rootHash()); + auto trie = SecureTrieDB(const_cast(&_s.m_db), _s.rootHash()); for (auto i: trie) d.insert(i.first), dtr.insert(i.first); for (auto i: _s.m_cache) diff --git a/libethereum/State.h b/libethereum/State.h index 37af0cf0e..a496a4a03 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -328,40 +328,43 @@ template void commit(std::map const& _cache, DB& _db, SecureTrieDB& _state) { for (auto const& i: _cache) - if (!i.second.isAlive()) - _state.remove(i.first); - else + if (i.second.isDirty()) { - RLPStream s(4); - s << i.second.nonce() << i.second.balance(); - - if (i.second.storageOverlay().empty()) - { - assert(i.second.baseRoot()); - s.append(i.second.baseRoot()); - } + if (!i.second.isAlive()) + _state.remove(i.first); else { - SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); } } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7ddfdb40d..292f62a03 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) target_link_libraries(testeth solidity) -if (NOT HEADLESS) +if (NOT HEADLESS AND NOT JUSTTESTS) target_link_libraries(testeth webthree) target_link_libraries(testeth natspec) endif() diff --git a/test/stateOriginal.cpp b/test/stateOriginal.cpp index 65ff5084f..5b7b0415e 100644 --- a/test/stateOriginal.cpp +++ b/test/stateOriginal.cpp @@ -20,6 +20,7 @@ * State test functions. */ +#include #include #include #include @@ -29,7 +30,21 @@ using namespace std; using namespace dev; using namespace dev::eth; -int stateTest() +namespace dev +{ +namespace test +{ + +int stateTest(); + +BOOST_AUTO_TEST_SUITE(StateIntegration) + +BOOST_AUTO_TEST_CASE(Basic) +{ + State s; +} + +BOOST_AUTO_TEST_CASE(Complex) { cnote << "Testing State..."; @@ -37,14 +52,15 @@ int stateTest() KeyPair myMiner = sha3("Gav's Miner"); // KeyPair you = sha3("123"); - Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); + Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count())); OverlayDB stateDB = State::openDB(); CanonBlockChain bc; - State s(myMiner.address(), stateDB); - cout << bc; + State s(myMiner.address(), stateDB); + cout << s; + // Sync up - this won't do much until we use the last state. s.sync(bc); @@ -52,7 +68,7 @@ int stateTest() // Mine to get some ether! s.commitToMine(bc); - while (!s.mine(100).completed) {} + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -65,7 +81,7 @@ int stateTest() // Inject a transaction to transfer funds from miner to me. bytes tx; { - Transaction t(1000, 0, 0, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); + Transaction t(1000, 10000, 10000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); assert(t.sender() == myMiner.address()); tx = t.rlp(); } @@ -76,7 +92,7 @@ int stateTest() // Mine to get some ether and set in stone. s.commitToMine(bc); s.commitToMine(bc); - while (!s.mine(50).completed) { s.commitToMine(bc); } + while (!s.mine(100, true).completed) {} s.completeMine(); bc.attemptImport(s.blockData(), stateDB); @@ -85,7 +101,9 @@ int stateTest() s.sync(bc); cout << s; - - return 0; } +BOOST_AUTO_TEST_SUITE_END() + +} +} diff --git a/test/trie.cpp b/test/trie.cpp index 18e115da0..84d0e846f 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -54,6 +54,26 @@ using dev::operator <<; BOOST_AUTO_TEST_SUITE(TrieTests) +BOOST_AUTO_TEST_CASE(fat_trie) +{ + h256 r; + MemoryDB fm; + { + FatGenericTrieDB ft(&fm); + ft.init(); + ft.insert(h256("69", h256::FromHex, h256::AlignRight).ref(), h256("414243", h256::FromHex, h256::AlignRight).ref()); + for (auto i: ft) + cnote << i.first << i.second; + r = ft.root(); + } + { + FatGenericTrieDB ft(&fm); + ft.setRoot(r); + for (auto i: ft) + cnote << i.first << i.second; + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 012be4f084dd766d42f3cf1d9127f570180443c7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 173/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 348cab59e..583bfbf6e 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From 724cf629cf063b2d910e134c89015c82fbba901a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 174/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 3 + libevm/ExtVMFace.h | 3 + libevm/FeeStructure.cpp | 59 +++++--- libevm/FeeStructure.h | 50 ++++--- libevm/VM.cpp | 197 ++++++--------------------- libevmcore/Instruction.cpp | 267 ++++++++++++++++++------------------- libevmcore/Instruction.h | 14 ++ 7 files changed, 259 insertions(+), 334 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 30cbf1a5a..40ff62175 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -69,6 +69,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } + /// Does the account exist? + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final { diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 49535958a..8aacd7d83 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -143,6 +143,9 @@ public: /// Determine account's TX count. virtual u256 txCount(Address) { return 0; } + /// Does the account exist? + virtual bool exists(Address) { return false; } + /// Suicide the associated contract and give proceeds to the given address. virtual void suicide(Address) { sub.suicides.insert(myAddress); } diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 94eb956af..1c1bf8a9e 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -25,24 +25,41 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 const dev::eth::c_stepGas = 1; -u256 const dev::eth::c_balanceGas = 20; -u256 const dev::eth::c_sha3Gas = 10; -u256 const dev::eth::c_sha3WordGas = 10; -u256 const dev::eth::c_sloadGas = 20; -u256 const dev::eth::c_sstoreSetGas = 300; -u256 const dev::eth::c_sstoreResetGas = 100; -u256 const dev::eth::c_sstoreRefundGas = 100; -u256 const dev::eth::c_createGas = 100; -u256 const dev::eth::c_createDataGas = 5; -u256 const dev::eth::c_callGas = 20; -u256 const dev::eth::c_expGas = 1; -u256 const dev::eth::c_expByteGas = 1; -u256 const dev::eth::c_memoryGas = 1; -u256 const dev::eth::c_txDataZeroGas = 1; -u256 const dev::eth::c_txDataNonZeroGas = 5; -u256 const dev::eth::c_txGas = 500; -u256 const dev::eth::c_logGas = 32; -u256 const dev::eth::c_logDataGas = 1; -u256 const dev::eth::c_logTopicGas = 32; -u256 const dev::eth::c_copyGas = 1; +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + + diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 8ef384265..1b58c80e9 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,27 +28,37 @@ namespace dev namespace eth { -extern u256 const c_stepGas; ///< Once per operation, except for SSTORE, SLOAD, BALANCE, SHA3, CREATE, CALL. -extern u256 const c_balanceGas; ///< Once per BALANCE operation. -extern u256 const c_sha3Gas; ///< Once per SHA3 operation. -extern u256 const c_sha3WordGas; -extern u256 const c_sloadGas; ///< Once per SLOAD operation. -extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. -extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. -extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. -extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. +extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. +extern u256 const c_expGas; ///< Once per EXP instuction. +extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + +extern u256 const c_sha3Gas; ///< Once per SHA3 operation. +extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + +extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + +extern u256 const c_sloadGas; ///< Once per SLOAD operation. +extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. +extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. +extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. +extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + +extern u256 const c_logGas; ///< Per LOG* operation. +extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. +extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. +extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; -extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_expGas; ///< Once per EXP instuction. -extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. -extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. -extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. -extern u256 const c_logGas; ///< Per LOG* operation. -extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. -extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. -extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. +extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. +extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. +extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + +extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. +extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. +extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2ba18eda6..a52b0ec3e 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -21,7 +21,7 @@ #include "VM.h" #include - +using namespace std; using namespace dev; using namespace dev::eth; @@ -32,13 +32,33 @@ void VM::reset(u256 _gas) noexcept m_jumpDests.clear(); } +struct InstructionMetric +{ + int gasPriceTier; + int args; +}; + +static array metrics() +{ + array s_ret; + for (unsigned i = 0; i < 256; ++i) + { + InstructionInfo inst = instructionInfo((Instruction)i); + s_ret[i].gasPriceTier = inst.gasPriceTier; + s_ret[i].args = inst.args; + } + return s_ret; +} + bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { + static const array c_metrics = metrics(); + auto memNeed = [](u256 _offset, dev::u256 _size) { return _size ? (bigint)_offset + _size : (bigint)0; }; auto gasForMem = [](bigint _size) -> bigint { bigint s = _size / 32; - return (bigint)c_memoryGas * (s + s * s / 1024); + return (bigint)c_memoryGas * s + s * s / c_quadCoeffDiv; }; if (m_jumpDests.empty()) @@ -57,36 +77,35 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) Instruction inst = (Instruction)_ext.getCode(m_curPC); // FEES... - bigint runGas = c_stepGas; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; + // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. + //m_onFail = std::function(onOperation); + + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; + require(metric.args); + auto onOperation = [&]() { if (_onOp) _onOp(osteps - _steps - 1, inst, newTempSize > m_temp.size() ? (newTempSize - m_temp.size()) / 32 : bigint(0), runGas, this, &_ext); }; - // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. - //m_onFail = std::function(onOperation); switch (inst) { - case Instruction::STOP: - runGas = 0; - break; - - case Instruction::SUICIDE: - require(1); - runGas = 0; - break; - case Instruction::SSTORE: - require(2); if (!_ext.store(m_stack.back()) && m_stack[m_stack.size() - 2]) runGas = c_sstoreSetGas; else if (_ext.store(m_stack.back()) && !m_stack[m_stack.size() - 2]) { - runGas = 0; + runGas = c_sstoreClearGas; _ext.sub.refunds += c_sstoreRefundGas; } else @@ -94,52 +113,39 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::SLOAD: - require(1); runGas = c_sloadGas; break; // These all operate on memory and therefore potentially expand it: case Instruction::MSTORE: - require(2); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::MSTORE8: - require(2); newTempSize = (bigint)m_stack.back() + 1; break; case Instruction::MLOAD: - require(1); newTempSize = (bigint)m_stack.back() + 32; break; case Instruction::RETURN: - require(2); newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::SHA3: - require(2); runGas = c_sha3Gas + (m_stack[m_stack.size() - 2] + 31) / 32 * c_sha3WordGas; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 2]); break; case Instruction::CALLDATACOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::CODECOPY: - require(3); copySize = m_stack[m_stack.size() - 3]; newTempSize = memNeed(m_stack.back(), m_stack[m_stack.size() - 3]); break; case Instruction::EXTCODECOPY: - require(4); copySize = m_stack[m_stack.size() - 4]; newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::BALANCE: - require(1); - runGas = c_balanceGas; - break; case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -147,7 +153,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::LOG4: { unsigned n = (unsigned)inst - (unsigned)Instruction::LOG0; - require(n + 2); runGas = c_logGas + c_logTopicGas * n + (bigint)c_logDataGas * m_stack[m_stack.size() - 2]; newTempSize = memNeed(m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]); break; @@ -155,149 +160,27 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: - require(7); runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + runGas += c_callNewAccountGas; + if (m_stack[m_stack.size() - 3] > 0) + runGas += c_callValueTransferGas; newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); break; case Instruction::CREATE: { - require(3); newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]); runGas = c_createGas; break; } case Instruction::EXP: { - require(2); auto expon = m_stack[m_stack.size() - 2]; runGas = c_expGas + c_expByteGas * (32 - (h256(expon).firstBitSet() / 8)); break; } - - case Instruction::BLOCKHASH: - require(1); - break; - - case Instruction::PC: - case Instruction::MSIZE: - case Instruction::GAS: - case Instruction::JUMPDEST: - case Instruction::ADDRESS: - case Instruction::ORIGIN: - case Instruction::CALLER: - case Instruction::CALLVALUE: - case Instruction::CALLDATASIZE: - case Instruction::CODESIZE: - case Instruction::GASPRICE: - case Instruction::COINBASE: - case Instruction::TIMESTAMP: - case Instruction::NUMBER: - case Instruction::DIFFICULTY: - case Instruction::GASLIMIT: - case Instruction::PUSH1: - case Instruction::PUSH2: - case Instruction::PUSH3: - case Instruction::PUSH4: - case Instruction::PUSH5: - case Instruction::PUSH6: - case Instruction::PUSH7: - case Instruction::PUSH8: - case Instruction::PUSH9: - case Instruction::PUSH10: - case Instruction::PUSH11: - case Instruction::PUSH12: - case Instruction::PUSH13: - case Instruction::PUSH14: - case Instruction::PUSH15: - case Instruction::PUSH16: - case Instruction::PUSH17: - case Instruction::PUSH18: - case Instruction::PUSH19: - case Instruction::PUSH20: - case Instruction::PUSH21: - case Instruction::PUSH22: - case Instruction::PUSH23: - case Instruction::PUSH24: - case Instruction::PUSH25: - case Instruction::PUSH26: - case Instruction::PUSH27: - case Instruction::PUSH28: - case Instruction::PUSH29: - case Instruction::PUSH30: - case Instruction::PUSH31: - case Instruction::PUSH32: - break; - case Instruction::NOT: - case Instruction::ISZERO: - case Instruction::CALLDATALOAD: - case Instruction::EXTCODESIZE: - case Instruction::POP: - case Instruction::JUMP: - require(1); - break; - case Instruction::ADD: - case Instruction::MUL: - case Instruction::SUB: - case Instruction::DIV: - case Instruction::SDIV: - case Instruction::MOD: - case Instruction::SMOD: - case Instruction::LT: - case Instruction::GT: - case Instruction::SLT: - case Instruction::SGT: - case Instruction::EQ: - case Instruction::AND: - case Instruction::OR: - case Instruction::XOR: - case Instruction::BYTE: - case Instruction::JUMPI: - case Instruction::SIGNEXTEND: - require(2); - break; - case Instruction::ADDMOD: - case Instruction::MULMOD: - require(3); - break; - case Instruction::DUP1: - case Instruction::DUP2: - case Instruction::DUP3: - case Instruction::DUP4: - case Instruction::DUP5: - case Instruction::DUP6: - case Instruction::DUP7: - case Instruction::DUP8: - case Instruction::DUP9: - case Instruction::DUP10: - case Instruction::DUP11: - case Instruction::DUP12: - case Instruction::DUP13: - case Instruction::DUP14: - case Instruction::DUP15: - case Instruction::DUP16: - require(1 + (int)inst - (int)Instruction::DUP1); - break; - case Instruction::SWAP1: - case Instruction::SWAP2: - case Instruction::SWAP3: - case Instruction::SWAP4: - case Instruction::SWAP5: - case Instruction::SWAP6: - case Instruction::SWAP7: - case Instruction::SWAP8: - case Instruction::SWAP9: - case Instruction::SWAP10: - case Instruction::SWAP11: - case Instruction::SWAP12: - case Instruction::SWAP13: - case Instruction::SWAP14: - case Instruction::SWAP15: - case Instruction::SWAP16: - require((int)inst - (int)Instruction::SWAP1 + 2); - break; - default: - BOOST_THROW_EXCEPTION(BadInstruction()); + default:; } newTempSize = (newTempSize + 31) / 32 * 32; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index bba3d7745..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -162,136 +162,136 @@ const std::map dev::eth::c_instructions = }; static const std::map c_instructionInfo = -{ // Add, Args, Ret, SideEffects - { Instruction::STOP, { "STOP", 0, 0, 0, true } }, - { Instruction::ADD, { "ADD", 0, 2, 1, false } }, - { Instruction::SUB, { "SUB", 0, 2, 1, false } }, - { Instruction::MUL, { "MUL", 0, 2, 1, false } }, - { Instruction::DIV, { "DIV", 0, 2, 1, false } }, - { Instruction::SDIV, { "SDIV", 0, 2, 1, false } }, - { Instruction::MOD, { "MOD", 0, 2, 1, false } }, - { Instruction::SMOD, { "SMOD", 0, 2, 1, false } }, - { Instruction::EXP, { "EXP", 0, 2, 1, false } }, - { Instruction::NOT, { "NOT", 0, 1, 1, false } }, - { Instruction::LT, { "LT", 0, 2, 1, false } }, - { Instruction::GT, { "GT", 0, 2, 1, false } }, - { Instruction::SLT, { "SLT", 0, 2, 1, false } }, - { Instruction::SGT, { "SGT", 0, 2, 1, false } }, - { Instruction::EQ, { "EQ", 0, 2, 1, false } }, - { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false } }, - { Instruction::AND, { "AND", 0, 2, 1, false } }, - { Instruction::OR, { "OR", 0, 2, 1, false } }, - { Instruction::XOR, { "XOR", 0, 2, 1, false } }, - { Instruction::BYTE, { "BYTE", 0, 2, 1, false } }, - { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false } }, - { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false } }, - { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false } }, - { Instruction::SHA3, { "SHA3", 0, 2, 1, false } }, - { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false } }, - { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false } }, - { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false } }, - { Instruction::CALLER, { "CALLER", 0, 0, 1, false } }, - { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false } }, - { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false } }, - { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false } }, - { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true } }, - { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false } }, - { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true } }, - { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false } }, - { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false } }, - { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true } }, - { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false } }, - { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false } }, - { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false } }, - { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false } }, - { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false } }, - { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false } }, - { Instruction::POP, { "POP", 0, 1, 0, false } }, - { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false } }, - { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true } }, - { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true } }, - { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false } }, - { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true } }, - { Instruction::JUMP, { "JUMP", 0, 1, 0, true } }, - { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true } }, - { Instruction::PC, { "PC", 0, 0, 1, false } }, - { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false } }, - { Instruction::GAS, { "GAS", 0, 0, 1, false } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true } }, - { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false } }, - { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false } }, - { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false } }, - { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false } }, - { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false } }, - { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false } }, - { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false } }, - { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false } }, - { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false } }, - { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false } }, - { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false } }, - { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false } }, - { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false } }, - { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false } }, - { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false } }, - { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false } }, - { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false } }, - { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false } }, - { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false } }, - { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false } }, - { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false } }, - { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false } }, - { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false } }, - { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false } }, - { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false } }, - { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false } }, - { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false } }, - { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false } }, - { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false } }, - { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false } }, - { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false } }, - { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false } }, - { Instruction::DUP1, { "DUP1", 0, 1, 2, false } }, - { Instruction::DUP2, { "DUP2", 0, 2, 3, false } }, - { Instruction::DUP3, { "DUP3", 0, 3, 4, false } }, - { Instruction::DUP4, { "DUP4", 0, 4, 5, false } }, - { Instruction::DUP5, { "DUP5", 0, 5, 6, false } }, - { Instruction::DUP6, { "DUP6", 0, 6, 7, false } }, - { Instruction::DUP7, { "DUP7", 0, 7, 8, false } }, - { Instruction::DUP8, { "DUP8", 0, 8, 9, false } }, - { Instruction::DUP9, { "DUP9", 0, 9, 10, false } }, - { Instruction::DUP10, { "DUP10", 0, 10, 11, false } }, - { Instruction::DUP11, { "DUP11", 0, 11, 12, false } }, - { Instruction::DUP12, { "DUP12", 0, 12, 13, false } }, - { Instruction::DUP13, { "DUP13", 0, 13, 14, false } }, - { Instruction::DUP14, { "DUP14", 0, 14, 15, false } }, - { Instruction::DUP15, { "DUP15", 0, 15, 16, false } }, - { Instruction::DUP16, { "DUP16", 0, 16, 17, false } }, - { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false } }, - { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false } }, - { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false } }, - { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false } }, - { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false } }, - { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false } }, - { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false } }, - { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false } }, - { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false } }, - { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false } }, - { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false } }, - { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false } }, - { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false } }, - { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false } }, - { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false } }, - { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false } }, - { Instruction::LOG0, { "LOG0", 0, 2, 0, true } }, - { Instruction::LOG1, { "LOG1", 0, 3, 0, true } }, - { Instruction::LOG2, { "LOG2", 0, 4, 0, true } }, - { Instruction::LOG3, { "LOG3", 0, 5, 0, true } }, - { Instruction::LOG4, { "LOG4", 0, 6, 0, true } }, - { Instruction::CREATE, { "CREATE", 0, 3, 1, true } }, - { Instruction::CALL, { "CALL", 0, 7, 1, true } }, - { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true } }, - { Instruction::RETURN, { "RETURN", 0, 2, 0, true } }, - { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true } } +{ // Add, Args, Ret, SideEffects, GasPriceTier + { Instruction::STOP, { "STOP", 0, 0, 0, true, ZeroTier } }, + { Instruction::ADD, { "ADD", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SUB, { "SUB", 0, 2, 1, false, VeryLowTier } }, + { Instruction::MUL, { "MUL", 0, 2, 1, false, LowTier } }, + { Instruction::DIV, { "DIV", 0, 2, 1, false, LowTier } }, + { Instruction::SDIV, { "SDIV", 0, 2, 1, false, LowTier } }, + { Instruction::MOD, { "MOD", 0, 2, 1, false, LowTier } }, + { Instruction::SMOD, { "SMOD", 0, 2, 1, false, LowTier } }, + { Instruction::EXP, { "EXP", 0, 2, 1, false, SpecialTier } }, + { Instruction::NOT, { "NOT", 0, 1, 1, false, VeryLowTier } }, + { Instruction::LT, { "LT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::GT, { "GT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SLT, { "SLT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::SGT, { "SGT", 0, 2, 1, false, VeryLowTier } }, + { Instruction::EQ, { "EQ", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ISZERO, { "ISZERO", 0, 1, 1, false, VeryLowTier } }, + { Instruction::AND, { "AND", 0, 2, 1, false, VeryLowTier } }, + { Instruction::OR, { "OR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::XOR, { "XOR", 0, 2, 1, false, VeryLowTier } }, + { Instruction::BYTE, { "BYTE", 0, 2, 1, false, VeryLowTier } }, + { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, MidTier } }, + { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, MidTier } }, + { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, LowTier } }, + { Instruction::SHA3, { "SHA3", 0, 2, 1, false, SpecialTier } }, + { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, BaseTier } }, + { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, ExtTier } }, + { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLER, { "CALLER", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLVALUE, { "CALLVALUE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATALOAD,{ "CALLDATALOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::CALLDATASIZE,{ "CALLDATASIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CALLDATACOPY,{ "CALLDATACOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::CODESIZE, { "CODESIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::CODECOPY, { "CODECOPY", 0, 3, 0, true, VeryLowTier } }, + { Instruction::GASPRICE, { "GASPRICE", 0, 0, 1, false, BaseTier } }, + { Instruction::EXTCODESIZE, { "EXTCODESIZE", 0, 1, 1, false, ExtTier } }, + { Instruction::EXTCODECOPY, { "EXTCODECOPY", 0, 4, 0, true, ExtTier } }, + { Instruction::BLOCKHASH, { "BLOCKHASH", 0, 1, 1, false, ExtTier } }, + { Instruction::COINBASE, { "COINBASE", 0, 0, 1, false, BaseTier } }, + { Instruction::TIMESTAMP, { "TIMESTAMP", 0, 0, 1, false, BaseTier } }, + { Instruction::NUMBER, { "NUMBER", 0, 0, 1, false, BaseTier } }, + { Instruction::DIFFICULTY, { "DIFFICULTY", 0, 0, 1, false, BaseTier } }, + { Instruction::GASLIMIT, { "GASLIMIT", 0, 0, 1, false, BaseTier } }, + { Instruction::POP, { "POP", 0, 1, 0, false, BaseTier } }, + { Instruction::MLOAD, { "MLOAD", 0, 1, 1, false, VeryLowTier } }, + { Instruction::MSTORE, { "MSTORE", 0, 2, 0, true, VeryLowTier } }, + { Instruction::MSTORE8, { "MSTORE8", 0, 2, 0, true, VeryLowTier } }, + { Instruction::SLOAD, { "SLOAD", 0, 1, 1, false, SpecialTier } }, + { Instruction::SSTORE, { "SSTORE", 0, 2, 0, true, SpecialTier } }, + { Instruction::JUMP, { "JUMP", 0, 1, 0, true, MidTier } }, + { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, HighTier } }, + { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, + { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, + { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH4, { "PUSH4", 4, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH5, { "PUSH5", 5, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH6, { "PUSH6", 6, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH7, { "PUSH7", 7, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH8, { "PUSH8", 8, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH9, { "PUSH9", 9, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH10, { "PUSH10", 10, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH11, { "PUSH11", 11, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH12, { "PUSH12", 12, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH13, { "PUSH13", 13, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH14, { "PUSH14", 14, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH15, { "PUSH15", 15, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH16, { "PUSH16", 16, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH17, { "PUSH17", 17, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH18, { "PUSH18", 18, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH19, { "PUSH19", 19, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH20, { "PUSH20", 20, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH21, { "PUSH21", 21, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH22, { "PUSH22", 22, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH23, { "PUSH23", 23, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH24, { "PUSH24", 24, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH25, { "PUSH25", 25, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH26, { "PUSH26", 26, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH27, { "PUSH27", 27, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH28, { "PUSH28", 28, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH29, { "PUSH29", 29, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH30, { "PUSH30", 30, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH31, { "PUSH31", 31, 0, 1, false, VeryLowTier } }, + { Instruction::PUSH32, { "PUSH32", 32, 0, 1, false, VeryLowTier } }, + { Instruction::DUP1, { "DUP1", 0, 1, 2, false, VeryLowTier } }, + { Instruction::DUP2, { "DUP2", 0, 2, 3, false, VeryLowTier } }, + { Instruction::DUP3, { "DUP3", 0, 3, 4, false, VeryLowTier } }, + { Instruction::DUP4, { "DUP4", 0, 4, 5, false, VeryLowTier } }, + { Instruction::DUP5, { "DUP5", 0, 5, 6, false, VeryLowTier } }, + { Instruction::DUP6, { "DUP6", 0, 6, 7, false, VeryLowTier } }, + { Instruction::DUP7, { "DUP7", 0, 7, 8, false, VeryLowTier } }, + { Instruction::DUP8, { "DUP8", 0, 8, 9, false, VeryLowTier } }, + { Instruction::DUP9, { "DUP9", 0, 9, 10, false, VeryLowTier } }, + { Instruction::DUP10, { "DUP10", 0, 10, 11, false, VeryLowTier } }, + { Instruction::DUP11, { "DUP11", 0, 11, 12, false, VeryLowTier } }, + { Instruction::DUP12, { "DUP12", 0, 12, 13, false, VeryLowTier } }, + { Instruction::DUP13, { "DUP13", 0, 13, 14, false, VeryLowTier } }, + { Instruction::DUP14, { "DUP14", 0, 14, 15, false, VeryLowTier } }, + { Instruction::DUP15, { "DUP15", 0, 15, 16, false, VeryLowTier } }, + { Instruction::DUP16, { "DUP16", 0, 16, 17, false, VeryLowTier } }, + { Instruction::SWAP1, { "SWAP1", 0, 2, 2, false, VeryLowTier } }, + { Instruction::SWAP2, { "SWAP2", 0, 3, 3, false, VeryLowTier } }, + { Instruction::SWAP3, { "SWAP3", 0, 4, 4, false, VeryLowTier } }, + { Instruction::SWAP4, { "SWAP4", 0, 5, 5, false, VeryLowTier } }, + { Instruction::SWAP5, { "SWAP5", 0, 6, 6, false, VeryLowTier } }, + { Instruction::SWAP6, { "SWAP6", 0, 7, 7, false, VeryLowTier } }, + { Instruction::SWAP7, { "SWAP7", 0, 8, 8, false, VeryLowTier } }, + { Instruction::SWAP8, { "SWAP8", 0, 9, 9, false, VeryLowTier } }, + { Instruction::SWAP9, { "SWAP9", 0, 10, 10, false, VeryLowTier } }, + { Instruction::SWAP10, { "SWAP10", 0, 11, 11, false, VeryLowTier } }, + { Instruction::SWAP11, { "SWAP11", 0, 12, 12, false, VeryLowTier } }, + { Instruction::SWAP12, { "SWAP12", 0, 13, 13, false, VeryLowTier } }, + { Instruction::SWAP13, { "SWAP13", 0, 14, 14, false, VeryLowTier } }, + { Instruction::SWAP14, { "SWAP14", 0, 15, 15, false, VeryLowTier } }, + { Instruction::SWAP15, { "SWAP15", 0, 16, 16, false, VeryLowTier } }, + { Instruction::SWAP16, { "SWAP16", 0, 17, 17, false, VeryLowTier } }, + { Instruction::LOG0, { "LOG0", 0, 2, 0, true, SpecialTier } }, + { Instruction::LOG1, { "LOG1", 0, 3, 0, true, SpecialTier } }, + { Instruction::LOG2, { "LOG2", 0, 4, 0, true, SpecialTier } }, + { Instruction::LOG3, { "LOG3", 0, 5, 0, true, SpecialTier } }, + { Instruction::LOG4, { "LOG4", 0, 6, 0, true, SpecialTier } }, + { Instruction::CREATE, { "CREATE", 0, 3, 1, true, SpecialTier } }, + { Instruction::CALL, { "CALL", 0, 7, 1, true, SpecialTier } }, + { Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, SpecialTier } }, + { Instruction::RETURN, { "RETURN", 0, 2, 0, true, ZeroTier } }, + { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true, ZeroTier } } }; string dev::eth::disassemble(bytes const& _mem) @@ -326,12 +326,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } catch (...) { -#ifndef BOOST_NO_EXCEPTIONS - cwarn << "\n" << boost::current_exception_diagnostic_information(); -#else - cwarn << "\n"; -#endif - return InstructionInfo({"", 0, 0, 0, false}); + return InstructionInfo({"", 0, 0, 0, false, InvalidTier}); } } diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h index 5cf002c4c..9eab92713 100644 --- a/libevmcore/Instruction.h +++ b/libevmcore/Instruction.h @@ -223,6 +223,19 @@ inline Instruction logInstruction(unsigned _number) return Instruction(unsigned(Instruction::LOG0) + _number); } +enum Tier +{ + ZeroTier = 0, // 0, Zero + BaseTier, // 2, Quick + VeryLowTier, // 3, Fastest + LowTier, // 5, Fast + MidTier, // 8, Mid + HighTier, // 10, Slow + ExtTier, // 20, Ext + SpecialTier, // multiparam or otherwise special + InvalidTier // Invalid. +}; + /// Information structure for a particular instruction. struct InstructionInfo { @@ -231,6 +244,7 @@ struct InstructionInfo int args; ///< Number of items required on the stack for this instruction (and, for the purposes of ret, the number taken from the stack). int ret; ///< Number of items placed (back) on the stack by this instruction, assuming args items were removed. bool sideEffects; ///< false if the only effect on the execution environment (apart from gas usage) is a change to a topmost segment of the stack + int gasPriceTier; ///< Tier for gas pricing. }; /// Information on all the instructions. From f799303ea588276976eeea05230986eda3410fe5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 175/313] Gas fixes. Trie fixes. --- libdevcore/Exceptions.h | 1 + libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 8 ++++++-- libethereum/Client.cpp | 8 ++------ libevm/VM.cpp | 15 +++++++-------- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index e631a3b49..8c66cac49 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -46,6 +46,7 @@ struct BadRLP: virtual RLPException {}; struct NoNetworking: virtual Exception {}; struct NoUPnPDevice: virtual Exception {}; struct RootNotFound: virtual Exception {}; +struct BadRoot: virtual Exception {}; struct FileError: virtual Exception {}; struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): Exception("Interface " + _f + " not supported.") {} }; diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 583bfbf6e..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -93,7 +93,7 @@ public: /// True if the trie is initialised but empty (i.e. that the DB contains the root node which is empty). bool isEmpty() const { return m_root == c_shaNull && node(m_root).size(); } - h256 root() const { assert(node(m_root).size()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. + h256 root() const { if (!node(m_root).size()) BOOST_THROW_EXCEPTION(BadRoot()); /*std::cout << "Returning root as " << ret << " (really " << m_root << ")" << std::endl;*/ return m_root; } // patch the root in the case of the empty trie. TODO: handle this properly. void debugPrint() {} @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index b0b95c7bf..314594d2d 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -278,13 +278,9 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -#if ETH_DEBUG - cdebug << "checkWatch" << _watchId; -#endif +// cdebug << "checkWatch" << _watchId; auto& w = m_watches.at(_watchId); -#if ETH_DEBUG - cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); -#endif +// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index a52b0ec3e..6a6937f89 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -75,21 +75,20 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { // INSTRUCTION... Instruction inst = (Instruction)_ext.getCode(m_curPC); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -186,7 +185,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = (newTempSize + 31) / 32 * 32; if (newTempSize > m_temp.size()) runGas += gasForMem(newTempSize) - gasForMem(m_temp.size()); - runGas += c_copyGas * (copySize + 31) / 32; + runGas += c_copyGas * ((copySize + 31) / 32); onOperation(); // if (_onOp) From 4a530758b0c87055f948b55ef0f8c0b6e7866537 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 176/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 6a6937f89..2243da2e7 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From 64cf0a986c293f5200d281bd65fda1c87ad39a03 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 177/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- test/vm.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 40ff62175..2ff270de5 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/test/vm.h b/test/vm.h index f27bce50b..1c0190b69 100644 --- a/test/vm.h +++ b/test/vm.h @@ -52,6 +52,7 @@ public: virtual u256 store(u256 _n) override { return std::get<2>(addresses[myAddress])[_n]; } virtual void setStore(u256 _n, u256 _v) override { std::get<2>(addresses[myAddress])[_n] = _v; } + virtual bool exists(Address _a) override { return !!addresses.count(_a); } virtual u256 balance(Address _a) override { return std::get<0>(addresses[_a]); } virtual void subBalance(u256 _a) override { std::get<0>(addresses[myAddress]) -= _a; } virtual u256 txCount(Address _a) override { return std::get<1>(addresses[_a]); } From e7fae29713c8e6169b439cae674034fb71a23884 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 178/313] only check rootHash of state if FATDB is off --- test/state.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/state.cpp b/test/state.cpp index 17ebe2b77..72eda1a10 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -72,7 +72,13 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } if (_fillin) + { +#if ETH_FATDB importer.exportTest(output, theState); +#else + BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off")); +#endif + } else { BOOST_REQUIRE(o.count("post") > 0); @@ -85,6 +91,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) checkLog(theState.pending().size() ? theState.log(0) : LogEntries(), importer.m_environment.sub.logs); // check addresses +#if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -103,6 +111,8 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) } } checkAddresses >(expectedAddrs, resultAddrs); +#endif + BOOST_CHECK_MESSAGE(theState.rootHash() == h256(o["postStateRoot"].get_str()), "wrong post state root"); } } } From 472f15effe94f16021f6c0b6d1c74b9fcd34b4dd Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 179/313] add memory tests --- test/TestHelper.cpp | 2 ++ test/stMemoryTestFiller.json | 4 +-- test/state.cpp | 68 ++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 82add295e..104c03f2c 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -205,6 +205,8 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) } m_TestObject["post"] = json_spirit::mValue(postState); + m_TestObject["postStateRoot"] = toHex(_statePost.rootHash().asBytes()); + // export pre state json_spirit::mObject preState; diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json index e2b3b95a0..eac2d5875 100644 --- a/test/stMemoryTestFiller.json +++ b/test/stMemoryTestFiller.json @@ -1459,7 +1459,5 @@ "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "0xff55883355001144bbccddffeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } - }, - - + } } diff --git a/test/state.cpp b/test/state.cpp index 72eda1a10..612e44e6a 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -92,7 +92,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -172,50 +171,51 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) { - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } BOOST_AUTO_TEST_CASE(stMemoryStressTest) { - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); -} + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } BOOST_AUTO_TEST_CASE(stMemoryTest) { - dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); + dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From 7256d573d7c30bf361fb5cb191fcfc5eee0a5338 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 180/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From e9822bb3bb266d9582aa4b830fd826c74b236a7a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:18:00 +0100 Subject: [PATCH 181/313] Avoid invalid paranoia tests. --- libethereum/State.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 2d1ba2e33..508e0e617 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -134,7 +134,7 @@ State::State(State const& _s): void State::paranoia(std::string const& _when, bool _enforceRefs) const { -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB // TODO: variable on context; just need to work out when there should be no leftovers // [in general this is hard since contract alteration will result in nodes in the DB that are no directly part of the state DB]. if (!isTrieGood(_enforceRefs, false)) @@ -1091,7 +1091,7 @@ u256 State::execute(LastHashes const& _lh, bytesConstRef _rlp, bytes* o_output, commit(); -#if ETH_PARANOIA +#if ETH_PARANOIA && !ETH_FATDB ctrace << "Executed; now" << rootHash(); ctrace << old.diff(*this); From 7b22f8da22fa428edbf893bacaa89e7048b264e2 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 182/313] update gas costs --- libevm/FeeStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..58d756bae 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From 55b2bca0d30bda3e6918f2e86cc7bf33ecd1dbc9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 183/313] Log/bloom alterations. --- libdevcore/FixedHash.h | 2 ++ libethcore/BlockInfo.cpp | 2 +- libethcore/CommonEth.h | 7 +++++-- libethereum/BlockDetails.h | 4 ++-- libevm/FeeStructure.cpp | 7 ++++--- libevm/FeeStructure.h | 1 + libevm/VM.cpp | 17 ++--------------- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 3113b5427..eec988d76 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -240,6 +240,8 @@ inline std::ostream& operator<<(std::ostream& _out, FixedHash const& _h) } // Common types of FixedHash. +using h2048 = FixedHash<256>; +using h1024 = FixedHash<128>; using h520 = FixedHash<65>; using h512 = FixedHash<64>; using h256 = FixedHash<32>; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ce158c3cc..ce4407317 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -101,7 +101,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) stateRoot = _header[field = 3].toHash(); transactionsRoot = _header[field = 4].toHash(); receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + logBloom = _header[field = 6].toHash(); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 79525082f..89ca0aa06 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -44,8 +44,11 @@ std::string formatBalance(bigint const& _b); /// Get information concerning the currency denominations. std::vector> const& units(); -/// The log bloom's size (512 bit). -using LogBloom = h512; +/// The log bloom's size (2048-bit). +using LogBloom = h2048; + +/// Many log blooms. +using LogBlooms = std::vector; template inline u256 exp10() { diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 61b9667c4..9a3ac9ff1 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -55,10 +55,10 @@ struct BlockDetails struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } bytes rlp() const { RLPStream s; s << blooms; return s.out(); } - h512s blooms; + LogBlooms blooms; }; struct BlockReceipts diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 58d756bae..03dd14850 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 1b58c80e9..120034b0e 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 2243da2e7..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -563,21 +563,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) break; case Instruction::JUMPDEST: break; -/* case Instruction::LOG0: - _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); - break; - case Instruction::LOG1: - _ext.log({m_stack[m_stack.size() - 1]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 2], (unsigned)m_stack[m_stack.size() - 3])); - break; - case Instruction::LOG2: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 3], (unsigned)m_stack[m_stack.size() - 4])); - break; - case Instruction::LOG3: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 4], (unsigned)m_stack[m_stack.size() - 5])); - break; - case Instruction::LOG4: - _ext.log({m_stack[m_stack.size() - 1], m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 3], m_stack[m_stack.size() - 4]}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 5], (unsigned)m_stack[m_stack.size() - 6])); - break;*/ case Instruction::LOG0: _ext.log({}, bytesConstRef(m_temp.data() + (unsigned)m_stack[m_stack.size() - 1], (unsigned)m_stack[m_stack.size() - 2])); m_stack.pop_back(); @@ -635,6 +620,8 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALLCODE: { u256 gas = m_stack.back(); + if (m_stack[m_stack.size() - 3] > 0) + gas += c_callStipend; m_stack.pop_back(); Address receiveAddress = asAddress(m_stack.back()); m_stack.pop_back(); From 52661968ebc533a3a29856a967a28437085d5e8c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 184/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba25e74ce..43ee58eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 732782d3f..97e9a220b 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -82,10 +82,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)500; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)50 + (i.size() + 31) / 32 * 50; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)1 + (i.size() + 31) / 32 * 1; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index 84d0e846f..9e59dd316 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,6 +74,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 5d1e93ec0e000e58da52342437f8266671b1b9c5 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 185/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 38 +++++++++++++++++++++++++++++++++++++ libethereum/GenesisInfo.cpp | 4 ++++ 2 files changed, 42 insertions(+) create mode 100644 feeStructure.json diff --git a/feeStructure.json b/feeStructure.json new file mode 100644 index 000000000..f09464a5a --- /dev/null +++ b/feeStructure.json @@ -0,0 +1,38 @@ +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, + + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index b9b45d4b4..d7224b7cc 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -24,6 +24,10 @@ std::string const dev::eth::c_genesisInfo = R"ETHEREUM( { + "0000000000000000000000000000000000000001": { "wei": "1" }, + "0000000000000000000000000000000000000002": { "wei": "1" }, + "0000000000000000000000000000000000000003": { "wei": "1" }, + "0000000000000000000000000000000000000004": { "wei": "1" }, "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e6716f9544a56c530d868e4bfbacb172315bdead": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "b9c015918bdaba24b4ff057a92a3873d6eb201be": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, From f7dba3781ad45958cdd82e52ace9842a329277f6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 186/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethereum/GenesisInfo.cpp | 4 -- libethereum/Precompiled.cpp | 9 ++-- libevm/FeeStructure.cpp | 85 ++++++++++++++++++----------------- libevm/FeeStructure.h | 8 ++++ 5 files changed, 109 insertions(+), 85 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethereum/GenesisInfo.cpp b/libethereum/GenesisInfo.cpp index d7224b7cc..4e6a48284 100644 --- a/libethereum/GenesisInfo.cpp +++ b/libethereum/GenesisInfo.cpp @@ -36,9 +36,5 @@ R"ETHEREUM( "cd2a3d9f938e13cd947ec05abc7fe734df8dd826": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "6c386a4b26f73c802f34673f7248bb118f97424a": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, "e4157b34ea9615cfbde6b4fda419828124b70c78": { "wei": "1606938044258990275541962092341162602522202993782792835301376" }, - "b0afc46d9ce366d06ab4952ca27db1d9557ae9fd": { "finney": "154162184" }, - "f6b1e9dc460d4d62cc22ec5f987d726929c0f9f0": { "finney": "102774789" }, - "cc45122d8b7fa0b1eaa6b29e0fb561422a9239d0": { "finney": "51387394" }, - "b7576e9d314df41ec5506494293afb1bd5d3f65d": { "finney": "69423399" }, } )ETHEREUM"; diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 97e9a220b..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace std; using namespace dev; using namespace dev::eth; @@ -82,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 03dd14850..78c6ebfb2 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,45 +22,48 @@ #include "FeeStructure.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 120034b0e..9d60ac1bd 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } From 7ccf3d00b2270d6edb6d963afef134a2b1d35903 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 187/313] VM CALLCODE fix. --- libevm/FeeStructure.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9d60ac1bd..9109347dc 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From 10dccac64b75ef3468d8dce55e550e515ded2c16 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:03:47 +0100 Subject: [PATCH 188/313] Lenient gas limit. Two uncles only. Min 2048 difficulty & assoc adjustment. --- libethcore/BlockInfo.cpp | 9 ++++++--- libethcore/Exceptions.cpp | 36 ++++++++++++++++-------------------- libethcore/Exceptions.h | 5 +++-- libethereum/State.cpp | 21 +++++++++++---------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ce4407317..49ed1578b 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -191,16 +191,19 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(1024, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty >> 10) : (_parent.difficulty + (_parent.difficulty >> 10))); + return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } +template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } + void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (gasLimit != calculateGasLimit(_parent)) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent))); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + // Check timestamp is after previous timestamp. if (parentHash) diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index 4e758da76..c4628f4aa 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -27,24 +27,20 @@ using namespace std; using namespace dev; using namespace dev::eth; -InvalidBlockFormat::InvalidBlockFormat(int _f, bytesConstRef _d): - Exception("Invalid block format: Bad field " + toString(_f) + " (" + toHex(_d) + ")"), f(_f), d(_d.toBytes()) {} - -UncleInChain::UncleInChain(h256Set _uncles, h256 _block): - Exception("Uncle in block already mentioned: Uncles " + toString(_uncles) + " (" + _block.abridged() + ")"), uncles(_uncles), block(_block) {} - -InvalidTransactionsHash::InvalidTransactionsHash(h256 _head, h256 _real): - Exception("Invalid transactions hash: header says: " + toHex(_head.ref()) + " block is:" + toHex(_real.ref())), head(_head), real(_real) {} - -InvalidGasLimit::InvalidGasLimit(u256 _provided, u256 _valid): - Exception("Invalid gas limit (provided: " + toString(_provided) + " valid:" + toString(_valid) + ")"), provided(_provided), valid(_valid) {} - -InvalidMinGasPrice::InvalidMinGasPrice(u256 _provided, u256 _limit): - Exception("Invalid minimum gas price (provided: " + toString(_provided) + " limit:" + toString(_limit) + ")"), provided(_provided), limit(_limit) {} - -InvalidNonce::InvalidNonce(u256 _required, u256 _candidate): - Exception("Invalid nonce (r: " + toString(_required) + " c:" + toString(_candidate) + ")"), required(_required), candidate(_candidate) {} - -InvalidBlockNonce::InvalidBlockNonce(h256 _h, h256 _n, u256 _d): - Exception("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"), h(_h), n(_n), d(_d) {} +#if ALL_COMPILERS_ARE_CPP11 +#define ETH_RETURN_STRING(S) thread_local static string s_what; s_what = S; return s_what.c_str(); +#elsif USE_BOOST_TLS +static boost::thread_specific_ptr g_exceptionMessage; +#define ETH_RETURN_STRING(S) if (!g_exceptionMessage.get()); g_exceptionMessage.reset(new string); *g_exceptionMessage.get() = S; return g_exceptionMessage.get()->c_str(); +#else +#define ETH_RETURN_STRING(S) m_message = S; return m_message.c_str(); +#endif + +const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } +const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } +const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } +const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } +const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } +const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 21015cf6f..11497252f 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -47,6 +47,7 @@ struct InvalidSignature: virtual dev::Exception {}; class InvalidBlockFormat: virtual public dev::Exception { public: InvalidBlockFormat(int _f, bytesConstRef _d); int f; bytes d; }; struct InvalidUnclesHash: virtual dev::Exception {}; struct InvalidUncle: virtual dev::Exception {}; +struct TooManyUncles: virtual dev::Exception {}; struct UncleTooOld: virtual dev::Exception {}; class UncleInChain: virtual public dev::Exception { public: UncleInChain(h256Set _uncles, h256 _block); h256Set uncles; h256 block; }; struct DuplicateUncleNonce: virtual dev::Exception {}; @@ -55,8 +56,8 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real); h256 head; h256 real; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0); u256 provided; u256 valid; }; -class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0); u256 provided; u256 limit; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; +class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; struct InvalidReceiptsStateRoot: virtual dev::Exception {}; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 508e0e617..5fbe8d48d 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -487,10 +487,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) receiptsTrie.init(); LastHashes lh = getLastHashes(_bc, (unsigned)m_previousBlock.number); + RLP rlp(_block); // All ok with the block generally. Play back the transactions now... unsigned i = 0; - for (auto const& tr: RLP(_block)[1]) + for (auto const& tr: rlp[1]) { RLPStream k; k << i; @@ -504,17 +505,11 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) ++i; } - if (transactionsTrie.root() != m_currentBlock.transactionsRoot) - { - cwarn << "Bad transactions state root!"; - BOOST_THROW_EXCEPTION(InvalidTransactionsStateRoot()); - } - if (receiptsTrie.root() != m_currentBlock.receiptsRoot) { cwarn << "Bad receipts state root."; cwarn << "Block:" << toHex(_block); - cwarn << "Block RLP:" << RLP(_block); + cwarn << "Block RLP:" << rlp; cwarn << "Calculated: " << receiptsTrie.root(); for (unsigned j = 0; j < i; ++j) { @@ -549,10 +544,14 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) u256 tdIncrease = m_currentBlock.difficulty; // Check uncles & apply their rewards to state. + if (rlp[2].itemCount() > 2) + BOOST_THROW_EXCEPTION(TooManyUncles()); + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); - for (auto const& i: RLP(_block)[2]) + + for (auto const& i: rlp[2]) { if (knownUncles.count(sha3(i.data()))) BOOST_THROW_EXCEPTION(UncleInChain(knownUncles, sha3(i.data()) )); @@ -700,7 +699,7 @@ void State::commitToMine(BlockChain const& _bc) // cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); auto p = m_previousBlock.parentHash; - for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash(); ++gen, p = _bc.details(p).parent) + for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash() && unclesCount < 2; ++gen, p = _bc.details(p).parent) { auto us = _bc.details(p).children; assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent! @@ -711,6 +710,8 @@ void State::commitToMine(BlockChain const& _bc) ubi.streamRLP(unclesData, WithNonce); ++unclesCount; uncleAddresses.push_back(ubi.coinbaseAddress); + if (unclesCount == 2) + break; } } } From 4d1464783a42854ae0e1e8fb2c4f48a94cf1e78a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 189/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 92 ++++++++-------------------------------- libethcore/CommonEth.cpp | 8 +--- libethereum/State.cpp | 28 ++++++------ libethereum/State.h | 38 ++++------------- 4 files changed, 43 insertions(+), 123 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 1abf2d8c0..79852304c 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -334,20 +334,19 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class HashedGenericTrieDB: private SpecificTrieDB, h256> +template +class SecureGenericTrieDB: private TrieDB { - using Super = SpecificTrieDB, h256>; + using Super = TrieDB; public: - using DB = _DB; - - HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} - HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; + using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -360,84 +359,29 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - - // empty from the PoV of the iterator interface; still need a basic iterator impl though. - class iterator - { - public: - using value_type = std::pair; - - iterator() {} - iterator(HashedGenericTrieDB const*) {} - iterator(HashedGenericTrieDB const*, bytesConstRef) {} - - iterator& operator++() { return *this; } - value_type operator*() const { return value_type(); } - value_type operator->() const { return value_type(); } - - bool operator==(iterator const&) const { return true; } - bool operator!=(iterator const&) const { return false; } - - value_type at() const { return value_type(); } - }; - iterator begin() const { return iterator(); } - iterator end() const { return iterator(); } - iterator lower_bound(bytesConstRef) const { return iterator(); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } }; -// Hashed & Basic -template -class FatGenericTrieDB: public GenericTrieDB +template +class SecureTrieDB: public SecureGenericTrieDB { - using Super = GenericTrieDB; + using Super = SecureGenericTrieDB; public: - FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} - FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} - void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - - void init() { Super::init(); m_secure.init(); syncRoot(); } - - void setRoot(h256 _root) - { - if (!m_secure.isNull()) - Super::db()->removeAux(m_secure.root()); - m_secure.setRoot(_root); - auto rb = Super::db()->lookupAux(m_secure.root()); - auto r = h256(rb); - Super::setRoot(r); - } - - h256 root() const { return m_secure.root(); } - - void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } - void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } - - std::set leftOvers(std::ostream* = nullptr) const { return {}; } - bool check(bool) const { return m_secure.check(false) && Super::check(false); } - -private: - void syncRoot() - { - // Root changed. Need to record the mapping so we can determine on setRoot. - Super::db()->insertAux(m_secure.root(), Super::root().ref()); - } + std::string operator[](KeyType _k) const { return at(_k); } - HashedGenericTrieDB m_secure; + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template using TrieDB = SpecificTrieDB, KeyType>; - -#if ETH_FATDB -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#else -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#endif - } // Template implementations... diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index ad41780e9..8facdf0f1 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,13 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 6 + -#if ETH_FATDB - 1000 -#else - 0 -#endif -; +const unsigned c_databaseVersion = 5; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 5fbe8d48d..919410d21 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,10 +180,11 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,9 +346,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -947,9 +949,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1185,8 +1188,9 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index a496a4a03..7c3cec2a6 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,36 +334,14 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; - } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); } } } From 72e681a65b6a4e85805c865cb3b7c1cf7ed15147 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 190/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 5 ++- libdevcrypto/TrieDB.h | 75 ++++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index eec988d76..dceb1d70a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 7d39ba73b..2f4233f01 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,9 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } - void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } std::set keys() const; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 79852304c..91a39b3cc 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db = nullptr): m_db(_db) {} + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} + SpecificTrieDB(DB* _db): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -334,19 +334,20 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -359,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... From d9418085246cf3413012f3135eb54e60fd5364f3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 191/313] FatDB integrated. --- CMakeLists.txt | 8 +------- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/CommonEth.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ee58eaa..e86ded470 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,6 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") - set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") - set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -51,11 +49,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (SOLIDITY) - add_definitions(-DETH_SOLIDITY) - endif() - - if (HEADLESS OR JUSTTESTS) + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 91a39b3cc..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index 8facdf0f1..eba10e321 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 919410d21..5fbe8d48d 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,11 +180,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -346,10 +345,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -949,10 +947,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1188,9 +1185,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From ae1cb7f1ffb0d2c016ea677c08a3e0483ed98ac8 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 192/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 3 +- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 6 ++-- libdevcrypto/OverlayDB.cpp | 16 ++-------- libdevcrypto/TrieDB.h | 2 +- libethcore/CommonEth.cpp | 2 +- libethereum/State.h | 38 ++++++++++++++++++----- test/trie.cpp | 62 -------------------------------------- 8 files changed, 42 insertions(+), 91 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e86ded470..ba25e74ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index dceb1d70a..eec988d76 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 2f4233f01..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,8 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; @@ -61,7 +61,7 @@ protected: std::map m_over; std::map m_refCount; - std::set m_auxActive; + h256 m_auxKey; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,16 +52,8 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - for (auto const& i: m_auxActive) - if (m_aux.count(i)) - { - m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; - m_aux.erase(i); - } - cdebug << "Discarding " << keysOf(m_aux); - m_auxActive.clear(); - m_aux.clear(); + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } @@ -73,9 +65,7 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, aux(_h).ref(), &v); - if (v.empty()) - cwarn << "Aux not found: " << _h; + m_db->Get(m_readOptions, _h.ref(), &v); return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..f32170cd4 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index eba10e321..ad41780e9 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/State.h b/libethereum/State.h index 7c3cec2a6..a496a4a03 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,14 +334,36 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } } } diff --git a/test/trie.cpp b/test/trie.cpp index 9e59dd316..84d0e846f 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,68 +74,6 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } -BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Secure Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - GenericTrieDB t(&m); - MemoryDB hm; - HashedGenericTrieDB ht(&hm); - MemoryDB fm; - FatGenericTrieDB ft(&fm); - t.init(); - ht.init(); - ft.init(); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - ht.insert(k.first, k.second); - ft.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) - { - BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); - BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); - BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); - } - BOOST_CHECK_EQUAL(ht.root(), ft.root()); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 628a145f21e1d31311d0ddfbfc5f234f7c2a199c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 193/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f32170cd4..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From 798f636c239ffe40f01144204ac8927098754fc3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 194/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 2 +- libevm/FeeStructure.cpp | 84 ++++++++++++++++++-------------------- libevm/FeeStructure.h | 14 +++---- libevm/VM.cpp | 14 ++++--- libevmcore/Instruction.cpp | 2 +- 5 files changed, 55 insertions(+), 61 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 2ff270de5..40ff62175 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 78c6ebfb2..1c1bf8a9e 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,48 +22,44 @@ #include "FeeStructure.h" using namespace std; -namespace dev -{ -namespace eth -{ - -//--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; -u256 const c_expGas = 10; -u256 const c_expByteGas = 10; -u256 const c_sha3Gas = 30; -u256 const c_sha3WordGas = 6; -u256 const c_sloadGas = 50; -u256 const c_sstoreSetGas = 20000; -u256 const c_sstoreResetGas = 5000; -u256 const c_sstoreClearGas = 5000; -u256 const c_sstoreRefundGas = 15000; -u256 const c_jumpdestGas = 1; -u256 const c_logGas = 375; -u256 const c_logDataGas = 8; -u256 const c_logTopicGas = 375; -u256 const c_createGas = 32000; -u256 const c_callGas = 40; -u256 const c_callStipend = 2300; -u256 const c_callValueTransferGas = 9000; -u256 const c_callNewAccountGas = 25000; -u256 const c_suicideRefundGas = 24000; -u256 const c_memoryGas = 3; -u256 const c_quadCoeffDiv = 512; -u256 const c_createDataGas = 200; -u256 const c_txGas = 21000; -u256 const c_txDataZeroGas = 4; -u256 const c_txDataNonZeroGas = 68; -u256 const c_copyGas = 3; -u256 const c_ecrecoverGas = 3000; -u256 const c_sha256Gas = 60; -u256 const c_sha256WordGas = 12; -u256 const c_ripemd160Gas = 600; -u256 const c_ripemd160WordGas = 120; -u256 const c_identityGas = 15; -u256 const c_identityWordGas = 3; -//--- END: AUTOGENERATED FROM /feeStructure.json - -} -} +using namespace dev; +using namespace dev::eth; + +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9109347dc..1b58c80e9 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,41 +28,37 @@ namespace dev namespace eth { -//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_ecrecoverGas; -extern u256 const c_sha256Gas; -extern u256 const c_sha256WordGas; -extern u256 const c_ripemd160Gas; -extern u256 const c_ripemd160WordGas; -extern u256 const c_identityGas; -extern u256 const c_identityWordGas; } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index e0b487c9b..9f2fa6874 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,13 +82,19 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas = c_tierStepGas[metric.gasPriceTier]; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -145,10 +151,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::JUMPDEST: - runGas = 1; - break; - case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -164,7 +166,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index 23f19ac94..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From 1c73db86952066968b9122eddf4a01163ee871db Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 195/313] Gas fixes. Trie fixes. --- libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 6 +++++- libethereum/Client.cpp | 9 +++++++-- libevm/VM.cpp | 8 +------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 314594d2d..fbcc0619d 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -278,9 +278,14 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -// cdebug << "checkWatch" << _watchId; +#if ETH_DEBUG && 0 + cdebug << "checkWatch" << _watchId; +#endif + auto& w = m_watches.at(_watchId); +#if ETH_DEBUG && 0 + cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); +#endif auto& w = m_watches.at(_watchId); -// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 9f2fa6874..f4e904e3f 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,19 +82,13 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() From b3c0366cfabc31df819c5b0279a73601eb6a494a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 196/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index f4e904e3f..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From e44062cca903ba44b7340f16ad59e4aae9de466b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 197/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 40ff62175..2ff270de5 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final From b24ea8badc78de79b436b911c1c6566e96389c9a Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 198/313] only check rootHash of state if FATDB is off --- test/state.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/state.cpp b/test/state.cpp index 612e44e6a..f94d834be 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -92,6 +92,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) From d19b50d6e6ce5b063687cf4f512c6f20f11e9f1c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 199/313] add memory tests --- test/state.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index f94d834be..d82b86b62 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -92,7 +92,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -206,16 +205,46 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) } } - BOOST_AUTO_TEST_CASE(stSolidityTest) - { - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); - } +BOOST_AUTO_TEST_CASE(stSolidityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryTest) { dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } +BOOST_AUTO_TEST_CASE(stMemoryStressTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stCreateTest) { From 017fd72f309e3445ad34da1dea85e598166bed3d Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 200/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From d413de8f11166ac27f8b3e8d4e13a8b5a39345dd Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 201/313] update gas costs --- libevm/FeeStructure.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 1c1bf8a9e..58d756bae 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From 942818628a67e2eb7a5671120640705b2907b545 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 202/313] Log/bloom alterations. --- libevm/FeeStructure.cpp | 7 ++++--- libevm/FeeStructure.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 58d756bae..03dd14850 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 1b58c80e9..120034b0e 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. From b65fb1f20d46ae9d1c255931643efc8ec25df1c6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 203/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba25e74ce..43ee58eaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..121af1b59 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index 84d0e846f..9e59dd316 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,6 +74,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 47a85bd57e1b37f91dee8d457323539adeef8856 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 204/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 88 +++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f5acf0f0b..f09464a5a 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,54 +1,38 @@ -var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} From 055d643000f6677722cac5a508b636f765e50cfc Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 205/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethereum/Precompiled.cpp | 8 ++-- libevm/FeeStructure.cpp | 85 ++++++++++++++++++----------------- libevm/FeeStructure.h | 8 ++++ 4 files changed, 108 insertions(+), 81 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 121af1b59..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 03dd14850..78c6ebfb2 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -22,45 +22,48 @@ #include "FeeStructure.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 120034b0e..9d60ac1bd 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } From e24600816240b28253b1413d2fa3c53386a6a69f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 206/313] VM CALLCODE fix. --- libevm/FeeStructure.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 9d60ac1bd..9109347dc 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From 179c5dffde0301d9c8a1381e886e1d5f98184f3e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:12:27 +0100 Subject: [PATCH 207/313] state rebase. --- test/state.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index d82b86b62..f32286e13 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -228,24 +228,6 @@ BOOST_AUTO_TEST_CASE(stMemoryTest) dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stMemoryStressTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From 3eb2ad3593bc2c37a4af6b729f9c7a3f74bd2d4f Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 17:36:09 +0100 Subject: [PATCH 208/313] remove genesis state from state tests Conflicts: test/state.cpp --- test/TestHelper.cpp | 10 +-------- test/TestHelper.h | 3 +-- test/state.cpp | 53 ++++++++++++++++++--------------------------- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 104c03f2c..befd571ea 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -69,7 +69,7 @@ namespace test struct ValueTooLarge: virtual Exception {}; bigint const c_max256plus1 = bigint(1) << 256; -ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller): m_TestObject(_o) +ImportTest::ImportTest(json_spirit::mObject& _o, bool isFiller) : m_statePre(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(_o["env"].get_obj()["currentCoinbase"].get_str()), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) { importEnv(_o["env"].get_obj()); importState(_o["pre"].get_obj(), m_statePre); @@ -183,13 +183,8 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) // export post state json_spirit::mObject postState; - std::map genesis = genesisState(); - for (auto const& a: _statePost.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(_statePost.balance(a.first)); o["nonce"] = toString(_statePost.transactionsFrom(a.first)); @@ -212,9 +207,6 @@ void ImportTest::exportTest(bytes const& _output, State const& _statePost) for (auto const& a: m_statePre.addresses()) { - if (genesis.count(a.first)) - continue; - json_spirit::mObject o; o["balance"] = toString(m_statePre.balance(a.first)); o["nonce"] = toString(m_statePre.transactionsFrom(a.first)); diff --git a/test/TestHelper.h b/test/TestHelper.h index 6f9143c5c..849f822bd 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -47,9 +47,8 @@ namespace test class ImportTest { public: - ImportTest(json_spirit::mObject& _o) : m_TestObject(_o) {} + ImportTest(json_spirit::mObject& _o) : m_statePre(Address(), OverlayDB(), eth::BaseState::Empty), m_statePost(Address(), OverlayDB(), eth::BaseState::Empty), m_TestObject(_o) {} ImportTest(json_spirit::mObject& _o, bool isFiller); - // imports void importEnv(json_spirit::mObject& _o); void importState(json_spirit::mObject& _o, eth::State& _state); diff --git a/test/state.cpp b/test/state.cpp index f32286e13..6ac23c14d 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -65,6 +65,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) catch (Exception const& _e) { cnote << "state execution did throw an exception: " << diagnostic_information(_e); + theState.commit(); } catch (std::exception const& _e) { @@ -169,23 +170,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); +//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--quadratic" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); +// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { @@ -205,29 +206,17 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) } } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } BOOST_AUTO_TEST_CASE(stMemoryTest) { dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From 49b9a0224ac7e9c2d69b6f1019dd5c7eddee33b6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 11:55:22 +0100 Subject: [PATCH 209/313] New Proof-of-Work. --- CMakeLists.txt | 3 +- alethzero/MainWin.cpp | 2 +- eth/CMakeLists.txt | 2 +- libdevcore/Common.h | 1 + libdevcore/CommonData.h | 5 +- libdevcore/CommonIO.cpp | 23 +++ libdevcore/CommonIO.h | 4 + libdevcore/FixedHash.h | 1 + libethcore/BlockInfo.cpp | 20 ++- libethcore/BlockInfo.h | 8 +- libethcore/CMakeLists.txt | 1 + libethcore/CommonEth.cpp | 2 +- libethcore/CommonEth.h | 2 + libethcore/Exceptions.h | 5 +- libethcore/ProofOfWork.cpp | 182 ++++++++++++++------ libethcore/ProofOfWork.h | 67 ++++--- libethereum/CanonBlockChain.cpp | 4 +- libethereum/Client.cpp | 4 +- libethereum/Client.h | 6 +- libethereum/Interface.h | 2 +- libethereum/State.cpp | 21 ++- libethereum/State.h | 2 +- libweb3jsonrpc/WebThreeStubServerBase.cpp | 4 +- libweb3jsonrpc/WebThreeStubServerBase.h | 2 +- libweb3jsonrpc/abstractwebthreestubserver.h | 6 +- libweb3jsonrpc/spec.json | 2 +- mix/MixClient.h | 2 +- test/block.cpp | 112 ++++++++++-- test/dagger.cpp | 2 + test/webthreestubclient.h | 3 +- 30 files changed, 363 insertions(+), 137 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ee58eaa..dffdd9027 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ function(configureProject) endif() endfunction() - +set(CPPETHEREUM 1) function(createBuildInfo) # Set build platform; to be written to BuildInfo.h @@ -174,6 +174,7 @@ add_subdirectory(libp2p) add_subdirectory(libdevcrypto) add_subdirectory(libwhisper) +add_subdirectory(libethash) add_subdirectory(libethcore) add_subdirectory(libevm) add_subdirectory(libethereum) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 797db6441..bbe9d9f02 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1366,7 +1366,7 @@ void Main::on_blocks_currentItemChanged() s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info.headerHash(WithoutNonce), info.nonce) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index 68ee8c775..fbc6a8b24 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -26,7 +26,7 @@ if (JSONRPC) endif() target_link_libraries(${EXECUTABLE} webthree) -target_link_libraries(${EXECUTABLE} secp256k1) +target_link_libraries(${EXECUTABLE} ethash) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 9edeacccb..764b3454e 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -65,6 +65,7 @@ using bytesConstRef = vector_ref; // Numeric types. using bigint = boost::multiprecision::number>; +using u64 = boost::multiprecision::number>; using u128 = boost::multiprecision::number>; using u256 = boost::multiprecision::number>; using s256 = boost::multiprecision::number>; diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 3cdf3b449..2c9fd30ef 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -96,7 +96,10 @@ template inline void toBigEndian(_T _val, _Out& o_out) { for (auto i = o_out.size(); i-- != 0; _val >>= 8) - o_out[i] = (typename _Out::value_type)(uint8_t)_val; + { + _T v = _val & (_T)0xff; + o_out[i] = (typename _Out::value_type)(uint8_t)v; + } } /// Converts a big-endian byte-stream represented on a templated collection to a templated integer value. diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index feb4121cb..288dbd1ff 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -57,6 +57,24 @@ string dev::memDump(bytes const& _bytes, unsigned _width, bool _html) return ret.str(); } +// Don't forget to delete[] later. +bytesRef dev::contentsNew(std::string const& _file) +{ + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return bytesRef(); + // get length of file: + is.seekg (0, is.end); + streamoff length = is.tellg(); + if (length == 0) // return early, MSVC does not like reading 0 bytes + return bytesRef(); + is.seekg (0, is.beg); + bytesRef ret(new byte[length], length); + is.read((char*)ret.data(), length); + is.close(); + return ret; +} + bytes dev::contents(std::string const& _file) { std::ifstream is(_file, std::ifstream::binary); @@ -79,3 +97,8 @@ void dev::writeFile(std::string const& _file, bytes const& _data) ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); } +void dev::writeFile(std::string const& _file, bytesConstRef _data) +{ + ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); +} + diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 23092b702..5769b6c64 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -42,9 +42,13 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +/// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. +bytesRef contentsNew(std::string const& _file); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytes const& _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +void writeFile(std::string const& _file, bytesConstRef _data); /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index eec988d76..7fa5b411a 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -247,6 +247,7 @@ using h512 = FixedHash<64>; using h256 = FixedHash<32>; using h160 = FixedHash<20>; using h128 = FixedHash<16>; +using h64 = FixedHash<8>; using h512s = std::vector; using h256s = std::vector; using h160s = std::vector; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 49ed1578b..6c645372e 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -30,7 +30,7 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 17; +u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; BlockInfo::BlockInfo(): timestamp(Invalid256) { @@ -56,7 +56,9 @@ void BlockInfo::setEmpty() gasUsed = 0; timestamp = 0; extraData.clear(); - nonce = h256(); + seedHash = h256(); + mixBytes = h256(); + nonce = Nonce(); hash = headerHash(WithNonce); } @@ -76,11 +78,11 @@ h256 BlockInfo::headerHash(IncludeNonce _n) const void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const { - _s.appendList(_n == WithNonce ? 14 : 13) + _s.appendList(_n == WithNonce ? 16 : 14) << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom - << difficulty << number << gasLimit << gasUsed << timestamp << extraData; + << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << nonce; + _s << mixBytes << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -108,7 +110,9 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - nonce = _header[field = 13].toHash(); + seedHash = _header[field = 13].toHash(); + mixBytes = _header[field = 14].toHash(); + nonce = _header[field = 15].toHash(); } catch (Exception const& _e) @@ -118,7 +122,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) } // check it hashes according to proof of work or that it's the genesis block. - if (_checkNonce && parentHash && !ProofOfWork::verify(headerHash(WithoutNonce), nonce, difficulty)) + if (_checkNonce && parentHash && !ProofOfWork::verify(*this)) BOOST_THROW_EXCEPTION(InvalidBlockNonce(headerHash(WithoutNonce), nonce, difficulty)); if (gasUsed > gasLimit) @@ -176,6 +180,7 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); + seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -204,7 +209,6 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); - // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 99efc6a17..fbc459b76 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -76,7 +76,9 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 nonce; + h256 mixBytes; + h256 seedHash; + Nonce nonce; BlockInfo(); explicit BlockInfo(bytes const& _block): BlockInfo(&_block) {} @@ -104,6 +106,8 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && + mixBytes == _cmp.mixBytes && + seedHash == _cmp.seedHash && nonce == _cmp.nonce; } bool operator!=(BlockInfo const& _cmp) const { return !operator==(_cmp); } @@ -129,7 +133,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 1d17525a0..f562bc948 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -22,6 +22,7 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() +target_link_libraries(${EXECUTABLE} ethash) target_link_libraries(${EXECUTABLE} devcrypto) target_link_libraries(${EXECUTABLE} devcore) diff --git a/libethcore/CommonEth.cpp b/libethcore/CommonEth.cpp index ad41780e9..822ede5aa 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/CommonEth.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 55; +const unsigned c_protocolVersion = 56; const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 diff --git a/libethcore/CommonEth.h b/libethcore/CommonEth.h index 89ca0aa06..edefda380 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/CommonEth.h @@ -66,5 +66,7 @@ static const u256 finney = exp10<15>(); static const u256 szabo = exp10<12>(); static const u256 wei = exp10<0>(); +using Nonce = h64; + } } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 11497252f..bc9441c6b 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,6 +22,7 @@ #pragma once #include +#include "CommonEth.h" namespace dev { @@ -63,8 +64,8 @@ struct InvalidTransactionsStateRoot: virtual dev::Exception {}; struct InvalidReceiptsStateRoot: virtual dev::Exception {}; struct InvalidTimestamp: virtual dev::Exception {}; struct InvalidLogBloom: virtual dev::Exception {}; -class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0); u256 required; u256 candidate; }; -class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), h256 _n = h256(), u256 _d = 0); h256 h; h256 n; u256 d; }; +class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; }; +class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), Nonce _n = Nonce(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; Nonce n; u256 d; virtual const char* what() const noexcept; }; struct InvalidParentHash: virtual dev::Exception {}; struct InvalidNumber: virtual dev::Exception {}; struct InvalidContractAddress: virtual public dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 181e379b5..084225a38 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -20,12 +20,18 @@ */ #include +#include #include #include #include #include +#include +#include #include +#include #include +#include +#include "BlockInfo.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -35,72 +41,144 @@ namespace dev namespace eth { -template -static inline void update(_T& _sha, u256 const& _value) +class Ethasher { - int i = 0; - for (u256 v = _value; v; ++i, v >>= 8) {} - byte buf[32]; - bytesRef bufRef(buf, i); - toBigEndian(_value, bufRef); - _sha.Update(buf, i); -} +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; + } + + byte const* full(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash].data(); + } + + static ethash_params params(BlockInfo const& _header) + { + return params((unsigned)_header.number); + } + + static ethash_params params(unsigned _n) + { + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; + } + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; -template -static inline void update(_T& _sha, h256 const& _value) +Ethasher* Ethasher::s_this = nullptr; + +bool Ethash::verify(BlockInfo const& _header) { - int i = 0; - byte const* data = _value.data(); - for (; i != 32 && data[i] == 0; ++i); - _sha.Update(data + i, 32 - i); + bigint boundary = (bigint(1) << 256) / _header.difficulty; + u256 e(eval(_header, _header.nonce)); + return e <= boundary; } -template -static inline h256 get(_T& _sha) +h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { - h256 ret; - _sha.TruncatedFinal(&ret[0], 32); - return ret; + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return h256(r.result, h256::ConstructFromPointer); } -h256 DaggerEvaluator::node(h256 const& _root, h256 const& _xn, uint_fast32_t _L, uint_fast32_t _i) +std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - if (_L == _i) - return _root; - u256 m = (_L == 9) ? 16 : 3; - CryptoPP::SHA3_256 bsha; - for (uint_fast32_t k = 0; k < m; ++k) + auto h = _header.headerHash(WithoutNonce); + auto p = Ethasher::params(_header); + auto d = Ethasher::get()->full(_header); + + std::pair ret; + static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); + uint64_t tryNonce = (uint64_t)(u64)(m_last = Nonce::random(s_eng)); + + bigint boundary = (bigint(1) << 256) / _header.difficulty; + ret.first.requirement = log2((double)boundary); + + // 2^ 0 32 64 128 256 + // [--------*-------------------------] + // + // evaluate until we run out of time + auto startTime = std::chrono::steady_clock::now(); + if (!_turbo) + std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); + double best = 1e99; // high enough to be effectively infinity :) + Proof result; + ethash_return_value ethashReturn; + unsigned hashCount = 0; + for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - CryptoPP::SHA3_256 sha; - update(sha, _root); - update(sha, _xn); - update(sha, (u256)_L); - update(sha, (u256)_i); - update(sha, (u256)k); - uint_fast32_t pk = (uint_fast32_t)(u256)get(sha) & ((1 << ((_L - 1) * 3)) - 1); - auto u = node(_root, _xn, _L - 1, pk); - update(bsha, u); + ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); + u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + best = std::min(best, log2((double)val)); + if (val <= boundary) + { + ret.first.completed = true; + result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.nonce = u64(tryNonce); + break; + } } - return get(bsha); -} + ret.first.hashes = hashCount; + ret.first.best = best; + ret.second = result; -h256 DaggerEvaluator::eval(h256 const& _root, h256 const& _nonce) -{ - h256 extranonce = (u256)_nonce >> 26; // with xn = floor(n / 2^26) -> assuming this is with xn = floor(N / 2^26) - CryptoPP::SHA3_256 bsha; - for (uint_fast32_t k = 0; k < 4; ++k) + if (ret.first.completed) { - //sha256(D || xn || i || k) -> sha256(D || xn || k) - there's no 'i' here! - CryptoPP::SHA3_256 sha; - update(sha, _root); - update(sha, extranonce); - update(sha, _nonce); - update(sha, (u256)k); - uint_fast32_t pk = (uint_fast32_t)(u256)get(sha) & 0x1ffffff; // mod 8^8 * 2 [ == mod 2^25 ?! ] [ == & ((1 << 25) - 1) ] [ == & 0x1ffffff ] - auto u = node(_root, extranonce, 9, pk); - update(bsha, u); + BlockInfo test = _header; + assignResult(result, test); + assert(verify(test)); } - return get(bsha); + + return ret; } } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index c3c3f192b..7b9787f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -28,6 +28,7 @@ #include #include #include "CommonEth.h" +#include "BlockInfo.h" #define FAKE_DAGGER 1 @@ -45,47 +46,63 @@ struct MineInfo bool completed = false; }; -template -class ProofOfWorkEngine: public Evaluator +class Ethash { public: - static bool verify(h256 const& _root, h256 const& _nonce, u256 const& _difficulty) { return (bigint)(u256)Evaluator::eval(_root, _nonce) <= (bigint(1) << 256) / _difficulty; } + // bit-compatible with ethash_return_value + struct Proof + { + Nonce nonce; + h256 mixHash; + }; - inline std::pair mine(h256 const& _root, u256 const& _difficulty, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static bool verify(BlockInfo const& _header); + std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } protected: - h256 m_last; + Nonce m_last; }; -class SHA3Evaluator +template +class ProofOfWorkEngine: public Evaluator { public: - static h256 eval(h256 const& _root, h256 const& _nonce) { h256 b[2] = { _root, _nonce }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } -}; + using Proof = Nonce; + + static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } + + inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); -// TODO: class ARPoWEvaluator + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } -class DaggerEvaluator +protected: + Nonce m_last; +}; + +class SHA3Evaluator { public: - static h256 eval(h256 const& _root, h256 const& _nonce); - -private: - static h256 node(h256 const& _root, h256 const& _xn, uint_fast32_t _L, uint_fast32_t _i); + static h256 eval(h256 const& _root, Nonce const& _nonce) { h256 b[2] = { _root, h256(_nonce) }; return sha3(bytesConstRef((byte const*)&b[0], 64)); } }; using SHA3ProofOfWork = ProofOfWorkEngine; -using ProofOfWork = SHA3ProofOfWork; +using ProofOfWork = Ethash; template -std::pair ProofOfWorkEngine::mine(h256 const& _root, u256 const& _difficulty, unsigned _msTimeout, bool _continue, bool _turbo) +std::pair::Proof> ProofOfWorkEngine::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - std::pair ret; + auto headerHashWithoutNonce = _header.headerHash(WithoutNonce); + auto difficulty = _header.difficulty; + + std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); - u256 s = (m_last = h256::random(s_eng)); + Nonce::Arith s = (m_last = Nonce::random(s_eng)); - bigint d = (bigint(1) << 256) / _difficulty; + bigint d = (bigint(1) << 256) / difficulty; ret.first.requirement = log2((double)d); // 2^ 0 32 64 128 256 @@ -96,12 +113,12 @@ std::pair ProofOfWorkEngine::mine(h256 const& _root, if (!_turbo) std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) - h256 solution; + ProofOfWorkEngine::Proof solution; unsigned h = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; s++, h++) { - solution = (h256)s; - auto e = (bigint)(u256)Evaluator::eval(_root, solution); + solution = (ProofOfWorkEngine::Proof)s; + auto e = (bigint)(u256)Evaluator::eval(headerHashWithoutNonce, solution); best = std::min(best, log2((double)e)); if (e <= d) { @@ -114,7 +131,11 @@ std::pair ProofOfWorkEngine::mine(h256 const& _root, ret.second = solution; if (ret.first.completed) - assert(verify(_root, solution, _difficulty)); + { + BlockInfo test = _header; + assignResult(solution, test); + assert(verify(test)); + } return ret; } diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index 29fdc9acc..418373745 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -82,8 +82,8 @@ bytes CanonBlockChain::createGenesisBlock() stateRoot = state.root(); } - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); + block.appendList(16) + << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << h256() << h256() << Nonce(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index fbcc0619d..2db673d90 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -504,10 +504,10 @@ pair Client::getWork() return make_pair(m_remoteMiner.workHash(), m_remoteMiner.difficulty()); } -bool Client::submitNonce(h256 const&_nonce) +bool Client::submitWork(ProofOfWork::Proof const& _proof) { Guard l(x_remoteMiner); - return m_remoteMiner.submitWork(_nonce); + return m_remoteMiner.submitWork(_proof); } void Client::doWork() diff --git a/libethereum/Client.h b/libethereum/Client.h index 5fabca10b..41b1c1bc6 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -148,7 +148,7 @@ public: h256 workHash() const { return m_state.info().headerHash(IncludeNonce::WithoutNonce); } u256 const& difficulty() const { return m_state.info().difficulty; } - bool submitWork(h256 const& _nonce) { return (m_isComplete = m_state.completeMine(_nonce)); } + bool submitWork(ProofOfWork::Proof const& _result) { return (m_isComplete = m_state.completeMine(_result)); } virtual bool isComplete() const override { return m_isComplete; } virtual bytes const& blockData() const { return m_state.blockData(); } @@ -303,8 +303,8 @@ public: /// 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::pair getWork() override; - /// Submit the nonce for the proof-of-work. - virtual bool submitNonce(h256 const&_nonce) override; + /// Submit the proof for the proof-of-work. + virtual bool submitWork(ProofOfWork::Proof const& _proof) override; // Debug stuff: diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 847c181e0..2a9de14d1 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -154,7 +154,7 @@ public: /// Get hash of the current block to be mined minus the nonce (the 'work hash'). virtual std::pair getWork() = 0; /// Submit the nonce for the proof-of-work. - virtual bool submitNonce(h256 const&) = 0; + virtual bool submitWork(ProofOfWork::Proof const& _proof) = 0; /// Check the progress of the mining. virtual MineProgress miningProgress() const = 0; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 5fbe8d48d..568629084 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -256,7 +256,7 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi) { auto b = _bc.block(_block); bi.populate(b); - // bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. +// bi.verifyInternals(_bc.block(_block)); // Unneeded - we already verify on import into the blockchain. break; } catch (Exception const& _e) @@ -547,7 +547,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) if (rlp[2].itemCount() > 2) BOOST_THROW_EXCEPTION(TooManyUncles()); - set nonces = { m_currentBlock.nonce }; + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); @@ -774,23 +774,28 @@ MineInfo State::mine(unsigned _msTimeout, bool _turbo) MineInfo ret; // TODO: Miner class that keeps dagger between mine calls (or just non-polling mining). - tie(ret, m_currentBlock.nonce) = m_pow.mine(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.difficulty, _msTimeout, true, _turbo); + ProofOfWork::Proof r; + tie(ret, r) = m_pow.mine(m_currentBlock, _msTimeout, true, _turbo); if (!ret.completed) m_currentBytes.clear(); else - cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.nonce, m_currentBlock.difficulty); + { + ProofOfWork::assignResult(r, m_currentBlock); + cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); + } return ret; } -bool State::completeMine(h256 const& _nonce) +bool State::completeMine(ProofOfWork::Proof const& _nonce) { - if (!m_pow.verify(m_currentBlock.headerHash(WithoutNonce), _nonce, m_currentBlock.difficulty)) + ProofOfWork::assignResult(_nonce, m_currentBlock); + + if (!m_pow.verify(m_currentBlock)) return false; - m_currentBlock.nonce = _nonce; - cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock.headerHash(WithoutNonce), m_currentBlock.nonce, m_currentBlock.difficulty); + cnote << "Completed" << m_currentBlock.headerHash(WithoutNonce).abridged() << m_currentBlock.nonce.abridged() << m_currentBlock.difficulty << ProofOfWork::verify(m_currentBlock); completeMine(); diff --git a/libethereum/State.h b/libethereum/State.h index a496a4a03..33843c65c 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -112,7 +112,7 @@ public: /// Pass in a solution to the proof-of-work. /// @returns true iff the given nonce is a proof-of-work for this State's block. - bool completeMine(h256 const& _nonce); + bool completeMine(ProofOfWork::Proof const& _result); /// Attempt to find valid nonce for block that this state represents. /// This function is thread-safe. You can safely have other interactions with this object while it is happening. diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index f0d8bf6ef..e976c7008 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -461,9 +461,9 @@ Json::Value WebThreeStubServerBase::eth_getWork() return ret; } -bool WebThreeStubServerBase::eth_submitWork(std::string const& _nonce) +bool WebThreeStubServerBase::eth_submitWork(std::string const& _nonce, std::string const& _mixHash) { - return client()->submitNonce(jsToFixed<32>(_nonce)); + return client()->submitWork(ProofOfWork::Proof{jsToFixed(_nonce), jsToFixed<32>(_mixHash)}); } int WebThreeStubServerBase::eth_register(std::string const& _address) diff --git a/libweb3jsonrpc/WebThreeStubServerBase.h b/libweb3jsonrpc/WebThreeStubServerBase.h index 9535c33a0..993c82c5c 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.h +++ b/libweb3jsonrpc/WebThreeStubServerBase.h @@ -110,7 +110,7 @@ public: virtual bool eth_uninstallFilter(int _id); virtual Json::Value eth_getWork(); - virtual bool eth_submitWork(std::string const& _nonce); + virtual bool eth_submitWork(std::string const& _nonce, std::string const& _mixHash); virtual int eth_register(std::string const& _address); virtual bool eth_unregister(int _id); diff --git a/libweb3jsonrpc/abstractwebthreestubserver.h b/libweb3jsonrpc/abstractwebthreestubserver.h index e40c68acd..bb84afc9b 100644 --- a/libweb3jsonrpc/abstractwebthreestubserver.h +++ b/libweb3jsonrpc/abstractwebthreestubserver.h @@ -54,7 +54,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServerbindAndAddMethod(jsonrpc::Procedure("eth_filterLogs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_filterLogsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_logs", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_OBJECT, NULL), &AbstractWebThreeStubServer::eth_logsI); this->bindAndAddMethod(jsonrpc::Procedure("eth_getWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, NULL), &AbstractWebThreeStubServer::eth_getWorkI); - this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); + this->bindAndAddMethod(jsonrpc::Procedure("eth_submitWork", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_submitWorkI); this->bindAndAddMethod(jsonrpc::Procedure("eth_register", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_STRING, NULL), &AbstractWebThreeStubServer::eth_registerI); this->bindAndAddMethod(jsonrpc::Procedure("eth_unregister", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_unregisterI); this->bindAndAddMethod(jsonrpc::Procedure("eth_queuedTransactions", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_ARRAY, "param1",jsonrpc::JSON_INTEGER, NULL), &AbstractWebThreeStubServer::eth_queuedTransactionsI); @@ -254,7 +254,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServereth_submitWork(request[0u].asString()); + response = this->eth_submitWork(request[0u].asString(), request[1u].asString()); } inline virtual void eth_registerI(const Json::Value &request, Json::Value &response) { @@ -363,7 +363,7 @@ class AbstractWebThreeStubServer : public jsonrpc::AbstractServer getWork() override { return std::pair(); } - bool submitNonce(h256 const&) override { return false; } + bool submitWork(eth::ProofOfWork::Proof const&) override { return false; } /// @returns the last mined block information eth::BlockInfo blockInfo() const; std::vector userAccounts() { return m_userAccounts; } diff --git a/test/block.cpp b/test/block.cpp index 7c50eef4d..f398c893e 100644 --- a/test/block.cpp +++ b/test/block.cpp @@ -201,8 +201,12 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) // find new valid nonce ProofOfWork pow; MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + ProofOfWork::Proof proof; + while (!ProofOfWork::verify(blockFromFields)) + { + tie(ret, proof) = pow.mine(blockFromFields, 1000, true, true); + ProofOfWork::assignResult(proof, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); @@ -281,27 +285,97 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) o["transactions"] = txArray; o["rlp"] = "0x" + toHex(state.blockData()); - BlockInfo current_BlockHeader = state.info(); + BlockInfo currentBlockHeader = state.info(); // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - overwriteBlockHeader(o, current_BlockHeader); + + if (o.count("blockHeader")) + { + if (o["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = currentBlockHeader; + + if (o["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(o["blockHeader"].get_obj()["parentHash"].get_str()); + + if (o["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(o["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (o["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(o["blockHeader"].get_obj()["coinbase"].get_str()); + + if (o["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(o["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (o["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(o["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (o["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(o["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (o["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(o["blockHeader"].get_obj()["bloom"].get_str()); + + if (o["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(o["blockHeader"].get_obj()["difficulty"]); + + if (o["blockHeader"].get_obj().count("number")) + tmp.number = toInt(o["blockHeader"].get_obj()["number"]); + + if (o["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(o["blockHeader"].get_obj()["gasLimit"]); + + if (o["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(o["blockHeader"].get_obj()["gasUsed"]); + + if (o["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(o["blockHeader"].get_obj()["timestamp"]); + + if (o["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(o["blockHeader"].get_obj()["extraData"].get_str()); + + // find new valid nonce + + if (tmp != currentBlockHeader) + { + currentBlockHeader = tmp; + cout << "new header!\n"; + ProofOfWork pow; + MineInfo ret; + ProofOfWork::Proof proof; + while (!ProofOfWork::verify(currentBlockHeader)) + { + tie(ret, proof) = pow.mine(currentBlockHeader, 10000, true, true); + ProofOfWork::assignResult(proof, currentBlockHeader); + } + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(o["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + currentBlockHeader.populateFromHeader(c_bRLP, false); + } + } // write block header mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["parentHash"] = toString(currentBlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(currentBlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(currentBlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(currentBlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(currentBlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(currentBlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(currentBlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(currentBlockHeader.difficulty); + oBlockHeader["number"] = toString(currentBlockHeader.number); + oBlockHeader["gasLimit"] = toString(currentBlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(currentBlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(currentBlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(currentBlockHeader.extraData); + oBlockHeader["nonce"] = toString(currentBlockHeader.nonce); o["blockHeader"] = oBlockHeader; @@ -321,7 +395,7 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) } RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + currentBlockHeader.streamRLP(rlpStream2, WithNonce); RLPStream block2(3); block2.appendRaw(rlpStream2.out()); diff --git a/test/dagger.cpp b/test/dagger.cpp index 9422b6a96..87c49bd7d 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -30,6 +30,7 @@ using namespace dev::eth; int daggerTest() { +#if 0 cnote << "Testing ProofOfWork..."; // Test dagger { @@ -46,6 +47,7 @@ int daggerTest() cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; } +#endif return 0; } diff --git a/test/webthreestubclient.h b/test/webthreestubclient.h index 70aa9db99..6d97ea67a 100644 --- a/test/webthreestubclient.h +++ b/test/webthreestubclient.h @@ -437,10 +437,11 @@ class WebThreeStubClient : public jsonrpc::Client else throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString()); } - bool eth_submitWork(const std::string& param1) throw (jsonrpc::JsonRpcException) + bool eth_submitWork(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException) { Json::Value p; p.append(param1); + p.append(param2); Json::Value result = this->CallMethod("eth_submitWork",p); if (result.isBool()) return result.asBool(); From 79c336403acbe15dbd3792abbd2e91450233fcb4 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 12:04:15 +0100 Subject: [PATCH 210/313] blockchain tests Conflicts: test/block.cpp --- test/bcBlockChainTestFiller.json | 45 +++ test/block.cpp | 595 ------------------------------- test/blockchain.cpp | 537 ++++++++++++++++++++++++++++ test/vm.cpp | 54 +-- 4 files changed, 609 insertions(+), 622 deletions(-) create mode 100644 test/bcBlockChainTestFiller.json delete mode 100644 test/block.cpp create mode 100644 test/blockchain.cpp diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json new file mode 100644 index 000000000..050def25b --- /dev/null +++ b/test/bcBlockChainTestFiller.json @@ -0,0 +1,45 @@ +{ + "minDifficulty" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + } + ] + } +} diff --git a/test/block.cpp b/test/block.cpp deleted file mode 100644 index f398c893e..000000000 --- a/test/block.cpp +++ /dev/null @@ -1,595 +0,0 @@ -/* - This file is part of cpp-ethereum. - - cpp-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - cpp-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with cpp-ethereum. If not, see . -*/ -/** @file block.cpp - * @author Christoph Jentzsch - * @date 2015 - * block test functions. - */ - -#include -#include -#include "TestHelper.h" - -using namespace std; -using namespace json_spirit; -using namespace dev; -using namespace dev::eth; - -namespace dev { namespace test { - -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - - return rlpStream.out(); -} - -void overwriteBlockHeader(mObject& _o, BlockInfo _current_BlockHeader) -{ - if (_o.count("blockHeader")) - { - if (_o["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = _current_BlockHeader; - - if (_o["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(_o["blockHeader"].get_obj()["parentHash"].get_str()); - - if (_o["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(_o["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (_o["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(_o["blockHeader"].get_obj()["coinbase"].get_str()); - - if (_o["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(_o["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (_o["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(_o["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (_o["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(_o["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (_o["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(_o["blockHeader"].get_obj()["bloom"].get_str()); - - if (_o["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(_o["blockHeader"].get_obj()["difficulty"]); - - if (_o["blockHeader"].get_obj().count("number")) - tmp.number = toInt(_o["blockHeader"].get_obj()["number"]); - - if (_o["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(_o["blockHeader"].get_obj()["gasLimit"]); - - if (_o["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(_o["blockHeader"].get_obj()["gasUsed"]); - - if (_o["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(_o["blockHeader"].get_obj()["timestamp"]); - - if (_o["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(_o["blockHeader"].get_obj()["extraData"].get_str()); - - // find new valid nonce - - if (tmp != _current_BlockHeader) - { - _current_BlockHeader = tmp; - cout << "new header!\n"; - ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(_current_BlockHeader.headerHash(WithoutNonce), _current_BlockHeader.nonce, _current_BlockHeader.difficulty)) - tie(ret, _current_BlockHeader.nonce) = pow.mine(_current_BlockHeader.headerHash(WithoutNonce), _current_BlockHeader.difficulty, 10000, true, true); - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(_o["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - _current_BlockHeader.populateFromHeader(c_bRLP, false); - } - } -} - -void doBlockTests(json_spirit::mValue& _v, bool _fillin) -{ - for (auto& i: _v.get_obj()) - { - cerr << i.first << endl; - mObject& o = i.second.get_obj(); - - BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } - - BOOST_REQUIRE(o.count("pre")); - - ImportTest importer(o["pre"].get_obj()); - State state(Address(), OverlayDB(), BaseState::Empty); - importer.importState(o["pre"].get_obj(), state); - state.commit(); - - if (_fillin) - blockFromFields.stateRoot = state.rootHash(); - else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); - - if (_fillin) - { - // find new valid nonce - ProofOfWork pow; - MineInfo ret; - ProofOfWork::Proof proof; - while (!ProofOfWork::verify(blockFromFields)) - { - tie(ret, proof) = pow.mine(blockFromFields, 1000, true, true); - ProofOfWork::assignResult(proof, blockFromFields); - } - - //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - } - - // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); - - // construct blockchain - BlockChain bc(block.out(), string(), true); - - if (_fillin) - { - BOOST_REQUIRE(o.count("transactions")); - - TransactionQueue txs; - - for (auto const& txObj: o["transactions"].get_array()) - { - mObject tx = txObj.get_obj(); - importer.importTransaction(tx); - if (!txs.attemptImport(importer.m_transaction.rlp())) - cnote << "failed importing transaction\n"; - } - - try - { - state.sync(bc); - state.sync(bc,txs); - state.commitToMine(bc); - MineInfo info; - for (info.completed = false; !info.completed; info = state.mine()) {} - state.completeMine(); - } - catch (Exception const& _e) - { - cnote << "state sync or mining did throw an exception: " << diagnostic_information(_e); - return; - } - catch (std::exception const& _e) - { - cnote << "state sync or mining did throw an exception: " << _e.what(); - return; - } - - // write valid txs - mArray txArray; - Transactions txList; - for (auto const& txi: txs.transactions()) - { - Transaction tx(txi.second, CheckSignature::Sender); - txList.push_back(tx); - mObject txObject; - txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); - txObject["gasLimit"] = toString(tx.gas()); - txObject["gasPrice"] = toString(tx.gasPrice()); - txObject["r"] = "0x" + toString(tx.signature().r); - txObject["s"] = "0x" + toString(tx.signature().s); - txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); - txObject["value"] = toString(tx.value()); - - txArray.push_back(txObject); - } - - o["transactions"] = txArray; - o["rlp"] = "0x" + toHex(state.blockData()); - - BlockInfo currentBlockHeader = state.info(); - - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - - if (o.count("blockHeader")) - { - if (o["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = currentBlockHeader; - - if (o["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(o["blockHeader"].get_obj()["parentHash"].get_str()); - - if (o["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(o["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (o["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(o["blockHeader"].get_obj()["coinbase"].get_str()); - - if (o["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(o["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (o["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(o["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (o["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(o["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (o["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(o["blockHeader"].get_obj()["bloom"].get_str()); - - if (o["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(o["blockHeader"].get_obj()["difficulty"]); - - if (o["blockHeader"].get_obj().count("number")) - tmp.number = toInt(o["blockHeader"].get_obj()["number"]); - - if (o["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(o["blockHeader"].get_obj()["gasLimit"]); - - if (o["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(o["blockHeader"].get_obj()["gasUsed"]); - - if (o["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(o["blockHeader"].get_obj()["timestamp"]); - - if (o["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(o["blockHeader"].get_obj()["extraData"].get_str()); - - // find new valid nonce - - if (tmp != currentBlockHeader) - { - currentBlockHeader = tmp; - cout << "new header!\n"; - ProofOfWork pow; - MineInfo ret; - ProofOfWork::Proof proof; - while (!ProofOfWork::verify(currentBlockHeader)) - { - tie(ret, proof) = pow.mine(currentBlockHeader, 10000, true, true); - ProofOfWork::assignResult(proof, currentBlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(o["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - currentBlockHeader.populateFromHeader(c_bRLP, false); - } - } - - // write block header - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(currentBlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(currentBlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(currentBlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(currentBlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(currentBlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(currentBlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(currentBlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(currentBlockHeader.difficulty); - oBlockHeader["number"] = toString(currentBlockHeader.number); - oBlockHeader["gasLimit"] = toString(currentBlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(currentBlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(currentBlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(currentBlockHeader.extraData); - oBlockHeader["nonce"] = toString(currentBlockHeader.nonce); - - o["blockHeader"] = oBlockHeader; - - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - o["uncleHeaders"] = aUncleList; - - //txs: - - RLPStream txStream; - txStream.appendList(txList.size()); - for (unsigned i = 0; i < txList.size(); ++i) - { - RLPStream txrlp; - txList[i].streamRLP(txrlp); - txStream.appendRaw(txrlp.out()); - } - - RLPStream rlpStream2; - currentBlockHeader.streamRLP(rlpStream2, WithNonce); - - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); - - o["rlp"] = "0x" + toHex(block2.out()); - - if (sha3(RLP(state.blockData())[0].data()) != sha3(RLP(block2.out())[0].data())) - cnote << "block header mismatch\n"; - - if (sha3(RLP(state.blockData())[1].data()) != sha3(RLP(block2.out())[1].data())) - cnote << "txs mismatch\n"; - - if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; - - try - { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); - } - // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given - catch (...) - { - cnote << "block is invalid!\n"; - o.erase(o.find("blockHeader")); - o.erase(o.find("uncleHeaders")); - o.erase(o.find("transactions")); - } - } - - else - { - bytes blockRLP; - try - { - state.sync(bc); - blockRLP = importByteArray(o["rlp"].get_str()); - bc.import(blockRLP, state.db()); - state.sync(bc); - } - // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given - catch (Exception const& _e) - { - cnote << "state sync or block import did throw an exception: " << diagnostic_information(_e); - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - catch (std::exception const& _e) - { - cnote << "state sync or block import did throw an exception: " << _e.what(); - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - catch(...) - { - cnote << "state sync or block import did throw an exception\n"; - BOOST_CHECK(o.count("blockHeader") == 0); - BOOST_CHECK(o.count("transactions") == 0); - BOOST_CHECK(o.count("uncleHeaders") == 0); - continue; - } - - BOOST_REQUIRE(o.count("blockHeader")); - - mObject tObj = o["blockHeader"].get_obj(); - BlockInfo blockHeaderFromFields; - const bytes c_rlpBytesBlockHeader = createBlockRLPFromFields(tObj); - const RLP c_blockHeaderRLP(c_rlpBytesBlockHeader); - blockHeaderFromFields.populateFromHeader(c_blockHeaderRLP, false); - - BlockInfo blockFromRlp = bc.info(); - - //Check the fields restored from RLP to original fields - BOOST_CHECK_MESSAGE(blockHeaderFromFields.headerHash(WithNonce) == blockFromRlp.headerHash(WithNonce), "hash in given RLP not matching the block hash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.parentHash == blockFromRlp.parentHash, "parentHash in given RLP not matching the block parentHash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.sha3Uncles == blockFromRlp.sha3Uncles, "sha3Uncles in given RLP not matching the block sha3Uncles!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.coinbaseAddress == blockFromRlp.coinbaseAddress,"coinbaseAddress in given RLP not matching the block coinbaseAddress!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.stateRoot == blockFromRlp.stateRoot, "stateRoot in given RLP not matching the block stateRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.transactionsRoot == blockFromRlp.transactionsRoot, "transactionsRoot in given RLP not matching the block transactionsRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.receiptsRoot == blockFromRlp.receiptsRoot, "receiptsRoot in given RLP not matching the block receiptsRoot!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.logBloom == blockFromRlp.logBloom, "logBloom in given RLP not matching the block logBloom!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.difficulty == blockFromRlp.difficulty, "difficulty in given RLP not matching the block difficulty!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.number == blockFromRlp.number, "number in given RLP not matching the block number!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasLimit == blockFromRlp.gasLimit,"gasLimit in given RLP not matching the block gasLimit!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); - - BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); - - //Check transaction list - Transactions txsFromField; - - for (auto const& txObj: o["transactions"].get_array()) - { - mObject tx = txObj.get_obj(); - - BOOST_REQUIRE(tx.count("nonce")); - BOOST_REQUIRE(tx.count("gasPrice")); - BOOST_REQUIRE(tx.count("gasLimit")); - BOOST_REQUIRE(tx.count("to")); - BOOST_REQUIRE(tx.count("value")); - BOOST_REQUIRE(tx.count("v")); - BOOST_REQUIRE(tx.count("r")); - BOOST_REQUIRE(tx.count("s")); - BOOST_REQUIRE(tx.count("data")); - - try - { - Transaction t(createRLPStreamFromTransactionFields(tx).out(), CheckSignature::Sender); - txsFromField.push_back(t); - } - catch (Exception const& _e) - { - BOOST_ERROR("Failed transaction constructor with Exception: " << diagnostic_information(_e)); - } - catch (exception const& _e) - { - cnote << _e.what(); - } - } - - Transactions txsFromRlp; - RLP root(blockRLP); - for (auto const& tr: root[1]) - { - Transaction tx(tr.data(), CheckSignature::Sender); - txsFromRlp.push_back(tx); - } - - BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), "transaction list size does not match"); - - for (size_t i = 0; i < txsFromField.size(); ++i) - { - BOOST_CHECK_MESSAGE(txsFromField[i].data() == txsFromRlp[i].data(), "transaction data in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].gas() == txsFromRlp[i].gas(), "transaction gasLimit in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].gasPrice() == txsFromRlp[i].gasPrice(), "transaction gasPrice in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].nonce() == txsFromRlp[i].nonce(), "transaction nonce in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().r == txsFromRlp[i].signature().r, "transaction r in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().s == txsFromRlp[i].signature().s, "transaction s in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].signature().v == txsFromRlp[i].signature().v, "transaction v in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); - } - - // check uncle list - BOOST_CHECK_MESSAGE((o["uncleList"].type() == json_spirit::null_type ? 0 : o["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); - } - } -} - -} }// Namespace Close - - -BOOST_AUTO_TEST_SUITE(BlockTests) - -BOOST_AUTO_TEST_CASE(blValidBlockTest) -{ - dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -{ - dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -{ - dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(blForkBlocks) -{ - dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_CASE(userDefinedFile) -{ - dev::test::userDefinedTest("--singletest", dev::test::doBlockTests); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/test/blockchain.cpp b/test/blockchain.cpp new file mode 100644 index 000000000..7dad5b4f2 --- /dev/null +++ b/test/blockchain.cpp @@ -0,0 +1,537 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file block.cpp + * @author Christoph Jentzsch + * @date 2015 + * block test functions. + */ + +#include +#include +#include "TestHelper.h" + +using namespace std; +using namespace json_spirit; +using namespace dev; +using namespace dev::eth; + +namespace dev { namespace test { + +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << importByteArray(_tObj["extraData"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void doBlockTests(json_spirit::mValue& _v, bool _fillin) +{ + for (auto& i: _v.get_obj()) + { + cerr << i.first << endl; + mObject& o = i.second.get_obj(); + + BOOST_REQUIRE(o.count("genesisBlockHeader")); + BlockInfo blockFromFields; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + blockFromFields.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch(...) + { + cnote << "block population did throw an unknown exception\n"; + continue; + } + + BOOST_REQUIRE(o.count("pre")); + + ImportTest importer(o["pre"].get_obj()); + State state(Address(), OverlayDB(), BaseState::Empty); + importer.importState(o["pre"].get_obj(), state); + state.commit(); + + if (_fillin) + blockFromFields.stateRoot = state.rootHash(); + else + BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + + if (_fillin) + { + // find new valid nonce + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) + tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + + //update genesis block in json file + o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); + o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + } + + // create new "genesis" block + RLPStream rlpStream; + blockFromFields.streamRLP(rlpStream, WithNonce); + + RLPStream block(3); + block.appendRaw(rlpStream.out()); + block.appendRaw(RLPEmptyList); + block.appendRaw(RLPEmptyList); + + blockFromFields.verifyInternals(&block.out()); + + // construct blockchain + BlockChain bc(block.out(), string(), true); + + if (_fillin) + { + BOOST_REQUIRE(o.count("blocks")); + mArray blArray; + for (auto const& bl: o["blocks"].get_array()) + { + mObject blObj = bl.get_obj(); + BOOST_REQUIRE(blObj.count("transactions")); + + TransactionQueue txs; + + for (auto const& txObj: blObj["transactions"].get_array()) + { + mObject tx = txObj.get_obj(); + importer.importTransaction(tx); + if (!txs.attemptImport(importer.m_transaction.rlp())) + cnote << "failed importing transaction\n"; + } + + try + { + state.sync(bc); + state.sync(bc,txs); + state.commitToMine(bc); + MineInfo info; + for (info.completed = false; !info.completed; info = state.mine()) {} + state.completeMine(); + } + catch (Exception const& _e) + { + cnote << "state sync or mining did throw an exception: " << diagnostic_information(_e); + return; + } + catch (std::exception const& _e) + { + cnote << "state sync or mining did throw an exception: " << _e.what(); + return; + } + + // write valid txs + mArray txArray; + Transactions txList; + for (auto const& txi: txs.transactions()) + { + Transaction tx(txi.second, CheckSignature::Sender); + txList.push_back(tx); + mObject txObject; + txObject["nonce"] = toString(tx.nonce()); + txObject["data"] = toHex(tx.data()); + txObject["gasLimit"] = toString(tx.gas()); + txObject["gasPrice"] = toString(tx.gasPrice()); + txObject["r"] = "0x" + toString(tx.signature().r); + txObject["s"] = "0x" + toString(tx.signature().s); + txObject["v"] = to_string(tx.signature().v + 27); + txObject["to"] = toString(tx.receiveAddress()); + txObject["value"] = toString(tx.value()); + + txArray.push_back(txObject); + } + + blObj["transactions"] = txArray; + blObj["rlp"] = "0x" + toHex(state.blockData()); + + BlockInfo current_BlockHeader = state.info(); + + // overwrite blockheader with (possible wrong) data from "blockheader" in filler; + + if (blObj.count("blockHeader")) + { + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + cout << "new header!\n"; + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) + tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } + } + + // write block header + + mObject oBlockHeader; + oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); + oBlockHeader["number"] = toString(current_BlockHeader.number); + oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + + blObj["blockHeader"] = oBlockHeader; + + // write uncle list + mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. + blObj["uncleHeaders"] = aUncleList; + + //txs: + + RLPStream txStream; + txStream.appendList(txList.size()); + for (unsigned i = 0; i < txList.size(); ++i) + { + RLPStream txrlp; + txList[i].streamRLP(txrlp); + txStream.appendRaw(txrlp.out()); + } + + RLPStream rlpStream2; + current_BlockHeader.streamRLP(rlpStream2, WithNonce); + + RLPStream block2(3); + block2.appendRaw(rlpStream2.out()); + block2.appendRaw(txStream.out()); + block2.appendRaw(RLPEmptyList); + + blObj["rlp"] = "0x" + toHex(block2.out()); + + if (sha3(RLP(state.blockData())[0].data()) != sha3(RLP(block2.out())[0].data())) + cnote << "block header mismatch\n"; + + if (sha3(RLP(state.blockData())[1].data()) != sha3(RLP(block2.out())[1].data())) + cnote << "txs mismatch\n"; + + if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) + cnote << "uncle list mismatch\n"; + + try + { + ImportTest importerTmp(o["pre"].get_obj()); + State stateTmp(Address(), OverlayDB(), BaseState::Empty); + importerTmp.importState(o["pre"].get_obj(), stateTmp); + stateTmp.commit(); + BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); + stateTmp.sync(bcTmp); + bc.import(block2.out(), stateTmp.db()); + stateTmp.sync(bcTmp); + } + // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given + catch (...) + { + cnote << "block is invalid!\n"; + blObj.erase(blObj.find("blockHeader")); + blObj.erase(blObj.find("uncleHeaders")); + blObj.erase(blObj.find("transactions")); + } + blArray.push_back(blObj); + } + o["blocks"] = blArray; + } + + else + { + for (auto const& bl: o["blocks"].get_array()) + { + mObject blObj = bl.get_obj(); + bytes blockRLP; + try + { + state.sync(bc); + blockRLP = importByteArray(blObj["rlp"].get_str()); + bc.import(blockRLP, state.db()); + state.sync(bc); + } + // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given + catch (Exception const& _e) + { + cnote << "state sync or block import did throw an exception: " << diagnostic_information(_e); + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + catch (std::exception const& _e) + { + cnote << "state sync or block import did throw an exception: " << _e.what(); + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + catch(...) + { + cnote << "state sync or block import did throw an exception\n"; + BOOST_CHECK(blObj.count("blockHeader") == 0); + BOOST_CHECK(blObj.count("transactions") == 0); + BOOST_CHECK(blObj.count("uncleHeaders") == 0); + continue; + } + + BOOST_REQUIRE(blObj.count("blockHeader")); + + mObject tObj = blObj["blockHeader"].get_obj(); + BlockInfo blockHeaderFromFields; + const bytes c_rlpBytesBlockHeader = createBlockRLPFromFields(tObj); + const RLP c_blockHeaderRLP(c_rlpBytesBlockHeader); + blockHeaderFromFields.populateFromHeader(c_blockHeaderRLP, false); + + BlockInfo blockFromRlp = bc.info(); + + //Check the fields restored from RLP to original fields + BOOST_CHECK_MESSAGE(blockHeaderFromFields.headerHash(WithNonce) == blockFromRlp.headerHash(WithNonce), "hash in given RLP not matching the block hash!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.parentHash == blockFromRlp.parentHash, "parentHash in given RLP not matching the block parentHash!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.sha3Uncles == blockFromRlp.sha3Uncles, "sha3Uncles in given RLP not matching the block sha3Uncles!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.coinbaseAddress == blockFromRlp.coinbaseAddress,"coinbaseAddress in given RLP not matching the block coinbaseAddress!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.stateRoot == blockFromRlp.stateRoot, "stateRoot in given RLP not matching the block stateRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.transactionsRoot == blockFromRlp.transactionsRoot, "transactionsRoot in given RLP not matching the block transactionsRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.receiptsRoot == blockFromRlp.receiptsRoot, "receiptsRoot in given RLP not matching the block receiptsRoot!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.logBloom == blockFromRlp.logBloom, "logBloom in given RLP not matching the block logBloom!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.difficulty == blockFromRlp.difficulty, "difficulty in given RLP not matching the block difficulty!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.number == blockFromRlp.number, "number in given RLP not matching the block number!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasLimit == blockFromRlp.gasLimit,"gasLimit in given RLP not matching the block gasLimit!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); + + BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); + + //Check transaction list + + Transactions txsFromField; + + for (auto const& txObj: blObj["transactions"].get_array()) + { + mObject tx = txObj.get_obj(); + + BOOST_REQUIRE(tx.count("nonce")); + BOOST_REQUIRE(tx.count("gasPrice")); + BOOST_REQUIRE(tx.count("gasLimit")); + BOOST_REQUIRE(tx.count("to")); + BOOST_REQUIRE(tx.count("value")); + BOOST_REQUIRE(tx.count("v")); + BOOST_REQUIRE(tx.count("r")); + BOOST_REQUIRE(tx.count("s")); + BOOST_REQUIRE(tx.count("data")); + + try + { + Transaction t(createRLPStreamFromTransactionFields(tx).out(), CheckSignature::Sender); + txsFromField.push_back(t); + } + catch (Exception const& _e) + { + BOOST_ERROR("Failed transaction constructor with Exception: " << diagnostic_information(_e)); + } + catch (exception const& _e) + { + cnote << _e.what(); + } + } + + Transactions txsFromRlp; + RLP root(blockRLP); + for (auto const& tr: root[1]) + { + Transaction tx(tr.data(), CheckSignature::Sender); + txsFromRlp.push_back(tx); + } + + BOOST_CHECK_MESSAGE(txsFromRlp.size() == txsFromField.size(), "transaction list size does not match"); + + for (size_t i = 0; i < txsFromField.size(); ++i) + { + BOOST_CHECK_MESSAGE(txsFromField[i].data() == txsFromRlp[i].data(), "transaction data in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].gas() == txsFromRlp[i].gas(), "transaction gasLimit in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].gasPrice() == txsFromRlp[i].gasPrice(), "transaction gasPrice in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].nonce() == txsFromRlp[i].nonce(), "transaction nonce in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().r == txsFromRlp[i].signature().r, "transaction r in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().s == txsFromRlp[i].signature().s, "transaction s in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].signature().v == txsFromRlp[i].signature().v, "transaction v in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); + + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + } + + // check uncle list + BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + } + } + } +} + +} }// Namespace Close + + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); +} + +//BOOST_AUTO_TEST_CASE(blValidBlockTest) +//{ +// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) +//{ +// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) +//{ +// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blForkBlocks) +//{ +// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); +//} + +BOOST_AUTO_TEST_CASE(userDefinedFileBl) +{ + dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); +} + +BOOST_AUTO_TEST_SUITE_END() + diff --git a/test/vm.cpp b/test/vm.cpp index e78753e6a..eb7c174ec 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -533,33 +533,33 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest) } } -BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--inputlimits" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - -BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--inputlimits" || arg == "--all") - dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests); - } -} +//BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--inputlimits" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); + +// dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); + +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} + +//BOOST_AUTO_TEST_CASE(vmInputLimitsTest2) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--inputlimits" || arg == "--all") +// dev::test::executeTests("vmInputLimitsTest2", "/VMTests", dev::test::doVMTests); +// } +//} BOOST_AUTO_TEST_CASE(vmRandom) { From 9ce2393e0e6fcd49216c136b196ae19d1a5a708a Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:24:06 +0100 Subject: [PATCH 211/313] more block tests + bugfix for longer chains --- test/bcBlockChainTestFiller.json | 15 + ...er.json => bcInvalidHeaderTestFiller.json} | 427 ++++++++++-------- ...iller.json => bcValidBlockTestFiller.json} | 320 +++++++------ test/blockchain.cpp | 45 +- 4 files changed, 431 insertions(+), 376 deletions(-) rename test/{blInvalidHeaderTestFiller.json => bcInvalidHeaderTestFiller.json} (69%) rename test/{blValidBlockTestFiller.json => bcValidBlockTestFiller.json} (60%) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 050def25b..75ed62943 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -39,6 +39,21 @@ ], "uncleHeaders" : [ ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } ] } diff --git a/test/blInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json similarity index 69% rename from test/blInvalidHeaderTestFiller.json rename to test/bcInvalidHeaderTestFiller.json index 482eafc56..bba00834b 100644 --- a/test/blInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,8 +1,5 @@ { "log1_wrongBlockNumber" : { - "blockHeader" : { - "number" : "2" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -33,25 +30,30 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "number" : "2" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "log1_wrongBloom" : { - "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - }, + "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -68,6 +70,7 @@ "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, + "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10000000000", @@ -82,25 +85,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongCoinbase" : { - "blockHeader" : { - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -131,25 +138,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongDifficulty" : { - "blockHeader" : { - "difficulty" : "10000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -180,25 +191,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "difficulty" : "10000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "DifferentExtraData" : { - "blockHeader" : { - "extraData" : "42" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -229,25 +244,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "extraData" : "42" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongGasLimit" : { - "blockHeader" : { - "gasLimit" : "100000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -278,25 +297,30 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "gasLimit" : "100000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ + ] }, "wrongGasUsed" : { - "blockHeader" : { - "gasUsed" : "0" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -327,25 +351,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "gasUsed" : "0" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongNumber" : { - "blockHeader" : { - "number" : "0" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -376,25 +404,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "number" : "0" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongParentHash" : { - "blockHeader" : { - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -425,25 +457,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, - "wrongReceiptTrie" : { - "blockHeader" : { - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }, + "wrongReceiptTrie" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -474,25 +510,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongStateRoot" : { - "blockHeader" : { - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -523,25 +563,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongTimestamp" : { - "blockHeader" : { - "timestamp" : "0x54c98c80" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -572,25 +616,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "timestamp" : "0x54c98c80" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, - "wrongTransactionsTrie" : { - "blockHeader" : { - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" - }, + "wrongTransactionsTrie" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -621,25 +669,29 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "transactionsTrie" : "0x55e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, "wrongUncleHash" : { - "blockHeader" : { - "uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", @@ -670,18 +722,25 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "blockHeader" : { + "uncleHash" : "0x0dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] } } diff --git a/test/blValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json similarity index 60% rename from test/blValidBlockTestFiller.json rename to test/bcValidBlockTestFiller.json index 8099c0dd6..3ce79cf4d 100644 --- a/test/blValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -1,43 +1,4 @@ { - "diffTooLowToChange" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "42", - "gasLimit" : "100000", - "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, "diff1024" : { "genesisBlockHeader" : { @@ -64,19 +25,24 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "850", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] + }, "gasPrice0" : { @@ -104,18 +70,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "0", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "85000", + "gasPrice" : "0", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -144,18 +114,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "850", - "gasPrice" : "0", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "1000001", + "gasPrice" : "0", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "0" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -184,18 +158,22 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" + "transactions" : [ + { + "data" : "", + "gasLimit" : "500", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -224,27 +202,31 @@ "storage": {} } }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "7000000000" - }, + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "8000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "7000000000" + }, + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "8000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -273,27 +255,31 @@ "storage": {} } }, - "transactions" : [ - { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" - }, + "blocks" : [ { - "data" : "", - "gasLimit" : "500", - "gasPrice" : "9", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + }, + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "9", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ ] }, @@ -328,54 +314,64 @@ "storage": {} } }, - "transactions" : [ + "blocks" : [ { - "data" : "", - "gasLimit" : "5000", - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "5000000000" + "transactions" : [ + { + "data" : "", + "gasLimit" : "50000", + "gasPrice" : "10", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "5000000000" + } + ], + "uncleHeaders" : [ + ] } - ], - "uncleHeaders" : [ - ], - - "firstBlockTest" : { - "block" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", - "extraData" : "42", - "gasLimit" : "0x0dddb6", - "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", - "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - }, - "transactions" : [ - { - "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", - "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", - "to" : "", - "v" : "0x1b", - "value" : "" - } - ], - } + ] + }, + "dataTx" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "023101", + "extraData" : "42", + "gasLimit" : "0x0dddb6", + "gasUsed" : "100", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "62", + "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", + "gasLimit" : "0x0f3e6f", + "gasPrice" : "0x09184e72a000", + "nonce" : "0", + "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", + "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "to" : "", + "v" : "0x1b", + "value" : "" + } + ], + "uncleHeaders" : [ + ] + } + ] } } + diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 7dad5b4f2..69ea8fa2b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -81,7 +81,7 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void doBlockTests(json_spirit::mValue& _v, bool _fillin) +void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { for (auto& i: _v.get_obj()) { @@ -271,7 +271,6 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) if (tmp != current_BlockHeader) { current_BlockHeader = tmp; - cout << "new header!\n"; ProofOfWork pow; MineInfo ret; while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) @@ -343,14 +342,9 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) try { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); + state.sync(bc); + bc.import(block2.out(), state.db()); + state.sync(bc); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -505,32 +499,23 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcBlockChainTest) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); } -//BOOST_AUTO_TEST_CASE(blValidBlockTest) -//{ -// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -//} - -//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -//{ -// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -//{ -// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blForkBlocks) -//{ -// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -//} -BOOST_AUTO_TEST_CASE(userDefinedFileBl) +BOOST_AUTO_TEST_CASE(userDefinedFileBc) { - dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); + dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_SUITE_END() From 3f8be2aabc01836f7ae143f685d1a680937df256 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:44:41 +0100 Subject: [PATCH 212/313] fix blockGasLimit bug : 1024 -> 2048 --- libethcore/BlockInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 6c645372e..71cd0d110 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -206,8 +206,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); // Check timestamp is after previous timestamp. if (parentHash) From 9e6f149fd6d8a461fc8f4d221273811edb5df3eb Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 4 Mar 2015 16:01:13 +0300 Subject: [PATCH 213/313] Transaction Test Fillers POC9 gas fees increased, most tests are incorrect now need to review (wip) --- test/stPreCompiledContractsFiller.json | 6 +- test/stTransactionTestFiller.json | 144 ++++++++++++------------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/test/stPreCompiledContractsFiller.json b/test/stPreCompiledContractsFiller.json index 7c7fd8e4b..d571dfccc 100644 --- a/test/stPreCompiledContractsFiller.json +++ b/test/stPreCompiledContractsFiller.json @@ -378,16 +378,16 @@ "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", "currentNumber" : "0", - "currentGasLimit" : "10000000", + "currentGasLimit" : "100000000", "currentDifficulty" : "256", "currentTimestamp" : 1, "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" }, "pre" : { "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "20000000", + "balance" : "200000000", "nonce" : "0", - "code" : "{ [[ 2 ]] (CALL 500 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", + "code" : "{ [[ 2 ]] (CALL 20000000 2 0x13 0 0 0 32) [[ 0 ]] (MLOAD 0)}", "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { diff --git a/test/stTransactionTestFiller.json b/test/stTransactionTestFiller.json index 6b50774eb..1299e6d94 100644 --- a/test/stTransactionTestFiller.json +++ b/test/stTransactionTestFiller.json @@ -52,7 +52,7 @@ "transaction" : { "data" : "", - "gasLimit" : "500", + "gasLimit" : "21000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -84,7 +84,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -116,7 +116,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -138,7 +138,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1101", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -148,12 +148,12 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21600", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "502" + "value" : "5000" } }, @@ -170,7 +170,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -180,20 +180,20 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21600", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "502" + "value" : "5000" } }, "InternalCallHittingGasLimit" : { "env" : { - "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentCoinbase" : "2adf5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "22000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -227,7 +227,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1100", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -240,7 +240,7 @@ "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "21100", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -258,7 +258,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1100", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -271,7 +271,7 @@ "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "1100", + "currentGasLimit" : "21100", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -289,7 +289,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1101", + "gasLimit" : "21101", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -302,7 +302,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -310,7 +310,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "140000", "code" : "", "nonce" : "0", "storage" : { @@ -339,7 +339,7 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "130000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -352,7 +352,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "100000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -360,7 +360,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "30000", "code" : "", "nonce" : "0", "storage" : { @@ -389,7 +389,7 @@ "transaction" : { "data" : "", - "gasLimit" : "600", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -402,7 +402,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -410,7 +410,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -449,7 +449,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "21100", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -462,7 +462,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -470,7 +470,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "500000", "code" : "", "nonce" : "0", "storage" : { @@ -514,7 +514,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -527,7 +527,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -535,7 +535,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -544,7 +544,7 @@ "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10", - "code" : "{(CALL 0 0 1 0 0 0 0) (SUICIDE 0)}", + "code" : "{(CALL 20000 0x0000000000000000000000000000000000000000 1 0 0 0 0) (SUICIDE 0)}", "nonce" : "0", "storage" : { } @@ -552,7 +552,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "0", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -563,7 +563,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "50000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -576,7 +576,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -584,7 +584,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -592,8 +592,8 @@ }, "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10", - "code" : "{(CALL 20 0 1 0 0 0 0) (SUICIDE 0)}", + "balance" : "1000", + "code" : "{(CALL 22000 0x0000000000000000000000000000000000000000 1 0 0 0 0) (SUICIDE 0)}", "nonce" : "0", "storage" : { } @@ -601,7 +601,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "0", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -612,7 +612,7 @@ "transaction" : { "data" : "", - "gasLimit" : "700", + "gasLimit" : "50000", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -633,7 +633,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "122000", "code" : "", "nonce" : "0", "storage" : { @@ -642,7 +642,7 @@ "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { "balance" : "10000", - "code" : "{(SUICIDE 0) (CALL 0 2000 0 0 0 0 0) }", + "code" : "{(SUICIDE 0) (CALL 2000 0x0000000000000000000000000000000000000000 0 0 0 0 0) }", "nonce" : "0", "storage" : { } @@ -650,7 +650,7 @@ "0000000000000000000000000000000000000000" : { "balance" : "1110", - "code" : "{(SUICIDE 1)}", + "code" : "{(SUICIDE 0x0000000000000000000000000000000000000001)}", "nonce" : "0", "storage" : { } @@ -660,7 +660,7 @@ "transaction" : { "data" : "", - "gasLimit" : "3700", + "gasLimit" : "33700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -673,7 +673,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -681,7 +681,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "122000", "code" : "", "nonce" : "0", "storage" : { @@ -700,7 +700,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1700", + "gasLimit" : "31700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -713,7 +713,7 @@ "env" : { "currentCoinbase" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "currentDifficulty" : "45678256", - "currentGasLimit" : "10000", + "currentGasLimit" : "1000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -721,7 +721,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "7000", + "balance" : "22000", "code" : "", "nonce" : "0", "storage" : { @@ -740,7 +740,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1700", + "gasLimit" : "21700", "gasPrice" : "1", "nonce" : "", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -771,7 +771,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -784,7 +784,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -802,7 +802,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -815,7 +815,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -833,7 +833,7 @@ "transaction" : { "data" : "0x00000000000000000000112233445566778f32", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -846,7 +846,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -854,7 +854,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "43000", "code" : "", "nonce" : "0", "storage" : { @@ -864,7 +864,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5100", + "gasLimit" : "35100", "gasPrice" : "0", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -877,7 +877,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "100000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -885,7 +885,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "33000", "code" : "", "nonce" : "0", "storage" : { @@ -908,7 +908,7 @@ "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "currentDifficulty" : "45678256", - "currentGasLimit" : "1000000", + "currentGasLimit" : "10000000", "currentNumber" : "0", "currentTimestamp" : 1, "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" @@ -916,7 +916,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "3000", + "balance" : "33000", "code" : "", "nonce" : "0", "storage" : { @@ -926,8 +926,8 @@ "transaction" : { "data" : "0x3240349548983454", - "gasLimit" : "500", - "gasPrice" : "0", + "gasLimit" : "32600", + "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", @@ -999,7 +999,7 @@ "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "value" : "900" + "value" : "" } }, @@ -1048,7 +1048,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "100000", + "balance" : "1000000", "code" : "", "nonce" : "0", "storage" : { @@ -1058,7 +1058,7 @@ "transaction" : { "data" : "", - "gasLimit" : "1000", + "gasLimit" : "22000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1079,7 +1079,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "132000", "code" : "", "nonce" : "0", "storage" : { @@ -1089,7 +1089,7 @@ "transaction" : { "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", - "gasLimit" : "882", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1110,7 +1110,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -1120,7 +1120,7 @@ "transaction" : { "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", - "gasLimit" : "883", + "gasLimit" : "70000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1141,7 +1141,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "30000", "code" : "", "nonce" : "0", "storage" : { @@ -1159,7 +1159,7 @@ "transaction" : { "data" : "", - "gasLimit" : "882", + "gasLimit" : "21882", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From 3c08161974a70685c69a662320c36dce64f8be46 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:48:01 +0100 Subject: [PATCH 214/313] update block tests to latest changes PoW changes --- libethcore/ProofOfWork.cpp | 2 +- test/bcBlockChainTestFiller.json | 4 ++- test/bcInvalidHeaderTestFiller.json | 56 +++++++++++++++++++++-------- test/bcValidBlockTestFiller.json | 52 ++++++++++++++++++--------- test/blockchain.cpp | 36 +++++++++++++++---- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 084225a38..04e4249b6 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -162,7 +162,7 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign if (val <= boundary) { ret.first.completed = true; - result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); result.nonce = u64(tryNonce); break; } diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 75ed62943..827f49c58 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -7,12 +7,14 @@ "extraData" : "42", "gasLimit" : "100000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index bba00834b..5665a3418 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -7,7 +7,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -61,7 +63,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,7 +119,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -168,7 +174,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -221,7 +229,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -274,7 +284,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -328,7 +340,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -381,7 +395,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -434,7 +450,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -487,7 +505,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -540,7 +560,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -593,7 +615,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -646,7 +670,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -699,7 +725,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 3ce79cf4d..abb8afdf5 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -8,7 +8,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -30,7 +32,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "850", + "gasLimit" : "85000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -53,7 +55,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,7 +101,9 @@ "extraData" : "42", "gasLimit" : "1000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -141,7 +147,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -163,7 +171,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "500", + "gasLimit" : "50000", "gasPrice" : "10", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -185,7 +193,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -238,7 +248,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -291,7 +303,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -341,8 +355,10 @@ "extraData" : "42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "number" : "0", "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", @@ -351,19 +367,23 @@ "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } }, "blocks" : [ { "transactions" : [ { "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", + "gasLimit" : "50000", + "gasPrice" : "50", "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "", - "v" : "0x1b", "value" : "" } ], diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 69ea8fa2b..ccfd57722 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -75,6 +75,12 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("extraData")) rlpStream << importByteArray(_tObj["extraData"].get_str()); + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixBytes")) + rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -130,13 +136,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { // find new valid nonce ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + std::pair ret; + while (!ProofOfWork::verify(blockFromFields)) + { + ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); } // create new "genesis" block @@ -266,15 +276,25 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixBytes")) + tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + // find new valid nonce if (tmp != current_BlockHeader) { current_BlockHeader = tmp; + ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) - tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } } } else @@ -302,6 +322,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); blObj["blockHeader"] = oBlockHeader; @@ -423,6 +445,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); From 95587acdc0962752bb19041914fc06d9afb70466 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 15:17:34 +0100 Subject: [PATCH 215/313] More info in AZ. --- alethzero/MainWin.cpp | 22 ++++++++++++++++++---- libethcore/BlockInfo.cpp | 18 +++++++++++++----- libethcore/BlockInfo.h | 7 ++++--- libethcore/Exceptions.h | 1 + libethcore/ProofOfWork.cpp | 8 ++++---- libethcore/ProofOfWork.h | 11 ++++++++--- 6 files changed, 48 insertions(+), 19 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index bbe9d9f02..30bbe8243 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1362,11 +1362,16 @@ void Main::on_blocks_currentItemChanged() s << "   Children: " << details.children.size() << ""; s << "
Gas used/limit: " << info.gasUsed << "/" << info.gasLimit << ""; s << "
Coinbase: " << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << " " << info.coinbaseAddress; + s << "
Seed hash: " << info.seedHash << ""; + s << "
Mix hash: " << info.mixHash << ""; s << "
Nonce: " << info.nonce << ""; s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + { + auto e = ProofOfWork::eval(info); + s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; + } else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; @@ -1378,9 +1383,18 @@ void Main::on_blocks_currentItemChanged() for (auto u: block[2]) { BlockInfo uncle = BlockInfo::fromHeader(u.data()); - s << "
 Hash: " << uncle.hash << ""; - s << "
 Parent: " << uncle.parentHash << ""; - s << "
 Number: " << uncle.number << ""; + char const* line = "
 "; + s << line << "Hash: " << uncle.hash << ""; + s << line << "Parent: " << uncle.parentHash << ""; + s << line << "Number: " << uncle.number << ""; + s << line << "Coinbase: " << pretty(uncle.coinbaseAddress).toHtmlEscaped().toStdString() << " " << uncle.coinbaseAddress; + s << line << "Seed hash: " << uncle.seedHash << ""; + s << line << "Mix hash: " << uncle.mixHash << ""; + s << line << "Nonce: " << uncle.nonce << ""; + s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; + s << line << "Difficulty: " << uncle.difficulty << ""; + auto e = ProofOfWork::eval(uncle); + s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) s << "
Pre: " << BlockInfo(ethereum()->blockChain().block(info.parentHash)).stateRoot << ""; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 71cd0d110..c04f6fc29 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -57,7 +57,7 @@ void BlockInfo::setEmpty() timestamp = 0; extraData.clear(); seedHash = h256(); - mixBytes = h256(); + mixHash = h256(); nonce = Nonce(); hash = headerHash(WithNonce); } @@ -82,7 +82,7 @@ void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << mixBytes << nonce; + _s << mixHash << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -111,7 +111,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); seedHash = _header[field = 13].toHash(); - mixBytes = _header[field = 14].toHash(); + mixHash = _header[field = 14].toHash(); nonce = _header[field = 15].toHash(); } @@ -180,7 +180,12 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); - seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; + seedHash = calculateSeedHash(_parent); +} + +h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const +{ + return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -196,7 +201,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -209,6 +214,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (seedHash != calculateSeedHash(_parent)) + BOOST_THROW_EXCEPTION(InvalidSeedHash()); + // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index fbc459b76..d2072046d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -76,7 +76,7 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 mixBytes; + h256 mixHash; h256 seedHash; Nonce nonce; @@ -106,7 +106,7 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && - mixBytes == _cmp.mixBytes && + mixHash == _cmp.mixHash && seedHash == _cmp.seedHash && nonce == _cmp.nonce; } @@ -123,6 +123,7 @@ public: u256 calculateDifficulty(BlockInfo const& _parent) const; u256 calculateGasLimit(BlockInfo const& _parent) const; + h256 calculateSeedHash(BlockInfo const& _parent) const; /// sha3 of the header only. h256 headerHash(IncludeNonce _n) const; @@ -133,7 +134,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixHash << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index bc9441c6b..45667f44a 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -57,6 +57,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real); h256 head; h256 real; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; +struct InvalidSeedHash: virtual dev::Exception {}; class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 04e4249b6..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -118,16 +118,16 @@ Ethasher* Ethasher::s_this = nullptr; bool Ethash::verify(BlockInfo const& _header) { bigint boundary = (bigint(1) << 256) / _header.difficulty; - u256 e(eval(_header, _header.nonce)); - return e <= boundary; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; } -h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) +Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { auto p = Ethasher::params(_header); ethash_return_value r; ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return h256(r.result, h256::ConstructFromPointer); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7b9787f61..fdf51f0d4 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -55,12 +55,17 @@ public: Nonce nonce; h256 mixHash; }; + struct Result + { + h256 value; + h256 mixHash; + }; - static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } protected: Nonce m_last; From f6888d7c1d5fd3e1f0cdabb50f5ad5803bcf892d Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 4 Mar 2015 19:01:37 +0300 Subject: [PATCH 216/313] Gas Fee Test Changes (1) State Tests --- test/stBlockHashTestFiller.json | 6 +- test/stExampleFiller.json | 2 +- test/stInitCodeTestFiller.json | 34 +++++----- test/stLogTestsFiller.json | 92 +++++++++++++------------- test/stMemoryTestFiller.json | 2 +- test/stRefundTestFiller.json | 32 ++++----- test/stSolidityTestFiller.json | 14 ++-- test/stSpecialTestFiller.json | 4 +- test/stSystemOperationsTestFiller.json | 58 ++++++++-------- 9 files changed, 122 insertions(+), 122 deletions(-) diff --git a/test/stBlockHashTestFiller.json b/test/stBlockHashTestFiller.json index af2234976..5ecc5b1c7 100644 --- a/test/stBlockHashTestFiller.json +++ b/test/stBlockHashTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -59,7 +59,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -93,7 +93,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "8500", + "gasLimit" : "28500", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stExampleFiller.json b/test/stExampleFiller.json index 7acf695ed..9daefbd54 100644 --- a/test/stExampleFiller.json +++ b/test/stExampleFiller.json @@ -26,7 +26,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "10000", + "gasLimit" : "400000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stInitCodeTestFiller.json b/test/stInitCodeTestFiller.json index ea5467df8..902290121 100644 --- a/test/stInitCodeTestFiller.json +++ b/test/stInitCodeTestFiller.json @@ -21,7 +21,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "599", + "gasLimit" : "32599", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -43,7 +43,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "2", + "balance" : "22177", "code" : "", "nonce" : "0", "storage" : { @@ -53,7 +53,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "599", + "gasLimit" : "22176", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -74,7 +74,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "70000", "code" : "", "nonce" : "0", "storage" : { @@ -84,7 +84,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200600160008035811a8100", - "gasLimit" : "590", + "gasLimit" : "21590", "gasPrice" : "3", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -104,7 +104,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "50000", "code" : "", "nonce" : "0", "storage" : { @@ -114,7 +114,7 @@ "transaction" : { "data" : "0x6000f1", - "gasLimit" : "1000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -135,7 +135,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -145,7 +145,7 @@ "transaction" : { "data" : "0x600a80600c6000396000fff2ffff600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -166,7 +166,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -176,7 +176,7 @@ "transaction" : { "data" : "0x600a80600c600039600000f20000600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "pre" : { "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "code" : "", "nonce" : "0", "storage" : { @@ -207,7 +207,7 @@ "transaction" : { "data" : "0x600a80600c6000396000f200ff600160008035811a81", - "gasLimit" : "1000", + "gasLimit" : "23000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -245,7 +245,7 @@ "transaction" : { "data" : "0x00", - "gasLimit" : "10000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -283,7 +283,7 @@ "transaction" : { "data" : "0x00", - "gasLimit" : "10000", + "gasLimit" : "40000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -521,7 +521,7 @@ "transaction" : { "data" : "", - "gasLimit" : "5000", + "gasLimit" : "41000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -560,7 +560,7 @@ "transaction" : { "data" : "", - "gasLimit" : "15000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stLogTestsFiller.json b/test/stLogTestsFiller.json index 0f31c4c63..3b13698cf 100644 --- a/test/stLogTestsFiller.json +++ b/test/stLogTestsFiller.json @@ -32,7 +32,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -73,7 +73,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -114,9 +114,9 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "100000", + "value" : "2100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "data" : "" } @@ -156,7 +156,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -238,7 +238,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -279,7 +279,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -320,7 +320,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -361,7 +361,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -402,7 +402,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -444,7 +444,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -485,7 +485,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -526,7 +526,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -567,7 +567,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -608,7 +608,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -649,7 +649,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -690,7 +690,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -731,7 +731,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -772,7 +772,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -814,7 +814,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -855,7 +855,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -896,7 +896,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -937,7 +937,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -978,7 +978,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1019,7 +1019,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1060,7 +1060,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1101,7 +1101,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1142,7 +1142,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1184,7 +1184,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1225,7 +1225,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1266,7 +1266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1307,7 +1307,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1348,7 +1348,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1389,7 +1389,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1430,7 +1430,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1471,7 +1471,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1512,7 +1512,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1553,7 +1553,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1595,7 +1595,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1636,7 +1636,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1677,7 +1677,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1718,7 +1718,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1759,7 +1759,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1800,7 +1800,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1841,7 +1841,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "210000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stMemoryTestFiller.json b/test/stMemoryTestFiller.json index eac2d5875..f34307443 100644 --- a/test/stMemoryTestFiller.json +++ b/test/stMemoryTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "1000", + "gasLimit" : "22000", "to" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stRefundTestFiller.json b/test/stRefundTestFiller.json index 4809c0987..9e867a508 100644 --- a/test/stRefundTestFiller.json +++ b/test/stRefundTestFiller.json @@ -18,7 +18,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -27,7 +27,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -54,7 +54,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -63,7 +63,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -90,7 +90,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -99,7 +99,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "500", + "gasLimit" : "21000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -126,7 +126,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "502", + "balance" : "50200", "nonce" : "0", "code" : "", "storage": {} @@ -135,7 +135,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "502", + "gasLimit" : "21002", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -166,7 +166,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -175,7 +175,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -206,7 +206,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -215,7 +215,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -247,7 +247,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -256,7 +256,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -288,7 +288,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -297,7 +297,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "100000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSolidityTestFiller.json b/test/stSolidityTestFiller.json index 549c5f226..948dc5f7a 100644 --- a/test/stSolidityTestFiller.json +++ b/test/stSolidityTestFiller.json @@ -278,7 +278,7 @@ { "//" : "run()", "data" : "0xc0406226", - "gasLimit" : "15000", + "gasLimit" : "35000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -333,7 +333,7 @@ { "//" : "testRecursiveMethods()", "data" : "0x981a3165", - "gasLimit" : "2000", + "gasLimit" : "25000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -378,7 +378,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -388,7 +388,7 @@ { "//" : "testInfiniteLoop()", "data" : "0x296df0df", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -463,7 +463,7 @@ { "//" : "run(uint256)", "data" : "0xa444f5e900000000000000000000000000000000000000000000000000000000000204", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -508,7 +508,7 @@ } }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "500", + "balance" : "50000", "nonce" : "0", "code" : "", "storage": {} @@ -518,7 +518,7 @@ { "//" : "run()", "data" : "0xc0406226", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSpecialTestFiller.json b/test/stSpecialTestFiller.json index d01072b46..223d9f75f 100644 --- a/test/stSpecialTestFiller.json +++ b/test/stSpecialTestFiller.json @@ -22,7 +22,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -31,7 +31,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "850", + "gasLimit" : "22850", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", diff --git a/test/stSystemOperationsTestFiller.json b/test/stSystemOperationsTestFiller.json index 3b08ca67b..7460ca94e 100644 --- a/test/stSystemOperationsTestFiller.json +++ b/test/stSystemOperationsTestFiller.json @@ -25,7 +25,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -60,7 +60,7 @@ }, "transaction" : { "data" : "", - "gasLimit" : "10000", + "gasLimit" : "30000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -95,7 +95,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -129,7 +129,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -163,7 +163,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -197,7 +197,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -232,7 +232,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -257,7 +257,7 @@ "storage": {} }, "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000", + "balance" : "100000", "nonce" : "0", "code" : "", "storage": {} @@ -266,7 +266,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -300,7 +300,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -334,7 +334,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -368,7 +368,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -410,7 +410,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -452,7 +452,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -494,7 +494,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -536,7 +536,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -578,7 +578,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -619,7 +619,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -660,7 +660,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -701,7 +701,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -743,7 +743,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -785,7 +785,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -827,7 +827,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -870,7 +870,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -911,7 +911,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -952,7 +952,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -993,7 +993,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1035,7 +1035,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -1076,7 +1076,7 @@ "transaction" : { "nonce" : "0", "gasPrice" : "1", - "gasLimit" : "10000", + "gasLimit" : "30000", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "100000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", From e2f1bc4133e3a75620baff3b323f4beeeaa161f1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 17:35:23 +0100 Subject: [PATCH 217/313] Add date/time language to solidity. --- libdevcore/FixedHash.h | 4 ++-- libsolidity/AST.h | 8 +++++++- libsolidity/ExpressionCompiler.cpp | 3 +++ libsolidity/Parser.cpp | 9 +++++++++ libsolidity/Token.h | 24 ++++++++++++++++-------- libsolidity/Types.cpp | 19 ++++++++++++++++++- mix/MixClient.cpp | 9 ++++++--- test/SolidityScanner.cpp | 17 +++++++++++++++++ test/blockchain.cpp | 14 +++++++------- 9 files changed, 85 insertions(+), 22 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 7fa5b411a..b00a80c04 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -85,8 +85,8 @@ public: // The obvious comparison operators. bool operator==(FixedHash const& _c) const { return m_data == _c.m_data; } bool operator!=(FixedHash const& _c) const { return m_data != _c.m_data; } - bool operator<(FixedHash const& _c) const { return m_data < _c.m_data; } - bool operator>=(FixedHash const& _c) const { return m_data >= _c.m_data; } + bool operator<(FixedHash const& _c) const { for (unsigned i = 0; i < N; ++i) if (m_data[i] < _c.m_data[i]) return true; else if (m_data[i] > _c.m_data[i]) return false; return false; } + bool operator>=(FixedHash const& _c) const { return !operator<(_c); } // The obvious binary operators. FixedHash& operator^=(FixedHash const& _c) { for (unsigned i = 0; i < N; ++i) m_data[i] ^= _c.m_data[i]; return *this; } diff --git a/libsolidity/AST.h b/libsolidity/AST.h index c91c433ed..c3c2cd8d3 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1197,7 +1197,13 @@ public: Wei = Token::SubWei, Szabo = Token::SubSzabo, Finney = Token::SubFinney, - Ether = Token::SubEther + Ether = Token::SubEther, + Second = Token::SubSecond, + Minute = Token::SubMinute, + Hour = Token::SubHour, + Day = Token::SubDay, + Week = Token::SubWeek, + Year = Token::SubYear }; Literal(SourceLocation const& _location, Token::Value _token, ASTPointer const& _value, diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 793bd55e4..adaaff23e 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -258,6 +258,9 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation) case Token::BitNot: // ~ m_context << eth::Instruction::NOT; break; + case Token::After: // after + m_context << eth::Instruction::TIMESTAMP << eth::Instruction::ADD; + break; case Token::Delete: // delete solAssert(!!m_currentLValue, "LValue not retrieved."); m_currentLValue->setToZero(_unaryOperation.getLocation()); diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 3c88efc7c..44d111591 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -822,6 +822,15 @@ ASTPointer Parser::parsePrimaryExpression() expression = nodeFactory.createNode(token, literal, subdenomination); break; } + if (Token::isTimeSubdenomination(m_scanner->peekNextToken())) + { + ASTPointer literal = getLiteralAndAdvance(); + nodeFactory.markEndPosition(); + Literal::SubDenomination subdenomination = static_cast(m_scanner->getCurrentToken()); + m_scanner->next(); + expression = nodeFactory.createNode(token, literal, subdenomination); + break; + } // fall-through case Token::StringLiteral: nodeFactory.markEndPosition(); diff --git a/libsolidity/Token.h b/libsolidity/Token.h index 19afaee3a..85979b566 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -163,7 +163,7 @@ namespace solidity K(New, "new", 0) \ K(Public, "public", 0) \ K(Private, "private", 0) \ - K(Internal, "internal", 0) \ + K(Internal, "internal", 0) \ K(Return, "return", 0) \ K(Returns, "returns", 0) \ K(Struct, "struct", 0) \ @@ -172,11 +172,18 @@ namespace solidity K(While, "while", 0) \ K(Enum, "enum", 0) \ \ - /* Ether subdenominations */ \ - K(SubWei, "wei", 0) \ - K(SubSzabo, "szabo", 0) \ - K(SubFinney, "finney", 0) \ - K(SubEther, "ether", 0) \ + /* Ether subdenominations */ \ + K(SubWei, "wei", 0) \ + K(SubSzabo, "szabo", 0) \ + K(SubFinney, "finney", 0) \ + K(SubEther, "ether", 0) \ + K(SubSecond, "seconds", 0) \ + K(SubMinute, "minutes", 0) \ + K(SubHour, "hours", 0) \ + K(SubDay, "days", 0) \ + K(SubWeek, "weeks", 0) \ + K(SubYear, "years", 0) \ + K(After, "after", 0) \ /* type keywords, keep them in this order, keep int as first keyword * the implementation in Types.cpp has to be synced to this here */\ K(Int, "int", 0) \ @@ -377,12 +384,13 @@ public: } static bool isBitOp(Value op) { return (BitOr <= op && op <= SHR) || op == BitNot; } - static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub; } + static bool isUnaryOp(Value op) { return (Not <= op && op <= Delete) || op == Add || op == Sub || op == After; } static bool isCountOp(Value op) { return op == Inc || op == Dec; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return isVariableVisibilitySpecifier(op) || op == External; } static bool isVariableVisibilitySpecifier(Value op) { return op == Public || op == Private || op == Internal; } - static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; } + static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == SubEther; } + static bool isTimeSubdenomination(Value op) { return op == SubSecond || op == SubMinute || op == SubHour || op == SubDay || op == SubWeek || op == SubYear; } // Returns a string corresponding to the JS token string // (.e., "<" for the token LT) or NULL if the token doesn't diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 96feefff5..caa3b7169 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -195,7 +195,8 @@ TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const return TypePointer(); // for non-hash integers, we allow +, -, ++ and -- else if (_operator == Token::Add || _operator == Token::Sub || - _operator == Token::Inc || _operator == Token::Dec) + _operator == Token::Inc || _operator == Token::Dec || + _operator == Token::After) return shared_from_this(); else return TypePointer(); @@ -251,6 +252,7 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) switch (_literal.getSubDenomination()) { case Literal::SubDenomination::Wei: + case Literal::SubDenomination::Second: case Literal::SubDenomination::None: break; case Literal::SubDenomination::Szabo: @@ -262,6 +264,21 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) case Literal::SubDenomination::Ether: m_value *= bigint("1000000000000000000"); break; + case Literal::SubDenomination::Minute: + m_value *= bigint("60"); + break; + case Literal::SubDenomination::Hour: + m_value *= bigint("3600"); + break; + case Literal::SubDenomination::Day: + m_value *= bigint("86400"); + break; + case Literal::SubDenomination::Week: + m_value *= bigint("604800"); + break; + case Literal::SubDenomination::Year: + m_value *= bigint("31536000"); + break; } } diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index 2ce9455cf..781924db7 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -46,15 +46,18 @@ const u256 c_mixGenesisDifficulty = (u256) 1 << 4; class MixBlockChain: public dev::eth::BlockChain { public: - MixBlockChain(std::string const& _path, h256 _stateRoot): BlockChain(createGenesisBlock(_stateRoot), _path, true) + MixBlockChain(std::string const& _path, h256 _stateRoot): + BlockChain(createGenesisBlock(_stateRoot), _path, true) { } static bytes createGenesisBlock(h256 _stateRoot) { RLPStream block(3); - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_mixGenesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << std::string() << sha3(bytes(1, 42)); + block.appendList(16) + << h256() << EmptyListSHA3 << h160() << _stateRoot << EmptyTrie << EmptyTrie + << LogBloom() << c_mixGenesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 + << std::string() << h256() << h256() << h64(u64(42)); block.appendRaw(RLPEmptyList); block.appendRaw(RLPEmptyList); return block.out(); diff --git a/test/SolidityScanner.cpp b/test/SolidityScanner.cpp index 2e4e5db08..8d3e53929 100644 --- a/test/SolidityScanner.cpp +++ b/test/SolidityScanner.cpp @@ -264,6 +264,23 @@ BOOST_AUTO_TEST_CASE(ether_subdenominations) BOOST_CHECK_EQUAL(scanner.next(), Token::SubEther); } +BOOST_AUTO_TEST_CASE(time_subdenominations) +{ + Scanner scanner(CharStream("seconds minutes hours days weeks years")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::SubSecond); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubMinute); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubHour); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubDay); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubWeek); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubYear); +} + +BOOST_AUTO_TEST_CASE(time_after) +{ + Scanner scanner(CharStream("after 1")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::After); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ccfd57722..aea2bab07 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -78,8 +78,8 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("seedHash")) rlpStream << importByteArray(_tObj["seedHash"].get_str()); - if (_tObj.count("mixBytes")) - rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -146,7 +146,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); + o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); } // create new "genesis" block @@ -276,8 +276,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixBytes")) - tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); if (blObj["blockHeader"].get_obj().count("seedHash")) tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); @@ -322,7 +322,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); @@ -445,7 +445,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixHash == blockFromRlp.mixHash, "mixHash in given RLP not matching the block mixHash!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); From 2cfd93132b0655ec734315ecf5188bee2850d12f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 19:55:52 +0100 Subject: [PATCH 218/313] Params & JSON file. --- libdevcrypto/OverlayDB.cpp | 2 -- libethcore/BlockInfo.cpp | 19 +++++++++---------- libethcore/BlockInfo.h | 2 -- .../FeeStructure.cpp => libethcore/Params.cpp | 11 ++++++++++- libevm/FeeStructure.h => libethcore/Params.h | 10 ++++++++++ libethcore/ProofOfWork.cpp | 2 ++ libethereum/Client.h | 2 +- libethereum/Interface.h | 2 +- libethereum/Precompiled.cpp | 2 +- libethereum/State.h | 2 +- libevm/All.h | 1 - libevm/VM.h | 2 +- libsolidity/Types.cpp | 2 ++ feeStructure.json => params.json | 12 +++++++++++- 14 files changed, 49 insertions(+), 22 deletions(-) rename libevm/FeeStructure.cpp => libethcore/Params.cpp (84%) rename libevm/FeeStructure.h => libethcore/Params.h (91%) rename feeStructure.json => params.json (75%) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4bd698f57 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -56,10 +56,8 @@ void OverlayDB::commit() if (m_aux.count(i)) { m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; m_aux.erase(i); } - cdebug << "Discarding " << keysOf(m_aux); m_auxActive.clear(); m_aux.clear(); m_over.clear(); diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index c04f6fc29..ef7f7b8f0 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -25,13 +25,12 @@ #include #include "ProofOfWork.h" #include "Exceptions.h" +#include "Params.h" #include "BlockInfo.h" using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; - BlockInfo::BlockInfo(): timestamp(Invalid256) { } @@ -128,7 +127,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) if (gasUsed > gasLimit) BOOST_THROW_EXCEPTION(TooMuchGasUsed()); - if (number && extraData.size() > 1024) + if (number && extraData.size() > c_maximumExtraDataSize) BOOST_THROW_EXCEPTION(ExtraDataTooBig()); } @@ -185,23 +184,23 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const { - return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; + return number % c_epochDuration == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const { if (!parentHash) - return 1000000; + return c_genesisGasLimit; else - return max(125000, (_parent.gasLimit * (1024 - 1) + (_parent.gasUsed * 6 / 5)) / 1024); + return max(c_minGasLimit, (_parent.gasLimit * (c_gasLimitBoundDivisor - 1) + (_parent.gasUsed * 6 / 5)) / c_gasLimitBoundDivisor); } u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const { if (!parentHash) - return c_genesisDifficulty; + return (u256)c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -211,8 +210,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index d2072046d..bf986e3a1 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -30,8 +30,6 @@ namespace dev namespace eth { -extern u256 c_genesisDifficulty; - enum IncludeNonce { WithoutNonce = 0, diff --git a/libevm/FeeStructure.cpp b/libethcore/Params.cpp similarity index 84% rename from libevm/FeeStructure.cpp rename to libethcore/Params.cpp index 78c6ebfb2..f36af1375 100644 --- a/libevm/FeeStructure.cpp +++ b/libethcore/Params.cpp @@ -19,7 +19,7 @@ * @date 2014 */ -#include "FeeStructure.h" +#include "Params.h" using namespace std; namespace dev @@ -28,6 +28,15 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_genesisDifficulty = 2048; +u256 const c_maximumExtraDataSize = 1024; +u256 const c_epochDuration = 3000; +u256 const c_genesisGasLimit = 1000000; +u256 const c_minGasLimit = 125000; +u256 const c_gasLimitBoundDivisor = 1024; +u256 const c_minimumDifficulty = 2048; +u256 const c_difficultyBoundDivisor = 2048; +u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; u256 const c_expGas = 10; u256 const c_expByteGas = 10; diff --git a/libevm/FeeStructure.h b/libethcore/Params.h similarity index 91% rename from libevm/FeeStructure.h rename to libethcore/Params.h index 9109347dc..cab1852fa 100644 --- a/libevm/FeeStructure.h +++ b/libethcore/Params.h @@ -29,6 +29,16 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +extern u256 const c_genesisDifficulty; +extern u256 const c_maximumExtraDataSize; +extern u256 const c_epochDuration; +extern u256 const c_genesisGasLimit; +extern u256 const c_minGasLimit; +extern u256 const c_gasLimitBoundDivisor; +extern u256 const c_minimumDifficulty; +extern u256 const c_difficultyBoundDivisor; +extern u256 const c_durationLimit; + extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..332d739bb 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,6 +66,7 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } + cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -90,6 +91,7 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } + cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/libethereum/Client.h b/libethereum/Client.h index 41b1c1bc6..900d339ad 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include "CanonBlockChain.h" #include "TransactionQueue.h" diff --git a/libethereum/Interface.h b/libethereum/Interface.h index 2a9de14d1..817a5e4b0 100644 --- a/libethereum/Interface.h +++ b/libethereum/Interface.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include "LogFilter.h" #include "Transaction.h" #include "AccountDiff.h" diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..6e0d4756c 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/libethereum/State.h b/libethereum/State.h index 33843c65c..00a735291 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include "TransactionQueue.h" #include "Account.h" diff --git a/libevm/All.h b/libevm/All.h index 89c451ef4..2360d91b8 100644 --- a/libevm/All.h +++ b/libevm/All.h @@ -1,5 +1,4 @@ #pragma once #include "ExtVMFace.h" -#include "FeeStructure.h" #include "VM.h" diff --git a/libevm/VM.h b/libevm/VM.h index ecf5de292..f100badc4 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -27,7 +27,7 @@ #include #include #include -#include "FeeStructure.h" +#include #include "VMFace.h" namespace dev diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index caa3b7169..0b8259bfe 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -308,6 +308,8 @@ TypePointer IntegerConstantType::unaryOperatorResult(Token::Value _operator) con case Token::Sub: value = -m_value; break; + case Token::After: + return shared_from_this(); default: return TypePointer(); } diff --git a/feeStructure.json b/params.json similarity index 75% rename from feeStructure.json rename to params.json index f5acf0f0b..1b5682544 100644 --- a/feeStructure.json +++ b/params.json @@ -1,5 +1,15 @@ var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." }, + "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, + "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, + "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, + "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, + "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, + "minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." }, + "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, + "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, + + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "expGas": { "v": 10, "d": "Once per EXP instuction." }, "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, From c8a03dcf587679efe404ca681b19211910dfa0f9 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 21:32:26 +0100 Subject: [PATCH 219/313] merge --- libethcore/BlockInfo.cpp | 20 +- test/bcBlockChainTestFiller.json | 6 +- test/bcInvalidHeaderTestFiller.json | 88 ++++----- test/bcUncleTestFiller.json | 114 ++++++++++++ test/bcValidBlockTestFiller.json | 48 ++--- test/blockchain.cpp | 275 +++++++++++++++------------- 6 files changed, 341 insertions(+), 210 deletions(-) create mode 100644 test/bcUncleTestFiller.json diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index ef7f7b8f0..d8a2357a1 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -96,22 +96,22 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) int field = 0; try { - parentHash = _header[field = 0].toHash(); - sha3Uncles = _header[field = 1].toHash(); - coinbaseAddress = _header[field = 2].toHash
(); - stateRoot = _header[field = 3].toHash(); - transactionsRoot = _header[field = 4].toHash(); - receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + parentHash = _header[field = 0].toHash(RLP::VeryStrict); + sha3Uncles = _header[field = 1].toHash(RLP::VeryStrict); + coinbaseAddress = _header[field = 2].toHash
(RLP::VeryStrict); + stateRoot = _header[field = 3].toHash(RLP::VeryStrict); + transactionsRoot = _header[field = 4].toHash(RLP::VeryStrict); + receiptsRoot = _header[field = 5].toHash(RLP::VeryStrict); + logBloom = _header[field = 6].toHash(RLP::VeryStrict); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - seedHash = _header[field = 13].toHash(); - mixHash = _header[field = 14].toHash(); - nonce = _header[field = 15].toHash(); + seedHash = _header[field = 13].toHash(RLP::VeryStrict); + mixHash = _header[field = 14].toHash(RLP::VeryStrict); + nonce = _header[field = 15].toHash(RLP::VeryStrict); } catch (Exception const& _e) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 827f49c58..8a0bf89fe 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -1,10 +1,10 @@ { "minDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1023", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", "number" : "0", @@ -12,7 +12,7 @@ "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index 5665a3418..aa32dfbab 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,13 +1,13 @@ { "log1_wrongBlockNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -57,13 +57,13 @@ "log1_wrongBloom" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -92,7 +92,7 @@ "blocks" : [ { "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, "transactions" : [ { @@ -113,13 +113,13 @@ "wrongCoinbase" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -168,13 +168,13 @@ "wrongDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -223,13 +223,13 @@ "DifferentExtraData" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -257,7 +257,7 @@ "blocks" : [ { "blockHeader" : { - "extraData" : "42" + "extraData" : "0x42" }, "transactions" : [ { @@ -278,13 +278,13 @@ "wrongGasLimit" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -334,13 +334,13 @@ "wrongGasUsed" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -389,13 +389,13 @@ "wrongNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -444,13 +444,13 @@ "wrongParentHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -499,13 +499,13 @@ "wrongReceiptTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -554,13 +554,13 @@ "wrongStateRoot" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -609,13 +609,13 @@ "wrongTimestamp" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -664,13 +664,13 @@ "wrongTransactionsTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -719,13 +719,13 @@ "wrongUncleHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json new file mode 100644 index 000000000..839e3ba46 --- /dev/null +++ b/test/bcUncleTestFiller.json @@ -0,0 +1,114 @@ +{ + "minDifficulty" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "2049", + "extraData" : "0x", + "gasLimit" : "99804806", + "gasUsed" : "21000", + "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", + "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", + "nonce" : "17ed77999bef2e4b", + "number" : "2", + "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", + "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", + "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", + "timestamp" : "1425490151", + "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "1", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + } +} diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index abb8afdf5..29b2e978e 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -2,13 +2,13 @@ "diff1024" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1024", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -49,13 +49,13 @@ "gasPrice0" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -95,13 +95,13 @@ "gasLimitTooHigh" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "1000000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -141,13 +141,13 @@ "SimpleTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -187,13 +187,13 @@ "txOrder" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -242,13 +242,13 @@ "txEqualValue" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -297,13 +297,13 @@ "log1_correct" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -349,13 +349,13 @@ "dataTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "023101", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index aea2bab07..55c39f56b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -31,61 +31,10 @@ using namespace dev::eth; namespace dev { namespace test { -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("seedHash")) - rlpStream << importByteArray(_tObj["seedHash"].get_str()); - - if (_tObj.count("mixHash")) - rlpStream << importByteArray(_tObj["mixHash"].get_str()); +bytes createBlockRLPFromFields(mObject& _tObj); +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - return rlpStream.out(); -} void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -147,6 +96,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); + o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); } // create new "genesis" block @@ -211,13 +161,13 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txList.push_back(tx); mObject txObject; txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); + txObject["data"] = "0x" + toHex(tx.data()); txObject["gasLimit"] = toString(tx.gas()); txObject["gasPrice"] = toString(tx.gasPrice()); txObject["r"] = "0x" + toString(tx.signature().r); txObject["s"] = "0x" + toString(tx.signature().s); txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); + txObject["to"] = tx.isCreation() ? "" : toString(tx.receiveAddress()); txObject["value"] = toString(tx.value()); txArray.push_back(txObject); @@ -232,78 +182,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj.count("blockHeader")) { - if (blObj["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = current_BlockHeader; - - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); - - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); - - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); - - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); - - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); - - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); - - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); - - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); - - // find new valid nonce - - if (tmp != current_BlockHeader) - { - current_BlockHeader = tmp; - - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) - { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); - } + overwriteBlockHeader(current_BlockHeader, blObj); } // write block header @@ -321,10 +200,11 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["hash"] = toString(current_BlockHeader.hash); blObj["blockHeader"] = oBlockHeader; @@ -506,7 +386,9 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions from rlp and transaction from field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].rlp() == txsFromRlp[i].rlp(), "transactions rlp do not match"); + } // check uncle list @@ -516,6 +398,137 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } } +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.count("hash") > 0 ? (_tObj.size() - 1) : _tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << fromHex(_tObj["extraData"].get_str()); + + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +{ + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } +} } }// Namespace Close @@ -536,6 +549,10 @@ BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); } +//BOOST_AUTO_TEST_CASE(bcUncleTest) +//{ +// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +//} BOOST_AUTO_TEST_CASE(userDefinedFileBc) { From ad1fe7840f39eaaa2d04547846e40e3e4e4a20e6 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 22:38:05 +0100 Subject: [PATCH 220/313] fix evmjit build --- evmjit/libevmjit-cpp/Env.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evmjit/libevmjit-cpp/Env.cpp b/evmjit/libevmjit-cpp/Env.cpp index 11882d79d..874993c84 100644 --- a/evmjit/libevmjit-cpp/Env.cpp +++ b/evmjit/libevmjit-cpp/Env.cpp @@ -1,7 +1,7 @@ #pragma GCC diagnostic ignored "-Wconversion" #include -#include +#include #include #include "Utils.h" From 458d832cc64b89773f7f704fc905a6217c1e4485 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:24:01 +0100 Subject: [PATCH 221/313] RLP tool. --- CMakeLists.txt | 1 + eth/main.cpp | 55 ++++---- libdevcore/CommonIO.cpp | 19 ++- libdevcore/CommonIO.h | 6 +- libethcore/Params.cpp | 4 +- libethcore/ProofOfWork.cpp | 2 - params.json | 8 +- rlp/CMakeLists.txt | 16 +++ rlp/base64.cpp | 128 +++++++++++++++++ rlp/base64.h | 40 ++++++ rlp/main.cpp | 279 +++++++++++++++++++++++++++++++++++++ 11 files changed, 516 insertions(+), 42 deletions(-) create mode 100644 rlp/CMakeLists.txt create mode 100644 rlp/base64.cpp create mode 100644 rlp/base64.h create mode 100644 rlp/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dffdd9027..59cfe4ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ if (EVMJIT) endif() add_subdirectory(libdevcore) +add_subdirectory(rlp) add_subdirectory(libevmcore) add_subdirectory(liblll) diff --git a/eth/main.cpp b/eth/main.cpp index e3753364f..a7bed4f3b 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -102,33 +102,31 @@ void help() cout << "Usage eth [OPTIONS] " << endl << "Options:" << endl - << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl - << " -b,--bootstrap Connect to the default Ethereum peerserver." << endl - << " -c,--client-name Add a name to your client's version string (default: blank)." << endl - << " -d,--db-path Load database from path (default: ~/.ethereum " << endl - << " /Etherum or Library/Application Support/Ethereum)." << endl - << " -f,--force-mining Mine even when there are no transaction to mine (Default: off)" << endl - << " -h,--help Show this help message and exit." << endl - << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl + << " -a,--address Set the coinbase (mining payout) address to addr (default: auto)." << endl + << " -b,--bootstrap Connect to the default Ethereum peerserver." << endl + << " -c,--client-name Add a name to your client's version string (default: blank)." << endl + << " -d,--db-path Load database from path (default: ~/.ethereum " << endl + << " /Etherum or Library/Application Support/Ethereum)." << endl + << " -f,--force-mining Mine even when there are no transaction to mine (Default: off)" << endl + << " -h,--help Show this help message and exit." << endl + << " -i,--interactive Enter interactive mode (default: non-interactive)." << endl #if ETH_JSONRPC << " -j,--json-rpc Enable JSON-RPC server (default: off)." << endl << " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl #endif - << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl - << " -m,--mining Enable mining, optionally for a specified number of blocks (Default: off)" << endl - << " -n,--upnp Use upnp for NAT (default: on)." << endl - << " -L,--local-networking Use peers whose addresses are local." << endl - << " -o,--mode Start a full node or a peer node (Default: full)." << endl - << " -p,--port Connect to remote port (default: 30303)." << endl - << " -r,--remote Connect to remote host (default: none)." << endl - << " -s,--secret Set the secret key for use with send command (default: auto)." << endl - << " --structured-logging Enables structured logging." << endl - << " --structured-logging-format Give time format string for structured logging output." << endl - << " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl - << " -u,--public-ip Force public ip to given (default; auto)." << endl - << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl - << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl - << " -V,--version Show the version and exit." << endl + << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl + << " -m,--mining Enable mining, optionally for a specified number of blocks (Default: off)" << endl + << " -n,--upnp Use upnp for NAT (default: on)." << endl + << " -L,--local-networking Use peers whose addresses are local." << endl + << " -o,--mode Start a full node or a peer node (Default: full)." << endl + << " -p,--port Connect to remote port (default: 30303)." << endl + << " -r,--remote Connect to remote host (default: none)." << endl + << " -s,--secret Set the secret key for use with send command (default: auto)." << endl + << " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl + << " -u,--public-ip Force public ip to given (default; auto)." << endl + << " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl + << " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl + << " -V,--version Show the version and exit." << endl #if ETH_EVMJIT << " --jit Use EVM JIT (default: off)." << endl #endif @@ -141,15 +139,14 @@ string credits(bool _interactive = false) std::ostringstream cout; cout << "Ethereum (++) " << dev::Version << endl - << " Code by Gav Wood, (c) 2013, 2014." << endl + << " Code by Gav Wood et al, (c) 2013, 2014, 2015." << endl << " Based on a design by Vitalik Buterin." << endl << endl; if (_interactive) - { - cout << "Type 'netstart 30303' to start networking" << endl; - cout << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl; - cout << "Type 'exit' to quit" << endl << endl; - } + cout + << "Type 'netstart 30303' to start networking" << endl + << "Type 'connect " << Host::pocHost() << " 30303' to connect" << endl + << "Type 'exit' to quit" << endl << endl; return cout.str(); } diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 288dbd1ff..4fa132073 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -84,7 +84,7 @@ bytes dev::contents(std::string const& _file) is.seekg (0, is.end); streamoff length = is.tellg(); if (length == 0) // return early, MSVC does not like reading 0 bytes - return {}; + return bytes(); is.seekg (0, is.beg); bytes ret(length); is.read((char*)ret.data(), length); @@ -92,9 +92,22 @@ bytes dev::contents(std::string const& _file) return ret; } -void dev::writeFile(std::string const& _file, bytes const& _data) +string dev::contentsString(std::string const& _file) { - ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); + std::ifstream is(_file, std::ifstream::binary); + if (!is) + return string(); + // get length of file: + is.seekg (0, is.end); + streamoff length = is.tellg(); + if (length == 0) // return early, MSVC does not like reading 0 bytes + return string(); + is.seekg (0, is.beg); + string ret; + ret.resize(length); + is.read((char*)ret.data(), length); + is.close(); + return ret; } void dev::writeFile(std::string const& _file, bytesConstRef _data) diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 5769b6c64..1fc8a65e4 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -42,13 +42,15 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +std::string contentsString(std::string const& _file); /// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. bytesRef contentsNew(std::string const& _file); -/// Write the given binary data into the given file, replacing the file if it pre-exists. -void writeFile(std::string const& _file, bytes const& _data); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytesConstRef _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +inline void writeFile(std::string const& _file, bytes const& _data) { writeFile(_file, bytesConstRef(&_data)); } +inline void writeFile(std::string const& _file, std::string const& _data) { writeFile(_file, bytesConstRef(_data)); } /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index f36af1375..d1154abcc 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -28,13 +28,13 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_genesisDifficulty = 2048; +u256 const c_genesisDifficulty = 131072; u256 const c_maximumExtraDataSize = 1024; u256 const c_epochDuration = 3000; u256 const c_genesisGasLimit = 1000000; u256 const c_minGasLimit = 125000; u256 const c_gasLimitBoundDivisor = 1024; -u256 const c_minimumDifficulty = 2048; +u256 const c_minimumDifficulty = 131072; u256 const c_difficultyBoundDivisor = 2048; u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 332d739bb..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,7 +66,6 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } - cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -91,7 +90,6 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } - cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/params.json b/params.json index 1b5682544..744f92154 100644 --- a/params.json +++ b/params.json @@ -1,13 +1,13 @@ var x = { - "genesisDifficulty": { "v": 2048, "d": "Difficulty of the Genesis block." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "minimumDifficulty": { "v": 2048, "d": "The minimum that the difficulty may ever be." }, + "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, + "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, + "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, + "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, "expGas": { "v": 10, "d": "Once per EXP instuction." }, diff --git a/rlp/CMakeLists.txt b/rlp/CMakeLists.txt new file mode 100644 index 000000000..0e2b5f57b --- /dev/null +++ b/rlp/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_policy(SET CMP0015 NEW) +set(CMAKE_AUTOMOC OFF) + +aux_source_directory(. SRC_LIST) + +include_directories(BEFORE ..) +include_directories(${LEVELDB_INCLUDE_DIRS}) + +set(EXECUTABLE rlp) + +add_executable(${EXECUTABLE} ${SRC_LIST}) + +target_link_libraries(${EXECUTABLE} devcrypto) + +install( TARGETS ${EXECUTABLE} DESTINATION bin) + diff --git a/rlp/base64.cpp b/rlp/base64.cpp new file mode 100644 index 000000000..5e2b32000 --- /dev/null +++ b/rlp/base64.cpp @@ -0,0 +1,128 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. + +#include "base64.h" + +#include + +using namespace std; +using namespace dev; + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +static inline bool is_base64(byte c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +std::string dev::base64_encode(bytesConstRef _in) { + std::string ret; + int i = 0; + int j = 0; + byte char_array_3[3]; + byte char_array_4[4]; + + auto buf = _in.data(); + auto bufLen = _in.size(); + + while (bufLen--) { + char_array_3[i++] = *(buf++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + } + + return ret; +} + +bytes dev::base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + byte char_array_4[4], char_array_3[3]; + bytes ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret.push_back(char_array_3[i]); + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); + } + + return ret; +} diff --git a/rlp/base64.h b/rlp/base64.h new file mode 100644 index 000000000..53ba282c8 --- /dev/null +++ b/rlp/base64.h @@ -0,0 +1,40 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +#pragma once + +#include +#include +#include + +namespace dev +{ + +std::string base64_encode(bytesConstRef _in); +bytes base64_decode(std::string const& _in); + +} diff --git a/rlp/main.cpp b/rlp/main.cpp new file mode 100644 index 000000000..9bd51cdfc --- /dev/null +++ b/rlp/main.cpp @@ -0,0 +1,279 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file main.cpp + * @author Gav Wood + * @date 2014 + * RLP tool. + */ +#include +#include +#include +#include +#include +#include +#include +#include "base64.h" +using namespace std; +using namespace dev; + +void help() +{ + cout + << "Usage rlp [OPTIONS] [ | -- ]" << endl + << "Options:" << endl + << " -V,--version Show the version and exit." << endl + ; + exit(0); +} + +void version() +{ + cout << "rlp version " << dev::Version << endl; + exit(0); +} + +enum class Mode { + ListArchive, + ExtractArchive, + Render, +}; + +enum class Encoding { + Auto, + Hex, + Base64, + Binary, +}; + +bool isAscii(string const& _s) +{ + for (char c: _s) + if (c < 32) + return false; + return true; +} + +class RLPStreamer +{ +public: + struct Prefs + { + string indent = " "; + bool hexInts = false; + bool forceString = false; + bool escapeAll = false; + bool forceHex = false; + }; + + RLPStreamer(ostream& _out, Prefs _p): m_out(_out), m_prefs(_p) {} + + void output(RLP const& _d, unsigned _level = 0) + { + if (_d.isNull()) + m_out << "null"; + else if (_d.isInt()) + if (m_prefs.hexInts) + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + else + m_out << _d.toInt(RLP::LaisezFaire); + else if (_d.isData()) + if (m_prefs.forceString || (!m_prefs.forceHex && isAscii(_d.toString()))) + m_out << escaped(_d.toString(), m_prefs.escapeAll); + else + m_out << toHex(_d.data()); + else if (_d.isList()) + { + m_out << "["; + string newline = "\n"; + for (unsigned i = 0; i < _level + 1; ++i) + newline += m_prefs.indent; + int j = 0; + for (auto i: _d) + { + m_out << (j++ ? + (m_prefs.indent.empty() ? ", " : ("," + newline)) : + (m_prefs.indent.empty() ? " " : newline)); + output(i, _level + 1); + } + newline = newline.substr(0, newline.size() - m_prefs.indent.size()); + m_out << (m_prefs.indent.empty() ? (j ? " ]" : "]") : (j ? newline + "]" : "]")); + } + } + +private: + std::ostream& m_out; + Prefs m_prefs; +}; + +int main(int argc, char** argv) +{ + Encoding encoding = Encoding::Auto; + Mode mode = Mode::Render; + string inputFile = "--"; + bool lenience = false; + RLPStreamer::Prefs prefs; + + for (int i = 1; i < argc; ++i) + { + string arg = argv[i]; + if (arg == "-h" || arg == "--help") + help(); + else if (arg == "-r" || arg == "--render") + mode = Mode::Render; + else if ((arg == "-i" || arg == "--indent") && argc > i) + prefs.indent = argv[++i]; + else if (arg == "--hex-ints") + prefs.hexInts = true; + else if (arg == "--force-string") + prefs.forceString = true; + else if (arg == "--force-hex") + prefs.forceHex = true; + else if (arg == "--force-escape") + prefs.escapeAll = true; + else if (arg == "-l" || arg == "--list-archive") + mode = Mode::ListArchive; + else if (arg == "-e" || arg == "--extract-archive") + mode = Mode::ExtractArchive; + else if (arg == "-L" || arg == "--lenience") + lenience = true; + else if (arg == "-V" || arg == "--version") + version(); + else if (arg == "-x" || arg == "--hex" || arg == "--base-16") + encoding = Encoding::Hex; + else if (arg == "--64" || arg == "--base-64") + encoding = Encoding::Base64; + else if (arg == "-b" || arg == "--bin" || arg == "--base-256") + encoding = Encoding::Binary; + else + inputFile = arg; + } + + bytes in; + if (inputFile == "--") + for (int i = cin.get(); i != -1; i = cin.get()) + in.push_back((byte)i); + else + in = contents(inputFile); + if (encoding == Encoding::Auto) + { + encoding = Encoding::Hex; + for (char b: in) + if (b != '\n' && b != ' ' && b != '\t') + { + if (encoding == Encoding::Hex && (b < '0' || b > '9' ) && (b < 'a' || b > 'f' ) && (b < 'A' || b > 'F' )) + { + cerr << "'" << b << "':" << (int)b << endl; + encoding = Encoding::Base64; + } + if (encoding == Encoding::Base64 && (b < '0' || b > '9' ) && (b < 'a' || b > 'z' ) && (b < 'A' || b > 'Z' ) && b != '+' && b != '/') + { + encoding = Encoding::Binary; + break; + } + } + } + bytes b; + switch (encoding) + { + case Encoding::Hex: + { + string s = asString(in); + boost::algorithm::replace_all(s, " ", ""); + boost::algorithm::replace_all(s, "\n", ""); + boost::algorithm::replace_all(s, "\t", ""); + b = fromHex(s); + break; + } + case Encoding::Base64: + { + string s = asString(in); + boost::algorithm::replace_all(s, " ", ""); + boost::algorithm::replace_all(s, "\n", ""); + boost::algorithm::replace_all(s, "\t", ""); + b = base64_decode(s); + break; + } + default: + swap(b, in); + break; + } + + try + { + RLP rlp(b); + switch (mode) + { + case Mode::ListArchive: + { + if (!rlp.isList()) + { + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); + } + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; + } + case Mode::ExtractArchive: + { + if (!rlp.isList()) + { + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); + } + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; + } + } + catch (...) + { + cerr << "Error: Invalid format; bad RLP." << endl; + exit(1); + } + + return 0; +} From ea9d6539c53bb73ace472dc593bf81971247304b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:36:20 +0100 Subject: [PATCH 222/313] Improvements to help text of RLP. --- rlp/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 9bd51cdfc..c3c04535b 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -35,6 +35,20 @@ void help() cout << "Usage rlp [OPTIONS] [ | -- ]" << endl << "Options:" << endl + << " -r,--render Render the given RLP. Options:" << endl + << " --indent Use string as the level indentation (default ' ')." << endl + << " --hex-ints Render integers in hex." << endl + << " --force-string Force all data to be rendered as C-style strings." << endl + << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl + << " --force-hex Force all data to be rendered as raw hex." << endl + << " -l,--list-archive List the items in the RLP list by hash and size." << endl + << " -e,--extract-archive Extract all items in the RLP list, named by hash." << endl + << "General options:" << endl + << " -L,--lenience Try not to bomb out early if possible." << endl + << " -x,--hex,--base-16 Treat input RLP as hex encoded data." << endl + << " --64,--base-64 Treat input RLP as base-64 encoded data." << endl + << " -b,--bin,--base-256 Treat input RLP as raw binary data." << endl + << " -h,--help Print this help message and exit." << endl << " -V,--version Show the version and exit." << endl ; exit(0); @@ -87,7 +101,7 @@ public: m_out << "null"; else if (_d.isInt()) if (m_prefs.hexInts) - m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire), 1), 1); else m_out << _d.toInt(RLP::LaisezFaire); else if (_d.isData()) From 2d5cfe0c37af7bd3e52d7a69464b6465388038ab Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 5 Mar 2015 12:48:30 +0300 Subject: [PATCH 223/313] VMTest Fillers execution gas amount changed --- test/vmArithmeticTestFiller.json | 324 ++++++------- test/vmBitwiseLogicOperationTestFiller.json | 248 +++++----- test/vmBlockInfoTestFiller.json | 44 +- test/vmEnvironmentalInfoTestFiller.json | 92 ++-- test/vmIOandFlowOperationsTestFiller.json | 488 ++++++++++---------- test/vmLogTestFiller.json | 184 ++++---- test/vmPerformanceTestFiller.json | 16 +- test/vmPushDupSwapTestFiller.json | 282 +++++------ test/vmSha3TestFiller.json | 26 +- test/vmSystemOperationsTestFiller.json | 64 +-- test/vmtestsFiller.json | 16 +- 11 files changed, 892 insertions(+), 892 deletions(-) diff --git a/test/vmArithmeticTestFiller.json b/test/vmArithmeticTestFiller.json index 1484de19c..933df72d1 100644 --- a/test/vmArithmeticTestFiller.json +++ b/test/vmArithmeticTestFiller.json @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -221,7 +221,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -249,7 +249,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -277,7 +277,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -305,7 +305,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -333,7 +333,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -361,7 +361,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -389,7 +389,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -417,7 +417,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -445,7 +445,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -473,7 +473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -501,7 +501,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -529,7 +529,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -557,7 +557,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -585,7 +585,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -613,7 +613,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -641,7 +641,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -669,7 +669,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -697,7 +697,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -725,7 +725,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -753,7 +753,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -781,7 +781,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -809,7 +809,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -837,7 +837,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -865,7 +865,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -893,7 +893,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -921,7 +921,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1005,7 +1005,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1033,7 +1033,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1061,7 +1061,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1089,7 +1089,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1117,7 +1117,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1145,7 +1145,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1173,7 +1173,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1201,7 +1201,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1229,7 +1229,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1257,7 +1257,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1369,7 +1369,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1397,7 +1397,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1537,7 +1537,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1565,7 +1565,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1593,7 +1593,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1621,7 +1621,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1649,7 +1649,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1677,7 +1677,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1705,7 +1705,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1733,7 +1733,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1762,7 +1762,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1790,7 +1790,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1930,7 +1930,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1958,7 +1958,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1986,7 +1986,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2014,7 +2014,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2042,7 +2042,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2070,7 +2070,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2098,7 +2098,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2126,7 +2126,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2154,7 +2154,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2183,7 +2183,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2211,7 +2211,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2239,7 +2239,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2267,7 +2267,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2295,7 +2295,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2323,7 +2323,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2351,7 +2351,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2379,7 +2379,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2407,7 +2407,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2435,7 +2435,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2463,7 +2463,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2491,7 +2491,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2519,7 +2519,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2547,7 +2547,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2575,7 +2575,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2603,7 +2603,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2631,7 +2631,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2659,7 +2659,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2687,7 +2687,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2715,7 +2715,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2743,7 +2743,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2771,7 +2771,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2799,7 +2799,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2827,7 +2827,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2855,7 +2855,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2883,7 +2883,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2911,7 +2911,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2939,7 +2939,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2967,7 +2967,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2995,7 +2995,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3023,7 +3023,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3051,7 +3051,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3079,7 +3079,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3107,7 +3107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3135,7 +3135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3163,7 +3163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3191,7 +3191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3219,7 +3219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3247,7 +3247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3275,7 +3275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3303,7 +3303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3331,7 +3331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3359,7 +3359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3387,7 +3387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3415,7 +3415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3443,7 +3443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3471,7 +3471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3499,7 +3499,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3527,7 +3527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3555,7 +3555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3583,7 +3583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3611,7 +3611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3639,7 +3639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3667,7 +3667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3695,7 +3695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3723,7 +3723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3751,7 +3751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3779,7 +3779,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3807,7 +3807,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3835,7 +3835,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3863,7 +3863,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3891,7 +3891,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3919,7 +3919,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3947,7 +3947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3975,7 +3975,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4003,7 +4003,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4031,7 +4031,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4059,7 +4059,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4087,7 +4087,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4115,7 +4115,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4143,7 +4143,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4171,7 +4171,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4199,7 +4199,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4227,7 +4227,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4255,7 +4255,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4283,7 +4283,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4311,7 +4311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4339,7 +4339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4367,7 +4367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4395,7 +4395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4423,7 +4423,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4451,7 +4451,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4479,7 +4479,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4507,7 +4507,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4535,7 +4535,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4563,7 +4563,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4591,7 +4591,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4619,7 +4619,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4647,7 +4647,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4675,7 +4675,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4703,7 +4703,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4731,7 +4731,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4759,7 +4759,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4787,7 +4787,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4815,7 +4815,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4843,7 +4843,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4871,7 +4871,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -4899,7 +4899,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmBitwiseLogicOperationTestFiller.json b/test/vmBitwiseLogicOperationTestFiller.json index 8954dca1e..1eb923f4f 100644 --- a/test/vmBitwiseLogicOperationTestFiller.json +++ b/test/vmBitwiseLogicOperationTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT (- 0 2) 0 )}", "storage": {} @@ -20,10 +20,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "value" : "10000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "10000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 0 (- 0 2) )}", "storage": {} @@ -48,10 +48,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "value" : "10000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "10000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -76,10 +76,10 @@ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", - "data" : "", + "value" : "10000000000000000000", + "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -95,7 +95,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (LT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -108,7 +108,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -123,7 +123,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] ( GT (- 0 2) 0 )}", "storage": {} @@ -136,7 +136,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -151,7 +151,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 0 (- 0 2) )}", "storage": {} @@ -164,7 +164,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -208,7 +208,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -221,7 +221,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -236,7 +236,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT (- 0 2) 0 )}", "storage": {} @@ -249,7 +249,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -264,7 +264,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 0 (- 0 2) )}", "storage": {} @@ -277,7 +277,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -292,7 +292,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -305,7 +305,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -321,7 +321,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -334,7 +334,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -349,7 +349,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SLT (- 0 5) (- 0 3) )}", "storage": {} @@ -362,7 +362,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -377,7 +377,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT (- 0 2) 0 )}", "storage": {} @@ -390,7 +390,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -405,7 +405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 0 (- 0 2) )}", "storage": {} @@ -418,7 +418,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -433,7 +433,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 115792089237316195423570985008687907853269984665640564039457584007913129639935 0 )}", "storage": {} @@ -446,7 +446,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -462,7 +462,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT 0 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -475,7 +475,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -490,7 +490,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SGT (- 0 5) (- 0 3) )}", "storage": {} @@ -503,7 +503,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -518,7 +518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (- 0 5) (- 0 3) )}", "storage": {} @@ -531,7 +531,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -546,7 +546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ 0 0)}", "storage": {} @@ -559,7 +559,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -574,7 +574,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ 115792089237316195423570985008687907853269984665640564039457584007913129639935 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -587,7 +587,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -602,7 +602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -615,7 +615,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -630,7 +630,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO 0 )}", "storage": {} @@ -643,7 +643,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "iszeo2": { @@ -657,7 +657,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ISZERO (- 0 2) )}", "storage": {} @@ -670,7 +670,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -685,7 +685,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 2 2) }", "storage": {} @@ -698,7 +698,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -713,7 +713,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 2 1) }", "storage": {} @@ -726,7 +726,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -741,7 +741,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 3 1) }", "storage": {} @@ -754,7 +754,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "and3": { @@ -768,7 +768,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -781,7 +781,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "and4": { @@ -795,7 +795,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -808,7 +808,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (AND 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 2 2) } ", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -879,7 +879,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 2 1) } ", "storage": {} @@ -892,7 +892,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -907,7 +907,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 3 1) } ", "storage": {} @@ -920,7 +920,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "or3": { @@ -934,7 +934,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -947,7 +947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "or4": { @@ -961,7 +961,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -974,7 +974,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -989,7 +989,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (OR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1002,7 +1002,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1017,7 +1017,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 2 2) } ", "storage": {} @@ -1030,7 +1030,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1045,7 +1045,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 2 1) } ", "storage": {} @@ -1058,7 +1058,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1073,7 +1073,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 3 1) } ", "storage": {} @@ -1086,7 +1086,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "xor3": { @@ -1100,7 +1100,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) } ", "storage": {} @@ -1113,7 +1113,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "xor4": { @@ -1127,7 +1127,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1140,7 +1140,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1155,7 +1155,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (XOR 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeefeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) } ", "storage": {} @@ -1168,7 +1168,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1183,7 +1183,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 0 )}", "storage": {} @@ -1196,7 +1196,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1211,7 +1211,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 2 )}", "storage": {} @@ -1224,7 +1224,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1239,7 +1239,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT 115792089237316195423570985008687907853269984665640564039457584007913129639935 )}", "storage": {} @@ -1252,7 +1252,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1267,7 +1267,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 2) )}", "storage": {} @@ -1280,7 +1280,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1295,7 +1295,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 115792089237316195423570985008687907853269984665640564039457584007913129639935) )}", "storage": {} @@ -1308,7 +1308,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1323,7 +1323,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NOT (- 0 0) )}", "storage": {} @@ -1336,7 +1336,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1351,7 +1351,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 0) 0x8040201008040201 ) } ", "storage": {} @@ -1364,7 +1364,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "byte1": { @@ -1378,7 +1378,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 1) 0x8040201008040201 ) } ", "storage": {} @@ -1391,7 +1391,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "byte2": { @@ -1405,7 +1405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 2) 0x8040201008040201 ) } ", "storage": {} @@ -1418,7 +1418,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1433,7 +1433,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 3) 0x8040201008040201 ) } ", "storage": {} @@ -1446,7 +1446,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1461,7 +1461,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 4) 0x8040201008040201 ) } ", "storage": {} @@ -1474,7 +1474,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1489,7 +1489,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 5) 0x8040201008040201 ) } ", "storage": {} @@ -1502,7 +1502,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1518,7 +1518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 6) 0x8040201008040201 ) } ", "storage": {} @@ -1531,7 +1531,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1546,7 +1546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 7) 0x8040201008040201 ) } ", "storage": {} @@ -1559,7 +1559,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1575,7 +1575,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (- 31 31) 0x8040201008040201 ) } ", "storage": {} @@ -1588,7 +1588,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1603,7 +1603,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE (SDIV 31 32) 0x8040201008040201 ) } ", "storage": {} @@ -1616,7 +1616,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1631,7 +1631,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x8040201008040201 ) } ", "storage": {} @@ -1644,7 +1644,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1659,7 +1659,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "1000000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BYTE 0 0x8040201008040201) } ", "storage": {} @@ -1672,7 +1672,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmBlockInfoTestFiller.json b/test/vmBlockInfoTestFiller.json index 04cbec51c..c86a9f2cb 100644 --- a/test/vmBlockInfoTestFiller.json +++ b/test/vmBlockInfoTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 2) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) }", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 0) }", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 1) [[ 1 ]] (BLOCKHASH 2) [[ 2 ]] (BLOCKHASH 256) }", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BLOCKHASH 0) [[ 1 ]] (BLOCKHASH 257) [[ 2 ]] (BLOCKHASH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (COINBASE) }", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (TIMESTAMP) }", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (NUMBER) }", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (DIFFICULTY) }", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GASLIMIT) }", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmEnvironmentalInfoTestFiller.json b/test/vmEnvironmentalInfoTestFiller.json index c63cd914c..4de871d9e 100644 --- a/test/vmEnvironmentalInfoTestFiller.json +++ b/test/vmEnvironmentalInfoTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADDRESS)}", "storage": {} @@ -38,7 +38,7 @@ }, "pre" : { "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADDRESS)}", "storage": {} @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681 )}", "storage": {} @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681aa )}", "storage": {} @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}", "storage": {} @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -207,7 +207,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (BALANCE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6) (BALANCE (ADDRESS)))}", "storage": {} @@ -236,7 +236,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (BALANCE 0xcd1722f3947def4cf144679da39c4c32bdc35681) (BALANCE (CALLER)))}", "storage": {} @@ -264,7 +264,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ORIGIN)}", "storage": {} @@ -292,7 +292,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLER)}", "storage": {} @@ -321,7 +321,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLVALUE)}", "storage": {} @@ -350,7 +350,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 0)}", "storage": {} @@ -378,7 +378,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 1)}", "storage": {} @@ -406,7 +406,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 5)}", "storage": {} @@ -434,7 +434,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATALOAD 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa)}", "storage": {} @@ -462,7 +462,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -490,7 +490,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -518,7 +518,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CALLDATASIZE)}", "storage": {} @@ -546,7 +546,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 2 ) [[ 0 ]] @0}", "storage": {} @@ -574,7 +574,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0 0 ) [[ 0 ]] @0}", "storage": {} @@ -602,7 +602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 0xff ) [[ 0 ]] @0}", "storage": {} @@ -630,7 +630,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 9 ) [[ 0 ]] @0}", "storage": {} @@ -658,7 +658,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 1 ) [[ 0 ]] @0}", "storage": {} @@ -686,7 +686,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CALLDATACOPY 0 1 0 ) [[ 0 ]] @0}", "storage": {} @@ -882,7 +882,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CODESIZE)}", "storage": {} @@ -910,7 +910,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}", "storage": {} @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }", "storage": {} @@ -966,7 +966,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 5 ) [[ 0 ]] @0 }", "storage": {} @@ -994,7 +994,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (CODECOPY 0 0 0 ) [[ 0 ]] @0 }", "storage": {} @@ -1022,7 +1022,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (GASPRICE) }", "storage": {} @@ -1050,7 +1050,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE 0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6aa )}", "storage": {} @@ -1078,7 +1078,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE 0xaa0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6 )}", "storage": {} @@ -1107,13 +1107,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (EXTCODESIZE (CALLER)) (CODESIZE) ) }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EQ (EXTCODESIZE (CALLER)) (CODESIZE) ) }", "storage": {} @@ -1140,13 +1140,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (CODESIZE) }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (EXTCODESIZE (CALLER) ) }", "storage": {} @@ -1174,7 +1174,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (ADDRESS) 0 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 8 ) [[ 0 ]] @0}", "storage": {} @@ -1202,13 +1202,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (CALLER) 0 0 0 ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1237,13 +1237,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY (CALLER) 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1271,13 +1271,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY 0xaacd1722f3947def4cf144679da39c4c32bdc35681 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} @@ -1305,13 +1305,13 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (EXTCODECOPY 0xcd1722f3947def4cf144679da39c4c32bdc35681aa 0 0 (EXTCODESIZE (CALLER) ) ) [[ 0 ]] @0 }", "storage": {} }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] 5 }", "storage": {} diff --git a/test/vmIOandFlowOperationsTestFiller.json b/test/vmIOandFlowOperationsTestFiller.json index f71109e17..995b9d6da 100644 --- a/test/vmIOandFlowOperationsTestFiller.json +++ b/test/vmIOandFlowOperationsTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600360045055", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5060026003600455", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600260035155", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600260035255", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 23) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{[[ 0 ]] (MLOAD 0) } ", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 1 23) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 1 ]] (MLOAD 7489573) } ", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 (+ 2 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23 ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -318,7 +318,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23 ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -331,7 +331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -346,7 +346,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ) [[ 1 ]] (MLOAD 1) } ", "storage": {} @@ -359,7 +359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -374,7 +374,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 1 0xff) (MSTORE8 2 0xee) [[ 1 ]] (MLOAD 0) } ", "storage": {} @@ -387,7 +387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -402,7 +402,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 10 0xee) [[ 20 ]] (SLOAD 0) } ", "storage": {} @@ -415,7 +415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -430,7 +430,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 10 0xee) [[ 20 ]] (SLOAD 100) } ", "storage": {} @@ -443,7 +443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -458,7 +458,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SSTORE 0 0xff) (SSTORE 1 0xee) (SSTORE 2 0xdd) [[ 10 ]] (SLOAD 1) [[ 20 ]] (SLOAD 2) } ", "storage": {} @@ -471,7 +471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -486,7 +486,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6009565b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b5b", "storage": {} @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6006560060015b6002600355", "storage": {} @@ -527,7 +527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -542,7 +542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016008570060015b6002600355", "storage": {} @@ -555,7 +555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -570,7 +570,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60055661eeff", "storage": {} @@ -583,7 +583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -598,7 +598,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600456655b6001600155", "storage": {} @@ -611,7 +611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -626,7 +626,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160075761eeff", "storage": {} @@ -639,7 +639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -654,7 +654,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600657655b6001600155", "storage": {} @@ -667,7 +667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -682,7 +682,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600056", "storage": {} @@ -695,7 +695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -710,7 +710,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x565b600056", "storage": {} @@ -723,7 +723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600401565b600360005260206000f3600656", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007566001600255", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "jump0_jumpdest0": { @@ -878,7 +878,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360075660015b600255", "storage": {} @@ -891,7 +891,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -906,7 +906,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007566001600255", "storage": {} @@ -919,7 +919,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -934,7 +934,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360085660015b600255", "storage": {} @@ -947,7 +947,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -962,7 +962,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a6008505660015b600255", "storage": {} @@ -975,7 +975,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -990,7 +990,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b6008505660015b600255", "storage": {} @@ -1003,7 +1003,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1018,7 +1018,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff0156", "storage": {} @@ -1031,7 +1031,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1046,7 +1046,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360016009576001600255", "storage": {} @@ -1059,7 +1059,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1074,7 +1074,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a5760015b600255", "storage": {} @@ -1087,7 +1087,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1102,7 +1102,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360006009576001600255", "storage": {} @@ -1115,7 +1115,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1130,7 +1130,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff576002600355", "storage": {} @@ -1143,7 +1143,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1158,7 +1158,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600101560060015b6002600355", "storage": {} @@ -1171,7 +1171,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1186,7 +1186,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016008600301570060015b6002600355", "storage": {} @@ -1199,7 +1199,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1214,7 +1214,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60056003015661eeff", "storage": {} @@ -1227,7 +1227,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1242,7 +1242,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460030156655b6001600155", "storage": {} @@ -1255,7 +1255,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1270,7 +1270,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160076003015761eeff", "storage": {} @@ -1283,7 +1283,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1298,7 +1298,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600660030157655b6001600155", "storage": {} @@ -1311,7 +1311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1326,7 +1326,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b586000555960115758600052596000575b58600055", "storage": {} @@ -1339,7 +1339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1354,7 +1354,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage": {} @@ -1367,7 +1367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1382,7 +1382,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600301566001600255", "storage": {} @@ -1395,7 +1395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "DynamicJump0_jumpdest0": { @@ -1409,7 +1409,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360076003015660015b600255", "storage": {} @@ -1422,7 +1422,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1437,7 +1437,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600301566001600255", "storage": {} @@ -1450,7 +1450,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1465,7 +1465,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360086003015660015b600255", "storage": {} @@ -1478,7 +1478,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1493,7 +1493,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a6008506003015660015b600255", "storage": {} @@ -1506,7 +1506,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1521,7 +1521,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b6008506003015660015b600255", "storage": {} @@ -1534,7 +1534,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1549,7 +1549,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff0160030156", "storage": {} @@ -1562,7 +1562,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1577,7 +1577,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360016009600301576001600255", "storage": {} @@ -1590,7 +1590,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1605,7 +1605,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a6003015760015b600255", "storage": {} @@ -1618,7 +1618,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1633,7 +1633,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360006009600301576001600255", "storage": {} @@ -1646,7 +1646,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1661,7 +1661,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0600301576002600355", "storage": {} @@ -1674,7 +1674,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1689,7 +1689,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160084301570060015b6002600355", "storage": {} @@ -1702,7 +1702,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1717,7 +1717,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600543015661eeff", "storage": {} @@ -1730,7 +1730,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1745,7 +1745,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6004430156655b6001600155", "storage": {} @@ -1758,7 +1758,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1773,7 +1773,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600743015761eeff", "storage": {} @@ -1786,7 +1786,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1801,7 +1801,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016006430157655b6001600155", "storage": {} @@ -1814,7 +1814,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1829,7 +1829,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage": {} @@ -1842,7 +1842,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1857,7 +1857,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360074301566001600255", "storage": {} @@ -1870,7 +1870,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "BlockNumberDynamicJump0_jumpdest0": { @@ -1884,7 +1884,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600743015660015b600255", "storage": {} @@ -1897,7 +1897,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1912,7 +1912,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x602360074301566001600255", "storage": {} @@ -1925,7 +1925,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1940,7 +1940,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600843015660015b600255", "storage": {} @@ -1953,7 +1953,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1968,7 +1968,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a60085043015660015b600255", "storage": {} @@ -1981,7 +1981,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1996,7 +1996,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b60085043015660015b600255", "storage": {} @@ -2009,7 +2009,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2024,7 +2024,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff01430156", "storage": {} @@ -2037,7 +2037,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2052,7 +2052,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600160094301576001600255", "storage": {} @@ -2065,7 +2065,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2080,7 +2080,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a43015760015b600255", "storage": {} @@ -2093,7 +2093,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2108,7 +2108,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600060094301576001600255", "storage": {} @@ -2121,7 +2121,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2136,7 +2136,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04301576002600355", "storage": {} @@ -2149,7 +2149,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2165,7 +2165,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PUSH1 3 JUMP", "code" : "0x6009436006575b566001", @@ -2179,7 +2179,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2194,7 +2194,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a436006575b5660015b6001600155", "storage": {} @@ -2207,7 +2207,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2222,7 +2222,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435660615b4343025660615b60615b5b5b6001600155", "storage": {} @@ -2235,7 +2235,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2250,7 +2250,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435660615b4343025660615b60615b605b6001600155", "storage": {} @@ -2263,7 +2263,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2278,7 +2278,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2291,7 +2291,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2306,7 +2306,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2319,7 +2319,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2334,7 +2334,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x435631615b60615b60615b606001600155", "storage": {} @@ -2347,7 +2347,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2362,7 +2362,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6001600860005401570060015b6002600355", "storage" : { @@ -2377,7 +2377,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2392,7 +2392,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600054015661eeff", "storage" : { @@ -2407,7 +2407,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2422,7 +2422,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60046000540156655b6001600155", "storage" : { @@ -2437,7 +2437,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2452,7 +2452,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60016007600054015761eeff", "storage" : { @@ -2467,7 +2467,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2482,7 +2482,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600160066000540157655b6001600155", "storage" : { @@ -2497,7 +2497,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2512,7 +2512,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x5b600060000156", "storage" : { @@ -2527,7 +2527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2542,7 +2542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600760005401566001600255", "storage" : { @@ -2558,7 +2558,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "JDfromStorageDynamicJump0_jumpdest0": { @@ -2572,7 +2572,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236007600054015660015b600255", "storage" : { @@ -2587,7 +2587,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2602,7 +2602,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600760005401566001600255", "storage" : { @@ -2618,7 +2618,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2633,7 +2633,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236008600054015660015b600255", "storage" : { @@ -2648,7 +2648,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2663,7 +2663,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600a600850600054015660015b600255", "storage" : { @@ -2679,7 +2679,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2694,7 +2694,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6023600b600850600054015660015b600255", "storage" : { @@ -2709,7 +2709,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2724,7 +2724,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x620fffff620fffff016000540156", "storage" : { @@ -2740,7 +2740,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2755,7 +2755,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600960005401576001600255", "storage" : { @@ -2770,7 +2770,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2785,7 +2785,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236001600a600054015760015b600255", "storage" : { @@ -2801,7 +2801,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2816,7 +2816,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60236000600960005401576001600255", "storage" : { @@ -2831,7 +2831,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2846,7 +2846,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff060005401576002600355", "storage" : { @@ -2861,7 +2861,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2877,7 +2877,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (PC)}", "storage": {} @@ -2890,7 +2890,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2905,7 +2905,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(SSTORE 0 0xff) [[ 0 ]] (PC)}", "storage": {} @@ -2918,7 +2918,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2933,7 +2933,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xff) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2946,7 +2946,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2961,7 +2961,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) [[ 0 ]] (MSIZE)}", "storage": {} @@ -2974,7 +2974,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -2989,7 +2989,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 32 0xeeee) [[ 0 ]] (MSIZE)}", "storage": {} @@ -3002,7 +3002,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3017,7 +3017,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 90 0xeeee) [[ 0 ]] (MSIZE)}", "storage": {} @@ -3030,7 +3030,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3045,7 +3045,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{(MSTORE 0 0xffffffffff) (MSTORE 90 0xeeee) [[ 0 ]] (GAS)}", "storage": {} @@ -3058,7 +3058,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3073,7 +3073,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{[[ 0 ]] (GAS)}", "storage": {} @@ -3086,7 +3086,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3101,7 +3101,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0x112233445566778899001122334455667788990011223344556677889900aabb 0 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 1 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 2 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 3 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 4 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 5 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 6 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 7 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 8 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 9 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 10 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 11 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 12 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 13 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 14 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 15 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 16 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 17 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 18 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 19 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 20 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 21 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 22 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 23 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 24 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 25 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 26 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 27 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 28 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 29 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 30 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 31 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 32 BYTE 0x112233445566778899001122334455667788990011223344556677889900aabb 2014 BYTE 0 0 SSTORE)", "storage": {} @@ -3114,7 +3114,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3129,7 +3129,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 2 0 MSTORE8 3 1 MSTORE8 0 MLOAD 1 MLOAD ADD 2 MSTORE 64 0 RETURN)", "storage": {} @@ -3142,7 +3142,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3157,7 +3157,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 1000000 RETURN)", "storage": {} @@ -3170,7 +3170,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3185,7 +3185,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [i] 1 ( if (> @i 0) { (return 39) [i] 2 } (return 1) ) }", "storage": {} @@ -3198,7 +3198,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3213,7 +3213,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0x4 0x6 0x9 0x14 JUMP JUMPDEST 0xa SUB 0x0 MSTORE MSIZE 0x0 RETURN JUMPDEST 0x0 MSTORE ADD 0x9 JUMP)", "storage": {} @@ -3226,7 +3226,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3241,7 +3241,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[69]] (caller) (return 0 (lll (when (= (caller) @@69) (for {} (< @i (calldatasize)) [i](+ @i 64) [[ (calldataload @i) ]] (calldataload (+ @i 32)) ) ) 0))}", "storage": {} @@ -3254,7 +3254,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3279,7 +3279,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "code" : "(asm 10 0 MSTORE JUMPDEST 0 MLOAD 1 SWAP1 SUB DUP1 0 MSTORE 5 JUMPI)", "nonce" : "0", "storage" : {} @@ -3298,7 +3298,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 27 37 MUL JUMP JUMPDEST)", "storage": {} @@ -3311,7 +3311,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3326,7 +3326,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 3 3 MUL JUMPI 0 0 JUMP)", "storage": {} @@ -3339,7 +3339,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3354,7 +3354,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(for [i]:10 (> @i 0) [i](- @i 1) [j](+ @i @j))", "storage": {} @@ -3367,7 +3367,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3382,7 +3382,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(for [i]:0 (< @i 10) [i](+ @i 1) [j](+ @i @j))", "storage": {} @@ -3395,7 +3395,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3410,7 +3410,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 4 3 ADD JUMP STOP JUMPDEST 1 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3423,7 +3423,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3438,7 +3438,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 8 6 ADD JUMP STOP JUMPDEST 1 0 MSTORE STOP JUMPDEST 2 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3451,7 +3451,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3466,7 +3466,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 1 4 5 ADD JUMPI STOP JUMPDEST 1 0 MSTORE MSIZE 0 RETURN)", "storage": {} @@ -3479,7 +3479,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3494,7 +3494,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 0 7 5 ADD JUMPI 1 0 MSTORE STOP JUMPDEST)", "storage": {} @@ -3507,7 +3507,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3522,7 +3522,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 10 JUMPDEST 1 DUP2 SUB DUP1 2 JUMPI 0 MSTORE8 1 MSTORE8 2 MSTORE8 3 MSTORE8 4 MSTORE8 5 MSTORE8 6 MSTORE8 7 MSTORE8 8 MSTORE8 9 MSTORE8 MSIZE 0 RETURN)", "storage": {} @@ -3535,7 +3535,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -3550,7 +3550,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(when (> 1 0) [i] 13)", "storage": {} @@ -3563,7 +3563,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmLogTestFiller.json b/test/vmLogTestFiller.json index 5b63957c5..fea69a4a9 100644 --- a/test/vmLogTestFiller.json +++ b/test/vmLogTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG0 0 0) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG0 0 32) (LOG0 2 16) }", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 0 1) }", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -123,7 +123,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 31 1) }", "storage": {} @@ -136,7 +136,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -151,7 +151,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1) }", "storage": {} @@ -164,7 +164,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -179,7 +179,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -192,7 +192,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -207,7 +207,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG0 1 0) }", "storage": {} @@ -220,7 +220,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -235,7 +235,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG1 0 0 0) }", "storage": {} @@ -248,7 +248,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -263,7 +263,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG1 0 32 0) }", "storage": {} @@ -276,7 +276,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -291,7 +291,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0 1 0) }", "storage": {} @@ -304,7 +304,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -320,7 +320,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 31 1 0) }", "storage": {} @@ -333,7 +333,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -348,7 +348,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0) }", "storage": {} @@ -361,7 +361,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -376,7 +376,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0) }", "storage": {} @@ -389,7 +389,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -404,7 +404,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 1 0 0) }", "storage": {} @@ -417,7 +417,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -432,7 +432,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG1 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -445,7 +445,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -460,7 +460,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG1 0 32 (CALLER)) }", "storage": {} @@ -473,7 +473,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -488,7 +488,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG2 0 0 0 0) }", "storage": {} @@ -501,7 +501,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -516,7 +516,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG2 0 32 0 0) }", "storage": {} @@ -529,7 +529,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -544,7 +544,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0 1 0 0) }", "storage": {} @@ -557,7 +557,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -573,7 +573,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 31 1 0 0) }", "storage": {} @@ -586,7 +586,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -601,7 +601,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0) }", "storage": {} @@ -614,7 +614,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -629,7 +629,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0) }", "storage": {} @@ -642,7 +642,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -657,7 +657,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 1 0 0 0) }", "storage": {} @@ -670,7 +670,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -685,7 +685,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG2 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -698,7 +698,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -713,7 +713,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG2 0 32 0 (CALLER) ) }", "storage": {} @@ -726,7 +726,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -741,7 +741,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG3 0 0 0 0 0) }", "storage": {} @@ -754,7 +754,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -769,7 +769,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG3 0 32 0 0 0) }", "storage": {} @@ -782,7 +782,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -797,7 +797,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0 1 0 0 0) }", "storage": {} @@ -810,7 +810,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -826,7 +826,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 31 1 0 0 0) }", "storage": {} @@ -839,7 +839,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -854,7 +854,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0 0) }", "storage": {} @@ -867,7 +867,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -882,7 +882,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0 0) }", "storage": {} @@ -895,7 +895,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -910,7 +910,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 1 0 0 0 0) }", "storage": {} @@ -923,7 +923,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG3 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -951,7 +951,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -966,7 +966,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 0 0 (CALLER) ) }", "storage": {} @@ -979,7 +979,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -994,7 +994,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 (PC) (PC) (PC) ) }", "storage": {} @@ -1007,7 +1007,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1022,7 +1022,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (LOG4 0 0 0 0 0 0) }", "storage": {} @@ -1035,7 +1035,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1050,7 +1050,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (LOG4 0 32 0 0 0 0) }", "storage": {} @@ -1063,7 +1063,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1078,7 +1078,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0 1 0 0 0 0) }", "storage": {} @@ -1091,7 +1091,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1107,7 +1107,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 31 1 0 0 0 0) }", "storage": {} @@ -1120,7 +1120,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1135,7 +1135,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 1 0 0 0 0) }", "storage": {} @@ -1148,7 +1148,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1163,7 +1163,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 1 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 0 0 0) }", "storage": {} @@ -1176,7 +1176,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1191,7 +1191,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 1 0 0 0 0 0) }", "storage": {} @@ -1204,7 +1204,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1219,7 +1219,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xaabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd) (LOG4 0 32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) }", "storage": {} @@ -1232,7 +1232,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1247,7 +1247,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 0 0 0 (CALLER) ) }", "storage": {} @@ -1260,7 +1260,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1275,7 +1275,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE8 0 0xff) (LOG3 0 32 (PC) (PC) (PC) (PC) ) }", "storage": {} @@ -1288,7 +1288,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmPerformanceTestFiller.json b/test/vmPerformanceTestFiller.json index e33bd1955..e9cb4806d 100644 --- a/test/vmPerformanceTestFiller.json +++ b/test/vmPerformanceTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "ManyFunctions.sol", "code" : "0x60e060020a60003504806301f99ad7146108c3578063023a624a146108d857806303bdecf5146108ed57806305fe035f14610902578063082d8f4914610917578063090bf3b71461092c5780630bd9c534146109415780630c4bfa94146109565780630e20ebe21461096b5780630f76de0d1461098057806310cfcc191461099557806313ce15a9146109aa578063140dcec4146109bf57806314d07a3e146109d45780631687f112146109e957806316eb6603146109fe578063172cf71714610a135780631bd6f59614610a285780631cdb857114610a3d5780631cf74ece14610a525780631d09ba2c14610a675780631f69aa5114610a7c578063223dcc7414610a9157806325e524d314610aa6578063261de7c414610abb5780632632924d14610ad05780632909cc5d14610ae55780632981699814610afa5780632a85a45d14610b0f5780632ca36da014610b245780632cbf1f0d14610b395780632d0f557314610b4e5780632d97867814610b6357806331db9efd14610b7857806332064db714610b8d57806332931fbb14610ba2578063355f51a014610bb7578063361bb34014610bcc578063364ddb0e14610be15780633792a01814610bf657806338c68f8f14610c0b57806338e586fd14610c20578063392d42ae14610c3557806339a87bd914610c4a5780633a95a33214610c5f5780633b8ecdf914610c745780633cf0659a14610c895780633eaf992314610c9e5780633fe97ead14610cb35780633ff11c8b14610cc8578063404efc5314610cdd578063407fce7b14610cf257806340c3b18714610d07578063440208c314610d1c57806344e86b2f14610d31578063455df57914610d465780634689ab4d14610d5b57806346be2e0c14610d70578063487cd86f14610d8557806348e6178214610d9a57806349d4a34414610daf5780634a0f597414610dc45780634bc24ec514610dd95780634c2fe45614610dee5780634cc885d414610e035780634eaaad7b14610e185780634eb166af14610e2d5780635050093414610e42578063506bff1114610e57578063508762c114610e6c578063526938f814610e8157806354400c6014610e96578063559510d814610eab57806355a5f70214610ec057806356ca528f14610ed5578063570a2a1614610eea5780635dab2e0f14610eff5780635dca53d314610f1457806362017ebc14610f29578063621a25f814610f3e578063626d4a3614610f5357806362b6a28214610f6857806364faf22c14610f7d57806366d7ffde14610f9257806367b886e814610fa757806367e902c714610fbc57806369d7774014610fd15780636b7ae8e614610fe65780636c3b659114610ffb5780636e54181e146110105780636e978d91146110255780636f63d2ec1461103a578063706332d11461104f57806370ac4bb9146110645780637138ef521461107957806371dd46a91461108e57806372a7c229146110a35780637376fc8d146110b8578063738a2679146110cd57806374552650146110e2578063746fc8d0146110f757806379254bb81461110c5780637adaa3f8146111215780637e4eb35b14611136578063885ec18e1461114b5780638b9ff6b6146111605780638ce113dc146111755780638defbc5e1461118a5780638f4613d51461119f5780638fdc24ba146111b45780639002dba4146111c957806391d15735146111de57806391d43b23146111f357806393b14daa1461120857806394d63afd1461121d57806395805dad1461123257806396f68782146112475780639740e4a21461125c578063981290131461127157806399a3f0e8146112865780639acb1ad41461129b5780639be07908146112b05780639c15be0b146112c55780639d451c4d146112da5780639d8ee943146112ef5780639ef6ca0f14611304578063a0db0a2214611319578063a18e2eb91461132e578063a408384914611343578063a57544da14611358578063a5a83e4d1461136d578063a6843f3414611382578063a6dacdd714611397578063a8c4c8bc146113ac578063aa058a73146113c1578063aad62da2146113d6578063aaf3e4f4146113eb578063ab81e77314611400578063abc93aee14611415578063abde33f71461142a578063b114b96c1461143f578063b3df873714611454578063b4174cb014611469578063b5d02a561461147e578063b731e84814611493578063b7b96723146114a8578063bbcded7a146114bd578063bbececa9146114d2578063beca7440146114e7578063bf8981c0146114fc578063c028c67414611511578063c2385fa614611526578063c319a02c1461153b578063c569bae014611550578063c6715f8114611565578063c7b98dec1461157a578063c9acab841461158f578063ca9efc73146115a4578063cad80024146115b9578063cdadb0fa146115ce578063cdbdf391146115e3578063cf460fa5146115f8578063cf69318a1461160d578063d1835b8c14611622578063d353a1cb14611637578063d3e141e01461164c578063d5ec7e1d14611661578063d7ead1de14611676578063d90b02aa1461168b578063d959e244146116a0578063d9e68b44146116b5578063daacb24f146116ca578063dc12a805146116df578063dd946033146116f4578063dda5142414611709578063de6612171461171e578063dfb9560c14611733578063e03827d214611748578063e21720001461175d578063e2c718d814611772578063e3da539914611787578063e48e603f1461179c578063e5f9ec29146117b1578063e6c0459a146117c6578063e70addec146117db578063e7a01215146117f0578063ea7f4d2714611805578063ebb6c59f1461181a578063ed6302be1461182f578063ed64b36b14611844578063eecd278914611859578063f0ed14e01461186e578063f0f2134414611883578063f1e328f914611898578063f1e6f4cd146118ad578063f32fe995146118c2578063f75165c6146118d7578063f7ed71d0146118ec578063f80f44f314611901578063f8bc050514611916578063fbd3c51a1461192b578063fd72009014611940578063fed3a3001461195557005b6108ce600435612edf565b8060005260206000f35b6108e3600435612fb5565b8060005260206000f35b6108f8600435613f47565b8060005260206000f35b61090d600435612a11565b8060005260206000f35b6109226004356127ec565b8060005260206000f35b61093760043561215c565b8060005260206000f35b61094c6004356128c2565b8060005260206000f35b61096160043561310f565b8060005260206000f35b610976600435614e0b565b8060005260206000f35b61098b600435613269565b8060005260206000f35b6109a0600435611a82565b8060005260206000f35b6109b5600435613e71565b8060005260206000f35b6109ca600435611dd2565b8060005260206000f35b6109df6004356120d0565b8060005260206000f35b6109f4600435613755565b8060005260206000f35b610a096004356134e3565b8060005260206000f35b610a1e6004356137e1565b8060005260206000f35b610a3360043561382b565b8060005260206000f35b610a48600435612b0b565b8060005260206000f35b610a5d60043561386d565b8060005260206000f35b610a726004356131e5565b8060005260206000f35b610a876004356143e9565b8060005260206000f35b610a9c60043561319b565b8060005260206000f35b610ab1600435612e11565b8060005260206000f35b610ac660043561234a565b8060005260206000f35b610adb6004356121e8565b8060005260206000f35b610af06004356119f6565b8060005260206000f35b610b05600435613bff565b8060005260206000f35b610b1a600435612606565b8060005260206000f35b610b2f6004356126d4565b8060005260206000f35b610b44600435613bb5565b8060005260206000f35b610b59600435612462565b8060005260206000f35b610b6e600435611e14565b8060005260206000f35b610b836004356149ab565b8060005260206000f35b610b98600435611c26565b8060005260206000f35b610bad600435612a7f565b8060005260206000f35b610bc2600435613457565b8060005260206000f35b610bd760043561340d565b8060005260206000f35b610bec60043561363d565b8060005260206000f35b610c01600435612e53565b8060005260206000f35b610c1660043561477b565b8060005260206000f35b610c2b600435612c6d565b8060005260206000f35b610c40600435612648565b8060005260206000f35b610c55600435612274565b8060005260206000f35b610c6a6004356138f9565b8060005260206000f35b610c7f600435612b55565b8060005260206000f35b610c94600435611eea565b8060005260206000f35b610ca9600435613ebb565b8060005260206000f35b610cbe600435613499565b8060005260206000f35b610cd3600435614807565b8060005260206000f35b610ce8600435611fb8565b8060005260206000f35b610cfd600435613083565b8060005260206000f35b610d126004356125bc565b8060005260206000f35b610d27600435613041565b8060005260206000f35b610d3c6004356140a1565b8060005260206000f35b610d516004356147bd565b8060005260206000f35b610d66600435611c70565b8060005260206000f35b610d7b600435612300565b8060005260206000f35b610d906004356123d6565b8060005260206000f35b610da5600435612c23565b8060005260206000f35b610dba600435614faf565b8060005260206000f35b610dcf600435612044565b8060005260206000f35b610de4600435613ae7565b8060005260206000f35b610df9600435614cf3565b8060005260206000f35b610e0e600435613d17565b8060005260206000f35b610e2360043561412d565b8060005260206000f35b610e38600435614177565b8060005260206000f35b610e4d60043561208e565b8060005260206000f35b610e62600435612dc7565b8060005260206000f35b610e77600435612f29565b8060005260206000f35b610e8c6004356124a4565b8060005260206000f35b610ea1600435611b58565b8060005260206000f35b610eb66004356136c9565b8060005260206000f35b610ecb600435613227565b8060005260206000f35b610ee0600435611acc565b8060005260206000f35b610ef5600435613687565b8060005260206000f35b610f0a6004356146a5565b8060005260206000f35b610f1f6004356121a6565b8060005260206000f35b610f346004356132f5565b8060005260206000f35b610f49600435613da3565b8060005260206000f35b610f5e60043561379f565b8060005260206000f35b610f73600435612878565b8060005260206000f35b610f88600435611b0e565b8060005260206000f35b610f9d600435611ea0565b8060005260206000f35b610fb2600435614ed9565b8060005260206000f35b610fc7600435614bdb565b8060005260206000f35b610fdc600435614c1d565b8060005260206000f35b610ff1600435614245565b8060005260206000f35b6110066004356146ef565b8060005260206000f35b61101b60043561428f565b8060005260206000f35b611030600435614ac3565b8060005260206000f35b611045600435613de5565b8060005260206000f35b61105a6004356132b3565b8060005260206000f35b61106f6004356122be565b8060005260206000f35b611084600435612e9d565b8060005260206000f35b611099600435611b9a565b8060005260206000f35b6110ae6004356127aa565b8060005260206000f35b6110c3600435613e2f565b8060005260206000f35b6110d8600435614849565b8060005260206000f35b6110ed600435614dc1565b8060005260206000f35b61110260043561333f565b8060005260206000f35b61111760043561211a565b8060005260206000f35b61112c600435612692565b8060005260206000f35b611141600435612904565b8060005260206000f35b611156600435612d3b565b8060005260206000f35b61116b600435614b91565b8060005260206000f35b611180600435613a5b565b8060005260206000f35b611195600435612232565b8060005260206000f35b6111aa600435612f6b565b8060005260206000f35b6111bf600435614d35565b8060005260206000f35b6111d4600435611a40565b8060005260206000f35b6111e9600435612ff7565b8060005260206000f35b6111fe60043561431b565b8060005260206000f35b611213600435613159565b8060005260206000f35b611228600435612b97565b8060005260206000f35b61123d600435612990565b8060005260206000f35b611252600435613b73565b8060005260206000f35b611267600435614961565b8060005260206000f35b61127c600435613381565b8060005260206000f35b611291600435613fd3565b8060005260206000f35b6112a660043561257a565b8060005260206000f35b6112bb600435614501565b8060005260206000f35b6112d0600435613d59565b8060005260206000f35b6112e56004356143a7565b8060005260206000f35b6112fa60043561405f565b8060005260206000f35b61130f60043561238c565b8060005260206000f35b611324600435612be1565b8060005260206000f35b611339600435613f89565b8060005260206000f35b61134e60043561294e565b8060005260206000f35b6113636004356124ee565b8060005260206000f35b611378600435614b4f565b8060005260206000f35b61138d6004356133cb565b8060005260206000f35b6113a26004356139cf565b8060005260206000f35b6113b7600435613c8b565b8060005260206000f35b6113cc600435612cf9565b8060005260206000f35b6113e1600435614a79565b8060005260206000f35b6113f66004356149ed565b8060005260206000f35b61140b600435613b29565b8060005260206000f35b611420600435613ccd565b8060005260206000f35b611435600435611f76565b8060005260206000f35b61144a600435614ff1565b8060005260206000f35b61145f600435613525565b8060005260206000f35b61147460043561356f565b8060005260206000f35b6114896004356129dc565b8060005260206000f35b61149e600435614ca9565b8060005260206000f35b6114b3600435612d85565b8060005260206000f35b6114c86004356141b9565b8060005260206000f35b6114dd600435614475565b8060005260206000f35b6114f26004356135fb565b8060005260206000f35b611507600435612530565b8060005260206000f35b61151c600435614663565b8060005260206000f35b611531600435614433565b8060005260206000f35b611546600435614f23565b8060005260206000f35b61155b600435614c67565b8060005260206000f35b611570600435611d3e565b8060005260206000f35b611585600435612a3d565b8060005260206000f35b61159a600435613a11565b8060005260206000f35b6115af600435614619565b8060005260206000f35b6115c4600435613985565b8060005260206000f35b6115d9600435613943565b8060005260206000f35b6115ee600435612418565b8060005260206000f35b6116036004356119b4565b8060005260206000f35b611618600435613a9d565b8060005260206000f35b61162d600435611cb2565b8060005260206000f35b6116426004356129d2565b8060005260206000f35b611657600435612caf565b8060005260206000f35b61166c600435611d88565b8060005260206000f35b611681600435614203565b8060005260206000f35b61169660043561458d565b8060005260206000f35b6116ab600435611f2c565b8060005260206000f35b6116c0600435612a23565b8060005260206000f35b6116d5600435612836565b8060005260206000f35b6116ea6004356138b7565b8060005260206000f35b6116ff6004356145d7565b8060005260206000f35b61171460043561454b565b8060005260206000f35b6117296004356142d1565b8060005260206000f35b61173e600435611e5e565b8060005260206000f35b611753600435614015565b8060005260206000f35b611768600435613c41565b8060005260206000f35b61177d600435611be4565b8060005260206000f35b611792600435614b05565b8060005260206000f35b6117a7600435613713565b8060005260206000f35b6117bc6004356135b1565b8060005260206000f35b6117d16004356144bf565b8060005260206000f35b6117e660043561491f565b8060005260206000f35b6117fb600435612ac9565b8060005260206000f35b6118106004356130cd565b8060005260206000f35b6118256004356140eb565b8060005260206000f35b61183a600435614f65565b8060005260206000f35b61184f60043561196a565b8060005260206000f35b6118646004356148d5565b8060005260206000f35b611879600435614d7f565b8060005260206000f35b61188e600435612002565b8060005260206000f35b6118a3600435613efd565b8060005260206000f35b6118b860043561271e565b8060005260206000f35b6118cd600435614e4d565b8060005260206000f35b6118e2600435611cfc565b8060005260206000f35b6118f7600435612760565b8060005260206000f35b61190c600435614e97565b8060005260206000f35b61192160043561435d565b8060005260206000f35b611936600435614731565b8060005260206000f35b61194b600435614893565b8060005260206000f35b611960600435614a37565b8060005260206000f35b6000600061197f61197a846129dc565b6129dc565b9050605d60020a811015611992576119a2565b61199b816119f6565b91506119ae565b6119ab816119b4565b91505b50919050565b600060006119c1836129dc565b9050605e60020a8110156119d4576119e4565b6119dd81611a40565b91506119f0565b6119ed81611a82565b91505b50919050565b60006000611a0b611a06846129dc565b6129dc565b9050605e60020a811015611a1e57611a2e565b611a2781611a82565b9150611a3a565b611a3781611a40565b91505b50919050565b60006000611a4d836129dc565b9050605f60020a811015611a6057611a70565b611a6981611acc565b9150611a7c565b611a7981611b0e565b91505b50919050565b60006000611a97611a92846129dc565b6129dc565b9050605f60020a811015611aaa57611aba565b611ab381611b0e565b9150611ac6565b611ac381611acc565b91505b50919050565b60006000611ad9836129dc565b9050606060020a811015611aec57611afc565b611af581611b58565b9150611b08565b611b0581611b9a565b91505b50919050565b60006000611b23611b1e846129dc565b6129dc565b9050606060020a811015611b3657611b46565b611b3f81611b9a565b9150611b52565b611b4f81611b58565b91505b50919050565b60006000611b65836129dc565b9050606160020a811015611b7857611b88565b611b8181611be4565b9150611b94565b611b9181611c26565b91505b50919050565b60006000611baf611baa846129dc565b6129dc565b9050606160020a811015611bc257611bd2565b611bcb81611c26565b9150611bde565b611bdb81611be4565b91505b50919050565b60006000611bf1836129dc565b9050606260020a811015611c0457611c14565b611c0d81611c70565b9150611c20565b611c1d81611cb2565b91505b50919050565b60006000611c3b611c36846129dc565b6129dc565b9050606260020a811015611c4e57611c5e565b611c5781611cb2565b9150611c6a565b611c6781611c70565b91505b50919050565b60006000611c7d836129dc565b9050606360020a811015611c9057611ca0565b611c9981611cfc565b9150611cac565b611ca981611d88565b91505b50919050565b60006000611cc7611cc2846129dc565b6129dc565b9050606360020a811015611cda57611cea565b611ce381611d88565b9150611cf6565b611cf381611cfc565b91505b50919050565b60006000611d09836129dc565b9050606460020a811015611d1c57611d2c565b611d2581611dd2565b9150611d38565b611d3581611e14565b91505b50919050565b60006000611d53611d4e846129dc565b6129dc565b9050607a60020a811015611d6657611d76565b611d6f81613269565b9150611d82565b611d7f81613227565b91505b50919050565b60006000611d9d611d98846129dc565b6129dc565b9050606460020a811015611db057611dc0565b611db981611e14565b9150611dcc565b611dc981611dd2565b91505b50919050565b60006000611ddf836129dc565b9050606560020a811015611df257611e02565b611dfb81611e5e565b9150611e0e565b611e0b81611ea0565b91505b50919050565b60006000611e29611e24846129dc565b6129dc565b9050606560020a811015611e3c57611e4c565b611e4581611ea0565b9150611e58565b611e5581611e5e565b91505b50919050565b60006000611e6b836129dc565b9050606660020a811015611e7e57611e8e565b611e8781611eea565b9150611e9a565b611e9781611f2c565b91505b50919050565b60006000611eb5611eb0846129dc565b6129dc565b9050606660020a811015611ec857611ed8565b611ed181611f2c565b9150611ee4565b611ee181611eea565b91505b50919050565b60006000611ef7836129dc565b9050606760020a811015611f0a57611f1a565b611f1381611f76565b9150611f26565b611f2381611fb8565b91505b50919050565b60006000611f41611f3c846129dc565b6129dc565b9050606760020a811015611f5457611f64565b611f5d81611fb8565b9150611f70565b611f6d81611f76565b91505b50919050565b60006000611f83836129dc565b9050606860020a811015611f9657611fa6565b611f9f81612002565b9150611fb2565b611faf81612044565b91505b50919050565b60006000611fcd611fc8846129dc565b6129dc565b9050606860020a811015611fe057611ff0565b611fe981612044565b9150611ffc565b611ff981612002565b91505b50919050565b6000600061200f836129dc565b9050606960020a81101561202257612032565b61202b8161208e565b915061203e565b61203b816120d0565b91505b50919050565b60006000612059612054846129dc565b6129dc565b9050606960020a81101561206c5761207c565b612075816120d0565b9150612088565b6120858161208e565b91505b50919050565b6000600061209b836129dc565b9050606a60020a8110156120ae576120be565b6120b78161211a565b91506120ca565b6120c78161215c565b91505b50919050565b600060006120e56120e0846129dc565b6129dc565b9050606a60020a8110156120f857612108565b6121018161215c565b9150612114565b6121118161211a565b91505b50919050565b60006000612127836129dc565b9050606b60020a81101561213a5761214a565b612143816121a6565b9150612156565b612153816121e8565b91505b50919050565b6000600061217161216c846129dc565b6129dc565b9050606b60020a81101561218457612194565b61218d816121e8565b91506121a0565b61219d816121a6565b91505b50919050565b600060006121b3836129dc565b9050606c60020a8110156121c6576121d6565b6121cf81612232565b91506121e2565b6121df81612274565b91505b50919050565b600060006121fd6121f8846129dc565b6129dc565b9050606c60020a81101561221057612220565b61221981612274565b915061222c565b61222981612232565b91505b50919050565b6000600061223f836129dc565b9050606d60020a81101561225257612262565b61225b816122be565b915061226e565b61226b81612300565b91505b50919050565b60006000612289612284846129dc565b6129dc565b9050606d60020a81101561229c576122ac565b6122a581612300565b91506122b8565b6122b5816122be565b91505b50919050565b600060006122cb836129dc565b9050606e60020a8110156122de576122ee565b6122e78161234a565b91506122fa565b6122f78161238c565b91505b50919050565b60006000612315612310846129dc565b6129dc565b9050606e60020a81101561232857612338565b6123318161238c565b9150612344565b6123418161234a565b91505b50919050565b60006000612357836129dc565b9050606f60020a81101561236a5761237a565b612373816123d6565b9150612386565b61238381612418565b91505b50919050565b600060006123a161239c846129dc565b6129dc565b9050606f60020a8110156123b4576123c4565b6123bd81612418565b91506123d0565b6123cd816123d6565b91505b50919050565b600060006123e3836129dc565b9050607060020a8110156123f657612406565b6123ff81612462565b9150612412565b61240f816124a4565b91505b50919050565b6000600061242d612428846129dc565b6129dc565b9050607060020a81101561244057612450565b612449816124a4565b915061245c565b61245981612462565b91505b50919050565b6000600061246f836129dc565b9050607160020a81101561248257612492565b61248b816124ee565b915061249e565b61249b81612530565b91505b50919050565b600060006124b96124b4846129dc565b6129dc565b9050607160020a8110156124cc576124dc565b6124d581612530565b91506124e8565b6124e5816124ee565b91505b50919050565b600060006124fb836129dc565b9050607260020a81101561250e5761251e565b6125178161257a565b915061252a565b612527816125bc565b91505b50919050565b60006000612545612540846129dc565b6129dc565b9050607260020a81101561255857612568565b612561816125bc565b9150612574565b6125718161257a565b91505b50919050565b60006000612587836129dc565b9050607360020a81101561259a576125aa565b6125a381612606565b91506125b6565b6125b381612648565b91505b50919050565b600060006125d16125cc846129dc565b6129dc565b9050607360020a8110156125e4576125f4565b6125ed81612648565b9150612600565b6125fd81612606565b91505b50919050565b60006000612613836129dc565b9050607460020a81101561262657612636565b61262f81612692565b9150612642565b61263f816126d4565b91505b50919050565b6000600061265d612658846129dc565b6129dc565b9050607460020a81101561267057612680565b612679816126d4565b915061268c565b61268981612692565b91505b50919050565b6000600061269f836129dc565b9050607560020a8110156126b2576126c2565b6126bb8161271e565b91506126ce565b6126cb81612760565b91505b50919050565b600060006126e96126e4846129dc565b6129dc565b9050607560020a8110156126fc5761270c565b61270581612760565b9150612718565b6127158161271e565b91505b50919050565b6000600061272b836129dc565b9050607660020a81101561273e5761274e565b612747816127aa565b915061275a565b612757816127ec565b91505b50919050565b60006000612775612770846129dc565b6129dc565b9050607660020a81101561278857612798565b612791816127ec565b91506127a4565b6127a1816127aa565b91505b50919050565b600060006127b7836129dc565b9050607760020a8110156127ca576127da565b6127d381612836565b91506127e6565b6127e381612878565b91505b50919050565b600060006128016127fc846129dc565b6129dc565b9050607760020a81101561281457612824565b61281d81612878565b9150612830565b61282d81612836565b91505b50919050565b60006000612843836129dc565b9050607860020a81101561285657612866565b61285f816128c2565b9150612872565b61286f81612904565b91505b50919050565b6000600061288d612888846129dc565b6129dc565b9050607860020a8110156128a0576128b0565b6128a981612904565b91506128bc565b6128b9816128c2565b91505b50919050565b600060006128cf836129dc565b9050607960020a8110156128e2576128f2565b6128eb8161294e565b91506128fe565b6128fb81611d3e565b91505b50919050565b60006000612919612914846129dc565b6129dc565b9050607960020a81101561292c5761293c565b61293581611d3e565b9150612948565b6129458161294e565b91505b50919050565b6000600061295b836129dc565b9050607a60020a81101561296e5761297e565b61297781613227565b915061298a565b61298781613269565b91505b50919050565b6000600061299d836129dc565b9050604e60020a8110156129b0576129c0565b6129b981612a7f565b91506129cc565b6129c981612a3d565b91505b50919050565b6000819050919050565b600060007f5851f42d4c957f2c0000000000000000000000000000000000000000000000019050828102600101915050919050565b6000612a1c826129d2565b9050919050565b6000612a36612a31836129dc565b6129d2565b9050919050565b60006000612a4a836129dc565b9050604f60020a811015612a5d57612a6d565b612a6681612ac9565b9150612a79565b612a7681612b0b565b91505b50919050565b60006000612a94612a8f846129dc565b6129dc565b9050604f60020a811015612aa757612ab7565b612ab081612b0b565b9150612ac3565b612ac081612ac9565b91505b50919050565b60006000612ad6836129dc565b9050605060020a811015612ae957612af9565b612af281612b55565b9150612b05565b612b0281612b97565b91505b50919050565b60006000612b20612b1b846129dc565b6129dc565b9050605060020a811015612b3357612b43565b612b3c81612b97565b9150612b4f565b612b4c81612b55565b91505b50919050565b60006000612b62836129dc565b9050605160020a811015612b7557612b85565b612b7e81612be1565b9150612b91565b612b8e81612c23565b91505b50919050565b60006000612bac612ba7846129dc565b6129dc565b9050605160020a811015612bbf57612bcf565b612bc881612c23565b9150612bdb565b612bd881612be1565b91505b50919050565b60006000612bee836129dc565b9050605260020a811015612c0157612c11565b612c0a81612c6d565b9150612c1d565b612c1a81612caf565b91505b50919050565b60006000612c38612c33846129dc565b6129dc565b9050605260020a811015612c4b57612c5b565b612c5481612caf565b9150612c67565b612c6481612c6d565b91505b50919050565b60006000612c7a836129dc565b9050605360020a811015612c8d57612c9d565b612c9681612cf9565b9150612ca9565b612ca681612d3b565b91505b50919050565b60006000612cc4612cbf846129dc565b6129dc565b9050605360020a811015612cd757612ce7565b612ce081612d3b565b9150612cf3565b612cf081612cf9565b91505b50919050565b60006000612d06836129dc565b9050605460020a811015612d1957612d29565b612d2281612d85565b9150612d35565b612d3281612dc7565b91505b50919050565b60006000612d50612d4b846129dc565b6129dc565b9050605460020a811015612d6357612d73565b612d6c81612dc7565b9150612d7f565b612d7c81612d85565b91505b50919050565b60006000612d92836129dc565b9050605560020a811015612da557612db5565b612dae81612e11565b9150612dc1565b612dbe81612e53565b91505b50919050565b60006000612ddc612dd7846129dc565b6129dc565b9050605560020a811015612def57612dff565b612df881612e53565b9150612e0b565b612e0881612e11565b91505b50919050565b60006000612e1e836129dc565b9050605660020a811015612e3157612e41565b612e3a81612e9d565b9150612e4d565b612e4a81612edf565b91505b50919050565b60006000612e68612e63846129dc565b6129dc565b9050605660020a811015612e7b57612e8b565b612e8481612edf565b9150612e97565b612e9481612e9d565b91505b50919050565b60006000612eaa836129dc565b9050605760020a811015612ebd57612ecd565b612ec681612f29565b9150612ed9565b612ed681612f6b565b91505b50919050565b60006000612ef4612eef846129dc565b6129dc565b9050605760020a811015612f0757612f17565b612f1081612f6b565b9150612f23565b612f2081612f29565b91505b50919050565b60006000612f36836129dc565b9050605860020a811015612f4957612f59565b612f5281612fb5565b9150612f65565b612f6281612ff7565b91505b50919050565b60006000612f80612f7b846129dc565b6129dc565b9050605860020a811015612f9357612fa3565b612f9c81612ff7565b9150612faf565b612fac81612fb5565b91505b50919050565b60006000612fc2836129dc565b9050605960020a811015612fd557612fe5565b612fde81613041565b9150612ff1565b612fee81613083565b91505b50919050565b6000600061300c613007846129dc565b6129dc565b9050605960020a81101561301f5761302f565b61302881613083565b915061303b565b61303881613041565b91505b50919050565b6000600061304e836129dc565b9050605a60020a81101561306157613071565b61306a816130cd565b915061307d565b61307a8161310f565b91505b50919050565b60006000613098613093846129dc565b6129dc565b9050605a60020a8110156130ab576130bb565b6130b48161310f565b91506130c7565b6130c4816130cd565b91505b50919050565b600060006130da836129dc565b9050605b60020a8110156130ed576130fd565b6130f681613159565b9150613109565b6131068161319b565b91505b50919050565b6000600061312461311f846129dc565b6129dc565b9050605b60020a81101561313757613147565b6131408161319b565b9150613153565b61315081613159565b91505b50919050565b60006000613166836129dc565b9050605c60020a81101561317957613189565b613182816131e5565b9150613195565b6131928161196a565b91505b50919050565b600060006131b06131ab846129dc565b6129dc565b9050605c60020a8110156131c3576131d3565b6131cc8161196a565b91506131df565b6131dc816131e5565b91505b50919050565b600060006131f2836129dc565b9050605d60020a81101561320557613215565b61320e816119b4565b9150613221565b61321e816119f6565b91505b50919050565b60006000613234836129dc565b9050607b60020a81101561324757613257565b613250816132b3565b9150613263565b613260816132f5565b91505b50919050565b6000600061327e613279846129dc565b6129dc565b9050607b60020a811015613291576132a1565b61329a816132f5565b91506132ad565b6132aa816132b3565b91505b50919050565b600060006132c0836129dc565b9050607c60020a8110156132d3576132e3565b6132dc8161333f565b91506132ef565b6132ec81613381565b91505b50919050565b6000600061330a613305846129dc565b6129dc565b9050607c60020a81101561331d5761332d565b61332681613381565b9150613339565b6133368161333f565b91505b50919050565b6000600061334c836129dc565b9050607d60020a81101561335f5761336f565b613368816133cb565b915061337b565b6133788161340d565b91505b50919050565b60006000613396613391846129dc565b6129dc565b9050607d60020a8110156133a9576133b9565b6133b28161340d565b91506133c5565b6133c2816133cb565b91505b50919050565b600060006133d8836129dc565b9050607e60020a8110156133eb576133fb565b6133f481613457565b9150613407565b61340481613499565b91505b50919050565b6000600061342261341d846129dc565b6129dc565b9050607e60020a81101561343557613445565b61343e81613499565b9150613451565b61344e81613457565b91505b50919050565b60006000613464836129dc565b9050607f60020a81101561347757613487565b613480816134e3565b9150613493565b61349081613525565b91505b50919050565b600060006134ae6134a9846129dc565b6129dc565b9050607f60020a8110156134c1576134d1565b6134ca81613525565b91506134dd565b6134da816134e3565b91505b50919050565b600060006134f0836129dc565b9050608060020a81101561350357613513565b61350c8161356f565b915061351f565b61351c816135b1565b91505b50919050565b6000600061353a613535846129dc565b6129dc565b9050608060020a81101561354d5761355d565b613556816135b1565b9150613569565b6135668161356f565b91505b50919050565b6000600061357c836129dc565b9050608160020a81101561358f5761359f565b613598816135fb565b91506135ab565b6135a88161363d565b91505b50919050565b600060006135c66135c1846129dc565b6129dc565b9050608160020a8110156135d9576135e9565b6135e28161363d565b91506135f5565b6135f2816135fb565b91505b50919050565b60006000613608836129dc565b9050608260020a81101561361b5761362b565b61362481613687565b9150613637565b613634816136c9565b91505b50919050565b6000600061365261364d846129dc565b6129dc565b9050608260020a81101561366557613675565b61366e816136c9565b9150613681565b61367e81613687565b91505b50919050565b60006000613694836129dc565b9050608360020a8110156136a7576136b7565b6136b081613713565b91506136c3565b6136c081613755565b91505b50919050565b600060006136de6136d9846129dc565b6129dc565b9050608360020a8110156136f157613701565b6136fa81613755565b915061370d565b61370a81613713565b91505b50919050565b60006000613720836129dc565b9050608460020a81101561373357613743565b61373c8161379f565b915061374f565b61374c816137e1565b91505b50919050565b6000600061376a613765846129dc565b6129dc565b9050608460020a81101561377d5761378d565b613786816137e1565b9150613799565b6137968161379f565b91505b50919050565b600060006137ac836129dc565b9050608560020a8110156137bf576137cf565b6137c88161382b565b91506137db565b6137d88161386d565b91505b50919050565b600060006137f66137f1846129dc565b6129dc565b9050608560020a81101561380957613819565b6138128161386d565b9150613825565b6138228161382b565b91505b50919050565b60006000613838836129dc565b9050608660020a81101561384b5761385b565b613854816138b7565b9150613867565b613864816138f9565b91505b50919050565b6000600061388261387d846129dc565b6129dc565b9050608660020a811015613895576138a5565b61389e816138f9565b91506138b1565b6138ae816138b7565b91505b50919050565b600060006138c4836129dc565b9050608760020a8110156138d7576138e7565b6138e081613943565b91506138f3565b6138f081613985565b91505b50919050565b6000600061390e613909846129dc565b6129dc565b9050608760020a81101561392157613931565b61392a81613985565b915061393d565b61393a81613943565b91505b50919050565b60006000613950836129dc565b9050608860020a81101561396357613973565b61396c816139cf565b915061397f565b61397c81613a11565b91505b50919050565b6000600061399a613995846129dc565b6129dc565b9050608860020a8110156139ad576139bd565b6139b681613a11565b91506139c9565b6139c6816139cf565b91505b50919050565b600060006139dc836129dc565b9050608960020a8110156139ef576139ff565b6139f881613a5b565b9150613a0b565b613a0881613a9d565b91505b50919050565b60006000613a26613a21846129dc565b6129dc565b9050608960020a811015613a3957613a49565b613a4281613a9d565b9150613a55565b613a5281613a5b565b91505b50919050565b60006000613a68836129dc565b9050608a60020a811015613a7b57613a8b565b613a8481613ae7565b9150613a97565b613a9481613b29565b91505b50919050565b60006000613ab2613aad846129dc565b6129dc565b9050608a60020a811015613ac557613ad5565b613ace81613b29565b9150613ae1565b613ade81613ae7565b91505b50919050565b60006000613af4836129dc565b9050608b60020a811015613b0757613b17565b613b1081613b73565b9150613b23565b613b2081613bb5565b91505b50919050565b60006000613b3e613b39846129dc565b6129dc565b9050608b60020a811015613b5157613b61565b613b5a81613bb5565b9150613b6d565b613b6a81613b73565b91505b50919050565b60006000613b80836129dc565b9050608c60020a811015613b9357613ba3565b613b9c81613bff565b9150613baf565b613bac81613c41565b91505b50919050565b60006000613bca613bc5846129dc565b6129dc565b9050608c60020a811015613bdd57613bed565b613be681613c41565b9150613bf9565b613bf681613bff565b91505b50919050565b60006000613c0c836129dc565b9050608d60020a811015613c1f57613c2f565b613c2881613c8b565b9150613c3b565b613c3881613ccd565b91505b50919050565b60006000613c56613c51846129dc565b6129dc565b9050608d60020a811015613c6957613c79565b613c7281613ccd565b9150613c85565b613c8281613c8b565b91505b50919050565b60006000613c98836129dc565b9050608e60020a811015613cab57613cbb565b613cb481613d17565b9150613cc7565b613cc481613d59565b91505b50919050565b60006000613ce2613cdd846129dc565b6129dc565b9050608e60020a811015613cf557613d05565b613cfe81613d59565b9150613d11565b613d0e81613d17565b91505b50919050565b60006000613d24836129dc565b9050608f60020a811015613d3757613d47565b613d4081613da3565b9150613d53565b613d5081613de5565b91505b50919050565b60006000613d6e613d69846129dc565b6129dc565b9050608f60020a811015613d8157613d91565b613d8a81613de5565b9150613d9d565b613d9a81613da3565b91505b50919050565b60006000613db0836129dc565b9050609060020a811015613dc357613dd3565b613dcc81613e2f565b9150613ddf565b613ddc81613e71565b91505b50919050565b60006000613dfa613df5846129dc565b6129dc565b9050609060020a811015613e0d57613e1d565b613e1681613e71565b9150613e29565b613e2681613e2f565b91505b50919050565b60006000613e3c836129dc565b9050609160020a811015613e4f57613e5f565b613e5881613ebb565b9150613e6b565b613e6881613efd565b91505b50919050565b60006000613e86613e81846129dc565b6129dc565b9050609160020a811015613e9957613ea9565b613ea281613efd565b9150613eb5565b613eb281613ebb565b91505b50919050565b60006000613ec8836129dc565b9050609260020a811015613edb57613eeb565b613ee481613f47565b9150613ef7565b613ef481613f89565b91505b50919050565b60006000613f12613f0d846129dc565b6129dc565b9050609260020a811015613f2557613f35565b613f2e81613f89565b9150613f41565b613f3e81613f47565b91505b50919050565b60006000613f54836129dc565b9050609360020a811015613f6757613f77565b613f7081613fd3565b9150613f83565b613f8081614015565b91505b50919050565b60006000613f9e613f99846129dc565b6129dc565b9050609360020a811015613fb157613fc1565b613fba81614015565b9150613fcd565b613fca81613fd3565b91505b50919050565b60006000613fe0836129dc565b9050609460020a811015613ff357614003565b613ffc8161405f565b915061400f565b61400c816140a1565b91505b50919050565b6000600061402a614025846129dc565b6129dc565b9050609460020a81101561403d5761404d565b614046816140a1565b9150614059565b6140568161405f565b91505b50919050565b6000600061406c836129dc565b9050609560020a81101561407f5761408f565b614088816140eb565b915061409b565b6140988161412d565b91505b50919050565b600060006140b66140b1846129dc565b6129dc565b9050609560020a8110156140c9576140d9565b6140d28161412d565b91506140e5565b6140e2816140eb565b91505b50919050565b600060006140f8836129dc565b9050609660020a81101561410b5761411b565b61411481614177565b9150614127565b614124816141b9565b91505b50919050565b6000600061414261413d846129dc565b6129dc565b9050609660020a81101561415557614165565b61415e816141b9565b9150614171565b61416e81614177565b91505b50919050565b60006000614184836129dc565b9050609760020a811015614197576141a7565b6141a081614203565b91506141b3565b6141b081614245565b91505b50919050565b600060006141ce6141c9846129dc565b6129dc565b9050609760020a8110156141e1576141f1565b6141ea81614245565b91506141fd565b6141fa81614203565b91505b50919050565b60006000614210836129dc565b9050609860020a81101561422357614233565b61422c8161428f565b915061423f565b61423c816142d1565b91505b50919050565b6000600061425a614255846129dc565b6129dc565b9050609860020a81101561426d5761427d565b614276816142d1565b9150614289565b6142868161428f565b91505b50919050565b6000600061429c836129dc565b9050609960020a8110156142af576142bf565b6142b88161431b565b91506142cb565b6142c88161435d565b91505b50919050565b600060006142e66142e1846129dc565b6129dc565b9050609960020a8110156142f957614309565b6143028161435d565b9150614315565b6143128161431b565b91505b50919050565b60006000614328836129dc565b9050609a60020a81101561433b5761434b565b614344816143a7565b9150614357565b614354816143e9565b91505b50919050565b6000600061437261436d846129dc565b6129dc565b9050609a60020a81101561438557614395565b61438e816143e9565b91506143a1565b61439e816143a7565b91505b50919050565b600060006143b4836129dc565b9050609b60020a8110156143c7576143d7565b6143d081614433565b91506143e3565b6143e081614475565b91505b50919050565b600060006143fe6143f9846129dc565b6129dc565b9050609b60020a81101561441157614421565b61441a81614475565b915061442d565b61442a81614433565b91505b50919050565b60006000614440836129dc565b9050609c60020a81101561445357614463565b61445c816144bf565b915061446f565b61446c81614501565b91505b50919050565b6000600061448a614485846129dc565b6129dc565b9050609c60020a81101561449d576144ad565b6144a681614501565b91506144b9565b6144b6816144bf565b91505b50919050565b600060006144cc836129dc565b9050609d60020a8110156144df576144ef565b6144e88161454b565b91506144fb565b6144f88161458d565b91505b50919050565b60006000614516614511846129dc565b6129dc565b9050609d60020a81101561452957614539565b6145328161458d565b9150614545565b6145428161454b565b91505b50919050565b60006000614558836129dc565b9050609e60020a81101561456b5761457b565b614574816145d7565b9150614587565b61458481614619565b91505b50919050565b600060006145a261459d846129dc565b6129dc565b9050609e60020a8110156145b5576145c5565b6145be81614619565b91506145d1565b6145ce816145d7565b91505b50919050565b600060006145e4836129dc565b9050609f60020a8110156145f757614607565b61460081614663565b9150614613565b614610816146a5565b91505b50919050565b6000600061462e614629846129dc565b6129dc565b9050609f60020a81101561464157614651565b61464a816146a5565b915061465d565b61465a81614663565b91505b50919050565b60006000614670836129dc565b905060a060020a81101561468357614693565b61468c816146ef565b915061469f565b61469c81614731565b91505b50919050565b600060006146ba6146b5846129dc565b6129dc565b905060a060020a8110156146cd576146dd565b6146d681614731565b91506146e9565b6146e6816146ef565b91505b50919050565b600060006146fc836129dc565b905060a160020a81101561470f5761471f565b6147188161477b565b915061472b565b614728816147bd565b91505b50919050565b60006000614746614741846129dc565b6129dc565b905060a160020a81101561475957614769565b614762816147bd565b9150614775565b6147728161477b565b91505b50919050565b60006000614788836129dc565b905060a260020a81101561479b576147ab565b6147a481614807565b91506147b7565b6147b481614849565b91505b50919050565b600060006147d26147cd846129dc565b6129dc565b905060a260020a8110156147e5576147f5565b6147ee81614849565b9150614801565b6147fe81614807565b91505b50919050565b60006000614814836129dc565b905060a360020a81101561482757614837565b61483081614893565b9150614843565b614840816148d5565b91505b50919050565b6000600061485e614859846129dc565b6129dc565b905060a360020a81101561487157614881565b61487a816148d5565b915061488d565b61488a81614893565b91505b50919050565b600060006148a0836129dc565b905060a460020a8110156148b3576148c3565b6148bc8161491f565b91506148cf565b6148cc81614961565b91505b50919050565b600060006148ea6148e5846129dc565b6129dc565b905060a460020a8110156148fd5761490d565b61490681614961565b9150614919565b6149168161491f565b91505b50919050565b6000600061492c836129dc565b905060a560020a81101561493f5761494f565b614948816149ab565b915061495b565b614958816149ed565b91505b50919050565b60006000614976614971846129dc565b6129dc565b905060a560020a81101561498957614999565b614992816149ed565b91506149a5565b6149a2816149ab565b91505b50919050565b600060006149b8836129dc565b905060a660020a8110156149cb576149db565b6149d481614a37565b91506149e7565b6149e481614a79565b91505b50919050565b60006000614a026149fd846129dc565b6129dc565b905060a660020a811015614a1557614a25565b614a1e81614a79565b9150614a31565b614a2e81614a37565b91505b50919050565b60006000614a44836129dc565b905060a760020a811015614a5757614a67565b614a6081614ac3565b9150614a73565b614a7081614b05565b91505b50919050565b60006000614a8e614a89846129dc565b6129dc565b905060a760020a811015614aa157614ab1565b614aaa81614b05565b9150614abd565b614aba81614ac3565b91505b50919050565b60006000614ad0836129dc565b905060a860020a811015614ae357614af3565b614aec81614b4f565b9150614aff565b614afc81614b91565b91505b50919050565b60006000614b1a614b15846129dc565b6129dc565b905060a860020a811015614b2d57614b3d565b614b3681614b91565b9150614b49565b614b4681614b4f565b91505b50919050565b60006000614b5c836129dc565b905060a960020a811015614b6f57614b7f565b614b7881614bdb565b9150614b8b565b614b8881614c1d565b91505b50919050565b60006000614ba6614ba1846129dc565b6129dc565b905060a960020a811015614bb957614bc9565b614bc281614c1d565b9150614bd5565b614bd281614bdb565b91505b50919050565b60006000614be8836129dc565b905060aa60020a811015614bfb57614c0b565b614c0481614c67565b9150614c17565b614c1481614ca9565b91505b50919050565b60006000614c32614c2d846129dc565b6129dc565b905060aa60020a811015614c4557614c55565b614c4e81614ca9565b9150614c61565b614c5e81614c67565b91505b50919050565b60006000614c74836129dc565b905060ab60020a811015614c8757614c97565b614c9081614cf3565b9150614ca3565b614ca081614d35565b91505b50919050565b60006000614cbe614cb9846129dc565b6129dc565b905060ab60020a811015614cd157614ce1565b614cda81614d35565b9150614ced565b614cea81614cf3565b91505b50919050565b60006000614d00836129dc565b905060ac60020a811015614d1357614d23565b614d1c81614d7f565b9150614d2f565b614d2c81614dc1565b91505b50919050565b60006000614d4a614d45846129dc565b6129dc565b905060ac60020a811015614d5d57614d6d565b614d6681614dc1565b9150614d79565b614d7681614d7f565b91505b50919050565b60006000614d8c836129dc565b905060ad60020a811015614d9f57614daf565b614da881614e0b565b9150614dbb565b614db881614e4d565b91505b50919050565b60006000614dd6614dd1846129dc565b6129dc565b905060ad60020a811015614de957614df9565b614df281614e4d565b9150614e05565b614e0281614e0b565b91505b50919050565b60006000614e18836129dc565b905060ae60020a811015614e2b57614e3b565b614e3481614e97565b9150614e47565b614e4481614ed9565b91505b50919050565b60006000614e62614e5d846129dc565b6129dc565b905060ae60020a811015614e7557614e85565b614e7e81614ed9565b9150614e91565b614e8e81614e97565b91505b50919050565b60006000614ea4836129dc565b905060af60020a811015614eb757614ec7565b614ec081614f23565b9150614ed3565b614ed081614f65565b91505b50919050565b60006000614eee614ee9846129dc565b6129dc565b905060af60020a811015614f0157614f11565b614f0a81614f65565b9150614f1d565b614f1a81614f23565b91505b50919050565b60006000614f30836129dc565b905060b060020a811015614f4357614f53565b614f4c81614faf565b9150614f5f565b614f5c81614ff1565b91505b50919050565b60006000614f7a614f75846129dc565b6129dc565b905060b060020a811015614f8d57614f9d565b614f9681614ff1565b9150614fa9565b614fa681614faf565b91505b50919050565b60006000614fbc836129dc565b905060b160020a811015614fcf57614fdf565b614fd881612a11565b9150614feb565b614fe881612a23565b91505b50919050565b60006000615006615001846129dc565b6129dc565b905060b160020a81101561501957615029565b61502281612a23565b9150615035565b61503281612a11565b91505b5091905056", @@ -25,7 +25,7 @@ "//" : "ManyFunctions.start(1)", "data" : "0x95805DAD0000000000000000000000000000000000000000000000000000000000000001", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "ackermann31": { @@ -39,7 +39,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -54,7 +54,7 @@ "//" : "ackermann(3, 1)", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, "ackermann32": { @@ -68,7 +68,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -97,7 +97,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -126,7 +126,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", @@ -155,7 +155,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "//" : "PerformanceTester.sol", "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", diff --git a/test/vmPushDupSwapTestFiller.json b/test/vmPushDupSwapTestFiller.json index 1aca47922..9b8930e01 100644 --- a/test/vmPushDupSwapTestFiller.json +++ b/test/vmPushDupSwapTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60ff600355", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x61eeff600355", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x62ddeeff600355", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x63ccddeeff600355", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x64bbccddeeff600355", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x65aabbccddeeff600355", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -206,7 +206,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6699aabbccddeeff600355", "storage": {} @@ -219,7 +219,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -234,7 +234,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x678899aabbccddeeff600355", "storage": {} @@ -247,7 +247,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -262,7 +262,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x68778899aabbccddeeff600355", "storage": {} @@ -275,7 +275,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -290,7 +290,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6966778899aabbccddeeff600355", "storage": {} @@ -303,7 +303,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -318,7 +318,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6a5566778899aabbccddeeff600355", "storage": {} @@ -331,7 +331,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -346,7 +346,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6b445566778899aabbccddeeff600355", "storage": {} @@ -359,7 +359,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -374,7 +374,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6c33445566778899aabbccddeeff600355", "storage": {} @@ -387,7 +387,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -402,7 +402,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6d2233445566778899aabbccddeeff600355", "storage": {} @@ -415,7 +415,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -430,7 +430,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6e112233445566778899aabbccddeeff600355", "storage": {} @@ -443,7 +443,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -458,7 +458,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6f10112233445566778899aabbccddeeff600355", "storage": {} @@ -471,7 +471,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -486,7 +486,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x70ff00112233445566778899aabbccddeeff600355", "storage": {} @@ -499,7 +499,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x71eeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -527,7 +527,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -542,7 +542,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x72ddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -555,7 +555,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -570,7 +570,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x73ccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -583,7 +583,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -598,7 +598,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x74bbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -611,7 +611,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -626,7 +626,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x75aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -639,7 +639,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -654,7 +654,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7699aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -667,7 +667,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -682,7 +682,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -695,7 +695,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -710,7 +710,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x78778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -723,7 +723,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -738,7 +738,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7966778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -751,7 +751,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -767,7 +767,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7a5566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -780,7 +780,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -795,7 +795,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7b445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -808,7 +808,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -823,7 +823,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7c33445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -836,7 +836,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -851,7 +851,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7d2233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -864,7 +864,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -879,7 +879,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7e112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -892,7 +892,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -907,7 +907,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -920,7 +920,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -935,7 +935,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7fff10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff600355", "storage": {} @@ -948,7 +948,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -964,7 +964,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7fff10112233445566778899aabbccddeeff00112233445566778899aabbccdd", "storage": {} @@ -977,7 +977,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -992,7 +992,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 101 2002 303303 40444404 50555555505 60666666666606 7777777777777777 888888888888888888 99999999999999999999 10000000000000000000001 10111111111111111111111101 2022222222222222222222222202 303333333333333333333333333303 4044444444444444444444444444444404 505555555555555555555555555555555505 60666666666666666666666666666666666606 7077777777777777777777777777777777777707 808888888888888888888888888888888888888808 90999999999999999999999999999999999999999909 100000000000000000000000000000000000000000000001 10111111111111111111111111111111111111111111111101 2022222222222222222222222222222222222222222222222202 303333333333333333333333333333333333333333333333333303 40444444444444444444444444444444444444444444444444444404 50555555555555555555555555555555555555555555555555555555505 6066666666666666666666666666666666666666666666666666666666606 707777777777777777777777777777777777777777777777777777777777707 808888888888888888888888888888888888888888888888888888888888888808 90999999999999999999999999999999999999999999999999999999999999999909 100000000000000000000000000000000000000000000000000000000000000000000001 10111111111111111111111111111111111111111111111111111111111111111111111101 2022222222222222222222222222222222222222222222222222222222222222222222222202)", "storage": {} @@ -1020,7 +1020,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff80600355", "storage": {} @@ -1033,7 +1033,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1048,7 +1048,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff81600355", "storage": {} @@ -1061,7 +1061,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1076,7 +1076,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600181600355", "storage": {} @@ -1089,7 +1089,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1104,7 +1104,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60036002600182600355", "storage": {} @@ -1117,7 +1117,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1132,7 +1132,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460036002600183600355", "storage": {} @@ -1145,7 +1145,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1160,7 +1160,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600460036002600184600355", "storage": {} @@ -1173,7 +1173,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1188,7 +1188,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60066005600460036002600185600355", "storage": {} @@ -1201,7 +1201,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1216,7 +1216,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600760066005600460036002600186600355", "storage": {} @@ -1229,7 +1229,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1244,7 +1244,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600760066005600460036002600187600355", "storage": {} @@ -1257,7 +1257,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1272,7 +1272,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60096008600760066005600460036002600188600355", "storage": {} @@ -1285,7 +1285,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1300,7 +1300,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a60096008600760066005600460036002600189600355", "storage": {} @@ -1313,7 +1313,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1328,7 +1328,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600b600a6009600860076006600560046003600260018a600355", "storage": {} @@ -1341,7 +1341,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1356,7 +1356,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600c600b600a6009600860076006600560046003600260018b600355", "storage": {} @@ -1369,7 +1369,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1384,7 +1384,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600d600c600b600a6009600860076006600560046003600260018c600355", "storage": {} @@ -1397,7 +1397,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1412,7 +1412,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600e600d600c600b600a6009600860076006600560046003600260018d600355", "storage": {} @@ -1425,7 +1425,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1440,7 +1440,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600f600e600d600c600b600a6009600860076006600560046003600260018e600355", "storage": {} @@ -1453,7 +1453,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1468,7 +1468,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6010600f600e600d600c600b600a6009600860076006600560046003600260018f600355", "storage": {} @@ -1481,7 +1481,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1496,7 +1496,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff60039055", "storage": {} @@ -1509,7 +1509,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1524,7 +1524,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x7f10112233445566778899aabbccddeeff00112233445566778899aabbccddeeff60039155", "storage": {} @@ -1537,7 +1537,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1552,7 +1552,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6002600160039155", "storage": {} @@ -1565,7 +1565,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1580,7 +1580,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60036002600160039255", "storage": {} @@ -1593,7 +1593,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1608,7 +1608,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600460036002600160039355", "storage": {} @@ -1621,7 +1621,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1636,7 +1636,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6005600460036002600160039455", "storage": {} @@ -1649,7 +1649,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1664,7 +1664,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60066005600460036002600160039555", "storage": {} @@ -1677,7 +1677,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1692,7 +1692,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600760066005600460036002600160039655", "storage": {} @@ -1705,7 +1705,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1720,7 +1720,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6008600760066005600460036002600160039755", "storage": {} @@ -1733,7 +1733,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1748,7 +1748,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x60096008600760066005600460036002600160039855", "storage": {} @@ -1761,7 +1761,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1776,7 +1776,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600a60096008600760066005600460036002600160039955", "storage": {} @@ -1789,7 +1789,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1804,7 +1804,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600b600a60096008600760066005600460036002600160039a55", "storage": {} @@ -1817,7 +1817,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1832,7 +1832,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600c600b600a60096008600760066005600460036002600160039b55", "storage": {} @@ -1845,7 +1845,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1860,7 +1860,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600d600c600b600a60096008600760066005600460036002600160039c55", "storage": {} @@ -1873,7 +1873,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1888,7 +1888,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600e600d600c600b600a60096008600760066005600460036002600160039d55", "storage": {} @@ -1901,7 +1901,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1916,7 +1916,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x600f600e600d600c600b600a60096008600760066005600460036002600160039e55", "storage": {} @@ -1929,7 +1929,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1944,7 +1944,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6010600f600e600d600c600b600a60096008600760066005600460036002600160039f55", "storage": {} @@ -1957,7 +1957,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1972,7 +1972,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(asm 5 2 1 12 JUMPI POP POP STOP JUMPDEST SWAP1 1 22 JUMPI POP POP STOP JUMPDEST SUB 0 MSTORE 1 31 RETURN)", "storage": {} @@ -1985,7 +1985,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } } } diff --git a/test/vmSha3TestFiller.json b/test/vmSha3TestFiller.json index 142af79d0..f10601f00 100644 --- a/test/vmSha3TestFiller.json +++ b/test/vmSha3TestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0 0)}", "storage": {} @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 4 5)}", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 10 10)}", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 1000 0xfffff)}", "storage": {} @@ -107,7 +107,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0xfffffffff 100)}", "storage": {} @@ -135,7 +135,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -150,7 +150,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 10000 0xfffffffff )}", "storage": {} @@ -163,7 +163,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -178,7 +178,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (SHA3 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)}", "storage": {} @@ -191,7 +191,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, diff --git a/test/vmSystemOperationsTestFiller.json b/test/vmSystemOperationsTestFiller.json index 709af7079..bdbbdc29b 100644 --- a/test/vmSystemOperationsTestFiller.json +++ b/test/vmSystemOperationsTestFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0x601080600c6000396000f3006000355415600957005b60203560003555) [[ 0 ]] (CREATE 23 3 29) }", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -51,7 +51,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -79,7 +79,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -107,7 +107,7 @@ "value" : "100", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -122,7 +122,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -161,14 +161,14 @@ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "code" : "0x4243434242434243f14555", "data" : "0x", - "gas" : "10000", + "gas" : "100000", "gasPrice" : "100000000000000", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "code" : "0x4243434242434243f14555", "nonce" : "0", "storage" : { @@ -188,7 +188,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2) }", "storage": {} @@ -224,7 +224,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) (POST 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 ) }", "storage": {} @@ -260,7 +260,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLSTATELESS 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2 ) }", "storage": {} @@ -296,7 +296,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 0 2 ) }", "storage": {} @@ -333,7 +333,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 100 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -369,7 +369,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 987654321 64 64 0) }", "storage": {} @@ -405,7 +405,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 9865432 64 0) }", "storage": {} @@ -441,7 +441,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 987654 1) }", "storage": {} @@ -478,7 +478,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 987654 0) }", "storage": {} @@ -514,7 +514,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALL 500 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 987654 0 64 0) }", "storage": {} @@ -556,7 +556,7 @@ "storage": {} }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (+ (SLOAD 0) 1) [[ 1 ]] (CALL (- (GAS) 224) (ADDRESS) 0 0 0 0 0) } ", "storage": {} @@ -668,7 +668,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE (CALLER))}", "storage": {} @@ -704,7 +704,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE 0xaa1722f3947def4cf144679da39c4c32bdc35681 )}", "storage": {} @@ -740,7 +740,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (SUICIDE (ADDRESS) )}", "storage": {} @@ -866,7 +866,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) (POST 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 ) }", "storage": {} @@ -902,7 +902,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLSTATELESS 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -938,7 +938,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (MSTORE 0 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) (MSTORE 32 0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa ) [[ 0 ]] (CALLCODE 1000000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 23 0 64 64 0) }", "storage": {} @@ -974,7 +974,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "0x6000355415600957005b60203560003555", "storage": {} @@ -987,7 +987,7 @@ "value" : "1000000000000000000", "data" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffafffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -1002,7 +1002,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} @@ -1038,7 +1038,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} @@ -1074,7 +1074,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ 0 ]] (ADD (SLOAD 0) 1) (CALL (- (GAS) 1000) 0x945304eb96065b2a98b57a48a06ae28d285a71b5 1 0 0 0 0) }", "storage": {} @@ -1146,7 +1146,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) (SUICIDE 0x945304eb96065b2a98b57a48a06ae28d285a71b5) }", "storage": {} @@ -1182,7 +1182,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", "storage": {} diff --git a/test/vmtestsFiller.json b/test/vmtestsFiller.json index 75bf1da8f..c9f157f11 100644 --- a/test/vmtestsFiller.json +++ b/test/vmtestsFiller.json @@ -10,7 +10,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(suicide (caller))", "storage": {} @@ -23,7 +23,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -38,7 +38,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "{ (call (- (gas) 200) (caller) (+ 2 2 (* 4 4 4) (/ 2 2) (% 3 2) (- 8 2 2)) 0 0 0 0) }", "storage": {} @@ -51,7 +51,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -66,7 +66,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(seq (when (and 1 1) (call (- (gas) 200) (caller) 2 0 0 0 0)) (when (and 1 0) (call (- (gas) 200) (caller) 3 0 0 0 0)) (when (and 0 1) (call (- (gas) 200) (caller) 4 0 0 0 0)) (when (and 0 0) (call (- (gas) 200) (caller) 5 0 0 0 0)) (when (or 1 1) (call (- (gas) 200) (caller) 12 0 0 0 0)) (when (or 1 0) (call (- (gas) 200) (caller) 13 0 0 0 0)) (when (or 0 1) (call (- (gas) 200) (caller) 14 0 0 0 0)) (when (or 0 0) (call (- (gas) 200) (caller) 15 0 0 0 0)) )", "storage": {} @@ -79,7 +79,7 @@ "value" : "1000000000000000000", "data" : "", "gasPrice" : "100000000000000", - "gas" : "10000" + "gas" : "100000" } }, @@ -94,7 +94,7 @@ }, "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", + "balance" : "100000000000000000000000", "nonce" : "0", "code" : "(call (- (gas) 200) (caller) 500000000000000000 0 0 0 0)", "storage": {} @@ -107,7 +107,7 @@ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000", "gasPrice" : "100000000000000", - "gas" : "10000", + "gas" : "100000", "data" : "" } } From 103b9ea0a775af0e86c11804b71df87726ad6bea Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 11:09:34 +0100 Subject: [PATCH 224/313] Bunch of repotting/curating. [10:59:28] Vitalik Buterin: block.parent.gas_limit * 1023 / 1024 <= block.gas_limit <= block.parent.gas_limit * 1025/1024 --- alethzero/Context.cpp | 2 +- alethzero/Context.h | 2 +- alethzero/Debugger.h | 2 +- alethzero/MainWin.h | 2 +- alethzero/Transact.h | 2 +- rlp/base64.cpp => libdevcore/Base64.cpp | 12 +-- rlp/base64.h => libdevcore/Base64.h | 9 +- libdevcore/Common.h | 6 ++ libdevcore/CommonIO.h | 1 + libdevcore/CommonJS.cpp | 101 ++++++++++++++++++++ libdevcore/CommonJS.h | 116 +++++++++++++++++++++++ libethcore/BlockInfo.cpp | 12 +-- libethcore/BlockInfo.h | 2 +- libethcore/{CommonEth.cpp => Common.cpp} | 4 +- libethcore/{CommonEth.h => Common.h} | 2 +- libethcore/CommonJS.cpp | 79 +-------------- libethcore/CommonJS.h | 114 +++------------------- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 4 +- libethcore/ProofOfWork.h | 2 +- libethereum/Account.cpp | 2 +- libethereum/AccountDiff.h | 2 +- libethereum/BlockChain.h | 2 +- libethereum/BlockQueue.h | 2 +- libethereum/CanonBlockChain.h | 2 +- libethereum/EthereumHost.h | 2 +- libethereum/EthereumPeer.h | 2 +- libethereum/Executive.h | 2 +- libethereum/ExtVM.h | 2 +- libethereum/LogFilter.h | 2 +- libethereum/Miner.h | 2 +- libethereum/Precompiled.cpp | 2 +- libethereum/Transaction.h | 2 +- libethereum/TransactionQueue.h | 2 +- libethereum/Utility.cpp | 2 +- libevm/ExtVMFace.h | 2 +- libevm/VM.h | 2 +- mix/QEther.h | 2 +- rlp/main.cpp | 94 +++++++++--------- test/MemTrie.cpp | 2 +- test/TrieHash.cpp | 2 +- test/commonjs.cpp | 2 +- third/MainWin.h | 2 +- 43 files changed, 339 insertions(+), 275 deletions(-) rename rlp/base64.cpp => libdevcore/Base64.cpp (91%) rename rlp/base64.h => libdevcore/Base64.h (80%) create mode 100644 libdevcore/CommonJS.cpp create mode 100644 libdevcore/CommonJS.h rename libethcore/{CommonEth.cpp => Common.cpp} (97%) rename libethcore/{CommonEth.h => Common.h} (98%) diff --git a/alethzero/Context.cpp b/alethzero/Context.cpp index d187e6d47..7a5a986d1 100644 --- a/alethzero/Context.cpp +++ b/alethzero/Context.cpp @@ -21,7 +21,7 @@ #include "Context.h" #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/alethzero/Context.h b/alethzero/Context.h index 098690455..beb368c26 100644 --- a/alethzero/Context.h +++ b/alethzero/Context.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include class QComboBox; diff --git a/alethzero/Debugger.h b/alethzero/Debugger.h index 370ad6e30..76ef6a0d3 100644 --- a/alethzero/Debugger.h +++ b/alethzero/Debugger.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 0a2b3461e..b6a04ca6d 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/alethzero/Transact.h b/alethzero/Transact.h index f14005eff..8ef4f41e0 100644 --- a/alethzero/Transact.h +++ b/alethzero/Transact.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/rlp/base64.cpp b/libdevcore/Base64.cpp similarity index 91% rename from rlp/base64.cpp rename to libdevcore/Base64.cpp index 5e2b32000..684556cd5 100644 --- a/rlp/base64.cpp +++ b/libdevcore/Base64.cpp @@ -23,13 +23,11 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. - -#include "base64.h" +/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// Originally by René Nyffenegger, modified by some other guy and then devified by Gav Wood. +#include "Base64.h" #include - using namespace std; using namespace dev; @@ -42,7 +40,7 @@ static inline bool is_base64(byte c) { return (isalnum(c) || (c == '+') || (c == '/')); } -std::string dev::base64_encode(bytesConstRef _in) { +std::string dev::toBase64(bytesConstRef _in) { std::string ret; int i = 0; int j = 0; @@ -86,7 +84,7 @@ std::string dev::base64_encode(bytesConstRef _in) { return ret; } -bytes dev::base64_decode(std::string const& encoded_string) { +bytes dev::fromBase64(std::string const& encoded_string) { int in_len = encoded_string.size(); int i = 0; int j = 0; diff --git a/rlp/base64.h b/libdevcore/Base64.h similarity index 80% rename from rlp/base64.h rename to libdevcore/Base64.h index 53ba282c8..1e9c88429 100644 --- a/rlp/base64.h +++ b/libdevcore/Base64.h @@ -23,8 +23,9 @@ René Nyffenegger rene.nyffenegger@adp-gmbh.ch */ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +/// Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// Originally by René Nyffenegger. +/// DEVified by Gav Wood. #pragma once #include @@ -34,7 +35,7 @@ namespace dev { -std::string base64_encode(bytesConstRef _in); -bytes base64_decode(std::string const& _in); +std::string toBase64(bytesConstRef _in); +bytes fromBase64(std::string const& _in); } diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 764b3454e..b82cb827e 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -119,6 +119,12 @@ inline unsigned int toLog2(u256 _x) return ret; } +template +inline N diff(N const& _a, N const& _b) +{ + return std::max(_a, _b) - std::min(_a, _b); +} + /// RAII utility class whose destructor calls a given function. class ScopeGuard { public: diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 1fc8a65e4..03fc9cffc 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -36,6 +36,7 @@ #include #include #include "Common.h" +#include "Base64.h" namespace dev { diff --git a/libdevcore/CommonJS.cpp b/libdevcore/CommonJS.cpp new file mode 100644 index 000000000..f173e779e --- /dev/null +++ b/libdevcore/CommonJS.cpp @@ -0,0 +1,101 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CommonJS.cpp + * @authors: + * Gav Wood + * Marek Kotewicz + * @date 2014 + */ + +#include "CommonJS.h" + +namespace dev +{ + +bytes jsToBytes(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return fromHex(_s.substr(2)); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return toCompactBigEndian(bigint(_s)); + else + return bytes(); +} + +bytes padded(bytes _b, unsigned _l) +{ + while (_b.size() < _l) + _b.insert(_b.begin(), 0); + return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l))); +} + +bytes paddedRight(bytes _b, unsigned _l) +{ + _b.resize(_l); + return _b; +} + +bytes unpadded(bytes _b) +{ + auto p = asString(_b).find_last_not_of((char)0); + _b.resize(p == std::string::npos ? 0 : (p + 1)); + return _b; +} + +bytes unpadLeft(bytes _b) +{ + unsigned int i = 0; + if (_b.size() == 0) + return _b; + + while (i < _b.size() && _b[i] == byte(0)) + i++; + + if (i != 0) + _b.erase(_b.begin(), _b.begin() + i); + return _b; +} + +std::string fromRaw(h256 _n, unsigned* _inc) +{ + if (_n) + { + std::string s((char const*)_n.data(), 32); + auto l = s.find_first_of('\0'); + if (!l) + return ""; + if (l != std::string::npos) + { + auto p = s.find_first_not_of('\0', l); + if (!(p == std::string::npos || (_inc && p == 31))) + return ""; + if (_inc) + *_inc = (byte)s[31]; + s.resize(l); + } + for (auto i: s) + if (i < 32) + return ""; + return s; + } + return ""; +} + +} + diff --git a/libdevcore/CommonJS.h b/libdevcore/CommonJS.h new file mode 100644 index 000000000..d3e8e6daa --- /dev/null +++ b/libdevcore/CommonJS.h @@ -0,0 +1,116 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CommonJS.h + * @authors: + * Gav Wood + * Marek Kotewicz + * @date 2014 + */ + +#pragma once + +#include +#include "FixedHash.h" +#include "CommonData.h" +#include "CommonIO.h" + +namespace dev +{ + +template std::string toJS(FixedHash const& _h) +{ + return "0x" + toHex(_h.ref()); +} + +template std::string toJS(boost::multiprecision::number> const& _n) +{ + return "0x" + toHex(toCompactBigEndian(_n)); +} + +inline std::string toJS(dev::bytes const& _n) +{ + return "0x" + dev::toHex(_n); +} + +/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. +bytes jsToBytes(std::string const& _s); +/// Add '0' on the head of @a _b until @a _l. +bytes padded(bytes _b, unsigned _l); +/// Add '0' on the queue of @a _b until @a _l. +bytes paddedRight(bytes _b, unsigned _l); +/// Removing all trailing '0'. Returns empty array if input contains only '0' char. +bytes unpadded(bytes _s); +/// Remove all 0 byte on the head of @a _s. +bytes unpadLeft(bytes _s); +/// Convert h256 into user-readable string (by directly using std::string constructor). +std::string fromRaw(h256 _n, unsigned* _inc = nullptr); + +template FixedHash jsToFixed(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return FixedHash(_s.substr(2 + std::max(N * 2, _s.size() - 2) - N * 2)); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return (typename FixedHash::Arith)(_s); + else + // Binary + return FixedHash(); // FAIL +} + +inline std::string jsToFixed(double _s) +{ + return toJS(dev::u256(_s * (double)(dev::u256(1) << 128))); +} + +template boost::multiprecision::number> jsToInt(std::string const& _s) +{ + if (_s.substr(0, 2) == "0x") + // Hex + return fromBigEndian>>(fromHex(_s.substr(2))); + else if (_s.find_first_not_of("0123456789") == std::string::npos) + // Decimal + return boost::multiprecision::number>(_s); + else + // Binary + return 0; // FAIL +} + +inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } + +inline std::string jsToDecimal(std::string const& _s) +{ + return dev::toString(jsToU256(_s)); +} + +inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32) +{ + _s.resize(std::max(_s.size(), _padding)); + return "0x" + dev::toHex(_s); +} + +inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) +{ + return jsFromBinary(asBytes(_s), _padding); +} + +inline double jsFromFixed(std::string const& _s) +{ + return (double)jsToU256(_s) / (double)(dev::u256(1) << 128); +} + +} diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index d8a2357a1..270f96b07 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "ProofOfWork.h" #include "Exceptions.h" #include "Params.h" @@ -203,15 +203,15 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } -template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } - void BlockInfo::verifyParent(BlockInfo const& _parent) const -{ // Check difficulty is correct given the two timestamps. +{ + // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) BOOST_THROW_EXCEPTION(InvalidDifficulty()); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); + if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || + gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index bf986e3a1..a119d92eb 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -23,7 +23,7 @@ #include #include -#include "CommonEth.h" +#include "Common.h" namespace dev { diff --git a/libethcore/CommonEth.cpp b/libethcore/Common.cpp similarity index 97% rename from libethcore/CommonEth.cpp rename to libethcore/Common.cpp index 822ede5aa..65c0b8b92 100644 --- a/libethcore/CommonEth.cpp +++ b/libethcore/Common.cpp @@ -14,12 +14,12 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file CommonEth.cpp +/** @file Common.cpp * @author Gav Wood * @date 2014 */ -#include "CommonEth.h" +#include "Common.h" #include #include #include "Exceptions.h" diff --git a/libethcore/CommonEth.h b/libethcore/Common.h similarity index 98% rename from libethcore/CommonEth.h rename to libethcore/Common.h index edefda380..80a253bdd 100644 --- a/libethcore/CommonEth.h +++ b/libethcore/Common.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ -/** @file CommonEth.h +/** @file Common.h * @author Gav Wood * @date 2014 * diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index 388738528..ef9ac9f65 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -26,75 +26,12 @@ namespace dev { -bytes jsToBytes(std::string const& _s) +Address toAddress(std::string const& _sn) { - if (_s.substr(0, 2) == "0x") - // Hex - return fromHex(_s.substr(2)); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return toCompactBigEndian(bigint(_s)); + if (_sn.size() == 40) + return Address(fromHex(_sn)); else - return bytes(); -} - -bytes padded(bytes _b, unsigned _l) -{ - while (_b.size() < _l) - _b.insert(_b.begin(), 0); - return asBytes(asString(_b).substr(_b.size() - std::max(_l, _l))); -} - -bytes paddedRight(bytes _b, unsigned _l) -{ - _b.resize(_l); - return _b; -} - -bytes unpadded(bytes _b) -{ - auto p = asString(_b).find_last_not_of((char)0); - _b.resize(p == std::string::npos ? 0 : (p + 1)); - return _b; -} - -bytes unpadLeft(bytes _b) -{ - unsigned int i = 0; - if (_b.size() == 0) - return _b; - - while (i < _b.size() && _b[i] == byte(0)) - i++; - - if (i != 0) - _b.erase(_b.begin(), _b.begin() + i); - return _b; -} - -std::string fromRaw(h256 _n, unsigned* _inc) -{ - if (_n) - { - std::string s((char const*)_n.data(), 32); - auto l = s.find_first_of('\0'); - if (!l) - return ""; - if (l != std::string::npos) - { - auto p = s.find_first_not_of('\0', l); - if (!(p == std::string::npos || (_inc && p == 31))) - return ""; - if (_inc) - *_inc = (byte)s[31]; - s.resize(l); - } - for (auto i: s) - if (i < 32) - return ""; - return s; - } - return ""; + return Address(); } std::string prettyU256(u256 _n, bool _abridged) @@ -128,13 +65,5 @@ std::string prettyU256(u256 _n, bool _abridged) return s.str(); } -Address fromString(std::string const& _sn) -{ - if (_sn.size() == 40) - return Address(fromHex(_sn)); - else - return Address(); -} - } diff --git a/libethcore/CommonJS.h b/libethcore/CommonJS.h index abe74f0af..7d3071c68 100644 --- a/libethcore/CommonJS.h +++ b/libethcore/CommonJS.h @@ -24,124 +24,38 @@ #pragma once #include -#include -#include -#include -#include -#include "CommonEth.h" +#include +#include +#include "Common.h" + +// devcrypto namespace dev { -template std::string toJS(FixedHash const& _h) -{ - return "0x" + toHex(_h.ref()); -} +/// Strictly convert unprefixed hex string string to Address (h160). @returns empty address if (_a.size != 40). +Address toAddress(std::string const& _a); -template std::string toJS(boost::multiprecision::number> const& _n) -{ - return "0x" + toHex(toCompactBigEndian(_n)); -} +/// Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length. +inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } -inline std::string toJS(dev::bytes const& _n) -{ - return "0x" + dev::toHex(_n); -} +/// Leniently convert string to Secret (h256). Accepts integers, "0x" prefixing, non-exact length. +inline Secret jsToSecret(std::string const& _s) { return jsToFixed(_s); } + +/// Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length. +inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } -/// Convert string to byte array. Input parameters can be hex or dec. Returns empty array if invalid input e.g neither dec or hex. -bytes jsToBytes(std::string const& _s); -/// Add '0' on the head of @a _b until @a _l. -bytes padded(bytes _b, unsigned _l); -/// Add '0' on the queue of @a _b until @a _l. -bytes paddedRight(bytes _b, unsigned _l); -/// Removing all trailing '0'. Returns empty array if input contains only '0' char. -bytes unpadded(bytes _s); -/// Remove all 0 byte on the head of @a _s. -bytes unpadLeft(bytes _s); /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. std::string prettyU256(u256 _n, bool _abridged = true); -/// Convert h256 into user-readable string (by directly using std::string constructor). -std::string fromRaw(h256 _n, unsigned* _inc = nullptr); -/// Convert string to Address (h160), returns empty address if (_a.size != 40). -Address fromString(std::string const& _a); - -template FixedHash jsToFixed(std::string const& _s) -{ - if (_s.substr(0, 2) == "0x") - // Hex - return FixedHash(_s.substr(2 + std::max(N * 2, _s.size() - 2) - N * 2)); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return (typename FixedHash::Arith)(_s); - else - // Binary - return FixedHash(); // FAIL -} - -inline std::string jsToFixed(double _s) -{ - return toJS(dev::u256(_s * (double)(dev::u256(1) << 128))); -} - -template boost::multiprecision::number> jsToInt(std::string const& _s) -{ - if (_s.substr(0, 2) == "0x") - // Hex - return fromBigEndian>>(fromHex(_s.substr(2))); - else if (_s.find_first_not_of("0123456789") == std::string::npos) - // Decimal - return boost::multiprecision::number>(_s); - else - // Binary - return 0; // FAIL -} - -inline u256 jsToU256(std::string const& _s) { return jsToInt<32>(_s); } - -inline std::string jsToDecimal(std::string const& _s) -{ - return dev::toString(jsToU256(_s)); -} -inline std::string jsFromBinary(dev::bytes _s, unsigned _padding = 32) -{ - _s.resize(std::max(_s.size(), _padding)); - return "0x" + dev::toHex(_s); } -inline std::string jsFromBinary(std::string const& _s, unsigned _padding = 32) -{ - return jsFromBinary(asBytes(_s), _padding); -} - -inline double jsFromFixed(std::string const& _s) -{ - return (double)jsToU256(_s) / (double)(dev::u256(1) << 128); -} - -} - -// devcrypto - -#include - -namespace dev -{ - -inline Public jsToPublic(std::string const& _s) { return jsToFixed(_s); } -inline Secret jsToSecret(std::string const& _s) { return jsToFixed(_s); } - -} - - // ethcore namespace dev { namespace eth { -inline Address jsToAddress(std::string const& _s) { return jsToFixed(_s); } - struct TransactionSkeleton { bool creation = false; diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c4628f4aa..c489c8f4a 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 45667f44a..edf3d6b03 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,7 +22,7 @@ #pragma once #include -#include "CommonEth.h" +#include "Common.h" namespace dev { @@ -58,7 +58,7 @@ class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTr struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; struct InvalidSeedHash: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index fdf51f0d4..7006f6f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -27,7 +27,7 @@ #include #include #include -#include "CommonEth.h" +#include "Common.h" #include "BlockInfo.h" #define FAKE_DAGGER 1 diff --git a/libethereum/Account.cpp b/libethereum/Account.cpp index 74b6ebe7b..13eb0a8cd 100644 --- a/libethereum/Account.cpp +++ b/libethereum/Account.cpp @@ -20,7 +20,7 @@ */ #include "Account.h" -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/libethereum/AccountDiff.h b/libethereum/AccountDiff.h index 0c0ede4ae..dd494c0a5 100644 --- a/libethereum/AccountDiff.h +++ b/libethereum/AccountDiff.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace dev { diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 576deaadf..6d9e3f961 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "BlockDetails.h" diff --git a/libethereum/BlockQueue.h b/libethereum/BlockQueue.h index 210b9eeb0..5eefa9d8e 100644 --- a/libethereum/BlockQueue.h +++ b/libethereum/BlockQueue.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include namespace dev diff --git a/libethereum/CanonBlockChain.h b/libethereum/CanonBlockChain.h index d9739097a..7110dbc90 100644 --- a/libethereum/CanonBlockChain.h +++ b/libethereum/CanonBlockChain.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include "BlockDetails.h" diff --git a/libethereum/EthereumHost.h b/libethereum/EthereumHost.h index 0f06230ff..06575092c 100644 --- a/libethereum/EthereumHost.h +++ b/libethereum/EthereumHost.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include "CommonNet.h" #include "EthereumPeer.h" diff --git a/libethereum/EthereumPeer.h b/libethereum/EthereumPeer.h index 82adc4873..c95df6945 100644 --- a/libethereum/EthereumPeer.h +++ b/libethereum/EthereumPeer.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include "CommonNet.h" #include "DownloadMan.h" diff --git a/libethereum/Executive.h b/libethereum/Executive.h index bb5563604..2e89f0623 100644 --- a/libethereum/Executive.h +++ b/libethereum/Executive.h @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include "Transaction.h" diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index 2ff270de5..d63cd943a 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include "State.h" diff --git a/libethereum/LogFilter.h b/libethereum/LogFilter.h index 5f68cd5d0..7b8922a03 100644 --- a/libethereum/LogFilter.h +++ b/libethereum/LogFilter.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include "TransactionReceipt.h" namespace dev diff --git a/libethereum/Miner.h b/libethereum/Miner.h index 5914770d2..0c8eeb684 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "State.h" namespace dev diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 6e0d4756c..62d159418 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using namespace std; using namespace dev; diff --git a/libethereum/Transaction.h b/libethereum/Transaction.h index a9044970f..7dd28f7c6 100644 --- a/libethereum/Transaction.h +++ b/libethereum/Transaction.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace dev { diff --git a/libethereum/TransactionQueue.h b/libethereum/TransactionQueue.h index 22a420602..b58944e4f 100644 --- a/libethereum/TransactionQueue.h +++ b/libethereum/TransactionQueue.h @@ -23,7 +23,7 @@ #include #include -#include "libethcore/CommonEth.h" +#include "libethcore/Common.h" #include namespace dev diff --git a/libethereum/Utility.cpp b/libethereum/Utility.cpp index 31c5e278a..7b0a961b2 100644 --- a/libethereum/Utility.cpp +++ b/libethereum/Utility.cpp @@ -22,7 +22,7 @@ #include "Utility.h" #include -#include +#include #include using namespace std; using namespace dev; diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 8aacd7d83..4c6bcad0c 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace dev diff --git a/libevm/VM.h b/libevm/VM.h index f100badc4..f2c773e4b 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/mix/QEther.h b/mix/QEther.h index 794ba2ba1..f50c39e7c 100644 --- a/mix/QEther.h +++ b/mix/QEther.h @@ -23,7 +23,7 @@ #pragma once #include -#include +#include #include "QBigInt.h" namespace dev diff --git a/rlp/main.cpp b/rlp/main.cpp index c3c04535b..85c08e0e6 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -22,11 +22,9 @@ #include #include #include -#include #include #include #include -#include "base64.h" using namespace std; using namespace dev; @@ -218,7 +216,7 @@ int main(int argc, char** argv) boost::algorithm::replace_all(s, " ", ""); boost::algorithm::replace_all(s, "\n", ""); boost::algorithm::replace_all(s, "\t", ""); - b = base64_decode(s); + b = fromBase64(s); break; } default: @@ -228,60 +226,60 @@ int main(int argc, char** argv) try { - RLP rlp(b); - switch (mode) - { - case Mode::ListArchive: - { - if (!rlp.isList()) + RLP rlp(b); + switch (mode) { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); - } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ListArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; - } - break; - } - case Mode::ExtractArchive: - { - if (!rlp.isList()) - { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ExtractArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - ofstream fout; - fout.open(toString(sha3(i.data()))); - fout.write(reinterpret_cast(i.data().data()), i.data().size()); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; } - break; - } - case Mode::Render: - { - RLPStreamer s(cout, prefs); - s.output(rlp); - cout << endl; - break; - } - default:; - } } catch (...) { diff --git a/test/MemTrie.cpp b/test/MemTrie.cpp index c3a44e1e5..ab5a13b60 100644 --- a/test/MemTrie.cpp +++ b/test/MemTrie.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/TrieHash.cpp b/test/TrieHash.cpp index ee4f2e87d..ccf12c162 100644 --- a/test/TrieHash.cpp +++ b/test/TrieHash.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/test/commonjs.cpp b/test/commonjs.cpp index 041a14f68..72582c540 100644 --- a/test/commonjs.cpp +++ b/test/commonjs.cpp @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(jsToAddress) cnote << "Testing jsToPublic..."; KeyPair kp = KeyPair::create(); string string = toJS(kp.address()); - Address address = dev::eth::jsToAddress(string); + Address address = dev::jsToAddress(string); BOOST_CHECK_EQUAL(kp.address(), address); } diff --git a/third/MainWin.h b/third/MainWin.h index 513cfe96e..2f8f95f0e 100644 --- a/third/MainWin.h +++ b/third/MainWin.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include namespace Ui { From 5226fa880ba7ecba62f39f30674cc7d5633c48fb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 12:48:28 +0100 Subject: [PATCH 225/313] Make RLP JSON compatible by default. --- rlp/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 85c08e0e6..663bbf14d 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -36,6 +36,7 @@ void help() << " -r,--render Render the given RLP. Options:" << endl << " --indent Use string as the level indentation (default ' ')." << endl << " --hex-ints Render integers in hex." << endl + << " --ascii-strings Render data as C-style strings or hex depending on content being ASCII." << endl << " --force-string Force all data to be rendered as C-style strings." << endl << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl << " --force-hex Force all data to be rendered as raw hex." << endl @@ -86,7 +87,7 @@ public: { string indent = " "; bool hexInts = false; - bool forceString = false; + bool forceString = true; bool escapeAll = false; bool forceHex = false; }; @@ -150,6 +151,8 @@ int main(int argc, char** argv) prefs.indent = argv[++i]; else if (arg == "--hex-ints") prefs.hexInts = true; + else if (arg == "--ascii-strings") + prefs.forceString = prefs.forceHex = false; else if (arg == "--force-string") prefs.forceString = true; else if (arg == "--force-hex") From e36bb2726911eecbea3cbe1fcf332c117418b5fe Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 15:58:20 +0100 Subject: [PATCH 226/313] For Marek :) BlockChain::transaction(h256 _transactionHash) BlockChain::transactionHashes(h256 _blockHash) --- alethzero/MainWin.cpp | 5 +- libethcore/BlockInfo.h | 1 + libethcore/Ethasher.cpp | 115 +++++++++++++++++++++++++++++++++++++ libethcore/Ethasher.h | 97 +++++++++++++++++++++++++++++++ libethcore/ProofOfWork.cpp | 98 ++----------------------------- libethcore/ProofOfWork.h | 10 ---- libethereum/BlockChain.cpp | 6 ++ libethereum/BlockChain.h | 14 ++++- libethereum/BlockDetails.h | 14 +++++ test/dagger.cpp | 76 +++++++++++++++++------- 10 files changed, 308 insertions(+), 128 deletions(-) create mode 100644 libethcore/Ethasher.cpp create mode 100644 libethcore/Ethasher.h diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 30bbe8243..8c86cc4b7 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -40,6 +40,7 @@ #endif #include #include +#include #include #include #include @@ -1369,7 +1370,7 @@ void Main::on_blocks_currentItemChanged() s << "
Difficulty: " << info.difficulty << ""; if (info.number) { - auto e = ProofOfWork::eval(info); + auto e = Ethasher::eval(info); s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } else @@ -1393,7 +1394,7 @@ void Main::on_blocks_currentItemChanged() s << line << "Nonce: " << uncle.nonce << ""; s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; s << line << "Difficulty: " << uncle.difficulty << ""; - auto e = ProofOfWork::eval(uncle); + auto e = Ethasher::eval(uncle); s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index a119d92eb..95519b57d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -85,6 +85,7 @@ public: static h256 headerHash(bytes const& _block) { return headerHash(&_block); } static h256 headerHash(bytesConstRef _block); + static BlockInfo fromHeader(bytes const& _block) { return fromHeader(bytesConstRef(&_block)); } static BlockInfo fromHeader(bytesConstRef _block); explicit operator bool() const { return timestamp != Invalid256; } diff --git a/libethcore/Ethasher.cpp b/libethcore/Ethasher.cpp new file mode 100644 index 000000000..a28895a1a --- /dev/null +++ b/libethcore/Ethasher.cpp @@ -0,0 +1,115 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file Ethasher.cpp + * @author Gav Wood + * @date 2014 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "BlockInfo.h" +#include "Ethasher.h" +using namespace std; +using namespace chrono; +using namespace dev; +using namespace eth; + +Ethasher* dev::eth::Ethasher::s_this = nullptr; + +bytes const& Ethasher::cache(BlockInfo const& _header) +{ + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; +} + +bytesConstRef Ethasher::full(BlockInfo const& _header) +{ + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash]; +} + +ethash_params Ethasher::params(BlockInfo const& _header) +{ + return params((unsigned)_header.number); +} + +ethash_params Ethasher::params(unsigned _n) +{ + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; +} + +bool Ethasher::verify(BlockInfo const& _header) +{ + bigint boundary = (bigint(1) << 256) / _header.difficulty; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; +} + +Ethasher::Result Ethasher::eval(BlockInfo const& _header, Nonce const& _nonce) +{ + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; +} + diff --git a/libethcore/Ethasher.h b/libethcore/Ethasher.h new file mode 100644 index 000000000..cfe0d1c82 --- /dev/null +++ b/libethcore/Ethasher.h @@ -0,0 +1,97 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file Ethasher.h + * @author Gav Wood + * @date 2014 + * + * ProofOfWork algorithm. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include // TODO: REMOVE once everything merged into this class and an opaque API can be provided. +#include "Common.h" +#include "BlockInfo.h" + +namespace dev +{ +namespace eth +{ + +class Ethasher +{ +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header); + bytesConstRef full(BlockInfo const& _header); + static ethash_params params(BlockInfo const& _header); + static ethash_params params(unsigned _n); + + struct Result + { + h256 value; + h256 mixHash; + }; + + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); + static bool verify(BlockInfo const& _header); + + class Miner + { + public: + Miner(BlockInfo const& _header): + m_headerHash(_header.headerHash(WithoutNonce)), + m_params(Ethasher::params(_header)), + m_datasetPointer(Ethasher::get()->full(_header).data()) + {} + + inline h256 mine(uint64_t _nonce) + { + ethash_compute_full(&m_ethashReturn, m_datasetPointer, &m_params, m_headerHash.data(), _nonce); + return h256(m_ethashReturn.result, h256::ConstructFromPointer); + } + + inline h256 lastMixHash() const + { + return h256(m_ethashReturn.mix_hash, h256::ConstructFromPointer); + } + + private: + ethash_return_value m_ethashReturn; + h256 m_headerHash; + ethash_params m_params; + void const* m_datasetPointer; + }; + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; + +} +} diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..d261ccb1c 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -30,8 +30,8 @@ #include #include #include -#include #include "BlockInfo.h" +#include "Ethasher.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -41,100 +41,14 @@ namespace dev namespace eth { -class Ethasher -{ -public: - Ethasher() {} - - static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } - - bytes const& cache(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_caches.count(_header.seedHash)) - { - try { - boost::filesystem::create_directories(getDataDir() + "/ethashcache"); - } catch (...) {} - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; - m_caches[_header.seedHash] = contents(memoFile); - if (m_caches[_header.seedHash].empty()) - { - ethash_params p = params((unsigned)_header.number); - m_caches[_header.seedHash].resize(p.cache_size); - ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); - writeFile(memoFile, m_caches[_header.seedHash]); - } - } - return m_caches[_header.seedHash]; - } - - byte const* full(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_fulls.count(_header.seedHash)) - { - if (!m_fulls.empty()) - { - delete [] m_fulls.begin()->second.data(); - m_fulls.erase(m_fulls.begin()); - } - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; - m_fulls[_header.seedHash] = contentsNew(memoFile); - if (!m_fulls[_header.seedHash]) - { - ethash_params p = params((unsigned)_header.number); - m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); - auto c = cache(_header); - ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); - writeFile(memoFile, m_fulls[_header.seedHash]); - } - } - return m_fulls[_header.seedHash].data(); - } - - static ethash_params params(BlockInfo const& _header) - { - return params((unsigned)_header.number); - } - - static ethash_params params(unsigned _n) - { - ethash_params p; - p.cache_size = ethash_get_cachesize(_n); - p.full_size = ethash_get_datasize(_n); - return p; - } - -private: - static Ethasher* s_this; - RecursiveMutex x_this; - std::map m_caches; - std::map m_fulls; -}; - -Ethasher* Ethasher::s_this = nullptr; - bool Ethash::verify(BlockInfo const& _header) { - bigint boundary = (bigint(1) << 256) / _header.difficulty; - auto e = eval(_header, _header.nonce); - return (u256)e.value <= boundary && e.mixHash == _header.mixHash; -} - -Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) -{ - auto p = Ethasher::params(_header); - ethash_return_value r; - ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; + return Ethasher::verify(_header); } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - auto h = _header.headerHash(WithoutNonce); - auto p = Ethasher::params(_header); - auto d = Ethasher::get()->full(_header); + Ethasher::Miner m(_header); std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); @@ -152,17 +66,15 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) Proof result; - ethash_return_value ethashReturn; unsigned hashCount = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); - u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + u256 val(m.mine(tryNonce)); best = std::min(best, log2((double)val)); if (val <= boundary) { ret.first.completed = true; - result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); + result.mixHash = m.lastMixHash(); result.nonce = u64(tryNonce); break; } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7006f6f61..250ddb73d 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -49,20 +49,12 @@ struct MineInfo class Ethash { public: - // bit-compatible with ethash_return_value struct Proof { Nonce nonce; h256 mixHash; }; - struct Result - { - h256 value; - h256 mixHash; - }; - static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } @@ -78,9 +70,7 @@ public: using Proof = Nonce; static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } - inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } protected: diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index b1727ae1c..ac88e7cdf 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -308,7 +308,13 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); #if ETH_PARANOIA checkConsistency(); diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 6d9e3f961..cd3053c63 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -34,6 +34,7 @@ #include #include "BlockDetails.h" #include "Account.h" +#include "Transaction.h" #include "BlockQueue.h" namespace ldb = leveldb; @@ -61,6 +62,8 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using TransactionHashes = h256s; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -108,12 +111,19 @@ public: BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } BlockReceipts receipts() const { return receipts(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } + TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. bytes block(h256 _hash) const; bytes block() const { return block(currentHash()); } + /// Get a transaction from its hash. Thread-safe. + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. - bytes transaction(h256 _hash, unsigned _i) const { bytes b = block(_hash); return RLP(b)[1][_i].data().toBytes(); } + bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } bytes transaction(unsigned _i) const { return transaction(currentHash(), _i); } /// Get a number for the given hash (or the most recent mined if none given). Thread-safe. @@ -185,6 +195,8 @@ private: mutable BlockLogBloomsHash m_logBlooms; mutable boost::shared_mutex x_receipts; mutable BlockReceiptsHash m_receipts; + mutable boost::shared_mutex x_transactionAddresses; + mutable TransactionAddressHash m_transactionAddresses; mutable boost::shared_mutex x_cache; mutable std::map m_cache; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 9a3ac9ff1..b59d165ab 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -70,13 +70,27 @@ struct BlockReceipts TransactionReceipts receipts; }; +struct TransactionAddress +{ + TransactionAddress() {} + TransactionAddress(RLP const& _rlp) { blockHash = _rlp[0].toHash(); index = _rlp[1].toInt(); } + bytes rlp() const { RLPStream s(2); s << blockHash << index; return s.out(); } + + explicit operator bool() const { return !!blockHash; } + + h256 blockHash; + unsigned index = 0; +}; + using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; +using TransactionAddressHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; +static const TransactionAddress NullTransactionAddress; } } diff --git a/test/dagger.cpp b/test/dagger.cpp index 87c49bd7d..dec753fe7 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -17,37 +17,69 @@ /** @file dagger.cpp * @author Gav Wood * @date 2014 - * ProofOfWork test functions. + * Dashimoto test functions. */ -#include -#include +#include +#include +#include "JsonSpiritHeaders.h" +#include #include +#include +#include +#include "TestHelper.h" + using namespace std; -using namespace std::chrono; using namespace dev; using namespace dev::eth; -int daggerTest() +namespace js = json_spirit; + +using dev::operator <<; + +BOOST_AUTO_TEST_SUITE(DashimotoTests) + +BOOST_AUTO_TEST_CASE(basic_test) { -#if 0 - cnote << "Testing ProofOfWork..."; - // Test dagger - { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + string testPath = test::getTestPath(); + + testPath += "/PoWTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/ethash_tests.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'ethash_tests.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + BlockInfo header = BlockInfo::fromHeader(fromHex(o["header"].get_str())); + 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); + + unsigned cacheSize(o["cache_size"].get_int()); + h256 cacheHash(o["cache_hash"].get_str()); + BOOST_REQUIRE_EQUAL(Ethasher::get()->cache(header).size(), cacheSize); + BOOST_REQUIRE_EQUAL(sha3(Ethasher::get()->cache(header)), cacheHash); + +#if TEST_FULL + unsigned fullSize(o["full_size"].get_int()); + h256 fullHash(o["full_hash"].get_str()); + BOOST_REQUIRE_EQUAL(Ethasher::get()->full(header).size(), fullSize); + BOOST_REQUIRE_EQUAL(sha3(Ethasher::get()->full(header)), fullHash); #endif - return 0; + + h256 result(o["result"].get_str()); + Ethasher::Result r = Ethasher::eval(header); + BOOST_REQUIRE_EQUAL(r.value, result); + BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash); + } } +BOOST_AUTO_TEST_SUITE_END() + + From 08f27a3bbd8aa264be49399a40dc91666f70b383 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 19:38:31 +0100 Subject: [PATCH 227/313] Fast block hash from number. --- libethcore/Common.cpp | 9 +++-- libethereum/BlockChain.cpp | 79 ++++++++++++++++++++------------------ libethereum/BlockChain.h | 54 +++++++++++++++++++------- libethereum/BlockDetails.h | 11 ++++++ libethereum/Client.cpp | 11 +++++- libethereum/Client.h | 1 + libethereum/Miner.h | 3 ++ 7 files changed, 112 insertions(+), 56 deletions(-) diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 65c0b8b92..9eb622fe3 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,13 +33,14 @@ namespace eth { const unsigned c_protocolVersion = 56; -const unsigned c_databaseVersion = 6 + +const unsigned c_databaseBaseVersion = 7; #if ETH_FATDB - 1000 +const unsigned c_databaseVersionModifier = 1000; #else - 0 +const unsigned c_databaseVersionModifier = 0; #endif -; + +const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier; vector> const& units() { diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index ac88e7cdf..10f44576b 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -46,7 +46,7 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_db->NewIterator(_bc.m_readOptions); + auto it = _bc.m_blocksDB->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { @@ -103,9 +103,9 @@ void BlockChain::open(std::string _path, bool _killExisting) ldb::Options o; o.create_if_missing = true; - ldb::DB::Open(o, _path + "/blocks", &m_db); + ldb::DB::Open(o, _path + "/blocks", &m_blocksDB); ldb::DB::Open(o, _path + "/details", &m_extrasDB); - if (!m_db) + if (!m_blocksDB) BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); if (!m_extrasDB) BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); @@ -133,10 +133,10 @@ void BlockChain::close() { cnote << "Closing blockchain DB"; delete m_extrasDB; - delete m_db; + delete m_blocksDB; m_lastBlockHash = m_genesisHash; m_details.clear(); - m_cache.clear(); + m_blocks.clear(); } template @@ -295,6 +295,23 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_details[newHash] = BlockDetails((unsigned)pd.number + 1, td, bi.parentHash, {}); m_details[bi.parentHash].children.push_back(newHash); } + { + WriteGuard l(x_blockHashes); + m_blockHashes[h256(bi.number)].value = newHash; + } + // Collate transaction hashes and remember who they were. + h256s tas; + { + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + WriteGuard l(x_transactionAddresses); + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + { + tas.push_back(sha3(blockRLP[1][ta.index].data())); + m_transactionAddresses[tas.back()] = ta; + } + } { WriteGuard l(x_logBlooms); m_logBlooms[newHash] = blb; @@ -304,17 +321,14 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_receipts[newHash] = br; } - m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)dev::ref(m_details[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); - RLP blockRLP(_block); - TransactionAddress ta; - ta.blockHash = newHash; - for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) - m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); + m_blocksDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(h256(bi.number), ExtraBlockHash), (ldb::Slice)dev::ref(m_blockHashes[h256(bi.number)].rlp())); + for (auto const& h: tas) + m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraTransactionAddress), (ldb::Slice)dev::ref(m_transactionAddresses[h].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraLogBlooms), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraReceipts), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); #if ETH_PARANOIA checkConsistency(); @@ -420,7 +434,7 @@ void BlockChain::checkConsistency() WriteGuard l(x_details); m_details.clear(); } - ldb::Iterator* it = m_db->NewIterator(m_readOptions); + ldb::Iterator* it = m_blocksDB->NewIterator(m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().size() == 32) { @@ -463,12 +477,12 @@ bool BlockChain::isKnown(h256 _hash) const if (_hash == m_genesisHash) return true; { - ReadGuard l(x_cache); - if (m_cache.count(_hash)) + ReadGuard l(x_blocks); + if (m_blocks.count(_hash)) return true; } string d; - m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); + m_blocksDB->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); return !!d.size(); } @@ -478,14 +492,14 @@ bytes BlockChain::block(h256 _hash) const return m_genesisBlock; { - ReadGuard l(x_cache); - auto it = m_cache.find(_hash); - if (it != m_cache.end()) + ReadGuard l(x_blocks); + auto it = m_blocks.find(_hash); + if (it != m_blocks.end()) return it->second; } string d; - m_db->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); + m_blocksDB->Get(m_readOptions, ldb::Slice((char const*)&_hash, 32), &d); if (!d.size()) { @@ -493,18 +507,9 @@ bytes BlockChain::block(h256 _hash) const return bytes(); } - WriteGuard l(x_cache); - m_cache[_hash].resize(d.size()); - memcpy(m_cache[_hash].data(), d.data(), d.size()); - - return m_cache[_hash]; -} + WriteGuard l(x_blocks); + m_blocks[_hash].resize(d.size()); + memcpy(m_blocks[_hash].data(), d.data(), d.size()); -h256 BlockChain::numberHash(unsigned _n) const -{ - if (!_n) - return genesisHash(); - h256 ret = currentHash(); - for (; _n < details().number; ++_n, ret = details(ret).parent) {} - return ret; + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index cd3053c63..62a5bf792 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -62,8 +62,17 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using BlocksHash = std::map; using TransactionHashes = h256s; +enum { + ExtraDetails = 0, + ExtraBlockHash, + ExtraTransactionAddress, + ExtraLogBlooms, + ExtraReceipts +}; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -99,28 +108,31 @@ public: BlockInfo info(h256 _hash) const { return BlockInfo(block(_hash)); } BlockInfo info() const { return BlockInfo(block()); } - /// Get the familiar details concerning a block (or the most recent mined if none given). Thread-safe. - BlockDetails details(h256 _hash) const { return queryExtras(_hash, m_details, x_details, NullBlockDetails); } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. + bytes block(h256 _hash) const; + bytes block() const { return block(currentHash()); } + + /// Get the familial details concerning a block (or the most recent mined if none given). Thread-safe. + BlockDetails details(h256 _hash) const { return queryExtras(_hash, m_details, x_details, NullBlockDetails); } BlockDetails details() const { return details(currentHash()); } /// Get the transactions' log blooms of a block (or the most recent mined if none given). Thread-safe. - BlockLogBlooms logBlooms(h256 _hash) const { return queryExtras(_hash, m_logBlooms, x_logBlooms, NullBlockLogBlooms); } + BlockLogBlooms logBlooms(h256 _hash) const { return queryExtras(_hash, m_logBlooms, x_logBlooms, NullBlockLogBlooms); } BlockLogBlooms logBlooms() const { return logBlooms(currentHash()); } /// Get the transactions' receipts of a block (or the most recent mined if none given). Thread-safe. - BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } + BlockReceipts receipts(h256 _hash) const { return queryExtras(_hash, m_receipts, x_receipts, NullBlockReceipts); } BlockReceipts receipts() const { return receipts(currentHash()); } /// Get a list of transaction hashes for a given block. Thread-safe. TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } - /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. - bytes block(h256 _hash) const; - bytes block() const { return block(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + h256 numberHash(u256 _index) const { if (!_index) return genesisHash(); return queryExtras(h256(_index), m_blockHashes, x_blockHashes, NullBlockHash).value; } /// Get a transaction from its hash. Thread-safe. - bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } @@ -136,9 +148,6 @@ public: /// Get the hash of the genesis block. Thread-safe. h256 genesisHash() const { return m_genesisHash; } - /// Get the hash of a block of a given number. Slow; try not to use it too much. - h256 numberHash(unsigned _n) const; - /// Get all blocks not allowed as uncles given a parent (i.e. featured as uncles/main in parent, parent + 1, ... parent + 5). /// @returns set including the header-hash of every parent (including @a _parent) up to and including generation +5 /// togther with all their quoted uncles. @@ -160,6 +169,21 @@ public: */ h256s treeRoute(h256 _from, h256 _to, h256* o_common = nullptr, bool _pre = true, bool _post = true) const; + struct Statistics + { + unsigned memDetails; + unsigned memLogBlooms; + unsigned memReceipts; + unsigned memTransactionAddresses; + unsigned memCache; + }; + + /// @returns statistics about memory usage. + Statistics usage() const; + + /// Deallocate unused data. + void garbageCollect(); + private: void open(std::string _path, bool _killExisting = false); void close(); @@ -189,6 +213,8 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. + mutable boost::shared_mutex x_blocks; + mutable BlocksHash m_blocks; mutable boost::shared_mutex x_details; mutable BlockDetailsHash m_details; mutable boost::shared_mutex x_logBlooms; @@ -197,11 +223,11 @@ private: mutable BlockReceiptsHash m_receipts; mutable boost::shared_mutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_cache; - mutable std::map m_cache; + mutable boost::shared_mutex x_blockHashes; + mutable BlockHashHash m_blockHashes; /// The disk DBs. Thread-safe, so no need for locks. - ldb::DB* m_db; + ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; /// Hash of the last (valid) block on the longest chain. diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index b59d165ab..f9bccea1e 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -70,6 +70,15 @@ struct BlockReceipts TransactionReceipts receipts; }; +struct BlockHash +{ + BlockHash() {} + BlockHash(RLP const& _r) { value = _r.toHash(); } + bytes rlp() const { return dev::rlp(value); } + + h256 value; +}; + struct TransactionAddress { TransactionAddress() {} @@ -86,11 +95,13 @@ using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; using TransactionAddressHash = std::map; +using BlockHashHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; static const TransactionAddress NullTransactionAddress; +static const BlockHash NullBlockHash; } } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 2db673d90..827346c95 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -521,9 +521,18 @@ void Client::doWork() { if (m.isComplete()) { - cwork << "CHAIN <== postSTATE"; + // TODO: enable a short-circuit option since we mined it. will need to get the end state from the miner. + auto lm = dynamic_cast(&m); h256s hs; + if (false && lm && !m_verifyOwnBlocks) { + // TODO: implement + //m_bc.attemptImport(m_blockData(), m_stateDB, lm->state()); + // TODO: derive hs from lm->state() + } + else + { + cwork << "CHAIN <== postSTATE"; WriteGuard l(x_stateDB); hs = m_bc.attemptImport(m.blockData(), m_stateDB); } diff --git a/libethereum/Client.h b/libethereum/Client.h index 900d339ad..9fad6dc22 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -368,6 +368,7 @@ private: bool m_paranoia = false; ///< Should we be paranoid about our state? bool m_turboMining = false; ///< Don't squander all of our time mining actually just sleeping. bool m_forceMining = false; ///< Mine even when there are no transactions pending? + bool m_verifyOwnBlocks = true; ///< Shoudl be verify blocks that we mined? mutable Mutex m_filterLock; std::map m_filters; diff --git a/libethereum/Miner.h b/libethereum/Miner.h index 0c8eeb684..e472c6f64 100644 --- a/libethereum/Miner.h +++ b/libethereum/Miner.h @@ -131,6 +131,9 @@ public: /// Get and clear the mining history. std::list miningHistory() { Guard l(x_mineInfo); auto ret = m_mineHistory; m_mineHistory.clear(); return ret; } + /// @returns the state on which we mined. + State const& state() const { return m_mineState; } + private: /// Do some work on the mining. virtual void doWork(); From 0a5869739bef3bc51888b264e91412122aea43b7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 21:19:21 +0100 Subject: [PATCH 228/313] Caching. --- alethzero/Main.ui | 7 ++ alethzero/MainWin.cpp | 8 +++ alethzero/MainWin.h | 1 + libethereum/BlockChain.cpp | 124 +++++++++++++++++++++++++++++++++++ libethereum/BlockChain.h | 34 +++++++--- libethereum/BlockDetails.cpp | 5 +- libethereum/BlockDetails.h | 17 +++-- libethereum/Client.cpp | 1 + 8 files changed, 181 insertions(+), 16 deletions(-) diff --git a/alethzero/Main.ui b/alethzero/Main.ui index 9025aa846..8f6597ca5 100644 --- a/alethzero/Main.ui +++ b/alethzero/Main.ui @@ -38,6 +38,13 @@ + + + + 0 bytes used + + + diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 8c86cc4b7..fc230f034 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -141,6 +141,7 @@ Main::Main(QWidget *parent) : ui->configDock->close(); on_verbosity_valueChanged(); + statusBar()->addPermanentWidget(ui->cacheUsage); statusBar()->addPermanentWidget(ui->balance); statusBar()->addPermanentWidget(ui->peerCount); statusBar()->addPermanentWidget(ui->mineStatus); @@ -1144,6 +1145,12 @@ void Main::on_refresh_triggered() refreshAll(); } +void Main::refreshCache() +{ + BlockChain::Statistics s = ethereum()->blockChain().usage(); + ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); +} + void Main::timerEvent(QTimerEvent*) { // 7/18, Alex: aggregating timers, prelude to better threading? @@ -1172,6 +1179,7 @@ void Main::timerEvent(QTimerEvent*) interval = 0; refreshNetwork(); refreshWhispers(); + refreshCache(); poll(); } else diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index b6a04ca6d..cc867f06b 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -212,6 +212,7 @@ private: void refreshNetwork(); void refreshMining(); void refreshWhispers(); + void refreshCache(); void refreshAll(); void refreshPending(); diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 10f44576b..4415120c4 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -76,8 +76,33 @@ ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub) #endif } +#if ETH_DEBUG +static const chrono::system_clock::duration c_collectionDuration = chrono::seconds(15); +static const unsigned c_collectionQueueSize = 2; +static const unsigned c_maxCacheSize = 1024 * 1024 * 1; +static const unsigned c_minCacheSize = 1; +#else + +/// Duration between flushes. +static const chrono::system_clock::duration c_collectionDuration = chrono::seconds(60); + +/// Length of death row (total time in cache is multiple of this and collection duration). +static const unsigned c_collectionQueueSize = 20; + +/// Max size, above which we start forcing cache reduction. +static const unsigned c_maxCacheSize = 1024 * 1024 * 64; + +/// Min size, below which we don't bother flushing it. +static const unsigned c_minCacheSize = 1024 * 1024 * 32; + +#endif + BlockChain::BlockChain(bytes const& _genesisBlock, std::string _path, bool _killExisting) { + // initialise deathrow. + m_cacheUsage.resize(c_collectionQueueSize); + m_lastCollection = chrono::system_clock::now(); + // Initialise with the genesis as the last block on the longest chain. m_genesisBlock = _genesisBlock; m_genesisHash = sha3(RLP(m_genesisBlock)[0].data()); @@ -428,6 +453,103 @@ h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, boo return ret; } +void BlockChain::noteUsed(h256 const& _h, unsigned _extra) const +{ + auto id = CacheID(_h, _extra); + Guard l(x_cacheUsage); + m_cacheUsage[0].insert(id); + if (m_cacheUsage[1].count(id)) + m_cacheUsage[1].erase(id); + else + m_inUse.insert(id); +} + +template static unsigned getHashSize(map const& _map) +{ + unsigned ret = 0; + for (auto const& i: _map) + ret += i.second.size + 64; + return ret; +} + +void BlockChain::updateStats() const +{ + { + ReadGuard l1(x_blocks); + m_lastStats.memBlocks = 0; + for (auto const& i: m_blocks) + m_lastStats.memBlocks += i.second.size() + 64; + } + { + ReadGuard l2(x_details); + m_lastStats.memDetails = getHashSize(m_details); + } + { + ReadGuard l5(x_logBlooms); + m_lastStats.memLogBlooms = getHashSize(m_logBlooms); + } + { + ReadGuard l4(x_receipts); + m_lastStats.memReceipts = getHashSize(m_receipts); + } + { + ReadGuard l3(x_blockHashes); + m_lastStats.memBlockHashes = getHashSize(m_blockHashes); + } + { + ReadGuard l6(x_transactionAddresses); + m_lastStats.memTransactionAddresses = getHashSize(m_transactionAddresses); + } +} + +void BlockChain::garbageCollect(bool _force) +{ + updateStats(); + + if (!_force && chrono::system_clock::now() < m_lastCollection + c_collectionDuration && m_lastStats.memTotal() < c_maxCacheSize) + return; + if (m_lastStats.memTotal() < c_minCacheSize) + return; + + m_lastCollection = chrono::system_clock::now(); + + Guard l(x_cacheUsage); + WriteGuard l1(x_blocks); + WriteGuard l2(x_details); + WriteGuard l3(x_blockHashes); + WriteGuard l4(x_receipts); + WriteGuard l5(x_logBlooms); + WriteGuard l6(x_transactionAddresses); + for (CacheID const& id: m_cacheUsage.back()) + { + m_inUse.erase(id); + // kill i from cache. + switch (id.second) + { + case (unsigned)-1: + m_blocks.erase(id.first); + break; + case ExtraDetails: + m_details.erase(id.first); + break; + case ExtraBlockHash: + m_blockHashes.erase(id.first); + break; + case ExtraReceipts: + m_receipts.erase(id.first); + break; + case ExtraLogBlooms: + m_logBlooms.erase(id.first); + break; + case ExtraTransactionAddress: + m_transactionAddresses.erase(id.first); + break; + } + } + m_cacheUsage.pop_back(); + m_cacheUsage.push_front({}); +} + void BlockChain::checkConsistency() { { @@ -511,5 +633,7 @@ bytes BlockChain::block(h256 _hash) const m_blocks[_hash].resize(d.size()); memcpy(m_blocks[_hash].data(), d.data(), d.size()); + noteUsed(_hash); + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 62a5bf792..20c41b553 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -26,7 +26,7 @@ #include #pragma warning(pop) -#include +#include #include #include #include @@ -171,18 +171,20 @@ public: struct Statistics { + unsigned memBlocks; unsigned memDetails; unsigned memLogBlooms; unsigned memReceipts; unsigned memTransactionAddresses; - unsigned memCache; + unsigned memBlockHashes; + unsigned memTotal() const { return memBlocks + memDetails + memLogBlooms + memReceipts + memTransactionAddresses + memBlockHashes; } }; /// @returns statistics about memory usage. - Statistics usage() const; + Statistics usage(bool _freshen = false) const { if (_freshen) updateStats(); return m_lastStats; } /// Deallocate unused data. - void garbageCollect(); + void garbageCollect(bool _force = false); private: void open(std::string _path, bool _killExisting = false); @@ -205,6 +207,8 @@ private: return _n; } + noteUsed(_h, N); + WriteGuard l(_x); auto ret = _m.insert(std::make_pair(_h, T(RLP(s)))); return ret.first->second; @@ -213,19 +217,29 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. - mutable boost::shared_mutex x_blocks; + mutable SharedMutex x_blocks; mutable BlocksHash m_blocks; - mutable boost::shared_mutex x_details; + mutable SharedMutex x_details; mutable BlockDetailsHash m_details; - mutable boost::shared_mutex x_logBlooms; + mutable SharedMutex x_logBlooms; mutable BlockLogBloomsHash m_logBlooms; - mutable boost::shared_mutex x_receipts; + mutable SharedMutex x_receipts; mutable BlockReceiptsHash m_receipts; - mutable boost::shared_mutex x_transactionAddresses; + mutable SharedMutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_blockHashes; + mutable SharedMutex x_blockHashes; mutable BlockHashHash m_blockHashes; + using CacheID = std::pair; + mutable Mutex x_cacheUsage; + mutable std::deque> m_cacheUsage; + mutable std::set m_inUse; + void noteUsed(h256 const& _h, unsigned _extra = (unsigned)-1) const; + std::chrono::system_clock::time_point m_lastCollection; + + void updateStats() const; + mutable Statistics m_lastStats; + /// The disk DBs. Thread-safe, so no need for locks. ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; diff --git a/libethereum/BlockDetails.cpp b/libethereum/BlockDetails.cpp index 58f37b7aa..c15939fdb 100644 --- a/libethereum/BlockDetails.cpp +++ b/libethereum/BlockDetails.cpp @@ -32,9 +32,12 @@ BlockDetails::BlockDetails(RLP const& _r) totalDifficulty = _r[1].toInt(); parent = _r[2].toHash(); children = _r[3].toVector(); + size = _r.size(); } bytes BlockDetails::rlp() const { - return rlpList(number, totalDifficulty, parent, children); + auto ret = rlpList(number, totalDifficulty, parent, children); + size = ret.size(); + return ret; } diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index f9bccea1e..ed478568d 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -46,28 +46,32 @@ struct BlockDetails bool isNull() const { return !totalDifficulty; } explicit operator bool() const { return !isNull(); } - unsigned number; // TODO: remove? + unsigned number; u256 totalDifficulty; h256 parent; h256s children; + + mutable unsigned size; }; struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } - bytes rlp() const { RLPStream s; s << blooms; return s.out(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); size = _r.data().size(); } + bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } LogBlooms blooms; + mutable unsigned size; }; struct BlockReceipts { BlockReceipts() {} - BlockReceipts(RLP const& _r) { for (auto const& i: _r) receipts.emplace_back(i.data()); } - bytes rlp() const { RLPStream s(receipts.size()); for (TransactionReceipt const& i: receipts) i.streamRLP(s); return s.out(); } + BlockReceipts(RLP const& _r) { for (auto const& i: _r) receipts.emplace_back(i.data()); size = _r.data().size(); } + bytes rlp() const { RLPStream s(receipts.size()); for (TransactionReceipt const& i: receipts) i.streamRLP(s); size = s.out().size(); return s.out(); } TransactionReceipts receipts; + mutable unsigned size; }; struct BlockHash @@ -77,6 +81,7 @@ struct BlockHash bytes rlp() const { return dev::rlp(value); } h256 value; + static const unsigned size = 65; }; struct TransactionAddress @@ -89,6 +94,8 @@ struct TransactionAddress h256 blockHash; unsigned index = 0; + + static const unsigned size = 67; }; using BlockDetailsHash = std::map; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 827346c95..38d2f16ea 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -635,6 +635,7 @@ void Client::doWork() uninstallWatch(i); m_lastGarbageCollection = chrono::system_clock::now(); } + m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From e3381fbe3fb6f2e51fd255f42e415e4d26acea3d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 22:42:34 +0100 Subject: [PATCH 229/313] Cache reporting in AZ. --- alethzero/MainWin.cpp | 34 +++++++++++++++++++++++++++++++++- libethereum/Client.cpp | 7 +++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index fc230f034..b79bc6e83 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1145,10 +1145,42 @@ void Main::on_refresh_triggered() refreshAll(); } +static std::string niceUsed(unsigned _n) +{ + static const vector c_units = { "bytes", "KB", "MB", "GB", "TB", "PB" }; + unsigned u = 0; + while (_n > 10240) + { + _n /= 1024; + u++; + } + if (_n > 1000) + return toString(_n / 1000) + "." + toString((min(949, _n % 1000) + 50) / 100) + " " + c_units[u + 1]; + else + return toString(_n) + " " + c_units[u]; +} + void Main::refreshCache() { BlockChain::Statistics s = ethereum()->blockChain().usage(); - ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); + QString t; + auto f = [&](unsigned n, QString l) + { + t += ("%1 " + l).arg(QString::fromStdString(niceUsed(n))); + }; + f(s.memTotal(), "total"); + t += " ("; + f(s.memBlocks, "blocks"); + t += ", "; + f(s.memReceipts, "receipts"); + t += ", "; + f(s.memLogBlooms, "blooms"); + t += ", "; + f(s.memBlockHashes + s.memTransactionAddresses, "hashes"); + t += ", "; + f(s.memDetails, "family"); + t += ")"; + ui->cacheUsage->setText(t); } void Main::timerEvent(QTimerEvent*) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 38d2f16ea..b5355f1e0 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -620,7 +620,7 @@ void Client::doWork() this_thread::sleep_for(chrono::milliseconds(100)); if (chrono::system_clock::now() - m_lastGarbageCollection > chrono::seconds(5)) { - // garbage collect on watches + // watches garbage collection vector toUninstall; { Guard l(m_filterLock); @@ -633,9 +633,12 @@ void Client::doWork() } for (auto i: toUninstall) uninstallWatch(i); + + // blockchain GC + m_bc.garbageCollect(); + m_lastGarbageCollection = chrono::system_clock::now(); } - m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From 6ec4881934caa80e1918b57519b30bd21cff7794 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:11:24 +0100 Subject: [PATCH 230/313] add quadratic complexity tests --- test/state.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 6ac23c14d..5202aff22 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -170,23 +170,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -//{ -// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) -// { -// string arg = boost::unit_test::framework::master_test_suite().argv[i]; -// if (arg == "--quadratic" || arg == "--all") -// { -// auto start = chrono::steady_clock::now(); - -// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - -// auto end = chrono::steady_clock::now(); -// auto duration(chrono::duration_cast(end - start)); -// cnote << "test duration: " << duration.count() << " milliseconds.\n"; -// } -// } -//} +BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { From 24af87f7643437f6779f618b949da392606ee157 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:12:51 +0100 Subject: [PATCH 231/313] add uncle header feature for fillers --- test/blockchain.cpp | 282 ++++++++++++++++++++++++++++---------------- 1 file changed, 182 insertions(+), 100 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 55c39f56b..a23a756b1 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -33,8 +33,10 @@ namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - - +BlockInfo constructBlock(mObject& _o); +void updatePoW(BlockInfo& _bi); +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); +RLPStream createFullBlockFromHeader(const BlockInfo& _bi, const bytes& _txs = RLPEmptyList, const bytes& _uncles = RLPEmptyList); void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -44,86 +46,47 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } + BlockInfo biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj()); BOOST_REQUIRE(o.count("pre")); - ImportTest importer(o["pre"].get_obj()); State state(Address(), OverlayDB(), BaseState::Empty); importer.importState(o["pre"].get_obj(), state); state.commit(); if (_fillin) - blockFromFields.stateRoot = state.rootHash(); + biGenesisBlock.stateRoot = state.rootHash(); else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + BOOST_CHECK_MESSAGE(biGenesisBlock.stateRoot == state.rootHash(), "root hash does not match"); if (_fillin) { // find new valid nonce - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(blockFromFields)) - { - ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, blockFromFields); - } + updatePoW(biGenesisBlock); //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); - o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); + writeBlockHeaderToJson(o["genesisBlockHeader"].get_obj(), biGenesisBlock); } // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); + RLPStream rlpGenesisBlock = createFullBlockFromHeader(biGenesisBlock); + biGenesisBlock.verifyInternals(&rlpGenesisBlock.out()); // construct blockchain - BlockChain bc(block.out(), string(), true); + BlockChain bc(rlpGenesisBlock.out(), string(), true); if (_fillin) { BOOST_REQUIRE(o.count("blocks")); mArray blArray; + vector vBiBlocks; for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); - BOOST_REQUIRE(blObj.count("transactions")); + // get txs TransactionQueue txs; - + BOOST_REQUIRE(blObj.count("transactions")); for (auto const& txObj: blObj["transactions"].get_array()) { mObject tx = txObj.get_obj(); @@ -132,6 +95,35 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "failed importing transaction\n"; } + // write uncle list + BlockQueue uncleBlockQueue; + mArray aUncleList; + vector vBiUncles; + + for (auto const& uHObj: blObj["uncleHeaders"].get_array()) + { + mObject uncleHeaderObj = uHObj.get_obj(); + BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); + + // make uncle header valid + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + uncleBlockFromFields.timestamp = (u256)time(0); + + updatePoW(uncleBlockFromFields); + writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); + + aUncleList.push_back(uncleHeaderObj); + vBiUncles.push_back(uncleBlockFromFields); + + cnote << "import uncle in blockQueue"; + RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields); + uncleBlockQueue.import(&uncle.out(), bc); + } + + blObj["uncleHeaders"] = aUncleList; + bc.sync(uncleBlockQueue, state.db(), 4); + state.commitToMine(bc); + try { state.sync(bc); @@ -152,6 +144,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) return; } + blObj["rlp"] = "0x" + toHex(state.blockData()); + // write valid txs mArray txArray; Transactions txList; @@ -174,46 +168,19 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } blObj["transactions"] = txArray; - blObj["rlp"] = "0x" + toHex(state.blockData()); BlockInfo current_BlockHeader = state.info(); - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - if (blObj.count("blockHeader")) - { overwriteBlockHeader(current_BlockHeader, blObj); - } // write block header - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); - oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); - oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); - oBlockHeader["hash"] = toString(current_BlockHeader.hash); - + writeBlockHeaderToJson(oBlockHeader, current_BlockHeader); blObj["blockHeader"] = oBlockHeader; + vBiBlocks.push_back(current_BlockHeader); - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - blObj["uncleHeaders"] = aUncleList; - - //txs: - + // compare blocks from state and from rlp RLPStream txStream; txStream.appendList(txList.size()); for (unsigned i = 0; i < txList.size(); ++i) @@ -223,13 +190,16 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txStream.appendRaw(txrlp.out()); } - RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + RLPStream uncleStream; + uncleStream.appendList(vBiUncles.size()); + for (unsigned i = 0; i < vBiUncles.size(); ++i) + { + RLPStream uncleRlp; + vBiUncles[i].streamRLP(uncleRlp, WithNonce); + uncleStream.appendRaw(uncleRlp.out()); + } - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); + RLPStream block2 = createFullBlockFromHeader(current_BlockHeader, txStream.out(), uncleStream.out()); blObj["rlp"] = "0x" + toHex(block2.out()); @@ -240,13 +210,14 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "txs mismatch\n"; if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; + cnote << "uncle list mismatch\n" << RLP(state.blockData())[2].data() << "\n" << RLP(block2.out())[2].data(); try { state.sync(bc); bc.import(block2.out(), state.db()); state.sync(bc); + state.commit(); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -392,12 +363,51 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } // check uncle list - BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + + // uncles from uncle list field + vector uBlHsFromField; + if (blObj["uncleHeaders"].type() != json_spirit::null_type) + { + for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) + { + mObject uBlH = uBlHeaderObj.get_obj(); + cout << "uBlH.size(): " << uBlH.size() << endl; + BOOST_REQUIRE(uBlH.size() == 17); + bytes uncleRLP = createBlockRLPFromFields(uBlH); + const RLP c_uRLP(uncleRLP); + BlockInfo uncleBlockHeader; + try + { + uncleBlockHeader.populateFromHeader(c_uRLP, true); + } + catch(...) + { + BOOST_ERROR("invalid uncle header"); + } + uBlHsFromField.push_back(uncleBlockHeader); + } + } + + // uncles from block RLP + vector uBlHsFromRlp; + for (auto const& uRLP: root[2]) + { + BlockInfo uBl; + uBl.populateFromHeader(uRLP, true); + uBlHsFromRlp.push_back(uBl); + } + + BOOST_REQUIRE_EQUAL(uBlHsFromField.size(), uBlHsFromRlp.size()); + + for (size_t i = 0; i < uBlHsFromField.size(); ++i) + BOOST_CHECK_MESSAGE(uBlHsFromField[i] == uBlHsFromRlp[i], "block header in rlp and in field do not match"); } } } } +// helping functions + bytes createBlockRLPFromFields(mObject& _tObj) { RLPStream rlpStream; @@ -529,31 +539,103 @@ void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) current_BlockHeader.populateFromHeader(c_bRLP, false); } } -} }// Namespace Close +BlockInfo constructBlock(mObject& _o) +{ -BOOST_AUTO_TEST_SUITE(BlockChainTests) + BlockInfo ret; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(_o); + const RLP c_bRLP(c_blockRLP); + ret.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch(...) + { + BOOST_ERROR("block population did throw an unknown exception\n"); + } + return ret; +} -BOOST_AUTO_TEST_CASE(bcBlockChainTest) +void updatePoW(BlockInfo& _bi) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(_bi)) + { + ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _bi); + } } -BOOST_AUTO_TEST_CASE(bcValidBlockTest) +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi) { - dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); + _o["parentHash"] = toString(_bi.parentHash); + _o["uncleHash"] = toString(_bi.sha3Uncles); + _o["coinbase"] = toString(_bi.coinbaseAddress); + _o["stateRoot"] = toString(_bi.stateRoot); + _o["transactionsTrie"] = toString(_bi.transactionsRoot); + _o["receiptTrie"] = toString(_bi.receiptsRoot); + _o["bloom"] = toString(_bi.logBloom); + _o["difficulty"] = toString(_bi.difficulty); + _o["number"] = toString(_bi.number); + _o["gasLimit"] = toString(_bi.gasLimit); + _o["gasUsed"] = toString(_bi.gasUsed); + _o["timestamp"] = toString(_bi.timestamp); + _o["extraData"] ="0x" + toHex(_bi.extraData); + _o["mixHash"] = toString(_bi.mixHash); + _o["seedHash"] = toString(_bi.seedHash); + _o["nonce"] = toString(_bi.nonce); + _o["hash"] = toString(_bi.hash); } -BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, const bytes& _uncles ) { - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); + RLPStream rlpStream; + _bi.streamRLP(rlpStream, WithNonce); + + RLPStream ret(3); + ret.appendRaw(rlpStream.out()); + ret.appendRaw(_txs); + ret.appendRaw(_uncles); + + return ret; } +} }// Namespace Close -//BOOST_AUTO_TEST_CASE(bcUncleTest) + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +//BOOST_AUTO_TEST_CASE(bcBlockChainTest) +//{ +// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcValidBlockTest) +//{ +// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) //{ -// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); //} +BOOST_AUTO_TEST_CASE(bcUncleTest) +{ + dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +} + BOOST_AUTO_TEST_CASE(userDefinedFileBc) { dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); From 4a7e6487370275120119a20a840d1620c8688266 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:14:42 +0100 Subject: [PATCH 232/313] update blockchain test filler to new min diff and min gasLimit --- test/bcBlockChainTestFiller.json | 2 +- test/bcInvalidHeaderTestFiller.json | 56 ++++++++++++++--------------- test/bcValidBlockTestFiller.json | 32 ++++++++--------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 8a0bf89fe..b149f5938 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -3,7 +3,7 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index aa32dfbab..39a91a583 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -3,9 +3,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -59,9 +59,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,9 +115,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -170,9 +170,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -225,9 +225,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -280,9 +280,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -336,9 +336,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -391,9 +391,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -446,9 +446,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -501,9 +501,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -556,9 +556,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -611,9 +611,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -666,9 +666,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -721,9 +721,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 29b2e978e..14d4cfb2c 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -4,9 +4,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1024", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -51,9 +51,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,9 +97,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "1000000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -143,9 +143,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -189,9 +189,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -244,9 +244,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -299,9 +299,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -351,9 +351,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "0x0dddb6", + "gasLimit" : "125000", "gasUsed" : "100", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", From 7417a695a0ba607ec38db2d87cf980e1293dc0dc Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:16:17 +0100 Subject: [PATCH 233/313] add first uncle test --- test/bcUncleTestFiller.json | 73 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index 839e3ba46..d866b887c 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,9 +1,9 @@ { - "minDifficulty" : { + "oneUncle" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", @@ -54,24 +54,39 @@ "value" : "10" } ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], "uncleHeaders" : [ { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "2049", + "difficulty" : "131072", "extraData" : "0x", - "gasLimit" : "99804806", - "gasUsed" : "21000", - "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", - "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", - "nonce" : "17ed77999bef2e4b", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", "number" : "2", - "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", - "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", - "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", - "timestamp" : "1425490151", - "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] @@ -80,35 +95,19 @@ "transactions" : [ { "data" : "", - "gasLimit" : "8000000", - "gasPrice" : "0", - "nonce" : "2", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "3", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" } ], "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "1", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } ] - } + }, ] } + + } From 45986a1d79174644bc13a251acdfc0e0a14aa2b7 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:19:48 +0100 Subject: [PATCH 234/313] style --- test/blockchain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index a23a756b1..ec9f7b68d 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -367,7 +367,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // uncles from uncle list field vector uBlHsFromField; if (blObj["uncleHeaders"].type() != json_spirit::null_type) - { for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) { mObject uBlH = uBlHeaderObj.get_obj(); @@ -386,7 +385,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } uBlHsFromField.push_back(uncleBlockHeader); } - } // uncles from block RLP vector uBlHsFromRlp; From b343d0d42ead5eb6dbf17c2474833a5effaca9ad Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:32 +0100 Subject: [PATCH 235/313] style + add test cases --- test/blockchain.cpp | 108 ++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ec9f7b68d..e453e32ab 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -32,7 +32,7 @@ using namespace dev::eth; namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj); BlockInfo constructBlock(mObject& _o); void updatePoW(BlockInfo& _bi); void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); @@ -106,8 +106,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); // make uncle header valid - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); uncleBlockFromFields.timestamp = (u256)time(0); + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); @@ -462,79 +462,79 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj) { - if (blObj["blockHeader"].get_obj().size() != 14) + if (_blObj["blockHeader"].get_obj().size() != 14) { - BlockInfo tmp = current_BlockHeader; + BlockInfo tmp = _current_BlockHeader; - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(_blObj["blockHeader"].get_obj()["parentHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(_blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + if (_blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(_blObj["blockHeader"].get_obj()["coinbase"].get_str()); - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + if (_blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(_blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(_blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(_blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + if (_blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(_blObj["blockHeader"].get_obj()["bloom"].get_str()); - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + if (_blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(_blObj["blockHeader"].get_obj()["difficulty"]); - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + if (_blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(_blObj["blockHeader"].get_obj()["number"]); - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + if (_blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(_blObj["blockHeader"].get_obj()["gasLimit"]); - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + if (_blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(_blObj["blockHeader"].get_obj()["gasUsed"]); - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + if (_blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(_blObj["blockHeader"].get_obj()["timestamp"]); - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (_blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(_blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(_blObj["blockHeader"].get_obj()["mixHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(_blObj["blockHeader"].get_obj()["seedHash"].get_str()); // find new valid nonce - if (tmp != current_BlockHeader) + if (tmp != _current_BlockHeader) { - current_BlockHeader = tmp; + _current_BlockHeader = tmp; ProofOfWork pow; std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) + while (!ProofOfWork::verify(_current_BlockHeader)) { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); + ret = pow.mine(_current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _current_BlockHeader); } } } else { // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const bytes c_blockRLP = createBlockRLPFromFields(_blObj["blockHeader"].get_obj()); const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); + _current_BlockHeader.populateFromHeader(c_bRLP, false); } } @@ -614,20 +614,20 @@ RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, cons BOOST_AUTO_TEST_SUITE(BlockChainTests) -//BOOST_AUTO_TEST_CASE(bcBlockChainTest) -//{ -// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcValidBlockTest) -//{ -// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) -//{ -// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} BOOST_AUTO_TEST_CASE(bcUncleTest) { From 8ea37d5a1988c3a820f3871a94e3a9ff38b44093 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:49 +0100 Subject: [PATCH 236/313] add uncle tests --- test/bcUncleTestFiller.json | 348 +++++++++++++++++++++++++++++++++++- 1 file changed, 347 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index d866b887c..c0233ff91 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -90,6 +90,181 @@ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] + } + ] + }, + + "twoEqualUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "twoUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] }, { "transactions" : [ @@ -97,7 +272,91 @@ "data" : "", "gasLimit" : "80000050", "gasPrice" : "1", - "nonce" : "3", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "threeUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" @@ -106,6 +365,93 @@ "uncleHeaders" : [ ] }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "a55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } ] } From f2e78d7afb98ea3b7a0ca29312dac01297c11539 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 14:34:45 +0100 Subject: [PATCH 237/313] add secure trie tests --- test/trie.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/test/trie.cpp b/test/trie.cpp index 9e59dd316..e03e96830 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -198,6 +198,48 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } +BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -279,6 +321,69 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } +BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trietest_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + vector keysToBeDeleted; + for (auto& i: o["in"].get_array()) + { + vector values; + for (auto& s: i.get_array()) + { + if (s.type() == json_spirit::str_type) + values.push_back(s.get_str()); + else if (s.type() == json_spirit::null_type) + { + // mark entry for deletion + values.push_back(""); + if (!values[0].find("0x")) + values[0] = asString(fromHex(values[0].substr(2))); + keysToBeDeleted.push_back(values[0]); + } + else + BOOST_FAIL("Bad type (expected string)"); + } + + BOOST_REQUIRE(values.size() == 2); + ss.push_back(make_pair(values[0], values[1])); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) + t.remove(k.first); + else + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } +} + inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From 273bc7de6d4d0eceed0cc9b2bfd58e4ceba5f82c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:13:45 +0100 Subject: [PATCH 238/313] merge --- test/trie.cpp | 105 -------------------------------------------------- 1 file changed, 105 deletions(-) diff --git a/test/trie.cpp b/test/trie.cpp index e03e96830..9e59dd316 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -198,48 +198,6 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } -BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -321,69 +279,6 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } -BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trietest_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - vector keysToBeDeleted; - for (auto& i: o["in"].get_array()) - { - vector values; - for (auto& s: i.get_array()) - { - if (s.type() == json_spirit::str_type) - values.push_back(s.get_str()); - else if (s.type() == json_spirit::null_type) - { - // mark entry for deletion - values.push_back(""); - if (!values[0].find("0x")) - values[0] = asString(fromHex(values[0].substr(2))); - keysToBeDeleted.push_back(values[0]); - } - else - BOOST_FAIL("Bad type (expected string)"); - } - - BOOST_REQUIRE(values.size() == 2); - ss.push_back(make_pair(values[0], values[1])); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); - else - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } -} - inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From 18c305ed592d4c0eb9ea366e295b67ce7fc9c950 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:15:12 +0100 Subject: [PATCH 239/313] check for minGasLimit and minDifficulty when constructing block --- libethcore/BlockInfo.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 270f96b07..3b4878a7d 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -125,10 +125,16 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) BOOST_THROW_EXCEPTION(InvalidBlockNonce(headerHash(WithoutNonce), nonce, difficulty)); if (gasUsed > gasLimit) - BOOST_THROW_EXCEPTION(TooMuchGasUsed()); + BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(gasLimit), bigint(gasUsed)) ); + + if (difficulty < c_minimumDifficulty) + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); + + if (gasLimit < c_minGasLimit) + BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); if (number && extraData.size() > c_maximumExtraDataSize) - BOOST_THROW_EXCEPTION(ExtraDataTooBig()); + BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); } void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) @@ -207,7 +213,7 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. if (difficulty != calculateDifficulty(_parent)) - BOOST_THROW_EXCEPTION(InvalidDifficulty()); + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError((bigint)calculateDifficulty(_parent), (bigint)difficulty)); if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) From e70903f8757d4e7d3a646e9ebaab64681a9060a8 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:14:45 +0100 Subject: [PATCH 240/313] try to have a uncle with block number = 1 --- test/bcUncleTestFiller.json | 80 +++++++++++++++++++++++++++++++++++++ test/blockchain.cpp | 6 ++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index c0233ff91..e70f25bb4 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,4 +1,84 @@ { + "uncleHeaderAtBlock2" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + "oneUncle" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index e453e32ab..7f840bc76 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -80,6 +80,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_REQUIRE(o.count("blocks")); mArray blArray; vector vBiBlocks; + vBiBlocks.push_back(biGenesisBlock); for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); @@ -107,7 +108,10 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // make uncle header valid uncleBlockFromFields.timestamp = (u256)time(0); - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + if (vBiBlocks.size() > 2) + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + else + continue; updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); From e29ee8e404960c3108794ea830fec53fbd1ea3d3 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:16:11 +0100 Subject: [PATCH 241/313] fix --- test/bcUncleTestFiller.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index e70f25bb4..639051f2b 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -65,7 +65,7 @@ "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", "nonce" : "18a524c1790fa83b", - "number" : "2", + "number" : "1", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", From 80b7e70c96d4708fa459ead7ad5186eb0f41a204 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 11:17:26 +0100 Subject: [PATCH 242/313] Don't use flawed way of generating random keys. --- libdevcore/FixedHash.cpp | 2 +- libdevcore/FixedHash.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libdevcore/FixedHash.cpp b/libdevcore/FixedHash.cpp index 0369ea854..ae2d77c85 100644 --- a/libdevcore/FixedHash.cpp +++ b/libdevcore/FixedHash.cpp @@ -25,4 +25,4 @@ using namespace std; using namespace dev; -std::mt19937_64 dev::s_fixedHashEngine(time(0)); +std::random_device dev::s_fixedHashEngine; diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index b00a80c04..49c6ed2bf 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -31,7 +31,7 @@ namespace dev { -extern std::mt19937_64 s_fixedHashEngine; +extern std::random_device s_fixedHashEngine; /// Fixed-size raw-byte array container type, with an API optimised for storing hashes. /// Transparently converts to/from the corresponding arithmetic type; this will From f57afc2e6e5d1446e4cf8f1a26a73ee620b4eeb1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 11:57:07 +0100 Subject: [PATCH 243/313] Add the library until we figure out git subtree/submodule --- libethash/CMakeLists.txt | 39 +++++ libethash/compiler.h | 33 ++++ libethash/data_sizes.h | 247 ++++++++++++++++++++++++++++++ libethash/endian.h | 74 +++++++++ libethash/ethash.h | 93 +++++++++++ libethash/fnv.h | 38 +++++ libethash/internal.c | 298 ++++++++++++++++++++++++++++++++++++ libethash/internal.h | 48 ++++++ libethash/sha3.c | 151 ++++++++++++++++++ libethash/sha3.h | 27 ++++ libethash/sha3_cryptopp.cpp | 34 ++++ libethash/sha3_cryptopp.h | 15 ++ libethash/util.c | 41 +++++ libethash/util.h | 47 ++++++ 14 files changed, 1185 insertions(+) create mode 100644 libethash/CMakeLists.txt create mode 100644 libethash/compiler.h create mode 100644 libethash/data_sizes.h create mode 100644 libethash/endian.h create mode 100644 libethash/ethash.h create mode 100644 libethash/fnv.h create mode 100644 libethash/internal.c create mode 100644 libethash/internal.h create mode 100644 libethash/sha3.c create mode 100644 libethash/sha3.h create mode 100644 libethash/sha3_cryptopp.cpp create mode 100644 libethash/sha3_cryptopp.h create mode 100644 libethash/util.c create mode 100644 libethash/util.h diff --git a/libethash/CMakeLists.txt b/libethash/CMakeLists.txt new file mode 100644 index 000000000..7bc147af7 --- /dev/null +++ b/libethash/CMakeLists.txt @@ -0,0 +1,39 @@ +set(LIBRARY ethash) + +if (CPPETHEREUM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +#else () +endif () + +set(CMAKE_BUILD_TYPE Release) + +if (NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +endif() + +set(FILES util.c + util.h + internal.c + ethash.h + endian.h + compiler.h + fnv.h + data_sizes.h) + +if (NOT CRYPTOPP_FOUND) + find_package(CryptoPP 5.6.2) +endif() + +if (CRYPTOPP_FOUND) + add_definitions(-DWITH_CRYPTOPP) + include_directories( ${CRYPTOPP_INCLUDE_DIRS} ) + list(APPEND FILES sha3_cryptopp.cpp sha3_cryptopp.h) +else() + list(APPEND FILES sha3.c sha3.h) +endif() + +add_library(${LIBRARY} ${FILES}) + +if (CRYPTOPP_FOUND) + TARGET_LINK_LIBRARIES(${LIBRARY} ${CRYPTOPP_LIBRARIES}) +endif() diff --git a/libethash/compiler.h b/libethash/compiler.h new file mode 100644 index 000000000..9695871cd --- /dev/null +++ b/libethash/compiler.h @@ -0,0 +1,33 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file compiler.h + * @date 2014 + */ +#pragma once + +// Visual Studio doesn't support the inline keyword in C mode +#if defined(_MSC_VER) && !defined(__cplusplus) +#define inline __inline +#endif + +// pretend restrict is a standard keyword +#if defined(_MSC_VER) +#define restrict __restrict +#else +#define restrict __restrict__ +#endif + diff --git a/libethash/data_sizes.h b/libethash/data_sizes.h new file mode 100644 index 000000000..ccdf554a8 --- /dev/null +++ b/libethash/data_sizes.h @@ -0,0 +1,247 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software FoundationUUU,either version 3 of the LicenseUUU,or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be usefulU, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If notUUU,see . +*/ + +/** @file data_sizes.h +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +// TODO: Update this after ~3.5 years + +#pragma once + +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +// 500 Epochs worth of tabulated DAG sizes (~3.5 Years) + +// Generated with the following Mathematica Code: +// GetDataSizes[n_] := Module[{ +// DAGSizeBytesInit = 2^30, +// MixBytes = 128, +// DAGGrowth = 113000000, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = +// Floor[(DAGSizeBytesInit + DAGGrowth * j) / MixBytes]}, +// While[! PrimeQ[i], i--]; +// Sow[i*MixBytes]; j++]]]][[2]][[1]] + +static const size_t dag_sizes[] = { + 1073739904U, 1186739584U, 1299741568U, 1412741248U, 1525741696U, + 1638736768U, 1751741312U, 1864740736U, 1977740672U, 2090740864U, + 2203740544U, 2316741248U, 2429739392U, 2542740352U, 2655741824U, + 2768739712U, 2881740416U, 2994741632U, 3107740544U, 3220741504U, + 3333738112U, 3446741632U, 3559741312U, 3672740224U, 3785740928U, + 3898738304U, 4011741824U, 4124739712U, 4237735808U, 4350740864U, + 4463741824U, 4576741504U, 4689741184U, 4802739328U, 4915741568U, + 5028740224U, 5141740672U, 5254738304U, 5367741824U, 5480737664U, + 5593738112U, 5706741632U, 5819740544U, 5932734592U, 6045739904U, + 6158740096U, 6271740032U, 6384731776U, 6497732992U, 6610740352U, + 6723741056U, 6836741504U, 6949740416U, 7062740096U, 7175741824U, + 7288740224U, 7401741184U, 7514741632U, 7627741568U, 7740739712U, + 7853739136U, 7966740352U, 8079741568U, 8192739712U, 8305738624U, + 8418740864U, 8531740288U, 8644740736U, 8757735808U, 8870738816U, + 8983739264U, 9096740992U, 9209740928U, 9322739584U, 9435741824U, + 9548741504U, 9661739392U, 9774738304U, 9887741312U, 10000738688U, + 10113739136U, 10226741632U, 10339739776U, 10452741248U, 10565740928U, + 10678736512U, 10791734656U, 10904741248U, 11017738112U, 11130741632U, + 11243741312U, 11356739456U, 11469740416U, 11582734976U, 11695739008U, + 11808741248U, 11921734784U, 12034739072U, 12147741568U, 12260737408U, + 12373741696U, 12486738304U, 12599740544U, 12712740224U, 12825741184U, + 12938736256U, 13051741312U, 13164737408U, 13277738368U, 13390738048U, + 13503741824U, 13616741504U, 13729737088U, 13842740096U, 13955741312U, + 14068741504U, 14181740416U, 14294741632U, 14407739776U, 14520740224U, + 14633740928U, 14746736512U, 14859741824U, 14972740736U, 15085740928U, + 15198738304U, 15311732096U, 15424740736U, 15537739904U, 15650741632U, + 15763741568U, 15876737152U, 15989741696U, 16102740608U, 16215741056U, + 16328741248U, 16441740416U, 16554737792U, 16667740288U, 16780740992U, + 16893738112U, 17006741632U, 17119739008U, 17232735616U, 17345739392U, + 17458740352U, 17571736192U, 17684739712U, 17797739392U, 17910740096U, + 18023741312U, 18136740736U, 18249738112U, 18362738816U, 18475735424U, + 18588740224U, 18701738368U, 18814736768U, 18927737216U, 19040739968U, + 19153739648U, 19266736768U, 19379737984U, 19492739456U, 19605738368U, + 19718740352U, 19831741312U, 19944736384U, 20057741696U, 20170741376U, + 20283741824U, 20396737408U, 20509741696U, 20622741376U, 20735739008U, + 20848741504U, 20961740672U, 21074739328U, 21187740032U, 21300739456U, + 21413741696U, 21526740608U, 21639741824U, 21752737408U, 21865741696U, + 21978741376U, 22091741824U, 22204738432U, 22317740672U, 22430740096U, + 22543736704U, 22656741248U, 22769739904U, 22882739584U, 22995740288U, + 23108740736U, 23221740928U, 23334741376U, 23447737216U, 23560740992U, + 23673741184U, 23786740864U, 23899737728U, 24012741248U, 24125734784U, + 24238736512U, 24351741824U, 24464740736U, 24577737088U, 24690741632U, + 24803739776U, 24916740736U, 25029740416U, 25142740864U, 25255741568U, + 25368741248U, 25481740672U, 25594741376U, 25707741568U, 25820741504U, + 25933730432U, 26046739072U, 26159741824U, 26272741504U, 26385740672U, + 26498740096U, 26611741568U, 26724740992U, 26837739904U, 26950735232U, + 27063738496U, 27176741248U, 27289741184U, 27402740864U, 27515740544U, + 27628737152U, 27741740672U, 27854741632U, 27967740544U, 28080739712U, + 28193738368U, 28306741376U, 28419737728U, 28532739968U, 28645739648U, + 28758740096U, 28871741312U, 28984739456U, 29097740416U, 29210740864U, + 29323741312U, 29436740224U, 29549741696U, 29662738304U, 29775741568U, + 29888741504U, 30001740928U, 30114737024U, 30227735168U, 30340737664U, + 30453738368U, 30566737024U, 30679733632U, 30792740224U, 30905740928U, + 31018740352U, 31131740032U, 31244738944U, 31357737344U, 31470741376U, + 31583740544U, 31696740224U, 31809738112U, 31922739328U, 32035737472U, + 32148740992U, 32261741696U, 32374740352U, 32487741824U, 32600740736U, + 32713739648U, 32826740608U, 32939729792U, 33052740992U, 33165740672U, + 33278739584U, 33391741312U, 33504739712U, 33617740928U, 33730740608U, + 33843738496U, 33956739968U, 34069741696U, 34182739328U, 34295741824U, + 34408739968U, 34521740672U, 34634736512U, 34747741568U, 34860741248U, + 34973739392U, 35086738304U, 35199741056U, 35312736896U, 35425741184U, + 35538741376U, 35651740288U, 35764737152U, 35877741184U, 35990739584U, + 36103740544U, 36216740992U, 36329739392U, 36442737536U, 36555741568U, + 36668740736U, 36781741184U, 36894737024U, 37007741312U, 37120739456U, + 37233741184U, 37346736256U, 37459736192U, 37572734336U, 37685739904U, + 37798740352U, 37911737728U, 38024741504U, 38137739648U, 38250740608U, + 38363741824U, 38476740992U, 38589741184U, 38702740096U, 38815741312U, + 38928741248U, 39041738368U, 39154739584U, 39267741824U, 39380739712U, + 39493735808U, 39606741632U, 39719741312U, 39832741504U, 39945739648U, + 40058740352U, 40171740032U, 40284740992U, 40397740672U, 40510740352U, + 40623740288U, 40736738176U, 40849737856U, 40962741376U, 41075739776U, + 41188737664U, 41301735808U, 41414738048U, 41527741312U, 41640740992U, + 41753739904U, 41866739072U, 41979738496U, 42092740736U, 42205739648U, + 42318740608U, 42431741312U, 42544738688U, 42657741184U, 42770738048U, + 42883741568U, 42996741248U, 43109740928U, 43222736512U, 43335741056U, + 43448730496U, 43561740416U, 43674741632U, 43787740544U, 43900741504U, + 44013739648U, 44126740864U, 44239740544U, 44352741248U, 44465738368U, + 44578735232U, 44691739264U, 44804741504U, 44917741696U, 45030741376U, + 45143741824U, 45256740992U, 45369739136U, 45482740096U, 45595739776U, + 45708739712U, 45821740672U, 45934741376U, 46047741056U, 46160741248U, + 46273737088U, 46386740864U, 46499739008U, 46612739968U, 46725735296U, + 46838740864U, 46951741568U, 47064737152U, 47177741696U, 47290741376U, + 47403738752U, 47516741248U, 47629739648U, 47742741632U, 47855737984U, + 47968740224U, 48081738368U, 48194741632U, 48307739264U, 48420739712U, + 48533739136U, 48646738304U, 48759741824U, 48872741504U, 48985739392U, + 49098741376U, 49211741056U, 49324740992U, 49437738368U, 49550740864U, + 49663735424U, 49776737408U, 49889740672U, 50002738816U, 50115738752U, + 50228739712U, 50341741696U, 50454736768U, 50567738752U, 50680739968U, + 50793736832U, 50906734976U, 51019741568U, 51132739456U, 51245741696U, + 51358741376U, 51471741056U, 51584738944U, 51697734272U, 51810739072U, + 51923736448U, 52036740736U, 52149741184U, 52262737024U, 52375738496U, + 52488740992U, 52601739136U, 52714740352U, 52827736448U, 52940738176U, + 53053741696U, 53166740864U, 53279741824U, 53392741504U, 53505739136U, + 53618739584U, 53731741312U, 53844741248U, 53957741696U, 54070741376U, + 54183740288U, 54296741504U, 54409741696U, 54522739072U, 54635737472U, + 54748741504U, 54861736064U, 54974740096U, 55087741568U, 55200733568U, + 55313741696U, 55426734464U, 55539741056U, 55652741504U, 55765741184U, + 55878741376U, 55991730304U, 56104740992U, 56217740672U, 56330731648U, + 56443737472U, 56556724352U, 56669740672U, 56782739072U, 56895740032U, + 57008741248U, 57121741696U, 57234740096U, 57347741312U, 57460741504U +}; + +// 500 Epochs worth of tabulated DAG sizes (~3.5 Years) + +// Generated with the following Mathematica Code: +// GetCacheSizes[n_] := Module[{ +// DAGSizeBytesInit = 2^30, +// MixBytes = 128, +// DAGGrowth = 113000000, +// HashBytes = 64, +// DAGParents = 1024, +// j = 0}, +// Reap[ +// While[j < n, +// Module[{i = Floor[(DAGSizeBytesInit + DAGGrowth * j) / (DAGParents * HashBytes)]}, +// While[! PrimeQ[i], i--]; +// Sow[i*HashBytes]; j++]]]][[2]][[1]] + +const size_t cache_sizes[] = { + 1048384U, 1158208U, 1268416U, 1377856U, 1489856U, 1599296U, 1710656U, + 1820608U, 1930816U, 2041024U, 2151872U, 2261696U, 2371904U, 2482624U, + 2593216U, 2703296U, 2814016U, 2924224U, 3034816U, 3144896U, 3255488U, + 3365312U, 3475904U, 3586624U, 3696064U, 3806272U, 3917504U, 4027456U, + 4138304U, 4248512U, 4359104U, 4469312U, 4579264U, 4689728U, 4797376U, + 4909888U, 5020096U, 5131328U, 5241664U, 5351744U, 5461312U, 5572544U, + 5683264U, 5793472U, 5903552U, 6014144U, 6121664U, 6235072U, 6344896U, + 6454592U, 6565952U, 6675904U, 6786112U, 6896704U, 7006784U, 7117888U, + 7228096U, 7338304U, 7448768U, 7557952U, 7669184U, 7779776U, 7889216U, + 8000192U, 8110912U, 8220736U, 8331712U, 8441536U, 8552384U, 8662592U, + 8772928U, 8883136U, 8993728U, 9103168U, 9214528U, 9323968U, 9434816U, + 9545152U, 9655616U, 9766336U, 9876544U, 9986624U, 10097344U, 10207424U, + 10316864U, 10427968U, 10538432U, 10649152U, 10758976U, 10869568U, 10979776U, + 11089472U, 11200832U, 11309632U, 11420608U, 11531584U, 11641792U, 11751104U, + 11862976U, 11973184U, 12083264U, 12193856U, 12304064U, 12414656U, 12524608U, + 12635072U, 12745792U, 12855616U, 12965824U, 13076416U, 13187008U, 13297216U, + 13407808U, 13518016U, 13627072U, 13738688U, 13848256U, 13959488U, 14069696U, + 14180288U, 14290624U, 14399552U, 14511424U, 14621504U, 14732096U, 14841664U, + 14951744U, 15062336U, 15172672U, 15283264U, 15393088U, 15504448U, 15614272U, + 15723712U, 15834944U, 15945152U, 16055744U, 16165696U, 16277056U, 16387136U, + 16494784U, 16607936U, 16718272U, 16828736U, 16938176U, 17048384U, 17159872U, + 17266624U, 17380544U, 17490496U, 17600192U, 17711296U, 17821376U, 17931968U, + 18041152U, 18152896U, 18261952U, 18373568U, 18483392U, 18594112U, 18703936U, + 18814912U, 18924992U, 19034944U, 19145408U, 19256128U, 19366208U, 19477184U, + 19587136U, 19696576U, 19808192U, 19916992U, 20028352U, 20137664U, 20249024U, + 20358848U, 20470336U, 20580544U, 20689472U, 20801344U, 20911424U, 21020096U, + 21130688U, 21242176U, 21352384U, 21462208U, 21573824U, 21683392U, 21794624U, + 21904448U, 22013632U, 22125248U, 22235968U, 22344512U, 22456768U, 22566848U, + 22677056U, 22786496U, 22897984U, 23008064U, 23118272U, 23228992U, 23338816U, + 23449408U, 23560256U, 23670464U, 23780672U, 23891264U, 24001216U, 24110656U, + 24221888U, 24332608U, 24442688U, 24552512U, 24662464U, 24773696U, 24884032U, + 24994496U, 25105216U, 25215296U, 25324864U, 25435712U, 25546432U, 25655744U, + 25767232U, 25876672U, 25986368U, 26098112U, 26207936U, 26318912U, 26428736U, + 26539712U, 26650048U, 26760256U, 26869184U, 26979776U, 27091136U, 27201728U, + 27311552U, 27422272U, 27532352U, 27642304U, 27752896U, 27863744U, 27973952U, + 28082752U, 28194752U, 28305344U, 28415168U, 28524992U, 28636352U, 28746304U, + 28857152U, 28967104U, 29077184U, 29187904U, 29298496U, 29408576U, 29518912U, + 29628992U, 29739968U, 29850176U, 29960512U, 30070336U, 30180544U, 30290752U, + 30398912U, 30512192U, 30622784U, 30732992U, 30842176U, 30953536U, 31063744U, + 31174336U, 31284544U, 31395136U, 31504448U, 31615552U, 31725632U, 31835072U, + 31946176U, 32057024U, 32167232U, 32277568U, 32387008U, 32497984U, 32608832U, + 32719168U, 32829376U, 32939584U, 33050048U, 33160768U, 33271232U, 33381184U, + 33491648U, 33601856U, 33712576U, 33822016U, 33932992U, 34042816U, 34153024U, + 34263104U, 34373824U, 34485056U, 34594624U, 34704832U, 34816064U, 34926272U, + 35036224U, 35146816U, 35255104U, 35367104U, 35478208U, 35588416U, 35698496U, + 35808832U, 35918656U, 36029888U, 36139456U, 36250688U, 36360512U, 36471104U, + 36581696U, 36691136U, 36802112U, 36912448U, 37022912U, 37132864U, 37242944U, + 37354048U, 37464512U, 37574848U, 37684928U, 37794752U, 37904704U, 38015552U, + 38125888U, 38236864U, 38345792U, 38457152U, 38567744U, 38678336U, 38787776U, + 38897216U, 39009088U, 39117632U, 39230144U, 39340352U, 39450304U, 39560384U, + 39671488U, 39781312U, 39891392U, 40002112U, 40112704U, 40223168U, 40332608U, + 40443968U, 40553792U, 40664768U, 40774208U, 40884416U, 40993984U, 41105984U, + 41215424U, 41326528U, 41436992U, 41546048U, 41655872U, 41768128U, 41878336U, + 41988928U, 42098752U, 42209344U, 42319168U, 42429248U, 42540352U, 42649792U, + 42761024U, 42871616U, 42981824U, 43092032U, 43201856U, 43312832U, 43423552U, + 43533632U, 43643584U, 43753792U, 43864384U, 43974976U, 44084032U, 44195392U, + 44306368U, 44415296U, 44526016U, 44637248U, 44746816U, 44858048U, 44967872U, + 45078848U, 45188288U, 45299264U, 45409216U, 45518272U, 45630272U, 45740224U, + 45850432U, 45960896U, 46069696U, 46182208U, 46292416U, 46402624U, 46512064U, + 46623296U, 46733888U, 46843712U, 46953664U, 47065024U, 47175104U, 47285696U, + 47395904U, 47506496U, 47615296U, 47726912U, 47837632U, 47947712U, 48055232U, + 48168128U, 48277952U, 48387392U, 48499648U, 48609472U, 48720064U, 48830272U, + 48940096U, 49050944U, 49160896U, 49271744U, 49381568U, 49492288U, 49602752U, + 49712576U, 49822016U, 49934272U, 50042816U, 50154304U, 50264128U, 50374336U, + 50484416U, 50596288U, 50706752U, 50816704U, 50927168U, 51035456U, 51146944U, + 51258176U, 51366976U, 51477824U, 51589568U, 51699776U, 51809728U, 51920576U, + 52030016U, 52140736U, 52251328U, 52361152U, 52470592U, 52582592U, 52691776U, + 52803136U, 52912576U, 53020736U, 53132224U, 53242688U, 53354816U, 53465536U, + 53575232U, 53685568U, 53796544U, 53906752U, 54016832U, 54126656U, 54236992U, + 54347456U, 54457408U, 54569024U, 54679232U, 54789184U, 54899776U, 55008832U, + 55119296U, 55231168U, 55341248U, 55451584U, 55562048U, 55672256U, 55782208U, + 55893184U, 56002112U, 56113216U +}; + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/endian.h b/libethash/endian.h new file mode 100644 index 000000000..9ca842e47 --- /dev/null +++ b/libethash/endian.h @@ -0,0 +1,74 @@ +#pragma once + +#include +#include "compiler.h" + +static const uint8_t BitReverseTable256[] = + { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2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, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; + +static inline uint32_t bitfn_swap32(uint32_t a) { + return (BitReverseTable256[a & 0xff] << 24) | + (BitReverseTable256[(a >> 8) & 0xff] << 16) | + (BitReverseTable256[(a >> 16) & 0xff] << 8) | + (BitReverseTable256[(a >> 24) & 0xff]); +} + +static inline uint64_t bitfn_swap64(uint64_t a) { + return ((uint64_t) bitfn_swap32((uint32_t) (a >> 32))) | + (((uint64_t) bitfn_swap32((uint32_t) a)) << 32); +} + +#if defined(__MINGW32__) || defined(_WIN32) + # define LITTLE_ENDIAN 1234 + # define BYTE_ORDER LITTLE_ENDIAN +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) + # include +#elif defined(__OpenBSD__) || defined(__SVR4) + # include +#elif defined(__APPLE__) +# include +#elif defined( BSD ) && (BSD >= 199103) + # include +#elif defined( __QNXNTO__ ) && defined( __LITTLEENDIAN__ ) + # define LITTLE_ENDIAN 1234 + # define BYTE_ORDER LITTLE_ENDIAN +#elif defined( __QNXNTO__ ) && defined( __BIGENDIAN__ ) + # define BIG_ENDIAN 1234 + # define BYTE_ORDER BIG_ENDIAN +#else + +# include + +#endif + + +#if LITTLE_ENDIAN == BYTE_ORDER + +#define fix_endian32(x) (x) +#define fix_endian64(x) (x) + +#elif BIG_ENDIAN == BYTE_ORDER + +#define fix_endian32(x) bitfn_swap32(x) +#define fix_endian64(x) bitfn_swap64(x) + +#else +# error "endian not supported" +#endif // BYTE_ORDER \ No newline at end of file diff --git a/libethash/ethash.h b/libethash/ethash.h new file mode 100644 index 000000000..918a77413 --- /dev/null +++ b/libethash/ethash.h @@ -0,0 +1,93 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file ethash.h +* @date 2015 +*/ +#pragma once + +#include +#include +#include +#include +#include "compiler.h" + +#define REVISION 19 +#define DAGSIZE_BYTES_INIT 1073741824U // 2**30 +#define DAG_GROWTH 113000000U +#define EPOCH_LENGTH 30000U +#define MIX_BYTES 128 +#define DAG_PARENTS 256 +#define CACHE_ROUNDS 3 +#define ACCESSES 64 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ethash_params { + size_t full_size; // Size of full data set (in bytes, multiple of mix size (128)). + size_t cache_size; // Size of compute cache (in bytes, multiple of node size (64)). +} ethash_params; + +typedef struct ethash_return_value { + uint8_t result[32]; + uint8_t mix_hash[32]; +} ethash_return_value; + +size_t ethash_get_datasize(const uint32_t block_number); +size_t ethash_get_cachesize(const uint32_t block_number); + +// initialize the parameters +static inline void ethash_params_init(ethash_params *params, const uint32_t block_number) { + params->full_size = ethash_get_datasize(block_number); + params->cache_size = ethash_get_cachesize(block_number); +} + +typedef struct ethash_cache { + void *mem; +} ethash_cache; + +void ethash_mkcache(ethash_cache *cache, ethash_params const *params, const uint8_t seed[32]); +void ethash_compute_full_data(void *mem, ethash_params const *params, ethash_cache const *cache); +void ethash_full(ethash_return_value *ret, void const *full_mem, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce); +void ethash_light(ethash_return_value *ret, ethash_cache const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce); + +static inline void ethash_prep_light(void *cache, ethash_params const *params, const uint8_t seed[32]) { ethash_cache c; c.mem = cache; ethash_mkcache(&c, params, seed); } +static inline void ethash_compute_light(ethash_return_value *ret, void const *cache, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_cache c; c.mem = (void*)cache; ethash_light(ret, &c, params, header_hash, nonce); } +static inline void ethash_prep_full(void *full, ethash_params const *params, void const *cache) { ethash_cache c; c.mem = (void*)cache; ethash_compute_full_data(full, params, &c); } +static inline void ethash_compute_full(ethash_return_value *ret, void const *full, ethash_params const *params, const uint8_t header_hash[32], const uint64_t nonce) { ethash_full(ret, full, params, header_hash, nonce); } + +static inline int ethash_check_difficulty( + const uint8_t hash[32], + const uint8_t difficulty[32]) { + // Difficulty is big endian + for (int i = 0; i < 32; i++) { + if (hash[i] == difficulty[i]) continue; + return hash[i] < difficulty[i]; + } + return 1; +} + +int ethash_quick_check_difficulty( + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32], + const uint8_t difficulty[32]); + +#ifdef __cplusplus +} +#endif diff --git a/libethash/fnv.h b/libethash/fnv.h new file mode 100644 index 000000000..edabeaae2 --- /dev/null +++ b/libethash/fnv.h @@ -0,0 +1,38 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file fnv.h +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +#pragma once +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define FNV_PRIME 0x01000193 + +static inline uint32_t fnv_hash(const uint32_t x, const uint32_t y) { + return x*FNV_PRIME ^ y; +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/internal.c b/libethash/internal.c new file mode 100644 index 000000000..a2b82d375 --- /dev/null +++ b/libethash/internal.c @@ -0,0 +1,298 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file dash.cpp +* @author Tim Hughes +* @author Matthew Wampler-Doty +* @date 2015 +*/ + +#include +#include +#include +#include "ethash.h" +#include "fnv.h" +#include "endian.h" +#include "internal.h" +#include "data_sizes.h" + +#ifdef WITH_CRYPTOPP + +#include "sha3_cryptopp.h" + +#else +#include "sha3.h" +#endif // WITH_CRYPTOPP + +size_t ethash_get_datasize(const uint32_t block_number) { + assert(block_number / EPOCH_LENGTH < 500); + return dag_sizes[block_number / EPOCH_LENGTH]; +} + +size_t ethash_get_cachesize(const uint32_t block_number) { + assert(block_number / EPOCH_LENGTH < 500); + return cache_sizes[block_number / EPOCH_LENGTH]; +} + +// Follows Sergio's "STRICT MEMORY HARD HASHING FUNCTIONS" (2014) +// https://bitslog.files.wordpress.com/2013/12/memohash-v0-3.pdf +// SeqMemoHash(s, R, N) +void static ethash_compute_cache_nodes( + node *const nodes, + ethash_params const *params, + const uint8_t seed[32]) { + assert((params->cache_size % sizeof(node)) == 0); + uint32_t const num_nodes = (uint32_t)(params->cache_size / sizeof(node)); + + SHA3_512(nodes[0].bytes, seed, 32); + + for (unsigned i = 1; i != num_nodes; ++i) { + SHA3_512(nodes[i].bytes, nodes[i - 1].bytes, 64); + } + + for (unsigned j = 0; j != CACHE_ROUNDS; j++) { + for (unsigned i = 0; i != num_nodes; i++) { + uint32_t const idx = nodes[i].words[0] % num_nodes; + node data; + data = nodes[(num_nodes - 1 + i) % num_nodes]; + for (unsigned w = 0; w != NODE_WORDS; ++w) + { + data.words[w] ^= nodes[idx].words[w]; + } + SHA3_512(nodes[i].bytes, data.bytes, sizeof(data)); + } + } + + // now perform endian conversion +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != (num_nodes*NODE_WORDS); ++w) + { + nodes->words[w] = fix_endian32(nodes->words[w]); + } +#endif +} + +void ethash_mkcache( + ethash_cache *cache, + ethash_params const *params, + const uint8_t seed[32]) { + node *nodes = (node *) cache->mem; + ethash_compute_cache_nodes(nodes, params, seed); +} + +void ethash_calculate_dag_item( + node *const ret, + const unsigned node_index, + const struct ethash_params *params, + const struct ethash_cache *cache) { + + uint32_t num_parent_nodes = (uint32_t)(params->cache_size / sizeof(node)); + node const *cache_nodes = (node const *) cache->mem; + node const *init = &cache_nodes[node_index % num_parent_nodes]; + + memcpy(ret, init, sizeof(node)); + ret->words[0] ^= node_index; + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); + +#if defined(_M_X64) && ENABLE_SSE + __m128i const fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = ret->xmm[0]; + __m128i xmm1 = ret->xmm[1]; + __m128i xmm2 = ret->xmm[2]; + __m128i xmm3 = ret->xmm[3]; +#endif + + for (unsigned i = 0; i != DAG_PARENTS; ++i) + { + uint32_t parent_index = ((node_index ^ i)*FNV_PRIME ^ ret->words[i % NODE_WORDS]) % num_parent_nodes; + node const *parent = &cache_nodes[parent_index]; + + #if defined(_M_X64) && ENABLE_SSE + { + xmm0 = _mm_mullo_epi32(xmm0, fnv_prime); + xmm1 = _mm_mullo_epi32(xmm1, fnv_prime); + xmm2 = _mm_mullo_epi32(xmm2, fnv_prime); + xmm3 = _mm_mullo_epi32(xmm3, fnv_prime); + xmm0 = _mm_xor_si128(xmm0, parent->xmm[0]); + xmm1 = _mm_xor_si128(xmm1, parent->xmm[1]); + xmm2 = _mm_xor_si128(xmm2, parent->xmm[2]); + xmm3 = _mm_xor_si128(xmm3, parent->xmm[3]); + + // have to write to ret as values are used to compute index + ret->xmm[0] = xmm0; + ret->xmm[1] = xmm1; + ret->xmm[2] = xmm2; + ret->xmm[3] = xmm3; + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + ret->words[w] = fnv_hash(ret->words[w], parent->words[w]); + } + } + #endif + } + + SHA3_512(ret->bytes, ret->bytes, sizeof(node)); +} + +void ethash_compute_full_data( + void *mem, + ethash_params const *params, + ethash_cache const *cache) { + assert((params->full_size % (sizeof(uint32_t) * MIX_WORDS)) == 0); + assert((params->full_size % sizeof(node)) == 0); + node *full_nodes = mem; + + // now compute full nodes + for (unsigned n = 0; n != (params->full_size / sizeof(node)); ++n) { + ethash_calculate_dag_item(&(full_nodes[n]), n, params, cache); + } +} + +static void ethash_hash( + ethash_return_value * ret, + node const *full_nodes, + ethash_cache const *cache, + ethash_params const *params, + const uint8_t header_hash[32], + const uint64_t nonce) { + + assert((params->full_size % MIX_WORDS) == 0); + + // pack hash and nonce together into first 40 bytes of s_mix + assert(sizeof(node)*8 == 512); + node s_mix[MIX_NODES + 1]; + memcpy(s_mix[0].bytes, header_hash, 32); + +#if BYTE_ORDER != LITTLE_ENDIAN + s_mix[0].double_words[4] = fix_endian64(nonce); +#else + s_mix[0].double_words[4] = nonce; +#endif + + // compute sha3-512 hash and replicate across mix + SHA3_512(s_mix->bytes, s_mix->bytes, 40); + +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != 16; ++w) { + s_mix[0].words[w] = fix_endian32(s_mix[0].words[w]); + } +#endif + + node* const mix = s_mix + 1; + for (unsigned w = 0; w != MIX_WORDS; ++w) { + mix->words[w] = s_mix[0].words[w % NODE_WORDS]; + } + + unsigned const + page_size = sizeof(uint32_t) * MIX_WORDS, + num_full_pages = (unsigned)(params->full_size / page_size); + + + for (unsigned i = 0; i != ACCESSES; ++i) + { + uint32_t const index = ((s_mix->words[0] ^ i)*FNV_PRIME ^ mix->words[i % MIX_WORDS]) % num_full_pages; + + for (unsigned n = 0; n != MIX_NODES; ++n) + { + const node * dag_node = &full_nodes[MIX_NODES * index + n]; + + if (!full_nodes) { + node tmp_node; + ethash_calculate_dag_item(&tmp_node, index * MIX_NODES + n, params, cache); + dag_node = &tmp_node; + } + + #if defined(_M_X64) && ENABLE_SSE + { + __m128i fnv_prime = _mm_set1_epi32(FNV_PRIME); + __m128i xmm0 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[0]); + __m128i xmm1 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[1]); + __m128i xmm2 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[2]); + __m128i xmm3 = _mm_mullo_epi32(fnv_prime, mix[n].xmm[3]); + mix[n].xmm[0] = _mm_xor_si128(xmm0, dag_node->xmm[0]); + mix[n].xmm[1] = _mm_xor_si128(xmm1, dag_node->xmm[1]); + mix[n].xmm[2] = _mm_xor_si128(xmm2, dag_node->xmm[2]); + mix[n].xmm[3] = _mm_xor_si128(xmm3, dag_node->xmm[3]); + } + #else + { + for (unsigned w = 0; w != NODE_WORDS; ++w) { + mix[n].words[w] = fnv_hash(mix[n].words[w], dag_node->words[w]); + } + } + #endif + } + + } + + // compress mix + for (unsigned w = 0; w != MIX_WORDS; w += 4) + { + uint32_t reduction = mix->words[w+0]; + reduction = reduction*FNV_PRIME ^ mix->words[w+1]; + reduction = reduction*FNV_PRIME ^ mix->words[w+2]; + reduction = reduction*FNV_PRIME ^ mix->words[w+3]; + mix->words[w/4] = reduction; + } + +#if BYTE_ORDER != LITTLE_ENDIAN + for (unsigned w = 0; w != MIX_WORDS/4; ++w) { + mix->words[w] = fix_endian32(mix->words[w]); + } +#endif + + memcpy(ret->mix_hash, mix->bytes, 32); + // final Keccak hash + SHA3_256(ret->result, s_mix->bytes, 64+32); // Keccak-256(s + compressed_mix) +} + +void ethash_quick_hash( + uint8_t return_hash[32], + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32]) { + + uint8_t buf[64+32]; + memcpy(buf, header_hash, 32); +#if BYTE_ORDER != LITTLE_ENDIAN + nonce = fix_endian64(nonce); +#endif + memcpy(&(buf[32]), &nonce, 8); + SHA3_512(buf, buf, 40); + memcpy(&(buf[64]), mix_hash, 32); + SHA3_256(return_hash, buf, 64+32); +} + +int ethash_quick_check_difficulty( + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32], + const uint8_t difficulty[32]) { + + uint8_t return_hash[32]; + ethash_quick_hash(return_hash, header_hash, nonce, mix_hash); + return ethash_check_difficulty(return_hash, difficulty); +} + +void ethash_full(ethash_return_value * ret, void const *full_mem, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) { + ethash_hash(ret, (node const *) full_mem, NULL, params, previous_hash, nonce); +} + +void ethash_light(ethash_return_value * ret, ethash_cache const *cache, ethash_params const *params, const uint8_t previous_hash[32], const uint64_t nonce) { + ethash_hash(ret, NULL, cache, params, previous_hash, nonce); +} diff --git a/libethash/internal.h b/libethash/internal.h new file mode 100644 index 000000000..bcbacdaa4 --- /dev/null +++ b/libethash/internal.h @@ -0,0 +1,48 @@ +#pragma once +#include "compiler.h" +#include "endian.h" +#include "ethash.h" + +#define ENABLE_SSE 1 + +#if defined(_M_X64) && ENABLE_SSE +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// compile time settings +#define NODE_WORDS (64/4) +#define MIX_WORDS (MIX_BYTES/4) +#define MIX_NODES (MIX_WORDS / NODE_WORDS) +#include + +typedef union node { + uint8_t bytes[NODE_WORDS * 4]; + uint32_t words[NODE_WORDS]; + uint64_t double_words[NODE_WORDS / 2]; + +#if defined(_M_X64) && ENABLE_SSE + __m128i xmm[NODE_WORDS/4]; +#endif + +} node; + +void ethash_calculate_dag_item( + node *const ret, + const unsigned node_index, + ethash_params const *params, + ethash_cache const *cache +); + +void ethash_quick_hash( + uint8_t return_hash[32], + const uint8_t header_hash[32], + const uint64_t nonce, + const uint8_t mix_hash[32]); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/sha3.c b/libethash/sha3.c new file mode 100644 index 000000000..0c28230b8 --- /dev/null +++ b/libethash/sha3.c @@ -0,0 +1,151 @@ +/** libkeccak-tiny +* +* A single-file implementation of SHA-3 and SHAKE. +* +* Implementor: David Leon Gil +* License: CC0, attribution kindly requested. Blame taken too, +* but not liability. +*/ +#include "sha3.h" + +#include +#include +#include +#include + +/******** The Keccak-f[1600] permutation ********/ + +/*** Constants. ***/ +static const uint8_t rho[24] = \ + { 1, 3, 6, 10, 15, 21, + 28, 36, 45, 55, 2, 14, + 27, 41, 56, 8, 25, 43, + 62, 18, 39, 61, 20, 44}; +static const uint8_t pi[24] = \ + {10, 7, 11, 17, 18, 3, + 5, 16, 8, 21, 24, 4, + 15, 23, 19, 13, 12, 2, + 20, 14, 22, 9, 6, 1}; +static const uint64_t RC[24] = \ + {1ULL, 0x8082ULL, 0x800000000000808aULL, 0x8000000080008000ULL, + 0x808bULL, 0x80000001ULL, 0x8000000080008081ULL, 0x8000000000008009ULL, + 0x8aULL, 0x88ULL, 0x80008009ULL, 0x8000000aULL, + 0x8000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL, 0x8000000000008003ULL, + 0x8000000000008002ULL, 0x8000000000000080ULL, 0x800aULL, 0x800000008000000aULL, + 0x8000000080008081ULL, 0x8000000000008080ULL, 0x80000001ULL, 0x8000000080008008ULL}; + +/*** Helper macros to unroll the permutation. ***/ +#define rol(x, s) (((x) << s) | ((x) >> (64 - s))) +#define REPEAT6(e) e e e e e e +#define REPEAT24(e) REPEAT6(e e e e) +#define REPEAT5(e) e e e e e +#define FOR5(v, s, e) \ + v = 0; \ + REPEAT5(e; v += s;) + +/*** Keccak-f[1600] ***/ +static inline void keccakf(void* state) { + uint64_t* a = (uint64_t*)state; + uint64_t b[5] = {0}; + uint64_t t = 0; + uint8_t x, y; + + for (int i = 0; i < 24; i++) { + // Theta + FOR5(x, 1, + b[x] = 0; + FOR5(y, 5, + b[x] ^= a[x + y]; )) + FOR5(x, 1, + FOR5(y, 5, + a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); )) + // Rho and pi + t = a[1]; + x = 0; + REPEAT24(b[0] = a[pi[x]]; + a[pi[x]] = rol(t, rho[x]); + t = b[0]; + x++; ) + // Chi + FOR5(y, + 5, + FOR5(x, 1, + b[x] = a[y + x];) + FOR5(x, 1, + a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); )) + // Iota + a[0] ^= RC[i]; + } +} + +/******** The FIPS202-defined functions. ********/ + +/*** Some helper macros. ***/ + +#define _(S) do { S } while (0) +#define FOR(i, ST, L, S) \ + _(for (size_t i = 0; i < L; i += ST) { S; }) +#define mkapply_ds(NAME, S) \ + static inline void NAME(uint8_t* dst, \ + const uint8_t* src, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } +#define mkapply_sd(NAME, S) \ + static inline void NAME(const uint8_t* src, \ + uint8_t* dst, \ + size_t len) { \ + FOR(i, 1, len, S); \ + } + +mkapply_ds(xorin, dst[i] ^= src[i]) // xorin +mkapply_sd(setout, dst[i] = src[i]) // setout + +#define P keccakf +#define Plen 200 + +// Fold P*F over the full blocks of an input. +#define foldP(I, L, F) \ + while (L >= rate) { \ + F(a, I, rate); \ + P(a); \ + I += rate; \ + L -= rate; \ + } + +/** The sponge-based hash construction. **/ +static inline int hash(uint8_t* out, size_t outlen, + const uint8_t* in, size_t inlen, + size_t rate, uint8_t delim) { + if ((out == NULL) || ((in == NULL) && inlen != 0) || (rate >= Plen)) { + return -1; + } + uint8_t a[Plen] = {0}; + // Absorb input. + foldP(in, inlen, xorin); + // Xor in the DS and pad frame. + a[inlen] ^= delim; + a[rate - 1] ^= 0x80; + // Xor in the last block. + xorin(a, in, inlen); + // Apply P + P(a); + // Squeeze output. + foldP(out, outlen, setout); + setout(a, out, outlen); + memset(a, 0, 200); + return 0; +} + +#define defsha3(bits) \ + int sha3_##bits(uint8_t* out, size_t outlen, \ + const uint8_t* in, size_t inlen) { \ + if (outlen > (bits/8)) { \ + return -1; \ + } \ + return hash(out, outlen, in, inlen, 200 - (bits / 4), 0x01); \ + } + +/*** FIPS202 SHA3 FOFs ***/ +defsha3(256) +defsha3(512) \ No newline at end of file diff --git a/libethash/sha3.h b/libethash/sha3.h new file mode 100644 index 000000000..36a0a5301 --- /dev/null +++ b/libethash/sha3.h @@ -0,0 +1,27 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "compiler.h" +#include +#include + +#define decsha3(bits) \ + int sha3_##bits(uint8_t*, size_t, const uint8_t*, size_t); + +decsha3(256) +decsha3(512) + +static inline void SHA3_256(uint8_t * const ret, uint8_t const *data, const size_t size) { + sha3_256(ret, 32, data, size); +} + +static inline void SHA3_512(uint8_t * const ret, uint8_t const *data, const size_t size) { + sha3_512(ret, 64, data, size); +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/sha3_cryptopp.cpp b/libethash/sha3_cryptopp.cpp new file mode 100644 index 000000000..9454ce04a --- /dev/null +++ b/libethash/sha3_cryptopp.cpp @@ -0,0 +1,34 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ + +/** @file sha3.cpp +* @author Tim Hughes +* @date 2015 +*/ + +#include +#include + +extern "C" { +void SHA3_256(uint8_t *const ret, const uint8_t *data, size_t size) { + CryptoPP::SHA3_256().CalculateDigest(ret, data, size); +} + +void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size) { + CryptoPP::SHA3_512().CalculateDigest(ret, data, size); +} +} \ No newline at end of file diff --git a/libethash/sha3_cryptopp.h b/libethash/sha3_cryptopp.h new file mode 100644 index 000000000..f910960e1 --- /dev/null +++ b/libethash/sha3_cryptopp.h @@ -0,0 +1,15 @@ +#pragma once + +#include "compiler.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void SHA3_256(uint8_t *const ret, const uint8_t *data, size_t size); +void SHA3_512(uint8_t *const ret, const uint8_t *data, size_t size); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/libethash/util.c b/libethash/util.c new file mode 100644 index 000000000..fbf268b7d --- /dev/null +++ b/libethash/util.c @@ -0,0 +1,41 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file util.c + * @author Tim Hughes + * @date 2015 + */ +#include +#include +#include "util.h" + +#ifdef _MSC_VER + +// foward declare without all of Windows.h +__declspec(dllimport) void __stdcall OutputDebugStringA(const char* lpOutputString); + +void debugf(const char *str, ...) +{ + va_list args; + va_start(args, str); + + char buf[1<<16]; + _vsnprintf_s(buf, sizeof(buf), sizeof(buf), str, args); + buf[sizeof(buf)-1] = '\0'; + OutputDebugStringA(buf); +} + +#endif diff --git a/libethash/util.h b/libethash/util.h new file mode 100644 index 000000000..2f59076f6 --- /dev/null +++ b/libethash/util.h @@ -0,0 +1,47 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file util.h + * @author Tim Hughes + * @date 2015 + */ +#pragma once +#include +#include "compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +void debugf(const char *str, ...); +#else +#define debugf printf +#endif + +static inline uint32_t min_u32(uint32_t a, uint32_t b) +{ + return a < b ? a : b; +} + +static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_) +{ + return x < min_ ? min_ : (x > max_ ? max_ : x); +} + +#ifdef __cplusplus +} +#endif From 5ac16c53f3181c29145cd1de801b07aa81f21bf2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 244/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 92 +++++++++---------------------------------- libethcore/Common.cpp | 11 +----- libethereum/State.cpp | 28 +++++++------ libethereum/State.h | 38 ++++-------------- 4 files changed, 44 insertions(+), 125 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 1abf2d8c0..79852304c 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -334,20 +334,19 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class HashedGenericTrieDB: private SpecificTrieDB, h256> +template +class SecureGenericTrieDB: private TrieDB { - using Super = SpecificTrieDB, h256>; + using Super = TrieDB; public: - using DB = _DB; - - HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} - HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; + using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -360,84 +359,29 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - - // empty from the PoV of the iterator interface; still need a basic iterator impl though. - class iterator - { - public: - using value_type = std::pair; - - iterator() {} - iterator(HashedGenericTrieDB const*) {} - iterator(HashedGenericTrieDB const*, bytesConstRef) {} - - iterator& operator++() { return *this; } - value_type operator*() const { return value_type(); } - value_type operator->() const { return value_type(); } - - bool operator==(iterator const&) const { return true; } - bool operator!=(iterator const&) const { return false; } - - value_type at() const { return value_type(); } - }; - iterator begin() const { return iterator(); } - iterator end() const { return iterator(); } - iterator lower_bound(bytesConstRef) const { return iterator(); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } }; -// Hashed & Basic -template -class FatGenericTrieDB: public GenericTrieDB +template +class SecureTrieDB: public SecureGenericTrieDB { - using Super = GenericTrieDB; + using Super = SecureGenericTrieDB; public: - FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} - FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} - void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - - void init() { Super::init(); m_secure.init(); syncRoot(); } - - void setRoot(h256 _root) - { - if (!m_secure.isNull()) - Super::db()->removeAux(m_secure.root()); - m_secure.setRoot(_root); - auto rb = Super::db()->lookupAux(m_secure.root()); - auto r = h256(rb); - Super::setRoot(r); - } - - h256 root() const { return m_secure.root(); } - - void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } - void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } - - std::set leftOvers(std::ostream* = nullptr) const { return {}; } - bool check(bool) const { return m_secure.check(false) && Super::check(false); } - -private: - void syncRoot() - { - // Root changed. Need to record the mapping so we can determine on setRoot. - Super::db()->insertAux(m_secure.root(), Super::root().ref()); - } + std::string operator[](KeyType _k) const { return at(_k); } - HashedGenericTrieDB m_secure; + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template using TrieDB = SpecificTrieDB, KeyType>; - -#if ETH_FATDB -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#else -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#endif - } // Template implementations... diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 9eb622fe3..331ee837e 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -32,15 +32,8 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 56; -const unsigned c_databaseBaseVersion = 7; -#if ETH_FATDB -const unsigned c_databaseVersionModifier = 1000; -#else -const unsigned c_databaseVersionModifier = 0; -#endif - -const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier; +const unsigned c_protocolVersion = 55; +const unsigned c_databaseVersion = 5; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 568629084..faa212cc7 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,10 +180,11 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,9 +346,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -952,9 +954,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1190,8 +1193,9 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index 00a735291..eedf324fb 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,36 +334,14 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; - } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); } } } From 98083470abcdfc473cab246623993ddd3cdec1f1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 245/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 5 ++- libdevcrypto/TrieDB.h | 75 ++++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 49c6ed2bf..1da3f95d6 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 7d39ba73b..2f4233f01 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,9 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } - void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } std::set keys() const; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 79852304c..91a39b3cc 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db = nullptr): m_db(_db) {} + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} + SpecificTrieDB(DB* _db): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -334,19 +334,20 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -359,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... From 7a0f440b1ff0474bda6bb1b9a9d83d5126de32a6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 246/313] FatDB integrated. --- CMakeLists.txt | 8 +------- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/Common.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59cfe4ea3..2afe78bb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,6 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") - set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") - set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -51,11 +49,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (SOLIDITY) - add_definitions(-DETH_SOLIDITY) - endif() - - if (HEADLESS OR JUSTTESTS) + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 91a39b3cc..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 331ee837e..a9095c5cd 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index faa212cc7..568629084 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,11 +180,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -346,10 +345,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -954,10 +952,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1193,9 +1190,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From c3f998bad7a019a8ea68261dfde1a2b24374107b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 247/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 3 +- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 6 ++-- libdevcrypto/OverlayDB.cpp | 14 ++------- libdevcrypto/TrieDB.h | 2 +- libethcore/Common.cpp | 2 +- libethereum/BlockChain.cpp | 2 +- libethereum/State.h | 38 ++++++++++++++++++----- test/trie.cpp | 62 -------------------------------------- 9 files changed, 43 insertions(+), 90 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2afe78bb8..5ff81e153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 1da3f95d6..49c6ed2bf 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 2f4233f01..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,8 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; @@ -61,7 +61,7 @@ protected: std::map m_over; std::map m_refCount; - std::set m_auxActive; + h256 m_auxKey; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4bd698f57..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,8 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - for (auto const& i: m_auxActive) - if (m_aux.count(i)) - { - m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - m_aux.erase(i); - } - m_auxActive.clear(); - m_aux.clear(); + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } @@ -71,9 +65,7 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, aux(_h).ref(), &v); - if (v.empty()) - cwarn << "Aux not found: " << _h; + m_db->Get(m_readOptions, _h.ref(), &v); return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..f32170cd4 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index a9095c5cd..f47bb002b 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 4415120c4..93263d385 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -46,7 +46,7 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_blocksDB->NewIterator(_bc.m_readOptions); + auto it = _bc.m_db->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { diff --git a/libethereum/State.h b/libethereum/State.h index eedf324fb..00a735291 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,14 +334,36 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } } } diff --git a/test/trie.cpp b/test/trie.cpp index 9e59dd316..84d0e846f 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,68 +74,6 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } -BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Secure Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - GenericTrieDB t(&m); - MemoryDB hm; - HashedGenericTrieDB ht(&hm); - MemoryDB fm; - FatGenericTrieDB ft(&fm); - t.init(); - ht.init(); - ft.init(); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - ht.insert(k.first, k.second); - ft.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) - { - BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); - BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); - BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); - } - BOOST_CHECK_EQUAL(ht.root(), ft.root()); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 059dc92e277bd9f7665f5d5911c1039c5461f3cf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 248/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f32170cd4..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From 0d004524f3ecef7074cd618f4e3a84c1b7fd5432 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 249/313] New gas pricing for PoC-9. --- libethereum/ExtVM.h | 2 +- libevm/VM.cpp | 14 ++++++++------ libevmcore/Instruction.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index d63cd943a..a4ab7ead3 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/libevm/VM.cpp b/libevm/VM.cpp index e0b487c9b..9f2fa6874 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,13 +82,19 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas = c_tierStepGas[metric.gasPriceTier]; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -145,10 +151,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::JUMPDEST: - runGas = 1; - break; - case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -164,7 +166,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index 23f19ac94..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From 00c2e954865be4f7a3ca8c02493e5701e67c5fb6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 250/313] Gas fixes. Trie fixes. --- libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 6 +++++- libethereum/Client.cpp | 9 ++------- libevm/VM.cpp | 8 +------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index b5355f1e0..c9c182028 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -278,14 +278,9 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -#if ETH_DEBUG && 0 - cdebug << "checkWatch" << _watchId; -#endif - auto& w = m_watches.at(_watchId); -#if ETH_DEBUG && 0 - cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); -#endif +// cdebug << "checkWatch" << _watchId; auto& w = m_watches.at(_watchId); +// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 9f2fa6874..f4e904e3f 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,19 +82,13 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() From d2cda84f84e40a14279778bfd4d007c95627e0e2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 251/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index f4e904e3f..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From d6068763c5c5b289e40b88913e10c74d8128976a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 252/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index a4ab7ead3..d63cd943a 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final From 3f62b787aaafbd7c839a5bdc69e06fcc69865bbe Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 253/313] only check rootHash of state if FATDB is off --- test/state.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/state.cpp b/test/state.cpp index 5202aff22..71a4bbcfa 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -93,6 +93,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) From d6c89e465f56acd701af2b29cf139e85ad021247 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 254/313] add memory tests --- test/state.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/state.cpp b/test/state.cpp index 71a4bbcfa..5202aff22 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -93,7 +93,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) From 8b0829ed4da20d69142b34d64693832925adf803 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 255/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From 6aa1db26e661e52d843609bbfd28742fdbc42dd7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 256/313] Log/bloom alterations. --- libethcore/BlockInfo.cpp | 14 +++++++------- libethereum/BlockDetails.h | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 3b4878a7d..5e1752cab 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -96,13 +96,13 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) int field = 0; try { - parentHash = _header[field = 0].toHash(RLP::VeryStrict); - sha3Uncles = _header[field = 1].toHash(RLP::VeryStrict); - coinbaseAddress = _header[field = 2].toHash
(RLP::VeryStrict); - stateRoot = _header[field = 3].toHash(RLP::VeryStrict); - transactionsRoot = _header[field = 4].toHash(RLP::VeryStrict); - receiptsRoot = _header[field = 5].toHash(RLP::VeryStrict); - logBloom = _header[field = 6].toHash(RLP::VeryStrict); + parentHash = _header[field = 0].toHash(); + sha3Uncles = _header[field = 1].toHash(); + coinbaseAddress = _header[field = 2].toHash
(); + stateRoot = _header[field = 3].toHash(); + transactionsRoot = _header[field = 4].toHash(); + receiptsRoot = _header[field = 5].toHash(); + logBloom = _header[field = 6].toHash(); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index ed478568d..2ea558a14 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -57,11 +57,10 @@ struct BlockDetails struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); size = _r.data().size(); } - bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } + bytes rlp() const { RLPStream s; s << blooms; return s.out(); } LogBlooms blooms; - mutable unsigned size; }; struct BlockReceipts From 82cbf1c915f584edc3ec5d8e0a6b29cf57ea0f7c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 257/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ff81e153..59cfe4ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 62d159418..7f2d5b501 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index 84d0e846f..9e59dd316 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,6 +74,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From e479d6f6f20b5df9c349bb862823458a88feaa99 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 258/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 feeStructure.json diff --git a/feeStructure.json b/feeStructure.json new file mode 100644 index 000000000..f09464a5a --- /dev/null +++ b/feeStructure.json @@ -0,0 +1,38 @@ +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, + + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} From d636372c2334d713496aaea56874704d2ea108a2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 259/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethcore/Params.h | 8 ++++ libethereum/Precompiled.cpp | 12 ++--- 3 files changed, 66 insertions(+), 42 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethcore/Params.h b/libethcore/Params.h index cab1852fa..242a44ddd 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -74,5 +74,13 @@ extern u256 const c_ripemd160WordGas; extern u256 const c_identityGas; extern u256 const c_identityWordGas; +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 7f2d5b501..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include using namespace std; using namespace dev; using namespace dev::eth; @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() From 014a0ee274a1ec161278cf172f57a1344c74529b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 260/313] VM CALLCODE fix. --- libethcore/Params.h | 18 ------------------ libevm/VM.cpp | 2 +- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/libethcore/Params.h b/libethcore/Params.h index 242a44ddd..9109347dc 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -29,16 +29,6 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json -extern u256 const c_genesisDifficulty; -extern u256 const c_maximumExtraDataSize; -extern u256 const c_epochDuration; -extern u256 const c_genesisGasLimit; -extern u256 const c_minGasLimit; -extern u256 const c_gasLimitBoundDivisor; -extern u256 const c_minimumDifficulty; -extern u256 const c_difficultyBoundDivisor; -extern u256 const c_durationLimit; - extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. @@ -74,13 +64,5 @@ extern u256 const c_ripemd160WordGas; extern u256 const c_identityGas; extern u256 const c_identityWordGas; -extern u256 const c_ecrecoverGas; -extern u256 const c_sha256Gas; -extern u256 const c_sha256WordGas; -extern u256 const c_ripemd160Gas; -extern u256 const c_ripemd160WordGas; -extern u256 const c_identityGas; -extern u256 const c_identityWordGas; - } } diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From c40119340aa4478a51ff55882ac8b036e3e87766 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:03:47 +0100 Subject: [PATCH 261/313] Lenient gas limit. Two uncles only. Min 2048 difficulty & assoc adjustment. --- libethcore/BlockInfo.cpp | 9 ++++++--- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 3 +-- libethereum/State.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 5e1752cab..42dffe92f 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -206,9 +206,11 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return (u256)c_genesisDifficulty; else - return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); + return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } +template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } + void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. @@ -219,8 +221,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (seedHash != calculateSeedHash(_parent)) - BOOST_THROW_EXCEPTION(InvalidSeedHash()); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + // Check timestamp is after previous timestamp. if (parentHash) diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c489c8f4a..c4628f4aa 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index edf3d6b03..e1561ef0e 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -57,8 +57,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real); h256 head; h256 real; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; -struct InvalidSeedHash: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 568629084..ec6643684 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -547,7 +547,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) if (rlp[2].itemCount() > 2) BOOST_THROW_EXCEPTION(TooManyUncles()); - set nonces = { m_currentBlock.nonce }; + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); From 1328d7e7432b5612285041b6db4fe68428e9cbc3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 00:52:51 +0100 Subject: [PATCH 262/313] New SecureTrie. --- libdevcrypto/TrieDB.h | 92 +++++++++---------------------------------- libethcore/Common.cpp | 8 +--- libethereum/State.cpp | 28 +++++++------ libethereum/State.h | 38 ++++-------------- 4 files changed, 43 insertions(+), 123 deletions(-) diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 1abf2d8c0..79852304c 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -334,20 +334,19 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class HashedGenericTrieDB: private SpecificTrieDB, h256> +template +class SecureGenericTrieDB: private TrieDB { - using Super = SpecificTrieDB, h256>; + using Super = TrieDB; public: - using DB = _DB; - - HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} - HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + SecureGenericTrieDB(DB* _db): Super(_db) {} + SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; + using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -360,84 +359,29 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - - // empty from the PoV of the iterator interface; still need a basic iterator impl though. - class iterator - { - public: - using value_type = std::pair; - - iterator() {} - iterator(HashedGenericTrieDB const*) {} - iterator(HashedGenericTrieDB const*, bytesConstRef) {} - - iterator& operator++() { return *this; } - value_type operator*() const { return value_type(); } - value_type operator->() const { return value_type(); } - - bool operator==(iterator const&) const { return true; } - bool operator!=(iterator const&) const { return false; } - - value_type at() const { return value_type(); } - }; - iterator begin() const { return iterator(); } - iterator end() const { return iterator(); } - iterator lower_bound(bytesConstRef) const { return iterator(); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } }; -// Hashed & Basic -template -class FatGenericTrieDB: public GenericTrieDB +template +class SecureTrieDB: public SecureGenericTrieDB { - using Super = GenericTrieDB; + using Super = SecureGenericTrieDB; public: - FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} - FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } + SecureTrieDB(DB* _db): Super(_db) {} + SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} - void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - - void init() { Super::init(); m_secure.init(); syncRoot(); } - - void setRoot(h256 _root) - { - if (!m_secure.isNull()) - Super::db()->removeAux(m_secure.root()); - m_secure.setRoot(_root); - auto rb = Super::db()->lookupAux(m_secure.root()); - auto r = h256(rb); - Super::setRoot(r); - } - - h256 root() const { return m_secure.root(); } - - void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } - void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } - - std::set leftOvers(std::ostream* = nullptr) const { return {}; } - bool check(bool) const { return m_secure.check(false) && Super::check(false); } - -private: - void syncRoot() - { - // Root changed. Need to record the mapping so we can determine on setRoot. - Super::db()->insertAux(m_secure.root(), Super::root().ref()); - } + std::string operator[](KeyType _k) const { return at(_k); } - HashedGenericTrieDB m_secure; + bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } + void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } + void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } }; -template using TrieDB = SpecificTrieDB, KeyType>; - -#if ETH_FATDB -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#else -template using SecureTrieDB = SpecificTrieDB, KeyType>; -#endif - } // Template implementations... diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index f47bb002b..331ee837e 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,13 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 6 + -#if ETH_FATDB - 1000 -#else - 0 -#endif -; +const unsigned c_databaseVersion = 5; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index ec6643684..37a113905 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,10 +180,11 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - for (auto i: trie) - ads.insert(i.first), trieAds.insert(i.first); - for (auto i: trieD) - ads.insert(i.first), trieAdsD.insert(i.first); + // TODO: fix +// for (auto i: trie) +// ads.insert(i.first), trieAds.insert(i.first); +// for (auto i: trieD) +// ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -345,9 +346,10 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - for (auto const& i: m_state) - if (m_cache.find(i.first) == m_cache.end()) - ret[i.first] = RLP(i.second)[1].toInt(); + // TODO: fix. +// for (auto const& i: m_state) +// if (m_cache.find(i.first) == m_cache.end()) +// ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -952,9 +954,10 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) - for (auto const& i: memdb) - ret[i.first] = RLP(i.second).toInt(); + // TODO: fix +// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) +// for (auto const& i: memdb) +// ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1190,8 +1193,9 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - for (auto const& j: memdb) - mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + // TODO: fix +// for (auto const& j: memdb) +// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) diff --git a/libethereum/State.h b/libethereum/State.h index 00a735291..eedf324fb 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,36 +334,14 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); - } - - if (i.second.isFreshCode()) - { - h256 ch = sha3(i.second.code()); - _db.insert(ch, &i.second.code()); - s << ch; - } - else - s << i.second.codeHash(); - - _state.insert(i.first, &s.out()); + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); } } } From 49d7cdf1d4340243bba8e29d75e16b0a5c7ef515 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 17:47:27 +0100 Subject: [PATCH 263/313] Fat Trie and tests for it. --- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 5 ++- libdevcrypto/TrieDB.h | 75 ++++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 49c6ed2bf..1da3f95d6 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 7d39ba73b..2f4233f01 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,9 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } - void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } + bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } + void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } std::set keys() const; diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 79852304c..91a39b3cc 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db = nullptr): m_db(_db) {} + GenericTrieDB(DB* _db): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} + SpecificTrieDB(DB* _db): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -334,19 +334,20 @@ std::ostream& operator<<(std::ostream& _out, SpecificTrieDB co return _out; } -template -class SecureGenericTrieDB: private TrieDB +template +class HashedGenericTrieDB: private SpecificTrieDB, h256> { - using Super = TrieDB; + using Super = SpecificTrieDB, h256>; public: - SecureGenericTrieDB(DB* _db): Super(_db) {} - SecureGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + using DB = _DB; + + HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; using Super::init; using Super::setRoot; - using Super::haveRoot; /// True if the trie is uninitialised (i.e. that the DB doesn't contain the root node). using Super::isNull; @@ -359,29 +360,63 @@ public: using Super::check; std::string at(bytesConstRef _key) const { return Super::at(sha3(_key)); } + bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - bool contains(bytesConstRef _key) { return Super::contains(sha3(_key)); } + + // empty from the PoV of the iterator interface. + using iterator = void*; + iterator begin() const { return nullptr; } + iterator end() const { return nullptr; } + iterator lower_bound(bytesConstRef) const { return end(); } }; -template -class SecureTrieDB: public SecureGenericTrieDB +// Hashed & Basic +template +class FatGenericTrieDB: public GenericTrieDB { - using Super = SecureGenericTrieDB; + using Super = GenericTrieDB; public: - SecureTrieDB(DB* _db): Super(_db) {} - SecureTrieDB(DB* _db, h256 _root): Super(_db, _root) {} + FatGenericTrieDB(DB* _db): Super(_db), m_secure(_db) {} + FatGenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } - std::string operator[](KeyType _k) const { return at(_k); } + void open(DB* _db, h256 _root) { Super::open(_db); m_secure.open(_db); setRoot(_root); } - bool contains(KeyType _k) const { return Super::contains(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - std::string at(KeyType _k) const { return Super::at(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } - void insert(KeyType _k, bytesConstRef _value) { Super::insert(bytesConstRef((byte const*)&_k, sizeof(KeyType)), _value); } - void insert(KeyType _k, bytes const& _value) { insert(_k, bytesConstRef(&_value)); } - void remove(KeyType _k) { Super::remove(bytesConstRef((byte const*)&_k, sizeof(KeyType))); } + void init() { Super::init(); m_secure.init(); syncRoot(); } + + void setRoot(h256 _root) + { + m_secure.setRoot(_root); + Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + } + + h256 root() const { return m_secure.root(); } + + void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } + void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } + + std::set leftOvers(std::ostream* = nullptr) const { return {}; } + bool check(bool) const { return m_secure.check(false) && Super::check(false); } + +private: + void syncRoot() + { + // Root changed. Need to record the mapping so we can determine on setRoot. + Super::db()->insertAux(m_secure.root(), Super::root().ref()); + } + + HashedGenericTrieDB m_secure; }; +template using TrieDB = SpecificTrieDB, KeyType>; + +#if ETH_FAT_DB +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#else +template using SecureTrieDB = SpecificTrieDB, KeyType>; +#endif + } // Template implementations... From 4cd9b699bd7a6e7f4b870b10c9df9a103802fb0f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 18:15:05 +0100 Subject: [PATCH 264/313] FatDB integrated. --- CMakeLists.txt | 8 +------- libdevcrypto/TrieDB.h | 35 ++++++++++++++++++++++++++--------- libethcore/Common.cpp | 8 +++++++- libethereum/State.cpp | 28 ++++++++++++---------------- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59cfe4ea3..2afe78bb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,6 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") - set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") - set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -51,11 +49,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (SOLIDITY) - add_definitions(-DETH_SOLIDITY) - endif() - - if (HEADLESS OR JUSTTESTS) + if (HEADLESS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index 91a39b3cc..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -68,7 +68,7 @@ class GenericTrieDB public: using DB = _DB; - GenericTrieDB(DB* _db): m_db(_db) {} + GenericTrieDB(DB* _db = nullptr): m_db(_db) {} GenericTrieDB(DB* _db, h256 _root) { open(_db, _root); } ~GenericTrieDB() {} @@ -294,7 +294,7 @@ public: using DB = typename Generic::DB; using KeyType = _KeyType; - SpecificTrieDB(DB* _db): Generic(_db) {} + SpecificTrieDB(DB* _db = nullptr): Generic(_db) {} SpecificTrieDB(DB* _db, h256 _root): Generic(_db, _root) {} std::string operator[](KeyType _k) const { return at(_k); } @@ -342,7 +342,7 @@ class HashedGenericTrieDB: private SpecificTrieDB, h256> public: using DB = _DB; - HashedGenericTrieDB(DB* _db): Super(_db) {} + HashedGenericTrieDB(DB* _db = nullptr): Super(_db) {} HashedGenericTrieDB(DB* _db, h256 _root): Super(_db, _root) {} using Super::open; @@ -364,11 +364,28 @@ public: void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(sha3(_key), _value); } void remove(bytesConstRef _key) { Super::remove(sha3(_key)); } - // empty from the PoV of the iterator interface. - using iterator = void*; - iterator begin() const { return nullptr; } - iterator end() const { return nullptr; } - iterator lower_bound(bytesConstRef) const { return end(); } + // empty from the PoV of the iterator interface; still need a basic iterator impl though. + class iterator + { + public: + using value_type = std::pair; + + iterator() {} + iterator(HashedGenericTrieDB const*) {} + iterator(HashedGenericTrieDB const*, bytesConstRef) {} + + iterator& operator++() { return *this; } + value_type operator*() const { return value_type(); } + value_type operator->() const { return value_type(); } + + bool operator==(iterator const&) const { return true; } + bool operator!=(iterator const&) const { return false; } + + value_type at() const { return value_type(); } + }; + iterator begin() const { return iterator(); } + iterator end() const { return iterator(); } + iterator lower_bound(bytesConstRef) const { return iterator(); } }; // Hashed & Basic @@ -411,7 +428,7 @@ private: template using TrieDB = SpecificTrieDB, KeyType>; -#if ETH_FAT_DB +#if ETH_FATDB template using SecureTrieDB = SpecificTrieDB, KeyType>; #else template using SecureTrieDB = SpecificTrieDB, KeyType>; diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 331ee837e..a9095c5cd 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,7 +33,13 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5; +const unsigned c_databaseVersion = 5 + +#if ETH_FATDB + 1000 +#else + 0 +#endif +; vector> const& units() { diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 37a113905..ec6643684 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -180,11 +180,10 @@ StateDiff State::diff(State const& _c) const auto trie = SecureTrieDB(const_cast(&m_db), rootHash()); auto trieD = SecureTrieDB(const_cast(&_c.m_db), _c.rootHash()); - // TODO: fix -// for (auto i: trie) -// ads.insert(i.first), trieAds.insert(i.first); -// for (auto i: trieD) -// ads.insert(i.first), trieAdsD.insert(i.first); + for (auto i: trie) + ads.insert(i.first), trieAds.insert(i.first); + for (auto i: trieD) + ads.insert(i.first), trieAdsD.insert(i.first); for (auto i: m_cache) ads.insert(i.first); for (auto i: _c.m_cache) @@ -346,10 +345,9 @@ map State::addresses() const for (auto i: m_cache) if (i.second.isAlive()) ret[i.first] = i.second.balance(); - // TODO: fix. -// for (auto const& i: m_state) -// if (m_cache.find(i.first) == m_cache.end()) -// ret[i.first] = RLP(i.second)[1].toInt(); + for (auto const& i: m_state) + if (m_cache.find(i.first) == m_cache.end()) + ret[i.first] = RLP(i.second)[1].toInt(); return ret; } @@ -954,10 +952,9 @@ map State::storage(Address _id) const // Pull out all values from trie storage. if (it->second.baseRoot()) { - // TODO: fix -// SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) -// for (auto const& i: memdb) -// ret[i.first] = RLP(i.second).toInt(); + SecureTrieDB memdb(const_cast(&m_db), it->second.baseRoot()); // promise we won't alter the overlay! :) + for (auto const& i: memdb) + ret[i.first] = RLP(i.second).toInt(); } // Then merge cached storage over the top. @@ -1193,9 +1190,8 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, State const& _s) if (r) { SecureTrieDB memdb(const_cast(&_s.m_db), r[2].toHash()); // promise we won't alter the overlay! :) - // TODO: fix -// for (auto const& j: memdb) -// mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); + for (auto const& j: memdb) + mem[j.first] = RLP(j.second).toInt(), back.insert(j.first); } if (cache) for (auto const& j: cache->storageOverlay()) From bccb7c9e89e1e6d96b5a159e0d59c7225b12b439 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 22:54:05 +0100 Subject: [PATCH 265/313] State integration test. Fixes to the FatTrie. --- CMakeLists.txt | 3 +- libdevcore/FixedHash.h | 4 +-- libdevcrypto/MemoryDB.h | 6 ++-- libdevcrypto/OverlayDB.cpp | 16 ++-------- libdevcrypto/TrieDB.h | 2 +- libethcore/Common.cpp | 2 +- libethereum/State.h | 38 ++++++++++++++++++----- test/trie.cpp | 62 -------------------------------------- 8 files changed, 42 insertions(+), 91 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2afe78bb8..5ff81e153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ function(createDefaultCacheConfig) set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on") set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") + set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") endfunction() @@ -49,7 +50,7 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() - if (HEADLESS) + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() endfunction() diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 1da3f95d6..49c6ed2bf 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -65,10 +65,10 @@ public: FixedHash(Arith const& _arith) { toBigEndian(_arith, m_data); } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytes const& _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a byte array. - explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else if (_t != FailIfDifferent) { m_data.fill(0); auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } + explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a bytes in memory with given pointer. explicit FixedHash(byte const* _bs, ConstructFromPointerType) { memcpy(m_data.data(), _bs, N); } diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index 2f4233f01..ecda3b6ec 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -51,8 +51,8 @@ public: bool kill(h256 _h); void purge(); - bytes lookupAux(h256 _h) const { return asBytes(lookup(h256(sha3(_h).ref().cropped(16), h256::AlignRight))); } - void insertAux(h256 _h, bytesConstRef _v) { return insert(h256(sha3(_h).ref().cropped(16), h256::AlignRight), _v); } + bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } + void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } std::set keys() const; @@ -61,7 +61,7 @@ protected: std::map m_over; std::map m_refCount; - std::set m_auxActive; + h256 m_auxKey; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4f237becb 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,16 +52,8 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - for (auto const& i: m_auxActive) - if (m_aux.count(i)) - { - m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; - m_aux.erase(i); - } - cdebug << "Discarding " << keysOf(m_aux); - m_auxActive.clear(); - m_aux.clear(); + if (m_auxKey && m_aux.count(m_auxKey)) + m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); m_over.clear(); m_refCount.clear(); } @@ -73,9 +65,7 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, aux(_h).ref(), &v); - if (v.empty()) - cwarn << "Aux not found: " << _h; + m_db->Get(m_readOptions, _h.ref(), &v); return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..f32170cd4 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { return m_secure.root(); } + h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index a9095c5cd..f47bb002b 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,7 +33,7 @@ namespace eth { const unsigned c_protocolVersion = 55; -const unsigned c_databaseVersion = 5 + +const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 #else diff --git a/libethereum/State.h b/libethereum/State.h index eedf324fb..00a735291 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -334,14 +334,36 @@ void commit(std::map const& _cache, DB& _db, SecureTrieDB storageDB(&_db, i.second.baseRoot()); - for (auto const& j: i.second.storageOverlay()) - if (j.second) - storageDB.insert(j.first, rlp(j.second)); - else - storageDB.remove(j.first); - assert(storageDB.root()); - s.append(storageDB.root()); + RLPStream s(4); + s << i.second.nonce() << i.second.balance(); + + if (i.second.storageOverlay().empty()) + { + assert(i.second.baseRoot()); + s.append(i.second.baseRoot()); + } + else + { + SecureTrieDB storageDB(&_db, i.second.baseRoot()); + for (auto const& j: i.second.storageOverlay()) + if (j.second) + storageDB.insert(j.first, rlp(j.second)); + else + storageDB.remove(j.first); + assert(storageDB.root()); + s.append(storageDB.root()); + } + + if (i.second.isFreshCode()) + { + h256 ch = sha3(i.second.code()); + _db.insert(ch, &i.second.code()); + s << ch; + } + else + s << i.second.codeHash(); + + _state.insert(i.first, &s.out()); } } } diff --git a/test/trie.cpp b/test/trie.cpp index 9e59dd316..84d0e846f 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,68 +74,6 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } -BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Secure Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - GenericTrieDB t(&m); - MemoryDB hm; - HashedGenericTrieDB ht(&hm); - MemoryDB fm; - FatGenericTrieDB ft(&fm); - t.init(); - ht.init(); - ft.init(); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - ht.insert(k.first, k.second); - ft.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - BOOST_REQUIRE(ht.check(true)); - BOOST_REQUIRE(ft.check(true)); - for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) - { - BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); - BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); - BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); - } - BOOST_CHECK_EQUAL(ht.root(), ft.root()); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From dfc65d2fcea8c139dd1c4cd7cfc23846c112f85b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 1 Mar 2015 23:14:54 +0100 Subject: [PATCH 266/313] Fixes for FatTrie. --- libdevcrypto/OverlayDB.cpp | 11 ++++++++++- libdevcrypto/TrieDB.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index 4f237becb..d34dd1906 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -53,7 +53,14 @@ void OverlayDB::commit() m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } if (m_auxKey && m_aux.count(m_auxKey)) + { m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); + cdebug << "Committing aux: " << m_auxKey; + m_aux.erase(m_auxKey); + cdebug << "Discarding " << keysOf(m_aux); + } + m_auxKey = h256(); + m_aux.clear(); m_over.clear(); m_refCount.clear(); } @@ -65,7 +72,9 @@ bytes OverlayDB::lookupAux(h256 _h) const if (!ret.empty()) return ret; std::string v; - m_db->Get(m_readOptions, _h.ref(), &v); + m_db->Get(m_readOptions, aux(_h).ref(), &v); + if (v.empty()) + cwarn << "Aux not found: " << _h; return asBytes(v); } diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index f32170cd4..e00e03f44 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -408,7 +408,7 @@ public: Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); } - h256 root() const { const_cast(this)->syncRoot(); return m_secure.root(); } + h256 root() const { return m_secure.root(); } void insert(bytesConstRef _key, bytesConstRef _value) { Super::insert(_key, _value); m_secure.insert(_key, _value); syncRoot(); } void remove(bytesConstRef _key) { Super::remove(_key); m_secure.remove(_key); syncRoot(); } From d0a90764dbeec3f150b0d578a611dbbcda3ad1b0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 15:30:22 +0100 Subject: [PATCH 267/313] New gas pricing for PoC-9. --- libethcore/Params.cpp | 93 ++++++++++++++++---------------------- libethcore/Params.h | 14 ++---- libethereum/ExtVM.h | 2 +- libevm/VM.cpp | 14 +++--- libevmcore/Instruction.cpp | 2 +- 5 files changed, 55 insertions(+), 70 deletions(-) diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index d1154abcc..a59af5472 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -22,57 +22,44 @@ #include "Params.h" using namespace std; -namespace dev -{ -namespace eth -{ - -//--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_genesisDifficulty = 131072; -u256 const c_maximumExtraDataSize = 1024; -u256 const c_epochDuration = 3000; -u256 const c_genesisGasLimit = 1000000; -u256 const c_minGasLimit = 125000; -u256 const c_gasLimitBoundDivisor = 1024; -u256 const c_minimumDifficulty = 131072; -u256 const c_difficultyBoundDivisor = 2048; -u256 const c_durationLimit = 8; -u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; -u256 const c_expGas = 10; -u256 const c_expByteGas = 10; -u256 const c_sha3Gas = 30; -u256 const c_sha3WordGas = 6; -u256 const c_sloadGas = 50; -u256 const c_sstoreSetGas = 20000; -u256 const c_sstoreResetGas = 5000; -u256 const c_sstoreClearGas = 5000; -u256 const c_sstoreRefundGas = 15000; -u256 const c_jumpdestGas = 1; -u256 const c_logGas = 375; -u256 const c_logDataGas = 8; -u256 const c_logTopicGas = 375; -u256 const c_createGas = 32000; -u256 const c_callGas = 40; -u256 const c_callStipend = 2300; -u256 const c_callValueTransferGas = 9000; -u256 const c_callNewAccountGas = 25000; -u256 const c_suicideRefundGas = 24000; -u256 const c_memoryGas = 3; -u256 const c_quadCoeffDiv = 512; -u256 const c_createDataGas = 200; -u256 const c_txGas = 21000; -u256 const c_txDataZeroGas = 4; -u256 const c_txDataNonZeroGas = 68; -u256 const c_copyGas = 3; -u256 const c_ecrecoverGas = 3000; -u256 const c_sha256Gas = 60; -u256 const c_sha256WordGas = 12; -u256 const c_ripemd160Gas = 600; -u256 const c_ripemd160WordGas = 120; -u256 const c_identityGas = 15; -u256 const c_identityWordGas = 3; -//--- END: AUTOGENERATED FROM /feeStructure.json - -} -} +using namespace dev; +using namespace dev::eth; + +u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; +u256 const dev::eth::c_expGas = 10; +u256 const dev::eth::c_expByteGas = 10; + +u256 const dev::eth::c_sha3Gas = 30; +u256 const dev::eth::c_sha3WordGas = 6; + +u256 const dev::eth::c_sloadGas = 50; +u256 const dev::eth::c_sstoreSetGas = 20000; +u256 const dev::eth::c_sstoreResetGas = 5000; +u256 const dev::eth::c_sstoreClearGas = 5000; +u256 const dev::eth::c_sstoreRefundGas = 15000; +u256 const dev::eth::c_jumpdestGas = 1; + +u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logDataGas = 8; +u256 const dev::eth::c_logTopicGas = 2000; + +u256 const dev::eth::c_createGas = 32000; + +u256 const dev::eth::c_callGas = 40; +u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callNewAccountGas = 25000; + +u256 const dev::eth::c_suicideRefundGas = 24000; + +u256 const dev::eth::c_memoryGas = 3; +u256 const dev::eth::c_quadCoeffDiv = 512; + + +u256 const dev::eth::c_createDataGas = 200; +u256 const dev::eth::c_txGas = 21000; +u256 const dev::eth::c_txDataZeroGas = 37; +u256 const dev::eth::c_txDataNonZeroGas = 2; + +u256 const dev::eth::c_copyGas = 3; + diff --git a/libethcore/Params.h b/libethcore/Params.h index 9109347dc..1b58c80e9 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -28,41 +28,37 @@ namespace dev namespace eth { -//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. + extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. + extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. + extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. + extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. -extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. + extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. -extern u256 const c_ecrecoverGas; -extern u256 const c_sha256Gas; -extern u256 const c_sha256WordGas; -extern u256 const c_ripemd160Gas; -extern u256 const c_ripemd160WordGas; -extern u256 const c_identityGas; -extern u256 const c_identityWordGas; } } diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index d63cd943a..a4ab7ead3 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final diff --git a/libevm/VM.cpp b/libevm/VM.cpp index e0b487c9b..9f2fa6874 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,13 +82,19 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas = c_tierStepGas[metric.gasPriceTier]; + bigint runGas; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); + auto metric = c_metrics[(int)inst]; + int gasPriceTier = metric.gasPriceTier; + if (gasPriceTier == InvalidTier) + BOOST_THROW_EXCEPTION(BadInstruction()); + else + runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() @@ -145,10 +151,6 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; - case Instruction::JUMPDEST: - runGas = 1; - break; - case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: @@ -164,7 +166,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index 23f19ac94..eba075a4d 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From d095688bd07e41449c7789037cb85d0460b9579a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 17:27:10 +0100 Subject: [PATCH 268/313] Gas fixes. Trie fixes. --- libdevcrypto/MemoryDB.h | 5 +++-- libdevcrypto/OverlayDB.cpp | 17 +++++++++-------- libdevcrypto/TrieDB.h | 6 +++++- libethereum/Client.cpp | 9 +++++++-- libevm/VM.cpp | 8 +------- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/libdevcrypto/MemoryDB.h b/libdevcrypto/MemoryDB.h index ecda3b6ec..7d39ba73b 100644 --- a/libdevcrypto/MemoryDB.h +++ b/libdevcrypto/MemoryDB.h @@ -52,7 +52,8 @@ public: void purge(); bytes lookupAux(h256 _h) const { auto h = aux(_h); return m_aux.count(h) ? m_aux.at(h) : bytes(); } - void insertAux(h256 _h, bytesConstRef _v) { m_auxKey = aux(_h); m_aux[m_auxKey] = _v.toBytes(); } + void removeAux(h256 _h) { m_auxActive.erase(aux(_h)); } + void insertAux(h256 _h, bytesConstRef _v) { auto h = aux(_h); m_auxActive.insert(h); m_aux[h] = _v.toBytes(); } std::set keys() const; @@ -61,7 +62,7 @@ protected: std::map m_over; std::map m_refCount; - h256 m_auxKey; + std::set m_auxActive; std::map m_aux; mutable bool m_enforceRefs = false; diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index d34dd1906..ffe996bb6 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -52,14 +52,15 @@ void OverlayDB::commit() if (m_refCount[i.first]) m_db->Put(m_writeOptions, ldb::Slice((char const*)i.first.data(), i.first.size), ldb::Slice(i.second.data(), i.second.size())); } - if (m_auxKey && m_aux.count(m_auxKey)) - { - m_db->Put(m_writeOptions, m_auxKey.ref(), bytesConstRef(&m_aux[m_auxKey])); - cdebug << "Committing aux: " << m_auxKey; - m_aux.erase(m_auxKey); - cdebug << "Discarding " << keysOf(m_aux); - } - m_auxKey = h256(); + for (auto const& i: m_auxActive) + if (m_aux.count(i)) + { + m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); + cdebug << "Committing aux: " << i; + m_aux.erase(i); + } + cdebug << "Discarding " << keysOf(m_aux); + m_auxActive.clear(); m_aux.clear(); m_over.clear(); m_refCount.clear(); diff --git a/libdevcrypto/TrieDB.h b/libdevcrypto/TrieDB.h index e00e03f44..1abf2d8c0 100644 --- a/libdevcrypto/TrieDB.h +++ b/libdevcrypto/TrieDB.h @@ -404,8 +404,12 @@ public: void setRoot(h256 _root) { + if (!m_secure.isNull()) + Super::db()->removeAux(m_secure.root()); m_secure.setRoot(_root); - Super::setRoot(h256(Super::db()->lookupAux(m_secure.root()))); + auto rb = Super::db()->lookupAux(m_secure.root()); + auto r = h256(rb); + Super::setRoot(r); } h256 root() const { return m_secure.root(); } diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index c9c182028..b5355f1e0 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -278,9 +278,14 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) LocalisedLogEntries ret; try { -// cdebug << "checkWatch" << _watchId; +#if ETH_DEBUG && 0 + cdebug << "checkWatch" << _watchId; +#endif + auto& w = m_watches.at(_watchId); +#if ETH_DEBUG && 0 + cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); +#endif auto& w = m_watches.at(_watchId); -// cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 9f2fa6874..f4e904e3f 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -82,19 +82,13 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) BOOST_THROW_EXCEPTION(BadInstruction()); // FEES... - bigint runGas; + bigint runGas = c_tierStepGas[metric.gasPriceTier]; bigint newTempSize = m_temp.size(); bigint copySize = 0; // should work, but just seems to result in immediate errorless exit on initial execution. yeah. weird. //m_onFail = std::function(onOperation); - auto metric = c_metrics[(int)inst]; - int gasPriceTier = metric.gasPriceTier; - if (gasPriceTier == InvalidTier) - BOOST_THROW_EXCEPTION(BadInstruction()); - else - runGas = c_tierStepGas[metric.gasPriceTier]; require(metric.args); auto onOperation = [&]() From 8c69d8f8a8dd8d76f95fcc779e4caaf81c91ad70 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 18:41:15 +0100 Subject: [PATCH 269/313] JUMPDEST is 1. --- libevm/VM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libevm/VM.cpp b/libevm/VM.cpp index f4e904e3f..4592b7dcd 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -145,6 +145,10 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) newTempSize = memNeed(m_stack[m_stack.size() - 2], m_stack[m_stack.size() - 4]); break; + case Instruction::JUMPDEST: + runGas = 1; + break; + case Instruction::LOG0: case Instruction::LOG1: case Instruction::LOG2: From 1e06d1fb6954607243888f60f0205c8b31e97a28 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Mar 2015 19:54:16 +0100 Subject: [PATCH 270/313] Fix FakeExtVM. --- libethereum/ExtVM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index a4ab7ead3..d63cd943a 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -70,7 +70,7 @@ public: virtual u256 txCount(Address _a) override final { return m_s.transactionsFrom(_a); } /// Does the account exist? - virtual bool exists(Address _a) { return m_s.addressInUse(_a); } + virtual bool exists(Address _a) override final { return m_s.addressInUse(_a); } /// Suicide the associated contract to the given address. virtual void suicide(Address _a) override final From 2608572e6716022d8e7b5a5efb190471a12162e5 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 20:45:42 +0100 Subject: [PATCH 271/313] only check rootHash of state if FATDB is off --- test/state.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/state.cpp b/test/state.cpp index 5202aff22..71a4bbcfa 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -93,6 +93,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB + cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) From 6dad9826a38fdfffe1285f0f78501c9dc91b8c2c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 21:19:36 +0100 Subject: [PATCH 272/313] add memory tests --- test/state.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 71a4bbcfa..07409d000 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -93,7 +93,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) // check addresses #if ETH_FATDB - cout << "fatDB is defined\n"; auto expectedAddrs = importer.m_statePost.addresses(); auto resultAddrs = theState.addresses(); for (auto& expectedPair : expectedAddrs) @@ -207,16 +206,46 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) } } - BOOST_AUTO_TEST_CASE(stSolidityTest) - { - dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); - } +BOOST_AUTO_TEST_CASE(stSolidityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryTest) { dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } +BOOST_AUTO_TEST_CASE(stMemoryStressTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--memory" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stCreateTest) { From 6a3998000fc56d6a274aefed15e12de2957041d2 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 09:37:36 +0100 Subject: [PATCH 273/313] fix jumpdest - dont require anything on the stack --- libevmcore/Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index eba075a4d..23f19ac94 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -217,7 +217,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 0, 1, false, BaseTier } }, { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, BaseTier } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, BaseTier } }, - { Instruction::JUMPDEST, { "JUMPDEST", 0, 1, 0, true, SpecialTier } }, + { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, SpecialTier } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, VeryLowTier } }, { Instruction::PUSH2, { "PUSH2", 2, 0, 1, false, VeryLowTier } }, { Instruction::PUSH3, { "PUSH3", 3, 0, 1, false, VeryLowTier } }, From 5e13f007c697d4390f1ce14513a191d20d3541cf Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 11:20:39 +0100 Subject: [PATCH 274/313] update gas costs --- libethcore/Params.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index a59af5472..d986b889b 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -57,8 +57,8 @@ u256 const dev::eth::c_quadCoeffDiv = 512; u256 const dev::eth::c_createDataGas = 200; u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 37; -u256 const dev::eth::c_txDataNonZeroGas = 2; +u256 const dev::eth::c_txDataZeroGas = 4; +u256 const dev::eth::c_txDataNonZeroGas = 68; u256 const dev::eth::c_copyGas = 3; From a755ed3c5606745a82dcb2d0ba4c76a44949418c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 11:54:51 +0100 Subject: [PATCH 275/313] Log/bloom alterations. --- libethcore/Params.cpp | 7 ++++--- libethcore/Params.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index d986b889b..0c23eccd0 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -39,14 +39,15 @@ u256 const dev::eth::c_sstoreClearGas = 5000; u256 const dev::eth::c_sstoreRefundGas = 15000; u256 const dev::eth::c_jumpdestGas = 1; -u256 const dev::eth::c_logGas = 2000; +u256 const dev::eth::c_logGas = 375; u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 2000; +u256 const dev::eth::c_logTopicGas = 375; u256 const dev::eth::c_createGas = 32000; u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callValueTransferGas = 6700; +u256 const dev::eth::c_callStipend = 2300; +u256 const dev::eth::c_callValueTransferGas = 9000; u256 const dev::eth::c_callNewAccountGas = 25000; u256 const dev::eth::c_suicideRefundGas = 24000; diff --git a/libethcore/Params.h b/libethcore/Params.h index 1b58c80e9..120034b0e 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -50,6 +50,7 @@ extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG extern u256 const c_createGas; ///< Once per CREATE operation & contract-creation transaction. extern u256 const c_createDataGas; extern u256 const c_callGas; ///< Once per CALL operation & message call transaction. +extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. From ad2b3d53940c303fddab477dbf90dcf6ad2b09e9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:00:09 +0100 Subject: [PATCH 276/313] Update precompiled stuff. Add extra tests for secure trie. --- CMakeLists.txt | 5 +++ libethereum/Precompiled.cpp | 8 ++--- test/trie.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ff81e153..59cfe4ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ function(createDefaultCacheConfig) set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)") set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.") set(JUSTTESTS OFF CACHE BOOL "Build only for tests.") + set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)") endfunction() @@ -50,6 +51,10 @@ function(configureProject) add_definitions(-DETH_FATDB) endif() + if (SOLIDITY) + add_definitions(-DETH_SOLIDITY) + endif() + if (HEADLESS OR JUSTTESTS) add_definitions(-DETH_HEADLESS) endif() diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..121af1b59 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} }; std::map const& dev::eth::precompiled() diff --git a/test/trie.cpp b/test/trie.cpp index 84d0e846f..9e59dd316 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -74,6 +74,68 @@ BOOST_AUTO_TEST_CASE(fat_trie) } } +BOOST_AUTO_TEST_CASE(hex_encoded_securetrie_test) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/hex_encoded_securetrie_test.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'hex_encoded_securetrie_test.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000000000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + GenericTrieDB t(&m); + MemoryDB hm; + HashedGenericTrieDB ht(&hm); + MemoryDB fm; + FatGenericTrieDB ft(&fm); + t.init(); + ht.init(); + ft.init(); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + ht.insert(k.first, k.second); + ft.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + BOOST_REQUIRE(ht.check(true)); + BOOST_REQUIRE(ft.check(true)); + for (auto i = ft.begin(), j = t.begin(); i != ft.end() && j != t.end(); ++i, ++j) + { + BOOST_CHECK_EQUAL(i == ft.end(), j == t.end()); + BOOST_REQUIRE((*i).first.toBytes() == (*j).first.toBytes()); + BOOST_REQUIRE((*i).second.toBytes() == (*j).second.toBytes()); + } + BOOST_CHECK_EQUAL(ht.root(), ft.root()); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ht.root().asArray())); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(ft.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_test_anyorder) { string testPath = test::getTestPath(); From 55de9ccbf396274ab61c05502a729aed2b619b69 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:10:31 +0100 Subject: [PATCH 277/313] Alter Genesis block. Add FeeStructure. --- feeStructure.json | 88 +++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f5acf0f0b..f09464a5a 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,54 +1,38 @@ -var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} +{ + "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], + "expGas": 10, + "expByteGas": 10, + + "sha3Gas": 30, + "sha3WordGas": 6, + + "sloadGas": 50, + "sstoreSetGas": 20000, + "sstoreResetGas": 5000, + "sstoreClearGas": 5000, + "sstoreRefundGas": 15000, + "jumpdestGas": 1, + + "logGas": 375, + "logDataGas": 8, + "logTopicGas": 375, + + "createGas": 32000, -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ + "callGas": 40, + "callStipend": 2300, + "callValueTransferGas": 9000, + "callNewAccountGas": 25000, + "suicideRefundGas": 24000, + + "memoryGas": 3, + "quadCoeffDiv": 512, + + "createDataGas": 200, + "txGas": 21000, + "txDataZeroGas": 4, + "txDataNonZeroGas": 68, + + "copyGas": 3, +} From 81b0c13e7406708f2e218ca738e56b1cc9114c20 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:46:30 +0100 Subject: [PATCH 278/313] Fee structure stuff. --- feeStructure.json | 88 ++++++++++++++++++++++--------------- libethcore/Params.cpp | 85 ++++++++++++++++++----------------- libethcore/Params.h | 8 ++++ libethereum/Precompiled.cpp | 8 ++-- 4 files changed, 108 insertions(+), 81 deletions(-) diff --git a/feeStructure.json b/feeStructure.json index f09464a5a..f5acf0f0b 100644 --- a/feeStructure.json +++ b/feeStructure.json @@ -1,38 +1,54 @@ -{ - "tierStepGas": [ 0, 2, 3, 5, 8, 10, 20 ], - "expGas": 10, - "expByteGas": 10, - - "sha3Gas": 30, - "sha3WordGas": 6, - - "sloadGas": 50, - "sstoreSetGas": 20000, - "sstoreResetGas": 5000, - "sstoreClearGas": 5000, - "sstoreRefundGas": 15000, - "jumpdestGas": 1, - - "logGas": 375, - "logDataGas": 8, - "logTopicGas": 375, - - "createGas": 32000, - - "callGas": 40, - "callStipend": 2300, - "callValueTransferGas": 9000, - "callNewAccountGas": 25000, - - "suicideRefundGas": 24000, - - "memoryGas": 3, - "quadCoeffDiv": 512, +var x = { + "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, + "expGas": { "v": 10, "d": "Once per EXP instuction." }, + "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, + + "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, + "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, + + "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, + "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, + "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, + "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, + "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, + "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, + + "logGas": { "v": 375, "d": "Per LOG* operation." }, + "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, + "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, + + "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, + + "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, + "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, + "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, + "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, + + "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, + + "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, + "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, + + "createDataGas": { "v": 200, "d": "" }, + "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, + "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, + "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, + + "copyGas": { "v": 3, "d": "" }, + + "ecrecoverGas": { "v": 3000, "d": "" }, + "sha256Gas": { "v": 60, "d": "" }, + "sha256WordGas": { "v": 12, "d": "" }, + "ripemd160Gas": { "v": 600, "d": "" }, + "ripemd160WordGas": { "v": 120, "d": "" }, + "identityGas": { "v": 15, "d": "" }, + "identityWordGas": { "v": 3, "d": ""} +} - "createDataGas": 200, - "txGas": 21000, - "txDataZeroGas": 4, - "txDataNonZeroGas": 68, +/* +// to get C++ .h: +for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") +// to get C++ .cpp: +for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") +*/ - "copyGas": 3, -} diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index 0c23eccd0..41164b206 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -22,45 +22,48 @@ #include "Params.h" using namespace std; -using namespace dev; -using namespace dev::eth; - -u256 const dev::eth::c_tierStepGas[8] = { 0, 2, 3, 5, 8, 10, 20, 0 }; -u256 const dev::eth::c_expGas = 10; -u256 const dev::eth::c_expByteGas = 10; - -u256 const dev::eth::c_sha3Gas = 30; -u256 const dev::eth::c_sha3WordGas = 6; - -u256 const dev::eth::c_sloadGas = 50; -u256 const dev::eth::c_sstoreSetGas = 20000; -u256 const dev::eth::c_sstoreResetGas = 5000; -u256 const dev::eth::c_sstoreClearGas = 5000; -u256 const dev::eth::c_sstoreRefundGas = 15000; -u256 const dev::eth::c_jumpdestGas = 1; - -u256 const dev::eth::c_logGas = 375; -u256 const dev::eth::c_logDataGas = 8; -u256 const dev::eth::c_logTopicGas = 375; - -u256 const dev::eth::c_createGas = 32000; - -u256 const dev::eth::c_callGas = 40; -u256 const dev::eth::c_callStipend = 2300; -u256 const dev::eth::c_callValueTransferGas = 9000; -u256 const dev::eth::c_callNewAccountGas = 25000; - -u256 const dev::eth::c_suicideRefundGas = 24000; - -u256 const dev::eth::c_memoryGas = 3; -u256 const dev::eth::c_quadCoeffDiv = 512; - - -u256 const dev::eth::c_createDataGas = 200; -u256 const dev::eth::c_txGas = 21000; -u256 const dev::eth::c_txDataZeroGas = 4; -u256 const dev::eth::c_txDataNonZeroGas = 68; - -u256 const dev::eth::c_copyGas = 3; - +namespace dev +{ +namespace eth +{ + +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; +u256 const c_expGas = 10; +u256 const c_expByteGas = 10; +u256 const c_sha3Gas = 30; +u256 const c_sha3WordGas = 6; +u256 const c_sloadGas = 50; +u256 const c_sstoreSetGas = 20000; +u256 const c_sstoreResetGas = 5000; +u256 const c_sstoreClearGas = 5000; +u256 const c_sstoreRefundGas = 15000; +u256 const c_jumpdestGas = 1; +u256 const c_logGas = 375; +u256 const c_logDataGas = 8; +u256 const c_logTopicGas = 375; +u256 const c_createGas = 32000; +u256 const c_callGas = 40; +u256 const c_callStipend = 2300; +u256 const c_callValueTransferGas = 9000; +u256 const c_callNewAccountGas = 25000; +u256 const c_suicideRefundGas = 24000; +u256 const c_memoryGas = 3; +u256 const c_quadCoeffDiv = 512; +u256 const c_createDataGas = 200; +u256 const c_txGas = 21000; +u256 const c_txDataZeroGas = 4; +u256 const c_txDataNonZeroGas = 68; +u256 const c_copyGas = 3; +u256 const c_ecrecoverGas = 3000; +u256 const c_sha256Gas = 60; +u256 const c_sha256WordGas = 12; +u256 const c_ripemd160Gas = 600; +u256 const c_ripemd160WordGas = 120; +u256 const c_identityGas = 15; +u256 const c_identityWordGas = 3; +//--- END: AUTOGENERATED FROM /feeStructure.json + +} +} diff --git a/libethcore/Params.h b/libethcore/Params.h index 120034b0e..9d60ac1bd 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -61,5 +61,13 @@ extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data o extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. +extern u256 const c_ecrecoverGas; +extern u256 const c_sha256Gas; +extern u256 const c_sha256WordGas; +extern u256 const c_ripemd160Gas; +extern u256 const c_ripemd160WordGas; +extern u256 const c_identityGas; +extern u256 const c_identityWordGas; + } } diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 121af1b59..c62a00f88 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -83,10 +83,10 @@ static bytes identityCode(bytesConstRef _in) static const std::map c_precompiled = { - { 1, { [](bytesConstRef) -> bigint { return (bigint)3000; }, ecrecoverCode }}, - { 2, { [](bytesConstRef i) -> bigint { return (bigint)60 + (i.size() + 31) / 32 * 12; }, sha256Code }}, - { 3, { [](bytesConstRef i) -> bigint { return (bigint)600 + (i.size() + 31) / 32 * 120; }, ripemd160Code }}, - { 4, { [](bytesConstRef i) -> bigint { return (bigint)15 + (i.size() + 31) / 32 * 3; }, identityCode }} + { 1, { [](bytesConstRef) -> bigint { return c_ecrecoverGas; }, ecrecoverCode }}, + { 2, { [](bytesConstRef i) -> bigint { return c_sha256Gas + (i.size() + 31) / 32 * c_sha256WordGas; }, sha256Code }}, + { 3, { [](bytesConstRef i) -> bigint { return c_ripemd160Gas + (i.size() + 31) / 32 * c_ripemd160WordGas; }, ripemd160Code }}, + { 4, { [](bytesConstRef i) -> bigint { return c_identityGas + (i.size() + 31) / 32 * c_identityWordGas; }, identityCode }} }; std::map const& dev::eth::precompiled() From fae48e97e496b796b9c7e94a26aec2bc0995d33c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 13:52:53 +0100 Subject: [PATCH 279/313] VM CALLCODE fix. --- libethcore/Params.h | 7 +------ libevm/VM.cpp | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libethcore/Params.h b/libethcore/Params.h index 9d60ac1bd..9109347dc 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -28,22 +28,19 @@ namespace dev namespace eth { +//--- BEGIN: AUTOGENERATED FROM /feeStructure.json extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. - extern u256 const c_sha3Gas; ///< Once per SHA3 operation. extern u256 const c_sha3WordGas; ///< Once per word of the SHA3 operation's data. - extern u256 const c_copyGas; ///< Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. - extern u256 const c_sloadGas; ///< Once per SLOAD operation. extern u256 const c_sstoreSetGas; ///< Once per SSTORE operation if the zeroness changes from zero. extern u256 const c_sstoreResetGas; ///< Once per SSTORE operation if the zeroness doesn't change. extern u256 const c_sstoreClearGas; ///< Once per SSTORE operation if the zeroness changes to zero. extern u256 const c_sstoreRefundGas; ///< Refunded gas, once per SSTORE operation if the zeroness changes to zero. extern u256 const c_jumpdestGas; ///< Once per JUMPDEST operation. - extern u256 const c_logGas; ///< Per LOG* operation. extern u256 const c_logDataGas; ///< Per byte in a LOG* operation's data. extern u256 const c_logTopicGas; ///< Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. @@ -54,13 +51,11 @@ extern u256 const c_callStipend; ///< Free gas given at beginning of call. extern u256 const c_callNewAccountGas; ///< Paid for CALL when the destination address didn't exist prior. extern u256 const c_callValueTransferGas; ///< Paid for CALL when the value transfor is non-zero. extern u256 const c_suicideRefundGas; ///< Refunded following a suicide operation. - extern u256 const c_memoryGas; ///< Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. extern u256 const c_quadCoeffDiv; ///< Divisor for the quadratic particle of the memory cost equation. extern u256 const c_txGas; ///< Per transaction. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataZeroGas; ///< Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. extern u256 const c_txDataNonZeroGas; ///< Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. - extern u256 const c_ecrecoverGas; extern u256 const c_sha256Gas; extern u256 const c_sha256WordGas; diff --git a/libevm/VM.cpp b/libevm/VM.cpp index 4592b7dcd..e0b487c9b 100644 --- a/libevm/VM.cpp +++ b/libevm/VM.cpp @@ -164,7 +164,7 @@ bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) case Instruction::CALL: case Instruction::CALLCODE: runGas = (bigint)c_callGas + m_stack[m_stack.size() - 1]; - if (!_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) + if (inst != Instruction::CALLCODE && !_ext.exists(asAddress(m_stack[m_stack.size() - 2]))) runGas += c_callNewAccountGas; if (m_stack[m_stack.size() - 3] > 0) runGas += c_callValueTransferGas; From d8470e50edc41342420a5430b1304c5dd63f7e8b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 3 Mar 2015 17:12:27 +0100 Subject: [PATCH 280/313] state rebase. --- test/state.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 07409d000..b6a9d4256 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -229,24 +229,6 @@ BOOST_AUTO_TEST_CASE(stMemoryTest) dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stMemoryStressTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--memory" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stMemoryStressTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} - BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From 1732bd29652c87e093d7d2dbefb31e3a6831ac1b Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Tue, 3 Mar 2015 17:36:09 +0100 Subject: [PATCH 281/313] remove genesis state from state tests Conflicts: test/state.cpp --- test/state.cpp | 56 ++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index b6a9d4256..6ac23c14d 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -170,23 +170,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} +//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +//{ +// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) +// { +// string arg = boost::unit_test::framework::master_test_suite().argv[i]; +// if (arg == "--quadratic" || arg == "--all") +// { +// auto start = chrono::steady_clock::now(); + +// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + +// auto end = chrono::steady_clock::now(); +// auto duration(chrono::duration_cast(end - start)); +// cnote << "test duration: " << duration.count() << " milliseconds.\n"; +// } +// } +//} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { @@ -206,29 +206,17 @@ BOOST_AUTO_TEST_CASE(stMemoryStressTest) } } -BOOST_AUTO_TEST_CASE(stSolidityTest) -{ - for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) - { - string arg = boost::unit_test::framework::master_test_suite().argv[i]; - if (arg == "--quadratic" || arg == "--all") - { - auto start = chrono::steady_clock::now(); - - dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - - auto end = chrono::steady_clock::now(); - auto duration(chrono::duration_cast(end - start)); - cnote << "test duration: " << duration.count() << " milliseconds.\n"; - } - } -} + BOOST_AUTO_TEST_CASE(stSolidityTest) + { + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); + } BOOST_AUTO_TEST_CASE(stMemoryTest) { dev::test::executeTests("stMemoryTest", "/StateTests", dev::test::doStateTests); } + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) From eaef000af31f7013c84d7c774ee0a77700ac1fe2 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 11:55:22 +0100 Subject: [PATCH 282/313] New Proof-of-Work. --- alethzero/MainWin.cpp | 5 +- libdevcore/CommonIO.cpp | 5 ++ libdevcore/CommonIO.h | 6 +-- libethcore/BlockInfo.cpp | 20 ++++---- libethcore/BlockInfo.h | 6 +-- libethcore/Common.cpp | 2 +- libethcore/Exceptions.h | 2 +- libethcore/ProofOfWork.cpp | 98 ++++++++++++++++++++++++++++++++++++-- libethcore/ProofOfWork.h | 9 +++- libethereum/State.cpp | 2 +- test/dagger.cpp | 22 +++++---- 11 files changed, 134 insertions(+), 43 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index b79bc6e83..0242fe1fa 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1409,10 +1409,7 @@ void Main::on_blocks_currentItemChanged() s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - { - auto e = Ethasher::eval(info); - s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; - } + s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 4fa132073..d7e74d36e 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -115,3 +115,8 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data) ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); } +void dev::writeFile(std::string const& _file, bytesConstRef _data) +{ + ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); +} + diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 03fc9cffc..1f9e29e54 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -43,15 +43,13 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); -std::string contentsString(std::string const& _file); /// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. bytesRef contentsNew(std::string const& _file); /// Write the given binary data into the given file, replacing the file if it pre-exists. -void writeFile(std::string const& _file, bytesConstRef _data); +void writeFile(std::string const& _file, bytes const& _data); /// Write the given binary data into the given file, replacing the file if it pre-exists. -inline void writeFile(std::string const& _file, bytes const& _data) { writeFile(_file, bytesConstRef(&_data)); } -inline void writeFile(std::string const& _file, std::string const& _data) { writeFile(_file, bytesConstRef(_data)); } +void writeFile(std::string const& _file, bytesConstRef _data); /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 42dffe92f..e40c37f12 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -31,6 +31,8 @@ using namespace std; using namespace dev; using namespace dev::eth; +u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; + BlockInfo::BlockInfo(): timestamp(Invalid256) { } @@ -56,7 +58,7 @@ void BlockInfo::setEmpty() timestamp = 0; extraData.clear(); seedHash = h256(); - mixHash = h256(); + mixBytes = h256(); nonce = Nonce(); hash = headerHash(WithNonce); } @@ -81,7 +83,7 @@ void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << mixHash << nonce; + _s << mixBytes << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -109,9 +111,9 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - seedHash = _header[field = 13].toHash(RLP::VeryStrict); - mixHash = _header[field = 14].toHash(RLP::VeryStrict); - nonce = _header[field = 15].toHash(RLP::VeryStrict); + seedHash = _header[field = 13].toHash(); + mixBytes = _header[field = 14].toHash(); + nonce = _header[field = 15].toHash(); } catch (Exception const& _e) @@ -185,12 +187,7 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); - seedHash = calculateSeedHash(_parent); -} - -h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const -{ - return number % c_epochDuration == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; + seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -224,7 +221,6 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); - // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 95519b57d..6ed985f75 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -74,7 +74,7 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 mixHash; + h256 mixBytes; h256 seedHash; Nonce nonce; @@ -105,7 +105,7 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && - mixHash == _cmp.mixHash && + mixBytes == _cmp.mixBytes && seedHash == _cmp.seedHash && nonce == _cmp.nonce; } @@ -133,7 +133,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixHash << " " << _bi.seedHash << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index f47bb002b..65c0b8b92 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -32,7 +32,7 @@ namespace dev namespace eth { -const unsigned c_protocolVersion = 55; +const unsigned c_protocolVersion = 56; const unsigned c_databaseVersion = 6 + #if ETH_FATDB 1000 diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index e1561ef0e..bc9441c6b 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,7 +22,7 @@ #pragma once #include -#include "Common.h" +#include "CommonEth.h" namespace dev { diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index d261ccb1c..084225a38 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -30,8 +30,8 @@ #include #include #include +#include #include "BlockInfo.h" -#include "Ethasher.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -41,14 +41,100 @@ namespace dev namespace eth { +class Ethasher +{ +public: + Ethasher() {} + + static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } + + bytes const& cache(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_caches.count(_header.seedHash)) + { + try { + boost::filesystem::create_directories(getDataDir() + "/ethashcache"); + } catch (...) {} + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; + m_caches[_header.seedHash] = contents(memoFile); + if (m_caches[_header.seedHash].empty()) + { + ethash_params p = params((unsigned)_header.number); + m_caches[_header.seedHash].resize(p.cache_size); + ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); + writeFile(memoFile, m_caches[_header.seedHash]); + } + } + return m_caches[_header.seedHash]; + } + + byte const* full(BlockInfo const& _header) + { + RecursiveGuard l(x_this); + if (!m_fulls.count(_header.seedHash)) + { + if (!m_fulls.empty()) + { + delete [] m_fulls.begin()->second.data(); + m_fulls.erase(m_fulls.begin()); + } + std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; + m_fulls[_header.seedHash] = contentsNew(memoFile); + if (!m_fulls[_header.seedHash]) + { + ethash_params p = params((unsigned)_header.number); + m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); + auto c = cache(_header); + ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); + writeFile(memoFile, m_fulls[_header.seedHash]); + } + } + return m_fulls[_header.seedHash].data(); + } + + static ethash_params params(BlockInfo const& _header) + { + return params((unsigned)_header.number); + } + + static ethash_params params(unsigned _n) + { + ethash_params p; + p.cache_size = ethash_get_cachesize(_n); + p.full_size = ethash_get_datasize(_n); + return p; + } + +private: + static Ethasher* s_this; + RecursiveMutex x_this; + std::map m_caches; + std::map m_fulls; +}; + +Ethasher* Ethasher::s_this = nullptr; + bool Ethash::verify(BlockInfo const& _header) { - return Ethasher::verify(_header); + bigint boundary = (bigint(1) << 256) / _header.difficulty; + u256 e(eval(_header, _header.nonce)); + return e <= boundary; +} + +h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) +{ + auto p = Ethasher::params(_header); + ethash_return_value r; + ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); + return h256(r.result, h256::ConstructFromPointer); } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - Ethasher::Miner m(_header); + auto h = _header.headerHash(WithoutNonce); + auto p = Ethasher::params(_header); + auto d = Ethasher::get()->full(_header); std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); @@ -66,15 +152,17 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) Proof result; + ethash_return_value ethashReturn; unsigned hashCount = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - u256 val(m.mine(tryNonce)); + ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); + u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); best = std::min(best, log2((double)val)); if (val <= boundary) { ret.first.completed = true; - result.mixHash = m.lastMixHash(); + result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); result.nonce = u64(tryNonce); break; } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 250ddb73d..7b9787f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -27,7 +27,7 @@ #include #include #include -#include "Common.h" +#include "CommonEth.h" #include "BlockInfo.h" #define FAKE_DAGGER 1 @@ -49,15 +49,18 @@ struct MineInfo class Ethash { public: + // bit-compatible with ethash_return_value struct Proof { Nonce nonce; h256 mixHash; }; + static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static h256 eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } protected: Nonce m_last; @@ -70,7 +73,9 @@ public: using Proof = Nonce; static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } + inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } protected: diff --git a/libethereum/State.cpp b/libethereum/State.cpp index ec6643684..568629084 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -547,7 +547,7 @@ u256 State::enact(bytesConstRef _block, BlockChain const& _bc, bool _checkNonce) if (rlp[2].itemCount() > 2) BOOST_THROW_EXCEPTION(TooManyUncles()); - set nonces = { m_currentBlock.nonce }; + set nonces = { m_currentBlock.nonce }; Addresses rewarded; set knownUncles = _bc.allUnclesFrom(m_currentBlock.parentHash); diff --git a/test/dagger.cpp b/test/dagger.cpp index dec753fe7..720abbbaa 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -41,16 +41,16 @@ BOOST_AUTO_TEST_SUITE(DashimotoTests) BOOST_AUTO_TEST_CASE(basic_test) { - string testPath = test::getTestPath(); - - testPath += "/PoWTests"; - - cnote << "Testing Secure Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/ethash_tests.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'ethash_tests.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) +#if 0 + cnote << "Testing ProofOfWork..."; + // Test dagger + { + auto s = steady_clock::now(); + cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); + cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; + cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); + cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; + } { cnote << i.first; js::mObject& o = i.second.get_obj(); @@ -78,6 +78,8 @@ BOOST_AUTO_TEST_CASE(basic_test) BOOST_REQUIRE_EQUAL(r.value, result); BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash); } +#endif + return 0; } BOOST_AUTO_TEST_SUITE_END() From 702b45c4eb7c92fb11de97d30a5d901422ff0698 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 12:04:15 +0100 Subject: [PATCH 283/313] blockchain tests Conflicts: test/block.cpp --- test/bcBlockChainTestFiller.json | 25 +- test/blockchain.cpp | 560 +++++++++++++------------------ 2 files changed, 229 insertions(+), 356 deletions(-) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index b149f5938..050def25b 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -1,20 +1,18 @@ { "minDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", + "difficulty" : "1023", + "extraData" : "42", "gasLimit" : "100000000", "gasUsed" : "0", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, @@ -41,21 +39,6 @@ ], "uncleHeaders" : [ ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "8000000", - "gasPrice" : "0", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] } ] } diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 7f840bc76..7dad5b4f2 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -31,14 +31,57 @@ using namespace dev::eth; namespace dev { namespace test { -bytes createBlockRLPFromFields(mObject& _tObj); -void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj); -BlockInfo constructBlock(mObject& _o); -void updatePoW(BlockInfo& _bi); -void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); -RLPStream createFullBlockFromHeader(const BlockInfo& _bi, const bytes& _txs = RLPEmptyList, const bytes& _uncles = RLPEmptyList); - -void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << importByteArray(_tObj["extraData"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void doBlockTests(json_spirit::mValue& _v, bool _fillin) { for (auto& i: _v.get_obj()) { @@ -46,48 +89,81 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj()); + BlockInfo blockFromFields; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + blockFromFields.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + continue; + } + catch(...) + { + cnote << "block population did throw an unknown exception\n"; + continue; + } BOOST_REQUIRE(o.count("pre")); + ImportTest importer(o["pre"].get_obj()); State state(Address(), OverlayDB(), BaseState::Empty); importer.importState(o["pre"].get_obj(), state); state.commit(); if (_fillin) - biGenesisBlock.stateRoot = state.rootHash(); + blockFromFields.stateRoot = state.rootHash(); else - BOOST_CHECK_MESSAGE(biGenesisBlock.stateRoot == state.rootHash(), "root hash does not match"); + BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); if (_fillin) { // find new valid nonce - updatePoW(biGenesisBlock); + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) + tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); //update genesis block in json file - writeBlockHeaderToJson(o["genesisBlockHeader"].get_obj(), biGenesisBlock); + o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); + o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); } // create new "genesis" block - RLPStream rlpGenesisBlock = createFullBlockFromHeader(biGenesisBlock); - biGenesisBlock.verifyInternals(&rlpGenesisBlock.out()); + RLPStream rlpStream; + blockFromFields.streamRLP(rlpStream, WithNonce); + + RLPStream block(3); + block.appendRaw(rlpStream.out()); + block.appendRaw(RLPEmptyList); + block.appendRaw(RLPEmptyList); + + blockFromFields.verifyInternals(&block.out()); // construct blockchain - BlockChain bc(rlpGenesisBlock.out(), string(), true); + BlockChain bc(block.out(), string(), true); if (_fillin) { BOOST_REQUIRE(o.count("blocks")); mArray blArray; - vector vBiBlocks; - vBiBlocks.push_back(biGenesisBlock); for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); + BOOST_REQUIRE(blObj.count("transactions")); - // get txs TransactionQueue txs; - BOOST_REQUIRE(blObj.count("transactions")); + for (auto const& txObj: blObj["transactions"].get_array()) { mObject tx = txObj.get_obj(); @@ -96,38 +172,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "failed importing transaction\n"; } - // write uncle list - BlockQueue uncleBlockQueue; - mArray aUncleList; - vector vBiUncles; - - for (auto const& uHObj: blObj["uncleHeaders"].get_array()) - { - mObject uncleHeaderObj = uHObj.get_obj(); - BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); - - // make uncle header valid - uncleBlockFromFields.timestamp = (u256)time(0); - if (vBiBlocks.size() > 2) - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); - else - continue; - - updatePoW(uncleBlockFromFields); - writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); - - aUncleList.push_back(uncleHeaderObj); - vBiUncles.push_back(uncleBlockFromFields); - - cnote << "import uncle in blockQueue"; - RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields); - uncleBlockQueue.import(&uncle.out(), bc); - } - - blObj["uncleHeaders"] = aUncleList; - bc.sync(uncleBlockQueue, state.db(), 4); - state.commitToMine(bc); - try { state.sync(bc); @@ -148,8 +192,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) return; } - blObj["rlp"] = "0x" + toHex(state.blockData()); - // write valid txs mArray txArray; Transactions txList; @@ -159,32 +201,118 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txList.push_back(tx); mObject txObject; txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = "0x" + toHex(tx.data()); + txObject["data"] = toHex(tx.data()); txObject["gasLimit"] = toString(tx.gas()); txObject["gasPrice"] = toString(tx.gasPrice()); txObject["r"] = "0x" + toString(tx.signature().r); txObject["s"] = "0x" + toString(tx.signature().s); txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = tx.isCreation() ? "" : toString(tx.receiveAddress()); + txObject["to"] = toString(tx.receiveAddress()); txObject["value"] = toString(tx.value()); txArray.push_back(txObject); } blObj["transactions"] = txArray; + blObj["rlp"] = "0x" + toHex(state.blockData()); BlockInfo current_BlockHeader = state.info(); + // overwrite blockheader with (possible wrong) data from "blockheader" in filler; + if (blObj.count("blockHeader")) - overwriteBlockHeader(current_BlockHeader, blObj); + { + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + cout << "new header!\n"; + ProofOfWork pow; + MineInfo ret; + while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) + tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } + } // write block header + mObject oBlockHeader; - writeBlockHeaderToJson(oBlockHeader, current_BlockHeader); + oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); + oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); + oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); + oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); + oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); + oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); + oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); + oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); + oBlockHeader["number"] = toString(current_BlockHeader.number); + oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); + oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); + oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); + oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + blObj["blockHeader"] = oBlockHeader; - vBiBlocks.push_back(current_BlockHeader); - // compare blocks from state and from rlp + // write uncle list + mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. + blObj["uncleHeaders"] = aUncleList; + + //txs: + RLPStream txStream; txStream.appendList(txList.size()); for (unsigned i = 0; i < txList.size(); ++i) @@ -194,16 +322,13 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txStream.appendRaw(txrlp.out()); } - RLPStream uncleStream; - uncleStream.appendList(vBiUncles.size()); - for (unsigned i = 0; i < vBiUncles.size(); ++i) - { - RLPStream uncleRlp; - vBiUncles[i].streamRLP(uncleRlp, WithNonce); - uncleStream.appendRaw(uncleRlp.out()); - } + RLPStream rlpStream2; + current_BlockHeader.streamRLP(rlpStream2, WithNonce); - RLPStream block2 = createFullBlockFromHeader(current_BlockHeader, txStream.out(), uncleStream.out()); + RLPStream block2(3); + block2.appendRaw(rlpStream2.out()); + block2.appendRaw(txStream.out()); + block2.appendRaw(RLPEmptyList); blObj["rlp"] = "0x" + toHex(block2.out()); @@ -214,14 +339,18 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "txs mismatch\n"; if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n" << RLP(state.blockData())[2].data() << "\n" << RLP(block2.out())[2].data(); + cnote << "uncle list mismatch\n"; try { - state.sync(bc); - bc.import(block2.out(), state.db()); - state.sync(bc); - state.commit(); + ImportTest importerTmp(o["pre"].get_obj()); + State stateTmp(Address(), OverlayDB(), BaseState::Empty); + importerTmp.importState(o["pre"].get_obj(), stateTmp); + stateTmp.commit(); + BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); + stateTmp.sync(bcTmp); + bc.import(block2.out(), stateTmp.db()); + stateTmp.sync(bcTmp); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -300,8 +429,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixHash == blockFromRlp.mixHash, "mixHash in given RLP not matching the block mixHash!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); @@ -361,258 +488,16 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions from rlp and transaction from field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i].rlp() == txsFromRlp[i].rlp(), "transactions rlp do not match"); - + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); } // check uncle list - - // uncles from uncle list field - vector uBlHsFromField; - if (blObj["uncleHeaders"].type() != json_spirit::null_type) - for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) - { - mObject uBlH = uBlHeaderObj.get_obj(); - cout << "uBlH.size(): " << uBlH.size() << endl; - BOOST_REQUIRE(uBlH.size() == 17); - bytes uncleRLP = createBlockRLPFromFields(uBlH); - const RLP c_uRLP(uncleRLP); - BlockInfo uncleBlockHeader; - try - { - uncleBlockHeader.populateFromHeader(c_uRLP, true); - } - catch(...) - { - BOOST_ERROR("invalid uncle header"); - } - uBlHsFromField.push_back(uncleBlockHeader); - } - - // uncles from block RLP - vector uBlHsFromRlp; - for (auto const& uRLP: root[2]) - { - BlockInfo uBl; - uBl.populateFromHeader(uRLP, true); - uBlHsFromRlp.push_back(uBl); - } - - BOOST_REQUIRE_EQUAL(uBlHsFromField.size(), uBlHsFromRlp.size()); - - for (size_t i = 0; i < uBlHsFromField.size(); ++i) - BOOST_CHECK_MESSAGE(uBlHsFromField[i] == uBlHsFromRlp[i], "block header in rlp and in field do not match"); - } - } - } -} - -// helping functions - -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.count("hash") > 0 ? (_tObj.size() - 1) : _tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << fromHex(_tObj["extraData"].get_str()); - - if (_tObj.count("seedHash")) - rlpStream << importByteArray(_tObj["seedHash"].get_str()); - - if (_tObj.count("mixHash")) - rlpStream << importByteArray(_tObj["mixHash"].get_str()); - - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - - return rlpStream.out(); -} - -void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj) -{ - if (_blObj["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = _current_BlockHeader; - - if (_blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(_blObj["blockHeader"].get_obj()["parentHash"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(_blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(_blObj["blockHeader"].get_obj()["coinbase"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(_blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(_blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(_blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(_blObj["blockHeader"].get_obj()["bloom"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(_blObj["blockHeader"].get_obj()["difficulty"]); - - if (_blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(_blObj["blockHeader"].get_obj()["number"]); - - if (_blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(_blObj["blockHeader"].get_obj()["gasLimit"]); - - if (_blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(_blObj["blockHeader"].get_obj()["gasUsed"]); - - if (_blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(_blObj["blockHeader"].get_obj()["timestamp"]); - - if (_blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(_blObj["blockHeader"].get_obj()["extraData"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(_blObj["blockHeader"].get_obj()["mixHash"].get_str()); - - if (_blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(_blObj["blockHeader"].get_obj()["seedHash"].get_str()); - - // find new valid nonce - - if (tmp != _current_BlockHeader) - { - _current_BlockHeader = tmp; - - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(_current_BlockHeader)) - { - ret = pow.mine(_current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, _current_BlockHeader); + BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); } } } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(_blObj["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - _current_BlockHeader.populateFromHeader(c_bRLP, false); - } -} - -BlockInfo constructBlock(mObject& _o) -{ - - BlockInfo ret; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(_o); - const RLP c_bRLP(c_blockRLP); - ret.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - } - catch(...) - { - BOOST_ERROR("block population did throw an unknown exception\n"); - } - return ret; -} - -void updatePoW(BlockInfo& _bi) -{ - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(_bi)) - { - ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, _bi); - } } -void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi) -{ - _o["parentHash"] = toString(_bi.parentHash); - _o["uncleHash"] = toString(_bi.sha3Uncles); - _o["coinbase"] = toString(_bi.coinbaseAddress); - _o["stateRoot"] = toString(_bi.stateRoot); - _o["transactionsTrie"] = toString(_bi.transactionsRoot); - _o["receiptTrie"] = toString(_bi.receiptsRoot); - _o["bloom"] = toString(_bi.logBloom); - _o["difficulty"] = toString(_bi.difficulty); - _o["number"] = toString(_bi.number); - _o["gasLimit"] = toString(_bi.gasLimit); - _o["gasUsed"] = toString(_bi.gasUsed); - _o["timestamp"] = toString(_bi.timestamp); - _o["extraData"] ="0x" + toHex(_bi.extraData); - _o["mixHash"] = toString(_bi.mixHash); - _o["seedHash"] = toString(_bi.seedHash); - _o["nonce"] = toString(_bi.nonce); - _o["hash"] = toString(_bi.hash); -} - -RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, const bytes& _uncles ) -{ - RLPStream rlpStream; - _bi.streamRLP(rlpStream, WithNonce); - - RLPStream ret(3); - ret.appendRaw(rlpStream.out()); - ret.appendRaw(_txs); - ret.appendRaw(_uncles); - - return ret; -} } }// Namespace Close @@ -620,27 +505,32 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcBlockChainTest) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); } -BOOST_AUTO_TEST_CASE(bcValidBlockTest) -{ - dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); -} +//BOOST_AUTO_TEST_CASE(blValidBlockTest) +//{ +// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); +//} -BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) -{ - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); -} +//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) +//{ +// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); +//} -BOOST_AUTO_TEST_CASE(bcUncleTest) -{ - dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); -} +//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) +//{ +// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); +//} + +//BOOST_AUTO_TEST_CASE(blForkBlocks) +//{ +// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); +//} -BOOST_AUTO_TEST_CASE(userDefinedFileBc) +BOOST_AUTO_TEST_CASE(userDefinedFileBl) { - dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); + dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); } BOOST_AUTO_TEST_SUITE_END() From 240ad0901b51f6d060311bf217ec3de11687db58 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:24:06 +0100 Subject: [PATCH 284/313] more block tests + bugfix for longer chains --- test/bcBlockChainTestFiller.json | 15 +++ test/bcInvalidHeaderTestFiller.json | 172 ++++++++++++---------------- test/bcValidBlockTestFiller.json | 116 ++++++++----------- test/blockchain.cpp | 45 +++----- 4 files changed, 150 insertions(+), 198 deletions(-) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 050def25b..75ed62943 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -39,6 +39,21 @@ ], "uncleHeaders" : [ ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "8000000", + "gasPrice" : "0", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] } ] } diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index 39a91a583..bba00834b 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,15 +1,13 @@ { "log1_wrongBlockNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -57,15 +55,13 @@ "log1_wrongBloom" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -92,7 +88,7 @@ "blocks" : [ { "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, "transactions" : [ { @@ -113,15 +109,13 @@ "wrongCoinbase" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -168,15 +162,13 @@ "wrongDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -223,15 +215,13 @@ "DifferentExtraData" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -257,7 +247,7 @@ "blocks" : [ { "blockHeader" : { - "extraData" : "0x42" + "extraData" : "42" }, "transactions" : [ { @@ -278,15 +268,13 @@ "wrongGasLimit" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -334,15 +322,13 @@ "wrongGasUsed" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -389,15 +375,13 @@ "wrongNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -444,15 +428,13 @@ "wrongParentHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -499,15 +481,13 @@ "wrongReceiptTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -554,15 +534,13 @@ "wrongStateRoot" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -609,15 +587,13 @@ "wrongTimestamp" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -664,15 +640,13 @@ "wrongTransactionsTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -719,15 +693,13 @@ "wrongUncleHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 14d4cfb2c..3ce79cf4d 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -2,15 +2,13 @@ "diff1024" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "1024", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -32,7 +30,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "85000", + "gasLimit" : "850", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -49,15 +47,13 @@ "gasPrice0" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -95,15 +91,13 @@ "gasLimitTooHigh" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "1000000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -141,15 +135,13 @@ "SimpleTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -171,7 +163,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "50000", + "gasLimit" : "500", "gasPrice" : "10", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -187,15 +179,13 @@ "txOrder" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -242,15 +232,13 @@ "txEqualValue" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -297,15 +285,13 @@ "log1_correct" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "10000", + "extraData" : "42", + "gasLimit" : "100000", "gasUsed" : "0", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -349,16 +335,14 @@ "dataTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "125000", + "difficulty" : "023101", + "extraData" : "42", + "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "number" : "0", + "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "number" : "62", "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", @@ -367,23 +351,19 @@ "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } }, "blocks" : [ { "transactions" : [ { "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "50000", - "gasPrice" : "50", + "gasLimit" : "0x0f3e6f", + "gasPrice" : "0x09184e72a000", "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", + "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", "to" : "", + "v" : "0x1b", "value" : "" } ], diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 7dad5b4f2..69ea8fa2b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -81,7 +81,7 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void doBlockTests(json_spirit::mValue& _v, bool _fillin) +void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { for (auto& i: _v.get_obj()) { @@ -271,7 +271,6 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) if (tmp != current_BlockHeader) { current_BlockHeader = tmp; - cout << "new header!\n"; ProofOfWork pow; MineInfo ret; while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) @@ -343,14 +342,9 @@ void doBlockTests(json_spirit::mValue& _v, bool _fillin) try { - ImportTest importerTmp(o["pre"].get_obj()); - State stateTmp(Address(), OverlayDB(), BaseState::Empty); - importerTmp.importState(o["pre"].get_obj(), stateTmp); - stateTmp.commit(); - BlockChain bcTmp(block.out(), getDataDir() + "/tmpBlockChain.bc", true); - stateTmp.sync(bcTmp); - bc.import(block2.out(), stateTmp.db()); - stateTmp.sync(bcTmp); + state.sync(bc); + bc.import(block2.out(), state.db()); + state.sync(bc); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -505,32 +499,23 @@ BOOST_AUTO_TEST_SUITE(BlockChainTests) BOOST_AUTO_TEST_CASE(bcBlockChainTest) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockTests); + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); } -//BOOST_AUTO_TEST_CASE(blValidBlockTest) -//{ -// dev::test::executeTests("blValidBlockTest", "/BlockTests", dev::test::doBlockTests); -//} - -//BOOST_AUTO_TEST_CASE(blInvalidTransactionRLP) -//{ -// dev::test::executeTests("blInvalidTransactionRLP", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blInvalidHeaderTest) -//{ -// dev::test::executeTests("blInvalidHeaderTest", "/BlockTests", dev::test::doBlockTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(blForkBlocks) -//{ -// dev::test::executeTests("blForkBlocks", "/BlockTests", dev::test::doBlockTests); -//} -BOOST_AUTO_TEST_CASE(userDefinedFileBl) +BOOST_AUTO_TEST_CASE(userDefinedFileBc) { - dev::test::userDefinedTest("--bltest", dev::test::doBlockTests); + dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); } BOOST_AUTO_TEST_SUITE_END() From 21163d44e2185c507dcea471b838e96867a90c31 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:44:41 +0100 Subject: [PATCH 285/313] fix blockGasLimit bug : 1024 -> 2048 --- libethcore/BlockInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index e40c37f12..d3843b3bb 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -218,8 +218,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); // Check timestamp is after previous timestamp. if (parentHash) From c4a6fc785c4dcc256f1e399f8b791549c1d0d46c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 00:48:01 +0100 Subject: [PATCH 286/313] update block tests to latest changes PoW changes --- libethcore/ProofOfWork.cpp | 2 +- test/bcBlockChainTestFiller.json | 4 ++- test/bcInvalidHeaderTestFiller.json | 56 +++++++++++++++++++++-------- test/bcValidBlockTestFiller.json | 52 ++++++++++++++++++--------- test/blockchain.cpp | 36 +++++++++++++++---- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 084225a38..04e4249b6 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -162,7 +162,7 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign if (val <= boundary) { ret.first.completed = true; - result.mixHash = *reinterpret_cast(ethashReturn.mix_hash); + result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); result.nonce = u64(tryNonce); break; } diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 75ed62943..827f49c58 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -7,12 +7,14 @@ "extraData" : "42", "gasLimit" : "100000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index bba00834b..5665a3418 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -7,7 +7,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -61,7 +63,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,7 +119,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -168,7 +174,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -221,7 +229,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -274,7 +284,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -328,7 +340,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -381,7 +395,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -434,7 +450,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -487,7 +505,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -540,7 +560,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -593,7 +615,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -646,7 +670,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -699,7 +725,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 3ce79cf4d..abb8afdf5 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -8,7 +8,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -30,7 +32,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "850", + "gasLimit" : "85000", "gasPrice" : "1", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -53,7 +55,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,7 +101,9 @@ "extraData" : "42", "gasLimit" : "1000000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -141,7 +147,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -163,7 +171,7 @@ "transactions" : [ { "data" : "", - "gasLimit" : "500", + "gasLimit" : "50000", "gasPrice" : "10", "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", @@ -185,7 +193,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -238,7 +248,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -291,7 +303,9 @@ "extraData" : "42", "gasLimit" : "100000", "gasUsed" : "0", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", "number" : "0", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -341,8 +355,10 @@ "extraData" : "42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "nonce" : "0x498e88f5c14b0b60d6e14ce9c6cc958cbe16a1df8dd90210e50d2d77562a348d", - "number" : "62", + "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "number" : "0", "parentHash" : "0xefb4db878627027c81b3bb1c7dd3a18dae3914a49cdd24a3e40ab3bbfbb240c5", "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", @@ -351,19 +367,23 @@ "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" }, "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } }, "blocks" : [ { "transactions" : [ { "data" : "0x60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b56", - "gasLimit" : "0x0f3e6f", - "gasPrice" : "0x09184e72a000", + "gasLimit" : "50000", + "gasPrice" : "50", "nonce" : "0", - "r" : "0xd4287e915ebac7a8af390560fa53c8f0b7f13802ba0393d7afa5823c2560ca89", - "s" : "0xae75db31a34f7e386ad459646de98ec3a1c88cc91b11620b4ffd86871f579942", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "", - "v" : "0x1b", "value" : "" } ], diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 69ea8fa2b..ccfd57722 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -75,6 +75,12 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("extraData")) rlpStream << importByteArray(_tObj["extraData"].get_str()); + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixBytes")) + rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -130,13 +136,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { // find new valid nonce ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty)) - tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true); + std::pair ret; + while (!ProofOfWork::verify(blockFromFields)) + { + ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, blockFromFields); + } //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); + o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); } // create new "genesis" block @@ -266,15 +276,25 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixBytes")) + tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + // find new valid nonce if (tmp != current_BlockHeader) { current_BlockHeader = tmp; + ProofOfWork pow; - MineInfo ret; - while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty)) - tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true); + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } } } else @@ -302,6 +322,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); blObj["blockHeader"] = oBlockHeader; @@ -423,6 +445,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!"); From a1c042f5805d0b959d10300f2ca9fcbf2297fb32 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 15:17:34 +0100 Subject: [PATCH 287/313] More info in AZ. --- alethzero/MainWin.cpp | 7 +++++-- libethcore/BlockInfo.cpp | 18 +++++++++++++----- libethcore/BlockInfo.h | 6 +++--- libethcore/Exceptions.h | 1 + libethcore/ProofOfWork.cpp | 8 ++++---- libethcore/ProofOfWork.h | 11 ++++++++--- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 0242fe1fa..a096d2c15 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1409,7 +1409,10 @@ void Main::on_blocks_currentItemChanged() s << "
Hash w/o nonce: " << info.headerHash(WithoutNonce) << ""; s << "
Difficulty: " << info.difficulty << ""; if (info.number) - s << "
Proof-of-Work: " << ProofOfWork::eval(info) << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << ""; + { + auto e = ProofOfWork::eval(info); + s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; + } else s << "
Proof-of-Work: Phil has nothing to prove"; s << "
Parent: " << info.parentHash << ""; @@ -1431,7 +1434,7 @@ void Main::on_blocks_currentItemChanged() s << line << "Nonce: " << uncle.nonce << ""; s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; s << line << "Difficulty: " << uncle.difficulty << ""; - auto e = Ethasher::eval(uncle); + auto e = ProofOfWork::eval(uncle); s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index d3843b3bb..107a189fb 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -58,7 +58,7 @@ void BlockInfo::setEmpty() timestamp = 0; extraData.clear(); seedHash = h256(); - mixBytes = h256(); + mixHash = h256(); nonce = Nonce(); hash = headerHash(WithNonce); } @@ -83,7 +83,7 @@ void BlockInfo::streamRLP(RLPStream& _s, IncludeNonce _n) const << parentHash << sha3Uncles << coinbaseAddress << stateRoot << transactionsRoot << receiptsRoot << logBloom << difficulty << number << gasLimit << gasUsed << timestamp << extraData << seedHash; if (_n == WithNonce) - _s << mixBytes << nonce; + _s << mixHash << nonce; } h256 BlockInfo::headerHash(bytesConstRef _block) @@ -112,7 +112,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); seedHash = _header[field = 13].toHash(); - mixBytes = _header[field = 14].toHash(); + mixHash = _header[field = 14].toHash(); nonce = _header[field = 15].toHash(); } @@ -187,7 +187,12 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) gasLimit = calculateGasLimit(_parent); gasUsed = 0; difficulty = calculateDifficulty(_parent); - seedHash = number % 30 == 0 ? sha3(_parent.seedHash.asBytes() /*+ _parent.hash.asBytes()*/) : _parent.seedHash; + seedHash = calculateSeedHash(_parent); +} + +h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const +{ + return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -203,7 +208,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return (u256)c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -221,6 +226,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (seedHash != calculateSeedHash(_parent)) + BOOST_THROW_EXCEPTION(InvalidSeedHash()); + // Check timestamp is after previous timestamp. if (parentHash) { diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 6ed985f75..95519b57d 100644 --- a/libethcore/BlockInfo.h +++ b/libethcore/BlockInfo.h @@ -74,7 +74,7 @@ public: u256 gasUsed; u256 timestamp; bytes extraData; - h256 mixBytes; + h256 mixHash; h256 seedHash; Nonce nonce; @@ -105,7 +105,7 @@ public: gasUsed == _cmp.gasUsed && timestamp == _cmp.timestamp && extraData == _cmp.extraData && - mixBytes == _cmp.mixBytes && + mixHash == _cmp.mixHash && seedHash == _cmp.seedHash && nonce == _cmp.nonce; } @@ -133,7 +133,7 @@ inline std::ostream& operator<<(std::ostream& _out, BlockInfo const& _bi) { _out << _bi.hash << " " << _bi.parentHash << " " << _bi.sha3Uncles << " " << _bi.coinbaseAddress << " " << _bi.stateRoot << " " << _bi.transactionsRoot << " " << _bi.receiptsRoot << " " << _bi.logBloom << " " << _bi.difficulty << " " << _bi.number << " " << _bi.gasLimit << " " << - _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixBytes << " " << _bi.seedHash << " " << _bi.nonce; + _bi.gasUsed << " " << _bi.timestamp << " " << _bi.mixHash << " " << _bi.seedHash << " " << _bi.nonce; return _out; } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index bc9441c6b..45667f44a 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -57,6 +57,7 @@ struct InvalidGasUsed: virtual dev::Exception {}; class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTransactionsHash(h256 _head, h256 _real); h256 head; h256 real; }; struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; +struct InvalidSeedHash: virtual dev::Exception {}; class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 04e4249b6..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -118,16 +118,16 @@ Ethasher* Ethasher::s_this = nullptr; bool Ethash::verify(BlockInfo const& _header) { bigint boundary = (bigint(1) << 256) / _header.difficulty; - u256 e(eval(_header, _header.nonce)); - return e <= boundary; + auto e = eval(_header, _header.nonce); + return (u256)e.value <= boundary && e.mixHash == _header.mixHash; } -h256 Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) +Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) { auto p = Ethasher::params(_header); ethash_return_value r; ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return h256(r.result, h256::ConstructFromPointer); + return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7b9787f61..fdf51f0d4 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -55,12 +55,17 @@ public: Nonce nonce; h256 mixHash; }; + struct Result + { + h256 value; + h256 mixHash; + }; - static h256 eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static h256 eval(BlockInfo const& _header, Nonce const& _nonce); + static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } + static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixBytes = _r.mixHash; } + static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } protected: Nonce m_last; From 2b141737dd7ee2a4fb4a706d85b527946bf9a53d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 17:35:23 +0100 Subject: [PATCH 288/313] Add date/time language to solidity. --- test/blockchain.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ccfd57722..aea2bab07 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -78,8 +78,8 @@ bytes createBlockRLPFromFields(mObject& _tObj) if (_tObj.count("seedHash")) rlpStream << importByteArray(_tObj["seedHash"].get_str()); - if (_tObj.count("mixBytes")) - rlpStream << importByteArray(_tObj["mixBytes"].get_str()); + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); if (_tObj.count("nonce")) rlpStream << importByteArray(_tObj["nonce"].get_str()); @@ -146,7 +146,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) //update genesis block in json file o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes); + o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); } // create new "genesis" block @@ -276,8 +276,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj["blockHeader"].get_obj().count("extraData")) tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixBytes")) - tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str()); + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); if (blObj["blockHeader"].get_obj().count("seedHash")) tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); @@ -322,7 +322,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); - oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes); + oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); @@ -445,7 +445,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!"); - BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!"); + BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixHash == blockFromRlp.mixHash, "mixHash in given RLP not matching the block mixHash!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!"); BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!"); From 3a715aa10af7b3b837fd237a8586cba629c81939 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 19:55:52 +0100 Subject: [PATCH 289/313] Params & JSON file. --- feeStructure.json | 54 ------------------------------- libdevcrypto/OverlayDB.cpp | 2 -- libethcore/BlockInfo.cpp | 18 +++-------- libethcore/Params.cpp | 9 ++++++ libethcore/Params.h | 10 ++++++ libethcore/ProofOfWork.cpp | 2 ++ libethereum/Precompiled.cpp | 2 +- params.json | 64 ------------------------------------- 8 files changed, 27 insertions(+), 134 deletions(-) delete mode 100644 feeStructure.json delete mode 100644 params.json diff --git a/feeStructure.json b/feeStructure.json deleted file mode 100644 index f5acf0f0b..000000000 --- a/feeStructure.json +++ /dev/null @@ -1,54 +0,0 @@ -var x = { - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} - -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ - diff --git a/libdevcrypto/OverlayDB.cpp b/libdevcrypto/OverlayDB.cpp index ffe996bb6..4bd698f57 100644 --- a/libdevcrypto/OverlayDB.cpp +++ b/libdevcrypto/OverlayDB.cpp @@ -56,10 +56,8 @@ void OverlayDB::commit() if (m_aux.count(i)) { m_db->Put(m_writeOptions, i.ref(), bytesConstRef(&m_aux[i])); - cdebug << "Committing aux: " << i; m_aux.erase(i); } - cdebug << "Discarding " << keysOf(m_aux); m_auxActive.clear(); m_aux.clear(); m_over.clear(); diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 107a189fb..dc274f5e7 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -31,8 +31,6 @@ using namespace std; using namespace dev; using namespace dev::eth; -u256 dev::eth::c_genesisDifficulty = (u256)1 << 11; - BlockInfo::BlockInfo(): timestamp(Invalid256) { } @@ -129,14 +127,8 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) if (gasUsed > gasLimit) BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(gasLimit), bigint(gasUsed)) ); - if (difficulty < c_minimumDifficulty) - BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); - - if (gasLimit < c_minGasLimit) - BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); - if (number && extraData.size() > c_maximumExtraDataSize) - BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); + BOOST_THROW_EXCEPTION(ExtraDataTooBig()); } void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) @@ -192,7 +184,7 @@ void BlockInfo::populateFromParent(BlockInfo const& _parent) h256 BlockInfo::calculateSeedHash(BlockInfo const& _parent) const { - return number % 30 == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; + return number % c_epochDuration == 0 ? sha3(_parent.seedHash.asBytes()) : _parent.seedHash; } u256 BlockInfo::calculateGasLimit(BlockInfo const& _parent) const @@ -208,7 +200,7 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const if (!parentHash) return (u256)c_genesisDifficulty; else - return max(2048, timestamp >= _parent.timestamp + 8 ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); + return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } @@ -223,8 +215,8 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 2048) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 2048)); + if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index 41164b206..f36af1375 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -28,6 +28,15 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +u256 const c_genesisDifficulty = 2048; +u256 const c_maximumExtraDataSize = 1024; +u256 const c_epochDuration = 3000; +u256 const c_genesisGasLimit = 1000000; +u256 const c_minGasLimit = 125000; +u256 const c_gasLimitBoundDivisor = 1024; +u256 const c_minimumDifficulty = 2048; +u256 const c_difficultyBoundDivisor = 2048; +u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; u256 const c_expGas = 10; u256 const c_expByteGas = 10; diff --git a/libethcore/Params.h b/libethcore/Params.h index 9109347dc..cab1852fa 100644 --- a/libethcore/Params.h +++ b/libethcore/Params.h @@ -29,6 +29,16 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json +extern u256 const c_genesisDifficulty; +extern u256 const c_maximumExtraDataSize; +extern u256 const c_epochDuration; +extern u256 const c_genesisGasLimit; +extern u256 const c_minGasLimit; +extern u256 const c_gasLimitBoundDivisor; +extern u256 const c_minimumDifficulty; +extern u256 const c_difficultyBoundDivisor; +extern u256 const c_durationLimit; + extern u256 const c_tierStepGas[8]; ///< Once per operation, for a selection of them. extern u256 const c_expGas; ///< Once per EXP instuction. extern u256 const c_expByteGas; ///< Times ceil(log256(exponent)) for the EXP instruction. diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..332d739bb 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,6 +66,7 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } + cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -90,6 +91,7 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } + cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index c62a00f88..6e0d4756c 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::eth; diff --git a/params.json b/params.json deleted file mode 100644 index 744f92154..000000000 --- a/params.json +++ /dev/null @@ -1,64 +0,0 @@ -var x = { - "genesisGasLimit": { "v": 1000000, "d": "Gas limit of the Genesis block." }, - "minGasLimit": { "v": 125000, "d": "Minimum the gas limit may ever be." }, - "gasLimitBoundDivisor": { "v": 1024, "d": "The bound divisor of the gas limit, used in update calculations." }, - "genesisDifficulty": { "v": 131072, "d": "Difficulty of the Genesis block." }, - "minimumDifficulty": { "v": 131072, "d": "The minimum that the difficulty may ever be." }, - "difficultyBoundDivisor": { "v": 2048, "d": "The bound divisor of the difficulty, used in the update calculations." }, - "durationLimit": { "v": 8, "d": "The decision boundary on the blocktime duration used to determine whether difficulty should go up or not." }, - "maximumExtraDataSize": { "v": 1024, "d": "Maximum size extra data may be after Genesis." }, - "epochDuration": { "v": 3000, "d": "Duration between proof-of-work epochs." }, - - "tierStepGas": { "v": [ 0, 2, 3, 5, 8, 10, 20 ], "d": "Once per operation, for a selection of them." }, - "expGas": { "v": 10, "d": "Once per EXP instuction." }, - "expByteGas": { "v": 10, "d": "Times ceil(log256(exponent)) for the EXP instruction." }, - - "sha3Gas": { "v": 30, "d": "Once per SHA3 operation." }, - "sha3WordGas": { "v": 6, "d": "Once per word of the SHA3 operation's data." }, - - "sloadGas": { "v": 50, "d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added." }, - "sstoreSetGas": { "v": 20000, "d": "Once per SLOAD operation." }, - "sstoreResetGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness changes from zero." }, - "sstoreClearGas": { "v": 5000, "d": "Once per SSTORE operation if the zeroness doesn't change." }, - "sstoreRefundGas": { "v": 15000, "d": "Once per SSTORE operation if the zeroness changes to zero." }, - "jumpdestGas": { "v": 1, "d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero." }, - - "logGas": { "v": 375, "d": "Per LOG* operation." }, - "logDataGas": { "v": 8, "d": "Per byte in a LOG* operation's data." }, - "logTopicGas": { "v": 375, "d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas." }, - - "createGas": { "v": 32000, "d": "Once per CREATE operation & contract-creation transaction." }, - - "callGas": { "v": 40, "d": "Once per CALL operation & message call transaction." }, - "callStipend": { "v": 2300, "d": "Free gas given at beginning of call." }, - "callValueTransferGas": { "v": 9000, "d": "Paid for CALL when the value transfor is non-zero." }, - "callNewAccountGas": { "v": 25000, "d": "Paid for CALL when the destination address didn't exist prior." }, - - "suicideRefundGas": { "v": 24000, "d": "Refunded following a suicide operation." }, - - "memoryGas": { "v": 3, "d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL." }, - "quadCoeffDiv": { "v": 512, "d": "Divisor for the quadratic particle of the memory cost equation." }, - - "createDataGas": { "v": 200, "d": "" }, - "txGas": { "v": 21000, "d": "Per transaction. NOTE: Not payable on data of calls between transactions." }, - "txDataZeroGas": { "v": 4, "d": "Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions." }, - "txDataNonZeroGas": { "v": 68, "d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions." }, - - "copyGas": { "v": 3, "d": "" }, - - "ecrecoverGas": { "v": 3000, "d": "" }, - "sha256Gas": { "v": 60, "d": "" }, - "sha256WordGas": { "v": 12, "d": "" }, - "ripemd160Gas": { "v": 600, "d": "" }, - "ripemd160WordGas": { "v": 120, "d": "" }, - "identityGas": { "v": 15, "d": "" }, - "identityWordGas": { "v": 3, "d": ""} -} - -/* -// to get C++ .h: -for (i in x) console.log("/// " + x[i].d + "\nextern u256 const c_" + i + (x[i].v * 0 !== 0 ? "[" + (x[i].v.length + 1) + "]" : "") + ";") -// to get C++ .cpp: -for (i in x) console.log("u256 const c_" + i + (x[i].v * 0 === 0 ? " = " + x[i].v : "[] = {" + x[i].v.join(", ") + ", 0}") + ";") -*/ - From bede3bc95bb6c2185110a4c8deaa9f0d4bda4dab Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Wed, 4 Mar 2015 21:32:26 +0100 Subject: [PATCH 290/313] merge --- libethcore/BlockInfo.cpp | 20 +- test/bcBlockChainTestFiller.json | 6 +- test/bcInvalidHeaderTestFiller.json | 88 ++--- test/bcUncleTestFiller.json | 489 ++-------------------------- test/bcValidBlockTestFiller.json | 48 +-- test/blockchain.cpp | 275 ++++++++-------- 6 files changed, 259 insertions(+), 667 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index dc274f5e7..c8d5625a6 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -96,22 +96,22 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) int field = 0; try { - parentHash = _header[field = 0].toHash(); - sha3Uncles = _header[field = 1].toHash(); - coinbaseAddress = _header[field = 2].toHash
(); - stateRoot = _header[field = 3].toHash(); - transactionsRoot = _header[field = 4].toHash(); - receiptsRoot = _header[field = 5].toHash(); - logBloom = _header[field = 6].toHash(); + parentHash = _header[field = 0].toHash(RLP::VeryStrict); + sha3Uncles = _header[field = 1].toHash(RLP::VeryStrict); + coinbaseAddress = _header[field = 2].toHash
(RLP::VeryStrict); + stateRoot = _header[field = 3].toHash(RLP::VeryStrict); + transactionsRoot = _header[field = 4].toHash(RLP::VeryStrict); + receiptsRoot = _header[field = 5].toHash(RLP::VeryStrict); + logBloom = _header[field = 6].toHash(RLP::VeryStrict); difficulty = _header[field = 7].toInt(); number = _header[field = 8].toInt(); gasLimit = _header[field = 9].toInt(); gasUsed = _header[field = 10].toInt(); timestamp = _header[field = 11].toInt(); extraData = _header[field = 12].toBytes(); - seedHash = _header[field = 13].toHash(); - mixHash = _header[field = 14].toHash(); - nonce = _header[field = 15].toHash(); + seedHash = _header[field = 13].toHash(RLP::VeryStrict); + mixHash = _header[field = 14].toHash(RLP::VeryStrict); + nonce = _header[field = 15].toHash(RLP::VeryStrict); } catch (Exception const& _e) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 827f49c58..8a0bf89fe 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -1,10 +1,10 @@ { "minDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1023", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", "number" : "0", @@ -12,7 +12,7 @@ "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", "timestamp" : "0x54c98c81", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index 5665a3418..aa32dfbab 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -1,13 +1,13 @@ { "log1_wrongBlockNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -57,13 +57,13 @@ "log1_wrongBloom" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -92,7 +92,7 @@ "blocks" : [ { "blockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, "transactions" : [ { @@ -113,13 +113,13 @@ "wrongCoinbase" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -168,13 +168,13 @@ "wrongDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -223,13 +223,13 @@ "DifferentExtraData" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -257,7 +257,7 @@ "blocks" : [ { "blockHeader" : { - "extraData" : "42" + "extraData" : "0x42" }, "transactions" : [ { @@ -278,13 +278,13 @@ "wrongGasLimit" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -334,13 +334,13 @@ "wrongGasUsed" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -389,13 +389,13 @@ "wrongNumber" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -444,13 +444,13 @@ "wrongParentHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -499,13 +499,13 @@ "wrongReceiptTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -554,13 +554,13 @@ "wrongStateRoot" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -609,13 +609,13 @@ "wrongTimestamp" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -664,13 +664,13 @@ "wrongTransactionsTrie" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -719,13 +719,13 @@ "wrongUncleHash" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index 639051f2b..839e3ba46 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,9 +1,9 @@ { - "uncleHeaderAtBlock2" : { + "minDifficulty" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", + "difficulty" : "1023", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", @@ -58,300 +58,30 @@ { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", + "difficulty" : "2049", "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "1", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - } - ] - }, - - "oneUncle" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "2", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - } - ] - }, - - "twoEqualUncle" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "2", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", + "gasLimit" : "99804806", + "gasUsed" : "21000", + "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", + "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", + "nonce" : "17ed77999bef2e4b", "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", + "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", + "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", + "timestamp" : "1425490151", + "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] - } - ] - }, - - "twoUncle" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] }, { "transactions" : [ { "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", + "gasLimit" : "8000000", + "gasPrice" : "0", "nonce" : "2", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", @@ -360,180 +90,25 @@ ], "uncleHeaders" : [ { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "1023", + "extraData" : "0x42", + "gasLimit" : "100000000", "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - } - ] - }, - - "threeUncle" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "80000050", - "gasPrice" : "1", - "nonce" : "2", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "131072", - "extraData" : "0x", - "gasLimit" : "99902343", - "gasUsed" : "0", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "a55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "0x54c98c82", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + "number" : "1", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] } ] } - - } diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index abb8afdf5..29b2e978e 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -2,13 +2,13 @@ "diff1024" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "1024", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -49,13 +49,13 @@ "gasPrice0" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -95,13 +95,13 @@ "gasLimitTooHigh" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "1000000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -141,13 +141,13 @@ "SimpleTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -187,13 +187,13 @@ "txOrder" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -242,13 +242,13 @@ "txEqualValue" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -297,13 +297,13 @@ "log1_correct" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "10000", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "100000", "gasUsed" : "0", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", @@ -349,13 +349,13 @@ "dataTx" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", "difficulty" : "023101", - "extraData" : "42", + "extraData" : "0x42", "gasLimit" : "0x0dddb6", "gasUsed" : "100", - "mixBytes" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "nonce" : "0x0102030405060708", "number" : "0", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index aea2bab07..55c39f56b 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -31,61 +31,10 @@ using namespace dev::eth; namespace dev { namespace test { -bytes createBlockRLPFromFields(mObject& _tObj) -{ - RLPStream rlpStream; - rlpStream.appendList(_tObj.size()); - - if (_tObj.count("parentHash")) - rlpStream << importByteArray(_tObj["parentHash"].get_str()); - - if (_tObj.count("uncleHash")) - rlpStream << importByteArray(_tObj["uncleHash"].get_str()); - - if (_tObj.count("coinbase")) - rlpStream << importByteArray(_tObj["coinbase"].get_str()); - - if (_tObj.count("stateRoot")) - rlpStream << importByteArray(_tObj["stateRoot"].get_str()); - - if (_tObj.count("transactionsTrie")) - rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); - - if (_tObj.count("receiptTrie")) - rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); - - if (_tObj.count("bloom")) - rlpStream << importByteArray(_tObj["bloom"].get_str()); - - if (_tObj.count("difficulty")) - rlpStream << bigint(_tObj["difficulty"].get_str()); - - if (_tObj.count("number")) - rlpStream << bigint(_tObj["number"].get_str()); - - if (_tObj.count("gasLimit")) - rlpStream << bigint(_tObj["gasLimit"].get_str()); - - if (_tObj.count("gasUsed")) - rlpStream << bigint(_tObj["gasUsed"].get_str()); - - if (_tObj.count("timestamp")) - rlpStream << bigint(_tObj["timestamp"].get_str()); - - if (_tObj.count("extraData")) - rlpStream << importByteArray(_tObj["extraData"].get_str()); - - if (_tObj.count("seedHash")) - rlpStream << importByteArray(_tObj["seedHash"].get_str()); - - if (_tObj.count("mixHash")) - rlpStream << importByteArray(_tObj["mixHash"].get_str()); +bytes createBlockRLPFromFields(mObject& _tObj); +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - if (_tObj.count("nonce")) - rlpStream << importByteArray(_tObj["nonce"].get_str()); - return rlpStream.out(); -} void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -147,6 +96,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); + o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); } // create new "genesis" block @@ -211,13 +161,13 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txList.push_back(tx); mObject txObject; txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = toHex(tx.data()); + txObject["data"] = "0x" + toHex(tx.data()); txObject["gasLimit"] = toString(tx.gas()); txObject["gasPrice"] = toString(tx.gasPrice()); txObject["r"] = "0x" + toString(tx.signature().r); txObject["s"] = "0x" + toString(tx.signature().s); txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = toString(tx.receiveAddress()); + txObject["to"] = tx.isCreation() ? "" : toString(tx.receiveAddress()); txObject["value"] = toString(tx.value()); txArray.push_back(txObject); @@ -232,78 +182,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) if (blObj.count("blockHeader")) { - if (blObj["blockHeader"].get_obj().size() != 14) - { - - BlockInfo tmp = current_BlockHeader; - - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); - - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); - - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); - - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); - - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); - - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); - - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); - - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); - - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); - - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); - - // find new valid nonce - - if (tmp != current_BlockHeader) - { - current_BlockHeader = tmp; - - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) - { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); - } - } - } - else - { - // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); - } + overwriteBlockHeader(current_BlockHeader, blObj); } // write block header @@ -321,10 +200,11 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData); + oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); + oBlockHeader["hash"] = toString(current_BlockHeader.hash); blObj["blockHeader"] = oBlockHeader; @@ -506,7 +386,9 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_CHECK_MESSAGE(txsFromField[i].receiveAddress() == txsFromRlp[i].receiveAddress(), "transaction receiveAddress in rlp and in field do not match"); BOOST_CHECK_MESSAGE(txsFromField[i].value() == txsFromRlp[i].value(), "transaction receiveAddress in rlp and in field do not match"); - BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions in rlp and in transaction field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i] == txsFromRlp[i], "transactions from rlp and transaction from field do not match"); + BOOST_CHECK_MESSAGE(txsFromField[i].rlp() == txsFromRlp[i].rlp(), "transactions rlp do not match"); + } // check uncle list @@ -516,6 +398,137 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } } +bytes createBlockRLPFromFields(mObject& _tObj) +{ + RLPStream rlpStream; + rlpStream.appendList(_tObj.count("hash") > 0 ? (_tObj.size() - 1) : _tObj.size()); + + if (_tObj.count("parentHash")) + rlpStream << importByteArray(_tObj["parentHash"].get_str()); + + if (_tObj.count("uncleHash")) + rlpStream << importByteArray(_tObj["uncleHash"].get_str()); + + if (_tObj.count("coinbase")) + rlpStream << importByteArray(_tObj["coinbase"].get_str()); + + if (_tObj.count("stateRoot")) + rlpStream << importByteArray(_tObj["stateRoot"].get_str()); + + if (_tObj.count("transactionsTrie")) + rlpStream << importByteArray(_tObj["transactionsTrie"].get_str()); + + if (_tObj.count("receiptTrie")) + rlpStream << importByteArray(_tObj["receiptTrie"].get_str()); + + if (_tObj.count("bloom")) + rlpStream << importByteArray(_tObj["bloom"].get_str()); + + if (_tObj.count("difficulty")) + rlpStream << bigint(_tObj["difficulty"].get_str()); + + if (_tObj.count("number")) + rlpStream << bigint(_tObj["number"].get_str()); + + if (_tObj.count("gasLimit")) + rlpStream << bigint(_tObj["gasLimit"].get_str()); + + if (_tObj.count("gasUsed")) + rlpStream << bigint(_tObj["gasUsed"].get_str()); + + if (_tObj.count("timestamp")) + rlpStream << bigint(_tObj["timestamp"].get_str()); + + if (_tObj.count("extraData")) + rlpStream << fromHex(_tObj["extraData"].get_str()); + + if (_tObj.count("seedHash")) + rlpStream << importByteArray(_tObj["seedHash"].get_str()); + + if (_tObj.count("mixHash")) + rlpStream << importByteArray(_tObj["mixHash"].get_str()); + + if (_tObj.count("nonce")) + rlpStream << importByteArray(_tObj["nonce"].get_str()); + + return rlpStream.out(); +} + +void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +{ + if (blObj["blockHeader"].get_obj().size() != 14) + { + + BlockInfo tmp = current_BlockHeader; + + if (blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + + if (blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + + if (blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + + if (blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + + if (blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + + if (blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + + if (blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + + if (blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + + if (blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + + if (blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + + if (blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + + if (blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + + // find new valid nonce + + if (tmp != current_BlockHeader) + { + current_BlockHeader = tmp; + + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(current_BlockHeader)) + { + ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, current_BlockHeader); + } + } + } + else + { + // take the blockheader as is + const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const RLP c_bRLP(c_blockRLP); + current_BlockHeader.populateFromHeader(c_bRLP, false); + } +} } }// Namespace Close @@ -536,6 +549,10 @@ BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); } +//BOOST_AUTO_TEST_CASE(bcUncleTest) +//{ +// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +//} BOOST_AUTO_TEST_CASE(userDefinedFileBc) { From beb58f17f0a984ad2062f2875ae43dc0dda0c92b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:24:01 +0100 Subject: [PATCH 291/313] RLP tool. --- libdevcore/CommonIO.cpp | 5 -- libdevcore/CommonIO.h | 6 +- libethcore/Params.cpp | 4 +- libethcore/ProofOfWork.cpp | 2 - rlp/base64.cpp | 128 +++++++++++++++++++++++++++++++++++++ rlp/base64.h | 40 ++++++++++++ rlp/main.cpp | 115 +++++++++++++++------------------ 7 files changed, 224 insertions(+), 76 deletions(-) create mode 100644 rlp/base64.cpp create mode 100644 rlp/base64.h diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index d7e74d36e..4fa132073 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -115,8 +115,3 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data) ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); } -void dev::writeFile(std::string const& _file, bytesConstRef _data) -{ - ofstream(_file, ios::trunc).write((char const*)_data.data(), _data.size()); -} - diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 1f9e29e54..03fc9cffc 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -43,13 +43,15 @@ namespace dev /// Retrieve and returns the contents of the given file. If the file doesn't exist or isn't readable, returns an empty bytes. bytes contents(std::string const& _file); +std::string contentsString(std::string const& _file); /// Retrieve and returns the allocated contents of the given file. If the file doesn't exist or isn't readable, returns nullptr. Don't forget to delete [] when finished. bytesRef contentsNew(std::string const& _file); -/// Write the given binary data into the given file, replacing the file if it pre-exists. -void writeFile(std::string const& _file, bytes const& _data); /// Write the given binary data into the given file, replacing the file if it pre-exists. void writeFile(std::string const& _file, bytesConstRef _data); +/// Write the given binary data into the given file, replacing the file if it pre-exists. +inline void writeFile(std::string const& _file, bytes const& _data) { writeFile(_file, bytesConstRef(&_data)); } +inline void writeFile(std::string const& _file, std::string const& _data) { writeFile(_file, bytesConstRef(_data)); } /// Nicely renders the given bytes to a string, optionally as HTML. /// @a _bytes: bytes array to be rendered as string. @a _width of a bytes line. diff --git a/libethcore/Params.cpp b/libethcore/Params.cpp index f36af1375..d1154abcc 100644 --- a/libethcore/Params.cpp +++ b/libethcore/Params.cpp @@ -28,13 +28,13 @@ namespace eth { //--- BEGIN: AUTOGENERATED FROM /feeStructure.json -u256 const c_genesisDifficulty = 2048; +u256 const c_genesisDifficulty = 131072; u256 const c_maximumExtraDataSize = 1024; u256 const c_epochDuration = 3000; u256 const c_genesisGasLimit = 1000000; u256 const c_minGasLimit = 125000; u256 const c_gasLimitBoundDivisor = 1024; -u256 const c_minimumDifficulty = 2048; +u256 const c_minimumDifficulty = 131072; u256 const c_difficultyBoundDivisor = 2048; u256 const c_durationLimit = 8; u256 const c_tierStepGas[] = {0, 2, 3, 5, 8, 10, 20, 0}; diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index 332d739bb..c879df2ce 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -66,7 +66,6 @@ public: writeFile(memoFile, m_caches[_header.seedHash]); } } - cdebug << "sha3 of cache: " << sha3(m_caches[_header.seedHash]); return m_caches[_header.seedHash]; } @@ -91,7 +90,6 @@ public: writeFile(memoFile, m_fulls[_header.seedHash]); } } - cdebug << "sha3 of full pad: " << sha3(m_fulls[_header.seedHash]); return m_fulls[_header.seedHash].data(); } diff --git a/rlp/base64.cpp b/rlp/base64.cpp new file mode 100644 index 000000000..5e2b32000 --- /dev/null +++ b/rlp/base64.cpp @@ -0,0 +1,128 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. + +#include "base64.h" + +#include + +using namespace std; +using namespace dev; + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +static inline bool is_base64(byte c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +std::string dev::base64_encode(bytesConstRef _in) { + std::string ret; + int i = 0; + int j = 0; + byte char_array_3[3]; + byte char_array_4[4]; + + auto buf = _in.data(); + auto bufLen = _in.size(); + + while (bufLen--) { + char_array_3[i++] = *(buf++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + } + + return ret; +} + +bytes dev::base64_decode(std::string const& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + byte char_array_4[4], char_array_3[3]; + bytes ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret.push_back(char_array_3[i]); + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); + } + + return ret; +} diff --git a/rlp/base64.h b/rlp/base64.h new file mode 100644 index 000000000..53ba282c8 --- /dev/null +++ b/rlp/base64.h @@ -0,0 +1,40 @@ +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch +*/ +/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c +/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. +#pragma once + +#include +#include +#include + +namespace dev +{ + +std::string base64_encode(bytesConstRef _in); +bytes base64_decode(std::string const& _in); + +} diff --git a/rlp/main.cpp b/rlp/main.cpp index 663bbf14d..9bd51cdfc 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -22,9 +22,11 @@ #include #include #include +#include #include #include #include +#include "base64.h" using namespace std; using namespace dev; @@ -33,21 +35,6 @@ void help() cout << "Usage rlp [OPTIONS] [ | -- ]" << endl << "Options:" << endl - << " -r,--render Render the given RLP. Options:" << endl - << " --indent Use string as the level indentation (default ' ')." << endl - << " --hex-ints Render integers in hex." << endl - << " --ascii-strings Render data as C-style strings or hex depending on content being ASCII." << endl - << " --force-string Force all data to be rendered as C-style strings." << endl - << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl - << " --force-hex Force all data to be rendered as raw hex." << endl - << " -l,--list-archive List the items in the RLP list by hash and size." << endl - << " -e,--extract-archive Extract all items in the RLP list, named by hash." << endl - << "General options:" << endl - << " -L,--lenience Try not to bomb out early if possible." << endl - << " -x,--hex,--base-16 Treat input RLP as hex encoded data." << endl - << " --64,--base-64 Treat input RLP as base-64 encoded data." << endl - << " -b,--bin,--base-256 Treat input RLP as raw binary data." << endl - << " -h,--help Print this help message and exit." << endl << " -V,--version Show the version and exit." << endl ; exit(0); @@ -87,7 +74,7 @@ public: { string indent = " "; bool hexInts = false; - bool forceString = true; + bool forceString = false; bool escapeAll = false; bool forceHex = false; }; @@ -100,7 +87,7 @@ public: m_out << "null"; else if (_d.isInt()) if (m_prefs.hexInts) - m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire), 1), 1); + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); else m_out << _d.toInt(RLP::LaisezFaire); else if (_d.isData()) @@ -151,8 +138,6 @@ int main(int argc, char** argv) prefs.indent = argv[++i]; else if (arg == "--hex-ints") prefs.hexInts = true; - else if (arg == "--ascii-strings") - prefs.forceString = prefs.forceHex = false; else if (arg == "--force-string") prefs.forceString = true; else if (arg == "--force-hex") @@ -219,7 +204,7 @@ int main(int argc, char** argv) boost::algorithm::replace_all(s, " ", ""); boost::algorithm::replace_all(s, "\n", ""); boost::algorithm::replace_all(s, "\t", ""); - b = fromBase64(s); + b = base64_decode(s); break; } default: @@ -229,60 +214,60 @@ int main(int argc, char** argv) try { - RLP rlp(b); - switch (mode) - { - case Mode::ListArchive: + RLP rlp(b); + switch (mode) + { + case Mode::ListArchive: + { + if (!rlp.isList()) { - if (!rlp.isList()) - { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); - } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) - { - if (!i.isData()) - { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); - } - cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; - } - break; + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - case Mode::ExtractArchive: + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) { - if (!rlp.isList()) - { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); - } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + if (!i.isData()) { - if (!i.isData()) - { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); - } - ofstream fout; - fout.open(toString(sha3(i.data()))); - fout.write(reinterpret_cast(i.data().data()), i.data().size()); + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); } - break; + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; } - case Mode::Render: + break; + } + case Mode::ExtractArchive: + { + if (!rlp.isList()) { - RLPStreamer s(cout, prefs); - s.output(rlp); - cout << endl; - break; + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - default:; + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; + } } catch (...) { From 8bed787cfdfdaa6adeb3d0a04df859dd05f1ae4b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Mar 2015 23:36:20 +0100 Subject: [PATCH 292/313] Improvements to help text of RLP. --- rlp/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 9bd51cdfc..c3c04535b 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -35,6 +35,20 @@ void help() cout << "Usage rlp [OPTIONS] [ | -- ]" << endl << "Options:" << endl + << " -r,--render Render the given RLP. Options:" << endl + << " --indent Use string as the level indentation (default ' ')." << endl + << " --hex-ints Render integers in hex." << endl + << " --force-string Force all data to be rendered as C-style strings." << endl + << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl + << " --force-hex Force all data to be rendered as raw hex." << endl + << " -l,--list-archive List the items in the RLP list by hash and size." << endl + << " -e,--extract-archive Extract all items in the RLP list, named by hash." << endl + << "General options:" << endl + << " -L,--lenience Try not to bomb out early if possible." << endl + << " -x,--hex,--base-16 Treat input RLP as hex encoded data." << endl + << " --64,--base-64 Treat input RLP as base-64 encoded data." << endl + << " -b,--bin,--base-256 Treat input RLP as raw binary data." << endl + << " -h,--help Print this help message and exit." << endl << " -V,--version Show the version and exit." << endl ; exit(0); @@ -87,7 +101,7 @@ public: m_out << "null"; else if (_d.isInt()) if (m_prefs.hexInts) - m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire))); + m_out << toHex(toCompactBigEndian(_d.toInt(RLP::LaisezFaire), 1), 1); else m_out << _d.toInt(RLP::LaisezFaire); else if (_d.isData()) From c187452a1d2926924b2e10ff6a9f9f1dd881a07f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 11:09:34 +0100 Subject: [PATCH 293/313] Bunch of repotting/curating. [10:59:28] Vitalik Buterin: block.parent.gas_limit * 1023 / 1024 <= block.gas_limit <= block.parent.gas_limit * 1025/1024 --- libethcore/BlockInfo.cpp | 7 +- libethcore/Exceptions.cpp | 2 +- libethcore/Exceptions.h | 4 +- libethcore/ProofOfWork.h | 2 +- libethereum/Precompiled.cpp | 2 +- rlp/base64.cpp | 128 ------------------------------------ rlp/base64.h | 40 ----------- rlp/main.cpp | 94 +++++++++++++------------- 8 files changed, 54 insertions(+), 225 deletions(-) delete mode 100644 rlp/base64.cpp delete mode 100644 rlp/base64.h diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index c8d5625a6..7c3360e4a 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -203,8 +203,6 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const return max(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); } -template inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } - void BlockInfo::verifyParent(BlockInfo const& _parent) const { // Check difficulty is correct given the two timestamps. @@ -215,8 +213,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / c_gasLimitBoundDivisor) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / c_gasLimitBoundDivisor)); + if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || + gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c4628f4aa..c489c8f4a 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -39,7 +39,7 @@ static boost::thread_specific_ptr g_exceptionMessage; const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " default:" + toString(valid) + " givenDiff:" + toString(givenDiff) + " maxDiff:" + toString(maxDiff) + ")"); } +const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); } const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index 45667f44a..edf3d6b03 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -22,7 +22,7 @@ #pragma once #include -#include "CommonEth.h" +#include "Common.h" namespace dev { @@ -58,7 +58,7 @@ class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTr struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; struct InvalidSeedHash: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _valid = 0, u256 _gD = 0, u256 _mD = 0): provided(_provided), valid(_valid), givenDiff(_gD), maxDiff(_mD) {} u256 provided; u256 valid; u256 givenDiff; u256 maxDiff; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; }; class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index fdf51f0d4..7006f6f61 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -27,7 +27,7 @@ #include #include #include -#include "CommonEth.h" +#include "Common.h" #include "BlockInfo.h" #define FAKE_DAGGER 1 diff --git a/libethereum/Precompiled.cpp b/libethereum/Precompiled.cpp index 6e0d4756c..62d159418 100644 --- a/libethereum/Precompiled.cpp +++ b/libethereum/Precompiled.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using namespace std; using namespace dev; diff --git a/rlp/base64.cpp b/rlp/base64.cpp deleted file mode 100644 index 5e2b32000..000000000 --- a/rlp/base64.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - base64.cpp and base64.h - - Copyright (C) 2004-2008 René Nyffenegger - - This source code is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. - - 3. This notice may not be removed or altered from any source distribution. - - René Nyffenegger rene.nyffenegger@adp-gmbh.ch -*/ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. - -#include "base64.h" - -#include - -using namespace std; -using namespace dev; - -static const std::string base64_chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -static inline bool is_base64(byte c) { - return (isalnum(c) || (c == '+') || (c == '/')); -} - -std::string dev::base64_encode(bytesConstRef _in) { - std::string ret; - int i = 0; - int j = 0; - byte char_array_3[3]; - byte char_array_4[4]; - - auto buf = _in.data(); - auto bufLen = _in.size(); - - while (bufLen--) { - char_array_3[i++] = *(buf++); - if (i == 3) { - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for(i = 0; (i <4) ; i++) - ret += base64_chars[char_array_4[i]]; - i = 0; - } - } - - if (i) - { - for(j = i; j < 3; j++) - char_array_3[j] = '\0'; - - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for (j = 0; (j < i + 1); j++) - ret += base64_chars[char_array_4[j]]; - - while((i++ < 3)) - ret += '='; - } - - return ret; -} - -bytes dev::base64_decode(std::string const& encoded_string) { - int in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - byte char_array_4[4], char_array_3[3]; - bytes ret; - - while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { - char_array_4[i++] = encoded_string[in_]; in_++; - if (i ==4) { - for (i = 0; i <4; i++) - char_array_4[i] = base64_chars.find(char_array_4[i]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret.push_back(char_array_3[i]); - i = 0; - } - } - - if (i) { - for (j = i; j <4; j++) - char_array_4[j] = 0; - - for (j = 0; j <4; j++) - char_array_4[j] = base64_chars.find(char_array_4[j]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]); - } - - return ret; -} diff --git a/rlp/base64.h b/rlp/base64.h deleted file mode 100644 index 53ba282c8..000000000 --- a/rlp/base64.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - base64.cpp and base64.h - - Copyright (C) 2004-2008 René Nyffenegger - - This source code is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. - - 3. This notice may not be removed or altered from any source distribution. - - René Nyffenegger rene.nyffenegger@adp-gmbh.ch -*/ -/// code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c -/// originally by René Nyffenegger, modified by some other guy and then again by Gav Wood. -#pragma once - -#include -#include -#include - -namespace dev -{ - -std::string base64_encode(bytesConstRef _in); -bytes base64_decode(std::string const& _in); - -} diff --git a/rlp/main.cpp b/rlp/main.cpp index c3c04535b..85c08e0e6 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -22,11 +22,9 @@ #include #include #include -#include #include #include #include -#include "base64.h" using namespace std; using namespace dev; @@ -218,7 +216,7 @@ int main(int argc, char** argv) boost::algorithm::replace_all(s, " ", ""); boost::algorithm::replace_all(s, "\n", ""); boost::algorithm::replace_all(s, "\t", ""); - b = base64_decode(s); + b = fromBase64(s); break; } default: @@ -228,60 +226,60 @@ int main(int argc, char** argv) try { - RLP rlp(b); - switch (mode) - { - case Mode::ListArchive: - { - if (!rlp.isList()) + RLP rlp(b); + switch (mode) { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); - } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ListArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; - } - break; - } - case Mode::ExtractArchive: - { - if (!rlp.isList()) - { - cout << "Error: Invalid format; RLP data is not a list." << endl; - exit(1); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + cout << " " << i.size() << " bytes: " << sha3(i.data()) << endl; + } + break; } - cout << rlp.itemCount() << " items:" << endl; - for (auto i: rlp) + case Mode::ExtractArchive: { - if (!i.isData()) + if (!rlp.isList()) { - cout << "Error: Invalid format; RLP list item is not data." << endl; - if (!lenience) - exit(1); + cout << "Error: Invalid format; RLP data is not a list." << endl; + exit(1); } - ofstream fout; - fout.open(toString(sha3(i.data()))); - fout.write(reinterpret_cast(i.data().data()), i.data().size()); + cout << rlp.itemCount() << " items:" << endl; + for (auto i: rlp) + { + if (!i.isData()) + { + cout << "Error: Invalid format; RLP list item is not data." << endl; + if (!lenience) + exit(1); + } + ofstream fout; + fout.open(toString(sha3(i.data()))); + fout.write(reinterpret_cast(i.data().data()), i.data().size()); + } + break; + } + case Mode::Render: + { + RLPStreamer s(cout, prefs); + s.output(rlp); + cout << endl; + break; + } + default:; } - break; - } - case Mode::Render: - { - RLPStreamer s(cout, prefs); - s.output(rlp); - cout << endl; - break; - } - default:; - } } catch (...) { From 0a0aaf54f0f91985c401aa2fe1424c63d45df9c9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 12:48:28 +0100 Subject: [PATCH 294/313] Make RLP JSON compatible by default. --- rlp/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rlp/main.cpp b/rlp/main.cpp index 85c08e0e6..663bbf14d 100644 --- a/rlp/main.cpp +++ b/rlp/main.cpp @@ -36,6 +36,7 @@ void help() << " -r,--render Render the given RLP. Options:" << endl << " --indent Use string as the level indentation (default ' ')." << endl << " --hex-ints Render integers in hex." << endl + << " --ascii-strings Render data as C-style strings or hex depending on content being ASCII." << endl << " --force-string Force all data to be rendered as C-style strings." << endl << " --force-escape When rendering as C-style strings, force all characters to be escaped." << endl << " --force-hex Force all data to be rendered as raw hex." << endl @@ -86,7 +87,7 @@ public: { string indent = " "; bool hexInts = false; - bool forceString = false; + bool forceString = true; bool escapeAll = false; bool forceHex = false; }; @@ -150,6 +151,8 @@ int main(int argc, char** argv) prefs.indent = argv[++i]; else if (arg == "--hex-ints") prefs.hexInts = true; + else if (arg == "--ascii-strings") + prefs.forceString = prefs.forceHex = false; else if (arg == "--force-string") prefs.forceString = true; else if (arg == "--force-hex") From e241db70a8912471ac5ea4d91e57482d4d54b61d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 15:58:20 +0100 Subject: [PATCH 295/313] For Marek :) BlockChain::transaction(h256 _transactionHash) BlockChain::transactionHashes(h256 _blockHash) --- alethzero/MainWin.cpp | 4 +- libethcore/ProofOfWork.cpp | 98 ++------------------------------------ libethcore/ProofOfWork.h | 10 ---- libethereum/BlockChain.cpp | 19 ++++---- libethereum/BlockChain.h | 32 +++---------- libethereum/BlockDetails.h | 14 +++++- test/dagger.cpp | 22 ++++----- 7 files changed, 47 insertions(+), 152 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index a096d2c15..b79bc6e83 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1410,7 +1410,7 @@ void Main::on_blocks_currentItemChanged() s << "
Difficulty: " << info.difficulty << ""; if (info.number) { - auto e = ProofOfWork::eval(info); + auto e = Ethasher::eval(info); s << "
Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / info.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } else @@ -1434,7 +1434,7 @@ void Main::on_blocks_currentItemChanged() s << line << "Nonce: " << uncle.nonce << ""; s << line << "Hash w/o nonce: " << uncle.headerHash(WithoutNonce) << ""; s << line << "Difficulty: " << uncle.difficulty << ""; - auto e = ProofOfWork::eval(uncle); + auto e = Ethasher::eval(uncle); s << line << "Proof-of-Work: " << e.value << " <= " << (h256)u256((bigint(1) << 256) / uncle.difficulty) << " (mixhash: " << e.mixHash.abridged() << ")"; } if (info.parentHash) diff --git a/libethcore/ProofOfWork.cpp b/libethcore/ProofOfWork.cpp index c879df2ce..d261ccb1c 100644 --- a/libethcore/ProofOfWork.cpp +++ b/libethcore/ProofOfWork.cpp @@ -30,8 +30,8 @@ #include #include #include -#include #include "BlockInfo.h" +#include "Ethasher.h" #include "ProofOfWork.h" using namespace std; using namespace std::chrono; @@ -41,100 +41,14 @@ namespace dev namespace eth { -class Ethasher -{ -public: - Ethasher() {} - - static Ethasher* get() { if (!s_this) s_this = new Ethasher(); return s_this; } - - bytes const& cache(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_caches.count(_header.seedHash)) - { - try { - boost::filesystem::create_directories(getDataDir() + "/ethashcache"); - } catch (...) {} - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".cache"; - m_caches[_header.seedHash] = contents(memoFile); - if (m_caches[_header.seedHash].empty()) - { - ethash_params p = params((unsigned)_header.number); - m_caches[_header.seedHash].resize(p.cache_size); - ethash_prep_light(m_caches[_header.seedHash].data(), &p, _header.seedHash.data()); - writeFile(memoFile, m_caches[_header.seedHash]); - } - } - return m_caches[_header.seedHash]; - } - - byte const* full(BlockInfo const& _header) - { - RecursiveGuard l(x_this); - if (!m_fulls.count(_header.seedHash)) - { - if (!m_fulls.empty()) - { - delete [] m_fulls.begin()->second.data(); - m_fulls.erase(m_fulls.begin()); - } - std::string memoFile = getDataDir() + "/ethashcache/" + toHex(_header.seedHash.ref().cropped(0, 4)) + ".full"; - m_fulls[_header.seedHash] = contentsNew(memoFile); - if (!m_fulls[_header.seedHash]) - { - ethash_params p = params((unsigned)_header.number); - m_fulls[_header.seedHash] = bytesRef(new byte[p.full_size], p.full_size); - auto c = cache(_header); - ethash_prep_full(m_fulls[_header.seedHash].data(), &p, c.data()); - writeFile(memoFile, m_fulls[_header.seedHash]); - } - } - return m_fulls[_header.seedHash].data(); - } - - static ethash_params params(BlockInfo const& _header) - { - return params((unsigned)_header.number); - } - - static ethash_params params(unsigned _n) - { - ethash_params p; - p.cache_size = ethash_get_cachesize(_n); - p.full_size = ethash_get_datasize(_n); - return p; - } - -private: - static Ethasher* s_this; - RecursiveMutex x_this; - std::map m_caches; - std::map m_fulls; -}; - -Ethasher* Ethasher::s_this = nullptr; - bool Ethash::verify(BlockInfo const& _header) { - bigint boundary = (bigint(1) << 256) / _header.difficulty; - auto e = eval(_header, _header.nonce); - return (u256)e.value <= boundary && e.mixHash == _header.mixHash; -} - -Ethash::Result Ethash::eval(BlockInfo const& _header, Nonce const& _nonce) -{ - auto p = Ethasher::params(_header); - ethash_return_value r; - ethash_compute_light(&r, Ethasher::get()->cache(_header).data(), &p, _header.headerHash(WithoutNonce).data(), (uint64_t)(u64)_nonce); - return Result{h256(r.result, h256::ConstructFromPointer), h256(r.mix_hash, h256::ConstructFromPointer)}; + return Ethasher::verify(_header); } std::pair Ethash::mine(BlockInfo const& _header, unsigned _msTimeout, bool _continue, bool _turbo) { - auto h = _header.headerHash(WithoutNonce); - auto p = Ethasher::params(_header); - auto d = Ethasher::get()->full(_header); + Ethasher::Miner m(_header); std::pair ret; static std::mt19937_64 s_eng((time(0) + *reinterpret_cast(m_last.data()))); @@ -152,17 +66,15 @@ std::pair Ethash::mine(BlockInfo const& _header, unsign std::this_thread::sleep_for(std::chrono::milliseconds(_msTimeout * 90 / 100)); double best = 1e99; // high enough to be effectively infinity :) Proof result; - ethash_return_value ethashReturn; unsigned hashCount = 0; for (; (std::chrono::steady_clock::now() - startTime) < std::chrono::milliseconds(_msTimeout) && _continue; tryNonce++, hashCount++) { - ethash_compute_full(ðashReturn, d, &p, h.data(), tryNonce); - u256 val(h256(ethashReturn.result, h256::ConstructFromPointer)); + u256 val(m.mine(tryNonce)); best = std::min(best, log2((double)val)); if (val <= boundary) { ret.first.completed = true; - result.mixHash = h256(ethashReturn.mix_hash, h256::ConstructFromPointer); + result.mixHash = m.lastMixHash(); result.nonce = u64(tryNonce); break; } diff --git a/libethcore/ProofOfWork.h b/libethcore/ProofOfWork.h index 7006f6f61..250ddb73d 100644 --- a/libethcore/ProofOfWork.h +++ b/libethcore/ProofOfWork.h @@ -49,20 +49,12 @@ struct MineInfo class Ethash { public: - // bit-compatible with ethash_return_value struct Proof { Nonce nonce; h256 mixHash; }; - struct Result - { - h256 value; - h256 mixHash; - }; - static Result eval(BlockInfo const& _header) { return eval(_header, _header.nonce); } - static Result eval(BlockInfo const& _header, Nonce const& _nonce); static bool verify(BlockInfo const& _header); std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r.nonce; _header.mixHash = _r.mixHash; } @@ -78,9 +70,7 @@ public: using Proof = Nonce; static bool verify(BlockInfo const& _header) { return (bigint)(u256)Evaluator::eval(_header.headerHash(WithoutNonce), _header.nonce) <= (bigint(1) << 256) / _header.difficulty; } - inline std::pair mine(BlockInfo const& _header, unsigned _msTimeout = 100, bool _continue = true, bool _turbo = false); - static void assignResult(Proof const& _r, BlockInfo& _header) { _header.nonce = _r; } protected: diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 93263d385..84c95ed14 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -346,14 +346,17 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_receipts[newHash] = br; } - m_blocksDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(h256(bi.number), ExtraBlockHash), (ldb::Slice)dev::ref(m_blockHashes[h256(bi.number)].rlp())); - for (auto const& h: tas) - m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraTransactionAddress), (ldb::Slice)dev::ref(m_transactionAddresses[h].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraLogBlooms), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraReceipts), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)dev::ref(m_details[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); + m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + RLP blockRLP(_block); + TransactionAddress ta; + ta.blockHash = newHash; + for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) + m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); #if ETH_PARANOIA checkConsistency(); diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 20c41b553..6c95af621 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -62,17 +62,8 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); -using BlocksHash = std::map; using TransactionHashes = h256s; -enum { - ExtraDetails = 0, - ExtraBlockHash, - ExtraTransactionAddress, - ExtraLogBlooms, - ExtraReceipts -}; - /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -128,11 +119,12 @@ public: TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } - /// Get a list of transaction hashes for a given block. Thread-safe. - h256 numberHash(u256 _index) const { if (!_index) return genesisHash(); return queryExtras(h256(_index), m_blockHashes, x_blockHashes, NullBlockHash).value; } + /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. + bytes block(h256 _hash) const; + bytes block() const { return block(currentHash()); } /// Get a transaction from its hash. Thread-safe. - bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } @@ -225,20 +217,10 @@ private: mutable BlockLogBloomsHash m_logBlooms; mutable SharedMutex x_receipts; mutable BlockReceiptsHash m_receipts; - mutable SharedMutex x_transactionAddresses; + mutable boost::shared_mutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable SharedMutex x_blockHashes; - mutable BlockHashHash m_blockHashes; - - using CacheID = std::pair; - mutable Mutex x_cacheUsage; - mutable std::deque> m_cacheUsage; - mutable std::set m_inUse; - void noteUsed(h256 const& _h, unsigned _extra = (unsigned)-1) const; - std::chrono::system_clock::time_point m_lastCollection; - - void updateStats() const; - mutable Statistics m_lastStats; + mutable boost::shared_mutex x_cache; + mutable std::map m_cache; /// The disk DBs. Thread-safe, so no need for locks. ldb::DB* m_blocksDB; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 2ea558a14..a64519b8d 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -97,17 +97,27 @@ struct TransactionAddress static const unsigned size = 67; }; +struct TransactionAddress +{ + TransactionAddress() {} + TransactionAddress(RLP const& _rlp) { blockHash = _rlp[0].toHash(); index = _rlp[1].toInt(); } + bytes rlp() const { RLPStream s(2); s << blockHash << index; return s.out(); } + + explicit operator bool() const { return !!blockHash; } + + h256 blockHash; + unsigned index = 0; +}; + using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; using TransactionAddressHash = std::map; -using BlockHashHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; static const TransactionAddress NullTransactionAddress; -static const BlockHash NullBlockHash; } } diff --git a/test/dagger.cpp b/test/dagger.cpp index 720abbbaa..dec753fe7 100644 --- a/test/dagger.cpp +++ b/test/dagger.cpp @@ -41,16 +41,16 @@ BOOST_AUTO_TEST_SUITE(DashimotoTests) BOOST_AUTO_TEST_CASE(basic_test) { -#if 0 - cnote << "Testing ProofOfWork..."; - // Test dagger - { - auto s = steady_clock::now(); - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)0); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - cout << hex << ProofOfWork().eval((h256)(u256)1, (h256)(u256)1); - cout << " " << dec << duration_cast(steady_clock::now() - s).count() << " ms" << endl; - } + string testPath = test::getTestPath(); + + testPath += "/PoWTests"; + + cnote << "Testing Secure Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/ethash_tests.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'ethash_tests.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) { cnote << i.first; js::mObject& o = i.second.get_obj(); @@ -78,8 +78,6 @@ BOOST_AUTO_TEST_CASE(basic_test) BOOST_REQUIRE_EQUAL(r.value, result); BOOST_REQUIRE_EQUAL(r.mixHash, header.mixHash); } -#endif - return 0; } BOOST_AUTO_TEST_SUITE_END() From b5c2e82b195782bb4f9e52e950f94cce6f01b01c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 19:38:31 +0100 Subject: [PATCH 296/313] Fast block hash from number. --- libethcore/Common.cpp | 9 +++++---- libethereum/BlockChain.cpp | 23 +++++++++-------------- libethereum/BlockChain.h | 32 +++++++++++++++++++------------- libethereum/BlockDetails.h | 11 +++++++++++ 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/libethcore/Common.cpp b/libethcore/Common.cpp index 65c0b8b92..9eb622fe3 100644 --- a/libethcore/Common.cpp +++ b/libethcore/Common.cpp @@ -33,13 +33,14 @@ namespace eth { const unsigned c_protocolVersion = 56; -const unsigned c_databaseVersion = 6 + +const unsigned c_databaseBaseVersion = 7; #if ETH_FATDB - 1000 +const unsigned c_databaseVersionModifier = 1000; #else - 0 +const unsigned c_databaseVersionModifier = 0; #endif -; + +const unsigned c_databaseVersion = c_databaseBaseVersion + c_databaseVersionModifier; vector> const& units() { diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 84c95ed14..e45a051d8 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -46,7 +46,7 @@ namespace js = json_spirit; std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) { string cmp = toBigEndianString(_bc.currentHash()); - auto it = _bc.m_db->NewIterator(_bc.m_readOptions); + auto it = _bc.m_blocksDB->NewIterator(_bc.m_readOptions); for (it->SeekToFirst(); it->Valid(); it->Next()) if (it->key().ToString() != "best") { @@ -346,17 +346,14 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) m_receipts[newHash] = br; } - m_extrasDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)dev::ref(m_details[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 3), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_extrasDB->Put(m_writeOptions, toSlice(newHash, 4), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); - m_db->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); - RLP blockRLP(_block); - TransactionAddress ta; - ta.blockHash = newHash; - for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index) - m_extrasDB->Put(m_writeOptions, toSlice(sha3(blockRLP[1][ta.index].data()), 5), (ldb::Slice)dev::ref(ta.rlp())); + m_blocksDB->Put(m_writeOptions, toSlice(newHash), (ldb::Slice)ref(_block)); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(h256(bi.number), ExtraBlockHash), (ldb::Slice)dev::ref(m_blockHashes[h256(bi.number)].rlp())); + for (auto const& h: tas) + m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraTransactionAddress), (ldb::Slice)dev::ref(m_transactionAddresses[h].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraLogBlooms), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp())); + m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraReceipts), (ldb::Slice)dev::ref(m_receipts[newHash].rlp())); #if ETH_PARANOIA checkConsistency(); @@ -636,7 +633,5 @@ bytes BlockChain::block(h256 _hash) const m_blocks[_hash].resize(d.size()); memcpy(m_blocks[_hash].data(), d.data(), d.size()); - noteUsed(_hash); - return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 6c95af621..b24d643a7 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -62,8 +62,17 @@ std::map const& genesisState(); ldb::Slice toSlice(h256 _h, unsigned _sub = 0); +using BlocksHash = std::map; using TransactionHashes = h256s; +enum { + ExtraDetails = 0, + ExtraBlockHash, + ExtraTransactionAddress, + ExtraLogBlooms, + ExtraReceipts +}; + /** * @brief Implements the blockchain database. All data this gives is disk-backed. * @threadsafe @@ -119,12 +128,11 @@ public: TransactionHashes transactionHashes(h256 _hash) const { auto b = block(_hash); RLP rlp(b); h256s ret; for (auto t: rlp[1]) ret.push_back(sha3(t.data())); return ret; } TransactionHashes transactionHashes() const { return transactionHashes(currentHash()); } - /// Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe. - bytes block(h256 _hash) const; - bytes block() const { return block(currentHash()); } + /// Get a list of transaction hashes for a given block. Thread-safe. + h256 numberHash(u256 _index) const { if (!_index) return genesisHash(); return queryExtras(h256(_index), m_blockHashes, x_blockHashes, NullBlockHash).value; } /// Get a transaction from its hash. Thread-safe. - bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } + bytes transaction(h256 _transactionHash) const { TransactionAddress ta = queryExtras(_transactionHash, m_transactionAddresses, x_transactionAddresses, NullTransactionAddress); if (!ta) return bytes(); return transaction(ta.blockHash, ta.index); } /// Get a block's transaction (RLP format) for the given block hash (or the most recent mined if none given) & index. Thread-safe. bytes transaction(h256 _blockHash, unsigned _i) const { bytes b = block(_blockHash); return RLP(b)[1][_i].data().toBytes(); } @@ -163,20 +171,18 @@ public: struct Statistics { - unsigned memBlocks; unsigned memDetails; unsigned memLogBlooms; unsigned memReceipts; unsigned memTransactionAddresses; - unsigned memBlockHashes; - unsigned memTotal() const { return memBlocks + memDetails + memLogBlooms + memReceipts + memTransactionAddresses + memBlockHashes; } + unsigned memCache; }; /// @returns statistics about memory usage. - Statistics usage(bool _freshen = false) const { if (_freshen) updateStats(); return m_lastStats; } + Statistics usage() const; /// Deallocate unused data. - void garbageCollect(bool _force = false); + void garbageCollect(); private: void open(std::string _path, bool _killExisting = false); @@ -209,9 +215,9 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. - mutable SharedMutex x_blocks; + mutable boost::shared_mutex x_blocks; mutable BlocksHash m_blocks; - mutable SharedMutex x_details; + mutable boost::shared_mutex x_details; mutable BlockDetailsHash m_details; mutable SharedMutex x_logBlooms; mutable BlockLogBloomsHash m_logBlooms; @@ -219,8 +225,8 @@ private: mutable BlockReceiptsHash m_receipts; mutable boost::shared_mutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_cache; - mutable std::map m_cache; + mutable boost::shared_mutex x_blockHashes; + mutable BlockHashHash m_blockHashes; /// The disk DBs. Thread-safe, so no need for locks. ldb::DB* m_blocksDB; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index a64519b8d..14c7f206d 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -97,6 +97,15 @@ struct TransactionAddress static const unsigned size = 67; }; +struct BlockHash +{ + BlockHash() {} + BlockHash(RLP const& _r) { value = _r.toHash(); } + bytes rlp() const { return dev::rlp(value); } + + h256 value; +}; + struct TransactionAddress { TransactionAddress() {} @@ -113,11 +122,13 @@ using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; using TransactionAddressHash = std::map; +using BlockHashHash = std::map; static const BlockDetails NullBlockDetails; static const BlockLogBlooms NullBlockLogBlooms; static const BlockReceipts NullBlockReceipts; static const TransactionAddress NullTransactionAddress; +static const BlockHash NullBlockHash; } } From 7208686db86b01d190a033ccd54261b6aa922f12 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 21:19:21 +0100 Subject: [PATCH 297/313] Caching. --- alethzero/MainWin.cpp | 34 +--------------------------------- libethereum/BlockChain.cpp | 2 ++ libethereum/BlockChain.h | 26 +++++++++++++++++++------- libethereum/BlockDetails.h | 26 +++----------------------- libethereum/Client.cpp | 1 + 5 files changed, 26 insertions(+), 63 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index b79bc6e83..fc230f034 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1145,42 +1145,10 @@ void Main::on_refresh_triggered() refreshAll(); } -static std::string niceUsed(unsigned _n) -{ - static const vector c_units = { "bytes", "KB", "MB", "GB", "TB", "PB" }; - unsigned u = 0; - while (_n > 10240) - { - _n /= 1024; - u++; - } - if (_n > 1000) - return toString(_n / 1000) + "." + toString((min(949, _n % 1000) + 50) / 100) + " " + c_units[u + 1]; - else - return toString(_n) + " " + c_units[u]; -} - void Main::refreshCache() { BlockChain::Statistics s = ethereum()->blockChain().usage(); - QString t; - auto f = [&](unsigned n, QString l) - { - t += ("%1 " + l).arg(QString::fromStdString(niceUsed(n))); - }; - f(s.memTotal(), "total"); - t += " ("; - f(s.memBlocks, "blocks"); - t += ", "; - f(s.memReceipts, "receipts"); - t += ", "; - f(s.memLogBlooms, "blooms"); - t += ", "; - f(s.memBlockHashes + s.memTransactionAddresses, "hashes"); - t += ", "; - f(s.memDetails, "family"); - t += ")"; - ui->cacheUsage->setText(t); + ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); } void Main::timerEvent(QTimerEvent*) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index e45a051d8..4415120c4 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -633,5 +633,7 @@ bytes BlockChain::block(h256 _hash) const m_blocks[_hash].resize(d.size()); memcpy(m_blocks[_hash].data(), d.data(), d.size()); + noteUsed(_hash); + return m_blocks[_hash]; } diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index b24d643a7..20c41b553 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -171,18 +171,20 @@ public: struct Statistics { + unsigned memBlocks; unsigned memDetails; unsigned memLogBlooms; unsigned memReceipts; unsigned memTransactionAddresses; - unsigned memCache; + unsigned memBlockHashes; + unsigned memTotal() const { return memBlocks + memDetails + memLogBlooms + memReceipts + memTransactionAddresses + memBlockHashes; } }; /// @returns statistics about memory usage. - Statistics usage() const; + Statistics usage(bool _freshen = false) const { if (_freshen) updateStats(); return m_lastStats; } /// Deallocate unused data. - void garbageCollect(); + void garbageCollect(bool _force = false); private: void open(std::string _path, bool _killExisting = false); @@ -215,19 +217,29 @@ private: void checkConsistency(); /// The caches of the disk DB and their locks. - mutable boost::shared_mutex x_blocks; + mutable SharedMutex x_blocks; mutable BlocksHash m_blocks; - mutable boost::shared_mutex x_details; + mutable SharedMutex x_details; mutable BlockDetailsHash m_details; mutable SharedMutex x_logBlooms; mutable BlockLogBloomsHash m_logBlooms; mutable SharedMutex x_receipts; mutable BlockReceiptsHash m_receipts; - mutable boost::shared_mutex x_transactionAddresses; + mutable SharedMutex x_transactionAddresses; mutable TransactionAddressHash m_transactionAddresses; - mutable boost::shared_mutex x_blockHashes; + mutable SharedMutex x_blockHashes; mutable BlockHashHash m_blockHashes; + using CacheID = std::pair; + mutable Mutex x_cacheUsage; + mutable std::deque> m_cacheUsage; + mutable std::set m_inUse; + void noteUsed(h256 const& _h, unsigned _extra = (unsigned)-1) const; + std::chrono::system_clock::time_point m_lastCollection; + + void updateStats() const; + mutable Statistics m_lastStats; + /// The disk DBs. Thread-safe, so no need for locks. ldb::DB* m_blocksDB; ldb::DB* m_extrasDB; diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 14c7f206d..ed478568d 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -57,10 +57,11 @@ struct BlockDetails struct BlockLogBlooms { BlockLogBlooms() {} - BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); } - bytes rlp() const { RLPStream s; s << blooms; return s.out(); } + BlockLogBlooms(RLP const& _r) { blooms = _r.toVector(); size = _r.data().size(); } + bytes rlp() const { RLPStream s; s << blooms; size = s.out().size(); return s.out(); } LogBlooms blooms; + mutable unsigned size; }; struct BlockReceipts @@ -97,27 +98,6 @@ struct TransactionAddress static const unsigned size = 67; }; -struct BlockHash -{ - BlockHash() {} - BlockHash(RLP const& _r) { value = _r.toHash(); } - bytes rlp() const { return dev::rlp(value); } - - h256 value; -}; - -struct TransactionAddress -{ - TransactionAddress() {} - TransactionAddress(RLP const& _rlp) { blockHash = _rlp[0].toHash(); index = _rlp[1].toInt(); } - bytes rlp() const { RLPStream s(2); s << blockHash << index; return s.out(); } - - explicit operator bool() const { return !!blockHash; } - - h256 blockHash; - unsigned index = 0; -}; - using BlockDetailsHash = std::map; using BlockLogBloomsHash = std::map; using BlockReceiptsHash = std::map; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index b5355f1e0..541419791 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -639,6 +639,7 @@ void Client::doWork() m_lastGarbageCollection = chrono::system_clock::now(); } + m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From 53cc6cf71f869c31d2ab2d7a81acb89c33806cdd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 5 Mar 2015 22:42:34 +0100 Subject: [PATCH 298/313] Cache reporting in AZ. --- alethzero/MainWin.cpp | 34 +++++++++++++++++++++++++++++++++- libethereum/Client.cpp | 1 - 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index fc230f034..b79bc6e83 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1145,10 +1145,42 @@ void Main::on_refresh_triggered() refreshAll(); } +static std::string niceUsed(unsigned _n) +{ + static const vector c_units = { "bytes", "KB", "MB", "GB", "TB", "PB" }; + unsigned u = 0; + while (_n > 10240) + { + _n /= 1024; + u++; + } + if (_n > 1000) + return toString(_n / 1000) + "." + toString((min(949, _n % 1000) + 50) / 100) + " " + c_units[u + 1]; + else + return toString(_n) + " " + c_units[u]; +} + void Main::refreshCache() { BlockChain::Statistics s = ethereum()->blockChain().usage(); - ui->cacheUsage->setText(QString("%1 bytes used").arg(s.memTotal())); + QString t; + auto f = [&](unsigned n, QString l) + { + t += ("%1 " + l).arg(QString::fromStdString(niceUsed(n))); + }; + f(s.memTotal(), "total"); + t += " ("; + f(s.memBlocks, "blocks"); + t += ", "; + f(s.memReceipts, "receipts"); + t += ", "; + f(s.memLogBlooms, "blooms"); + t += ", "; + f(s.memBlockHashes + s.memTransactionAddresses, "hashes"); + t += ", "; + f(s.memDetails, "family"); + t += ")"; + ui->cacheUsage->setText(t); } void Main::timerEvent(QTimerEvent*) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 541419791..b5355f1e0 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -639,7 +639,6 @@ void Client::doWork() m_lastGarbageCollection = chrono::system_clock::now(); } - m_bc.garbageCollect(); } unsigned Client::numberOf(int _n) const From 59ba467f86ad2da67358bb6098414d74c89b493e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:11:24 +0100 Subject: [PATCH 299/313] add quadratic complexity tests --- test/state.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/state.cpp b/test/state.cpp index 6ac23c14d..5202aff22 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -170,23 +170,23 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } -//BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) -//{ -// for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) -// { -// string arg = boost::unit_test::framework::master_test_suite().argv[i]; -// if (arg == "--quadratic" || arg == "--all") -// { -// auto start = chrono::steady_clock::now(); - -// dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); - -// auto end = chrono::steady_clock::now(); -// auto duration(chrono::duration_cast(end - start)); -// cnote << "test duration: " << duration.count() << " milliseconds.\n"; -// } -// } -//} +BOOST_AUTO_TEST_CASE(stQuadraticComplexityTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--quadratic" || arg == "--all") + { + auto start = chrono::steady_clock::now(); + + dev::test::executeTests("stQuadraticComplexityTest", "/StateTests", dev::test::doStateTests); + + auto end = chrono::steady_clock::now(); + auto duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} BOOST_AUTO_TEST_CASE(stMemoryStressTest) { From 040f864359da06cdc2fec3dbba69aa2ff6944c26 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:12:51 +0100 Subject: [PATCH 300/313] add uncle header feature for fillers --- test/blockchain.cpp | 282 ++++++++++++++++++++++++++++---------------- 1 file changed, 182 insertions(+), 100 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index 55c39f56b..a23a756b1 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -33,8 +33,10 @@ namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); - - +BlockInfo constructBlock(mObject& _o); +void updatePoW(BlockInfo& _bi); +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); +RLPStream createFullBlockFromHeader(const BlockInfo& _bi, const bytes& _txs = RLPEmptyList, const bytes& _uncles = RLPEmptyList); void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) { @@ -44,86 +46,47 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) mObject& o = i.second.get_obj(); BOOST_REQUIRE(o.count("genesisBlockHeader")); - BlockInfo blockFromFields; - try - { - // construct genesis block - const bytes c_blockRLP = createBlockRLPFromFields(o["genesisBlockHeader"].get_obj()); - const RLP c_bRLP(c_blockRLP); - blockFromFields.populateFromHeader(c_bRLP, false); - } - catch (Exception const& _e) - { - cnote << "block population did throw an exception: " << diagnostic_information(_e); - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch (std::exception const& _e) - { - BOOST_ERROR("Failed block population with Exception: " << _e.what()); - continue; - } - catch(...) - { - cnote << "block population did throw an unknown exception\n"; - continue; - } + BlockInfo biGenesisBlock = constructBlock(o["genesisBlockHeader"].get_obj()); BOOST_REQUIRE(o.count("pre")); - ImportTest importer(o["pre"].get_obj()); State state(Address(), OverlayDB(), BaseState::Empty); importer.importState(o["pre"].get_obj(), state); state.commit(); if (_fillin) - blockFromFields.stateRoot = state.rootHash(); + biGenesisBlock.stateRoot = state.rootHash(); else - BOOST_CHECK_MESSAGE(blockFromFields.stateRoot == state.rootHash(), "root hash does not match"); + BOOST_CHECK_MESSAGE(biGenesisBlock.stateRoot == state.rootHash(), "root hash does not match"); if (_fillin) { // find new valid nonce - ProofOfWork pow; - std::pair ret; - while (!ProofOfWork::verify(blockFromFields)) - { - ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, blockFromFields); - } + updatePoW(biGenesisBlock); //update genesis block in json file - o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot); - o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce); - o["genesisBlockHeader"].get_obj()["mixHash"] = toString(blockFromFields.mixHash); - o["genesisBlockHeader"].get_obj()["hash"] = toString(blockFromFields.headerHash(WithNonce)); + writeBlockHeaderToJson(o["genesisBlockHeader"].get_obj(), biGenesisBlock); } // create new "genesis" block - RLPStream rlpStream; - blockFromFields.streamRLP(rlpStream, WithNonce); - - RLPStream block(3); - block.appendRaw(rlpStream.out()); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - - blockFromFields.verifyInternals(&block.out()); + RLPStream rlpGenesisBlock = createFullBlockFromHeader(biGenesisBlock); + biGenesisBlock.verifyInternals(&rlpGenesisBlock.out()); // construct blockchain - BlockChain bc(block.out(), string(), true); + BlockChain bc(rlpGenesisBlock.out(), string(), true); if (_fillin) { BOOST_REQUIRE(o.count("blocks")); mArray blArray; + vector vBiBlocks; for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); - BOOST_REQUIRE(blObj.count("transactions")); + // get txs TransactionQueue txs; - + BOOST_REQUIRE(blObj.count("transactions")); for (auto const& txObj: blObj["transactions"].get_array()) { mObject tx = txObj.get_obj(); @@ -132,6 +95,35 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "failed importing transaction\n"; } + // write uncle list + BlockQueue uncleBlockQueue; + mArray aUncleList; + vector vBiUncles; + + for (auto const& uHObj: blObj["uncleHeaders"].get_array()) + { + mObject uncleHeaderObj = uHObj.get_obj(); + BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); + + // make uncle header valid + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + uncleBlockFromFields.timestamp = (u256)time(0); + + updatePoW(uncleBlockFromFields); + writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); + + aUncleList.push_back(uncleHeaderObj); + vBiUncles.push_back(uncleBlockFromFields); + + cnote << "import uncle in blockQueue"; + RLPStream uncle = createFullBlockFromHeader(uncleBlockFromFields); + uncleBlockQueue.import(&uncle.out(), bc); + } + + blObj["uncleHeaders"] = aUncleList; + bc.sync(uncleBlockQueue, state.db(), 4); + state.commitToMine(bc); + try { state.sync(bc); @@ -152,6 +144,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) return; } + blObj["rlp"] = "0x" + toHex(state.blockData()); + // write valid txs mArray txArray; Transactions txList; @@ -174,46 +168,19 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } blObj["transactions"] = txArray; - blObj["rlp"] = "0x" + toHex(state.blockData()); BlockInfo current_BlockHeader = state.info(); - // overwrite blockheader with (possible wrong) data from "blockheader" in filler; - if (blObj.count("blockHeader")) - { overwriteBlockHeader(current_BlockHeader, blObj); - } // write block header - mObject oBlockHeader; - oBlockHeader["parentHash"] = toString(current_BlockHeader.parentHash); - oBlockHeader["uncleHash"] = toString(current_BlockHeader.sha3Uncles); - oBlockHeader["coinbase"] = toString(current_BlockHeader.coinbaseAddress); - oBlockHeader["stateRoot"] = toString(current_BlockHeader.stateRoot); - oBlockHeader["transactionsTrie"] = toString(current_BlockHeader.transactionsRoot); - oBlockHeader["receiptTrie"] = toString(current_BlockHeader.receiptsRoot); - oBlockHeader["bloom"] = toString(current_BlockHeader.logBloom); - oBlockHeader["difficulty"] = toString(current_BlockHeader.difficulty); - oBlockHeader["number"] = toString(current_BlockHeader.number); - oBlockHeader["gasLimit"] = toString(current_BlockHeader.gasLimit); - oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed); - oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp); - oBlockHeader["extraData"] ="0x" + toHex(current_BlockHeader.extraData); - oBlockHeader["mixHash"] = toString(current_BlockHeader.mixHash); - oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash); - oBlockHeader["nonce"] = toString(current_BlockHeader.nonce); - oBlockHeader["hash"] = toString(current_BlockHeader.hash); - + writeBlockHeaderToJson(oBlockHeader, current_BlockHeader); blObj["blockHeader"] = oBlockHeader; + vBiBlocks.push_back(current_BlockHeader); - // write uncle list - mArray aUncleList; // as of now, our parent is always the genesis block, so we can not have uncles. - blObj["uncleHeaders"] = aUncleList; - - //txs: - + // compare blocks from state and from rlp RLPStream txStream; txStream.appendList(txList.size()); for (unsigned i = 0; i < txList.size(); ++i) @@ -223,13 +190,16 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) txStream.appendRaw(txrlp.out()); } - RLPStream rlpStream2; - current_BlockHeader.streamRLP(rlpStream2, WithNonce); + RLPStream uncleStream; + uncleStream.appendList(vBiUncles.size()); + for (unsigned i = 0; i < vBiUncles.size(); ++i) + { + RLPStream uncleRlp; + vBiUncles[i].streamRLP(uncleRlp, WithNonce); + uncleStream.appendRaw(uncleRlp.out()); + } - RLPStream block2(3); - block2.appendRaw(rlpStream2.out()); - block2.appendRaw(txStream.out()); - block2.appendRaw(RLPEmptyList); + RLPStream block2 = createFullBlockFromHeader(current_BlockHeader, txStream.out(), uncleStream.out()); blObj["rlp"] = "0x" + toHex(block2.out()); @@ -240,13 +210,14 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) cnote << "txs mismatch\n"; if (sha3(RLP(state.blockData())[2].data()) != sha3(RLP(block2.out())[2].data())) - cnote << "uncle list mismatch\n"; + cnote << "uncle list mismatch\n" << RLP(state.blockData())[2].data() << "\n" << RLP(block2.out())[2].data(); try { state.sync(bc); bc.import(block2.out(), state.db()); state.sync(bc); + state.commit(); } // if exception is thrown, RLP is invalid and no blockHeader, Transaction list, or Uncle list should be given catch (...) @@ -392,12 +363,51 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } // check uncle list - BOOST_CHECK_MESSAGE((blObj["uncleList"].type() == json_spirit::null_type ? 0 : blObj["uncleList"].get_array().size()) == 0, "Uncle list is not empty, but the genesis block can not have uncles"); + + // uncles from uncle list field + vector uBlHsFromField; + if (blObj["uncleHeaders"].type() != json_spirit::null_type) + { + for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) + { + mObject uBlH = uBlHeaderObj.get_obj(); + cout << "uBlH.size(): " << uBlH.size() << endl; + BOOST_REQUIRE(uBlH.size() == 17); + bytes uncleRLP = createBlockRLPFromFields(uBlH); + const RLP c_uRLP(uncleRLP); + BlockInfo uncleBlockHeader; + try + { + uncleBlockHeader.populateFromHeader(c_uRLP, true); + } + catch(...) + { + BOOST_ERROR("invalid uncle header"); + } + uBlHsFromField.push_back(uncleBlockHeader); + } + } + + // uncles from block RLP + vector uBlHsFromRlp; + for (auto const& uRLP: root[2]) + { + BlockInfo uBl; + uBl.populateFromHeader(uRLP, true); + uBlHsFromRlp.push_back(uBl); + } + + BOOST_REQUIRE_EQUAL(uBlHsFromField.size(), uBlHsFromRlp.size()); + + for (size_t i = 0; i < uBlHsFromField.size(); ++i) + BOOST_CHECK_MESSAGE(uBlHsFromField[i] == uBlHsFromRlp[i], "block header in rlp and in field do not match"); } } } } +// helping functions + bytes createBlockRLPFromFields(mObject& _tObj) { RLPStream rlpStream; @@ -529,31 +539,103 @@ void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) current_BlockHeader.populateFromHeader(c_bRLP, false); } } -} }// Namespace Close +BlockInfo constructBlock(mObject& _o) +{ -BOOST_AUTO_TEST_SUITE(BlockChainTests) + BlockInfo ret; + try + { + // construct genesis block + const bytes c_blockRLP = createBlockRLPFromFields(_o); + const RLP c_bRLP(c_blockRLP); + ret.populateFromHeader(c_bRLP, false); + } + catch (Exception const& _e) + { + cnote << "block population did throw an exception: " << diagnostic_information(_e); + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch (std::exception const& _e) + { + BOOST_ERROR("Failed block population with Exception: " << _e.what()); + } + catch(...) + { + BOOST_ERROR("block population did throw an unknown exception\n"); + } + return ret; +} -BOOST_AUTO_TEST_CASE(bcBlockChainTest) +void updatePoW(BlockInfo& _bi) { - dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); + ProofOfWork pow; + std::pair ret; + while (!ProofOfWork::verify(_bi)) + { + ret = pow.mine(_bi, 10000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _bi); + } } -BOOST_AUTO_TEST_CASE(bcValidBlockTest) +void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi) { - dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); + _o["parentHash"] = toString(_bi.parentHash); + _o["uncleHash"] = toString(_bi.sha3Uncles); + _o["coinbase"] = toString(_bi.coinbaseAddress); + _o["stateRoot"] = toString(_bi.stateRoot); + _o["transactionsTrie"] = toString(_bi.transactionsRoot); + _o["receiptTrie"] = toString(_bi.receiptsRoot); + _o["bloom"] = toString(_bi.logBloom); + _o["difficulty"] = toString(_bi.difficulty); + _o["number"] = toString(_bi.number); + _o["gasLimit"] = toString(_bi.gasLimit); + _o["gasUsed"] = toString(_bi.gasUsed); + _o["timestamp"] = toString(_bi.timestamp); + _o["extraData"] ="0x" + toHex(_bi.extraData); + _o["mixHash"] = toString(_bi.mixHash); + _o["seedHash"] = toString(_bi.seedHash); + _o["nonce"] = toString(_bi.nonce); + _o["hash"] = toString(_bi.hash); } -BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, const bytes& _uncles ) { - dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); + RLPStream rlpStream; + _bi.streamRLP(rlpStream, WithNonce); + + RLPStream ret(3); + ret.appendRaw(rlpStream.out()); + ret.appendRaw(_txs); + ret.appendRaw(_uncles); + + return ret; } +} }// Namespace Close -//BOOST_AUTO_TEST_CASE(bcUncleTest) + +BOOST_AUTO_TEST_SUITE(BlockChainTests) + +//BOOST_AUTO_TEST_CASE(bcBlockChainTest) +//{ +// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcValidBlockTest) +//{ +// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +//} + +//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) //{ -// dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); //} +BOOST_AUTO_TEST_CASE(bcUncleTest) +{ + dev::test::executeTests("bcUncleTest", "/BlockTests", dev::test::doBlockchainTests); +} + BOOST_AUTO_TEST_CASE(userDefinedFileBc) { dev::test::userDefinedTest("--bctest", dev::test::doBlockchainTests); From 524070c1565d691fcbd22bad86f735c9ab550d1b Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:14:42 +0100 Subject: [PATCH 301/313] update blockchain test filler to new min diff and min gasLimit --- test/bcBlockChainTestFiller.json | 2 +- test/bcInvalidHeaderTestFiller.json | 56 ++++++++++++++--------------- test/bcValidBlockTestFiller.json | 32 ++++++++--------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/test/bcBlockChainTestFiller.json b/test/bcBlockChainTestFiller.json index 8a0bf89fe..b149f5938 100644 --- a/test/bcBlockChainTestFiller.json +++ b/test/bcBlockChainTestFiller.json @@ -3,7 +3,7 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", diff --git a/test/bcInvalidHeaderTestFiller.json b/test/bcInvalidHeaderTestFiller.json index aa32dfbab..39a91a583 100644 --- a/test/bcInvalidHeaderTestFiller.json +++ b/test/bcInvalidHeaderTestFiller.json @@ -3,9 +3,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -59,9 +59,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -115,9 +115,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -170,9 +170,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -225,9 +225,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -280,9 +280,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -336,9 +336,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -391,9 +391,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -446,9 +446,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -501,9 +501,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -556,9 +556,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -611,9 +611,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -666,9 +666,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -721,9 +721,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", diff --git a/test/bcValidBlockTestFiller.json b/test/bcValidBlockTestFiller.json index 29b2e978e..14d4cfb2c 100644 --- a/test/bcValidBlockTestFiller.json +++ b/test/bcValidBlockTestFiller.json @@ -4,9 +4,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1024", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -51,9 +51,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -97,9 +97,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "1000000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -143,9 +143,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -189,9 +189,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -244,9 +244,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -299,9 +299,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "10000", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "100000", + "gasLimit" : "125000", "gasUsed" : "0", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", @@ -351,9 +351,9 @@ "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "023101", + "difficulty" : "131072", "extraData" : "0x42", - "gasLimit" : "0x0dddb6", + "gasLimit" : "125000", "gasUsed" : "100", "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", From 92aa96f73e07ce86e856fdfe8bf8e2e88e28abc4 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:16:17 +0100 Subject: [PATCH 302/313] add first uncle test --- test/bcUncleTestFiller.json | 73 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index 839e3ba46..d866b887c 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,9 +1,9 @@ { - "minDifficulty" : { + "oneUncle" : { "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", + "difficulty" : "131072", "extraData" : "0x42", "gasLimit" : "100000000", "gasUsed" : "0", @@ -54,24 +54,39 @@ "value" : "10" } ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], "uncleHeaders" : [ { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "coinbase" : "0000000000000000000000000000000000000000", - "difficulty" : "2049", + "difficulty" : "131072", "extraData" : "0x", - "gasLimit" : "99804806", - "gasUsed" : "21000", - "hash" : "e940823998a293aa03c46423d9a9eec91ddca8e5e67445af9ebd3dff3456b4b2", - "mixHash" : "05204ec823225e794cce3f93eebfbd79b654366792ad408c7a206b9c588107d9", - "nonce" : "17ed77999bef2e4b", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", "number" : "2", - "parentHash" : "25143742f163f84ac5b5afcb2700f61e24421f756ec9551bd79a254d3310e710", - "receiptTrie" : "3d08abeec9cf28f9a518de4c71ebbfc8021f18dec3ccd0a72ad1fc0f168339d4", - "seedHash" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "66120efd3d0e512866232ed57647a33055770ec98eeaddcdbbdedca49a69f9ca", - "timestamp" : "1425490151", - "transactionsTrie" : "da09ee96fda181334d323831e7402e3a4727d9b631059d0ef47f03f817f83f34", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] @@ -80,35 +95,19 @@ "transactions" : [ { "data" : "", - "gasLimit" : "8000000", - "gasPrice" : "0", - "nonce" : "2", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "3", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" } ], "uncleHeaders" : [ - { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "1023", - "extraData" : "0x42", - "gasLimit" : "100000000", - "gasUsed" : "0", - "number" : "1", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } ] - } + }, ] } + + } From 036a3d16f6c7270a9beaa4c49c348d71e2477136 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:19:48 +0100 Subject: [PATCH 303/313] style --- test/blockchain.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index a23a756b1..ec9f7b68d 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -367,7 +367,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // uncles from uncle list field vector uBlHsFromField; if (blObj["uncleHeaders"].type() != json_spirit::null_type) - { for (auto const& uBlHeaderObj: blObj["uncleHeaders"].get_array()) { mObject uBlH = uBlHeaderObj.get_obj(); @@ -386,7 +385,6 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) } uBlHsFromField.push_back(uncleBlockHeader); } - } // uncles from block RLP vector uBlHsFromRlp; From 28d5850df53e6abc65f02a6a8ca07be7d47608c8 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:32 +0100 Subject: [PATCH 304/313] style + add test cases --- test/blockchain.cpp | 108 ++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/test/blockchain.cpp b/test/blockchain.cpp index ec9f7b68d..e453e32ab 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -32,7 +32,7 @@ using namespace dev::eth; namespace dev { namespace test { bytes createBlockRLPFromFields(mObject& _tObj); -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj); +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj); BlockInfo constructBlock(mObject& _o); void updatePoW(BlockInfo& _bi); void writeBlockHeaderToJson(mObject& _o, const BlockInfo& _bi); @@ -106,8 +106,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BlockInfo uncleBlockFromFields = constructBlock(uncleHeaderObj); // make uncle header valid - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); uncleBlockFromFields.timestamp = (u256)time(0); + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); @@ -462,79 +462,79 @@ bytes createBlockRLPFromFields(mObject& _tObj) return rlpStream.out(); } -void overwriteBlockHeader(BlockInfo& current_BlockHeader, mObject& blObj) +void overwriteBlockHeader(BlockInfo& _current_BlockHeader, mObject& _blObj) { - if (blObj["blockHeader"].get_obj().size() != 14) + if (_blObj["blockHeader"].get_obj().size() != 14) { - BlockInfo tmp = current_BlockHeader; + BlockInfo tmp = _current_BlockHeader; - if (blObj["blockHeader"].get_obj().count("parentHash")) - tmp.parentHash = h256(blObj["blockHeader"].get_obj()["parentHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("parentHash")) + tmp.parentHash = h256(_blObj["blockHeader"].get_obj()["parentHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("uncleHash")) - tmp.sha3Uncles = h256(blObj["blockHeader"].get_obj()["uncleHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("uncleHash")) + tmp.sha3Uncles = h256(_blObj["blockHeader"].get_obj()["uncleHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("coinbase")) - tmp.coinbaseAddress = Address(blObj["blockHeader"].get_obj()["coinbase"].get_str()); + if (_blObj["blockHeader"].get_obj().count("coinbase")) + tmp.coinbaseAddress = Address(_blObj["blockHeader"].get_obj()["coinbase"].get_str()); - if (blObj["blockHeader"].get_obj().count("stateRoot")) - tmp.stateRoot = h256(blObj["blockHeader"].get_obj()["stateRoot"].get_str()); + if (_blObj["blockHeader"].get_obj().count("stateRoot")) + tmp.stateRoot = h256(_blObj["blockHeader"].get_obj()["stateRoot"].get_str()); - if (blObj["blockHeader"].get_obj().count("transactionsTrie")) - tmp.transactionsRoot = h256(blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("transactionsTrie")) + tmp.transactionsRoot = h256(_blObj["blockHeader"].get_obj()["transactionsTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("receiptTrie")) - tmp.receiptsRoot = h256(blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); + if (_blObj["blockHeader"].get_obj().count("receiptTrie")) + tmp.receiptsRoot = h256(_blObj["blockHeader"].get_obj()["receiptTrie"].get_str()); - if (blObj["blockHeader"].get_obj().count("bloom")) - tmp.logBloom = LogBloom(blObj["blockHeader"].get_obj()["bloom"].get_str()); + if (_blObj["blockHeader"].get_obj().count("bloom")) + tmp.logBloom = LogBloom(_blObj["blockHeader"].get_obj()["bloom"].get_str()); - if (blObj["blockHeader"].get_obj().count("difficulty")) - tmp.difficulty = toInt(blObj["blockHeader"].get_obj()["difficulty"]); + if (_blObj["blockHeader"].get_obj().count("difficulty")) + tmp.difficulty = toInt(_blObj["blockHeader"].get_obj()["difficulty"]); - if (blObj["blockHeader"].get_obj().count("number")) - tmp.number = toInt(blObj["blockHeader"].get_obj()["number"]); + if (_blObj["blockHeader"].get_obj().count("number")) + tmp.number = toInt(_blObj["blockHeader"].get_obj()["number"]); - if (blObj["blockHeader"].get_obj().count("gasLimit")) - tmp.gasLimit = toInt(blObj["blockHeader"].get_obj()["gasLimit"]); + if (_blObj["blockHeader"].get_obj().count("gasLimit")) + tmp.gasLimit = toInt(_blObj["blockHeader"].get_obj()["gasLimit"]); - if (blObj["blockHeader"].get_obj().count("gasUsed")) - tmp.gasUsed = toInt(blObj["blockHeader"].get_obj()["gasUsed"]); + if (_blObj["blockHeader"].get_obj().count("gasUsed")) + tmp.gasUsed = toInt(_blObj["blockHeader"].get_obj()["gasUsed"]); - if (blObj["blockHeader"].get_obj().count("timestamp")) - tmp.timestamp = toInt(blObj["blockHeader"].get_obj()["timestamp"]); + if (_blObj["blockHeader"].get_obj().count("timestamp")) + tmp.timestamp = toInt(_blObj["blockHeader"].get_obj()["timestamp"]); - if (blObj["blockHeader"].get_obj().count("extraData")) - tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str()); + if (_blObj["blockHeader"].get_obj().count("extraData")) + tmp.extraData = importByteArray(_blObj["blockHeader"].get_obj()["extraData"].get_str()); - if (blObj["blockHeader"].get_obj().count("mixHash")) - tmp.mixHash = h256(blObj["blockHeader"].get_obj()["mixHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("mixHash")) + tmp.mixHash = h256(_blObj["blockHeader"].get_obj()["mixHash"].get_str()); - if (blObj["blockHeader"].get_obj().count("seedHash")) - tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str()); + if (_blObj["blockHeader"].get_obj().count("seedHash")) + tmp.seedHash = h256(_blObj["blockHeader"].get_obj()["seedHash"].get_str()); // find new valid nonce - if (tmp != current_BlockHeader) + if (tmp != _current_BlockHeader) { - current_BlockHeader = tmp; + _current_BlockHeader = tmp; ProofOfWork pow; std::pair ret; - while (!ProofOfWork::verify(current_BlockHeader)) + while (!ProofOfWork::verify(_current_BlockHeader)) { - ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) - Ethash::assignResult(ret.second, current_BlockHeader); + ret = pow.mine(_current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce) + Ethash::assignResult(ret.second, _current_BlockHeader); } } } else { // take the blockheader as is - const bytes c_blockRLP = createBlockRLPFromFields(blObj["blockHeader"].get_obj()); + const bytes c_blockRLP = createBlockRLPFromFields(_blObj["blockHeader"].get_obj()); const RLP c_bRLP(c_blockRLP); - current_BlockHeader.populateFromHeader(c_bRLP, false); + _current_BlockHeader.populateFromHeader(c_bRLP, false); } } @@ -614,20 +614,20 @@ RLPStream createFullBlockFromHeader(const BlockInfo& _bi,const bytes& _txs, cons BOOST_AUTO_TEST_SUITE(BlockChainTests) -//BOOST_AUTO_TEST_CASE(bcBlockChainTest) -//{ -// dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcBlockChainTest) +{ + dev::test::executeTests("bcBlockChainTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcValidBlockTest) -//{ -// dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcValidBlockTest) +{ + dev::test::executeTests("bcValidBlockTest", "/BlockTests", dev::test::doBlockchainTests); +} -//BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) -//{ -// dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); -//} +BOOST_AUTO_TEST_CASE(bcInvalidHeaderTest) +{ + dev::test::executeTests("bcInvalidHeaderTest", "/BlockTests", dev::test::doBlockchainTests); +} BOOST_AUTO_TEST_CASE(bcUncleTest) { From fa9814d6f269a7efa0d8eba1bc5fa4e73dcfa439 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 00:52:49 +0100 Subject: [PATCH 305/313] add uncle tests --- test/bcUncleTestFiller.json | 348 +++++++++++++++++++++++++++++++++++- 1 file changed, 347 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index d866b887c..c0233ff91 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -90,6 +90,181 @@ "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" } ] + } + ] + }, + + "twoEqualUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "twoUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] }, { "transactions" : [ @@ -97,7 +272,91 @@ "data" : "", "gasLimit" : "80000050", "gasPrice" : "1", - "nonce" : "3", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + + "threeUncle" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "10" @@ -106,6 +365,93 @@ "uncleHeaders" : [ ] }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "a55af905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } ] } From 8877a1834fc9158ab9c9f1891b5270007c6b5bcb Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Mon, 2 Mar 2015 14:34:45 +0100 Subject: [PATCH 306/313] add secure trie tests --- test/trie.cpp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/test/trie.cpp b/test/trie.cpp index 9e59dd316..e03e96830 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -198,6 +198,48 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } +BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + for (auto i: o["in"].get_obj()) + { + ss.push_back(make_pair(i.first, i.second.get_str())); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) + { + next_permutation(ss.begin(), ss.end()); + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } + } +} + BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -279,6 +321,69 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } +BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) +{ + string testPath = test::getTestPath(); + + testPath += "/TrieTests"; + + cnote << "Testing Trie..."; + js::mValue v; + string s = asString(contents(testPath + "/trietest_secureTrie.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + + for (auto& i: v.get_obj()) + { + cnote << i.first; + js::mObject& o = i.second.get_obj(); + vector> ss; + vector keysToBeDeleted; + for (auto& i: o["in"].get_array()) + { + vector values; + for (auto& s: i.get_array()) + { + if (s.type() == json_spirit::str_type) + values.push_back(s.get_str()); + else if (s.type() == json_spirit::null_type) + { + // mark entry for deletion + values.push_back(""); + if (!values[0].find("0x")) + values[0] = asString(fromHex(values[0].substr(2))); + keysToBeDeleted.push_back(values[0]); + } + else + BOOST_FAIL("Bad type (expected string)"); + } + + BOOST_REQUIRE(values.size() == 2); + ss.push_back(make_pair(values[0], values[1])); + if (!ss.back().first.find("0x")) + ss.back().first = asString(fromHex(ss.back().first.substr(2))); + if (!ss.back().second.find("0x")) + ss.back().second = asString(fromHex(ss.back().second.substr(2))); + } + + MemoryDB m; + SecureGenericTrieDB t(&m); + t.init(); + BOOST_REQUIRE(t.check(true)); + for (auto const& k: ss) + { + if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) + t.remove(k.first); + else + t.insert(k.first, k.second); + BOOST_REQUIRE(t.check(true)); + } + + BOOST_REQUIRE(!o["root"].is_null()); + BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); + } +} + inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From ee5a1f32888d492163443b3a2c68b3b3cc69b507 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:13:45 +0100 Subject: [PATCH 307/313] merge --- test/trie.cpp | 105 -------------------------------------------------- 1 file changed, 105 deletions(-) diff --git a/test/trie.cpp b/test/trie.cpp index e03e96830..9e59dd316 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -198,48 +198,6 @@ BOOST_AUTO_TEST_CASE(trie_test_anyorder) } } -BOOST_AUTO_TEST_CASE(trie_test_anyorder_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trieanyorder_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trieanyorder.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - for (auto i: o["in"].get_obj()) - { - ss.push_back(make_pair(i.first, i.second.get_str())); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) - { - next_permutation(ss.begin(), ss.end()); - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } - } -} - BOOST_AUTO_TEST_CASE(trie_tests_ordered) { string testPath = test::getTestPath(); @@ -321,69 +279,6 @@ BOOST_AUTO_TEST_CASE(trie_tests_ordered) } } -BOOST_AUTO_TEST_CASE(trie_tests_ordered_secureTrie) -{ - string testPath = test::getTestPath(); - - testPath += "/TrieTests"; - - cnote << "Testing Trie..."; - js::mValue v; - string s = asString(contents(testPath + "/trietest_secureTrie.json")); - BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); - js::read_string(s, v); - - for (auto& i: v.get_obj()) - { - cnote << i.first; - js::mObject& o = i.second.get_obj(); - vector> ss; - vector keysToBeDeleted; - for (auto& i: o["in"].get_array()) - { - vector values; - for (auto& s: i.get_array()) - { - if (s.type() == json_spirit::str_type) - values.push_back(s.get_str()); - else if (s.type() == json_spirit::null_type) - { - // mark entry for deletion - values.push_back(""); - if (!values[0].find("0x")) - values[0] = asString(fromHex(values[0].substr(2))); - keysToBeDeleted.push_back(values[0]); - } - else - BOOST_FAIL("Bad type (expected string)"); - } - - BOOST_REQUIRE(values.size() == 2); - ss.push_back(make_pair(values[0], values[1])); - if (!ss.back().first.find("0x")) - ss.back().first = asString(fromHex(ss.back().first.substr(2))); - if (!ss.back().second.find("0x")) - ss.back().second = asString(fromHex(ss.back().second.substr(2))); - } - - MemoryDB m; - SecureGenericTrieDB t(&m); - t.init(); - BOOST_REQUIRE(t.check(true)); - for (auto const& k: ss) - { - if (find(keysToBeDeleted.begin(), keysToBeDeleted.end(), k.first) != keysToBeDeleted.end() && k.second.empty()) - t.remove(k.first); - else - t.insert(k.first, k.second); - BOOST_REQUIRE(t.check(true)); - } - - BOOST_REQUIRE(!o["root"].is_null()); - BOOST_CHECK_EQUAL(o["root"].get_str(), "0x" + toHex(t.root().asArray())); - } -} - inline h256 stringMapHash256(StringMap const& _s) { return hash256(_s); From cf073b8b069135998bb9a8f533aab2749197779c Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 01:15:12 +0100 Subject: [PATCH 308/313] check for minGasLimit and minDifficulty when constructing block --- libethcore/BlockInfo.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 7c3360e4a..3b4878a7d 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -127,8 +127,14 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) if (gasUsed > gasLimit) BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(gasLimit), bigint(gasUsed)) ); + if (difficulty < c_minimumDifficulty) + BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); + + if (gasLimit < c_minGasLimit) + BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); + if (number && extraData.size() > c_maximumExtraDataSize) - BOOST_THROW_EXCEPTION(ExtraDataTooBig()); + BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); } void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) @@ -213,10 +219,6 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (gasLimit < _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor || - gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) - BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); - if (seedHash != calculateSeedHash(_parent)) BOOST_THROW_EXCEPTION(InvalidSeedHash()); From 2359185a259a802035050628b8dc6d52038e8d66 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:14:45 +0100 Subject: [PATCH 309/313] try to have a uncle with block number = 1 --- test/bcUncleTestFiller.json | 80 +++++++++++++++++++++++++++++++++++++ test/blockchain.cpp | 6 ++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index c0233ff91..e70f25bb4 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -1,4 +1,84 @@ { + "uncleHeaderAtBlock2" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "100000000", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "80000050", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0000000000000000000000000000000000000000", + "difficulty" : "131072", + "extraData" : "0x", + "gasLimit" : "99902343", + "gasUsed" : "0", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "0x54c98c82", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + }, + "oneUncle" : { "genesisBlockHeader" : { "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/blockchain.cpp b/test/blockchain.cpp index e453e32ab..7f840bc76 100644 --- a/test/blockchain.cpp +++ b/test/blockchain.cpp @@ -80,6 +80,7 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) BOOST_REQUIRE(o.count("blocks")); mArray blArray; vector vBiBlocks; + vBiBlocks.push_back(biGenesisBlock); for (auto const& bl: o["blocks"].get_array()) { mObject blObj = bl.get_obj(); @@ -107,7 +108,10 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) // make uncle header valid uncleBlockFromFields.timestamp = (u256)time(0); - uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + if (vBiBlocks.size() > 2) + uncleBlockFromFields.populateFromParent(vBiBlocks[vBiBlocks.size()-2]); + else + continue; updatePoW(uncleBlockFromFields); writeBlockHeaderToJson(uncleHeaderObj, uncleBlockFromFields); From 4d298812da2edf07f8f9f4e392c6dfa3b6401fa0 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 6 Mar 2015 09:16:11 +0100 Subject: [PATCH 310/313] fix --- test/bcUncleTestFiller.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bcUncleTestFiller.json b/test/bcUncleTestFiller.json index e70f25bb4..639051f2b 100644 --- a/test/bcUncleTestFiller.json +++ b/test/bcUncleTestFiller.json @@ -65,7 +65,7 @@ "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", "nonce" : "18a524c1790fa83b", - "number" : "2", + "number" : "1", "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "seedHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", From 6f7bcc489ad721d3781805682e648a8832ae9e60 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 12:33:59 +0100 Subject: [PATCH 311/313] Minor fix. --- libethereum/Client.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index b5355f1e0..7baebdc98 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -285,7 +285,6 @@ LocalisedLogEntries Client::checkWatch(unsigned _watchId) #if ETH_DEBUG && 0 cdebug << "lastPoll updated to " << chrono::duration_cast(chrono::system_clock::now().time_since_epoch()).count(); #endif - auto& w = m_watches.at(_watchId); std::swap(ret, w.changes); w.lastPoll = chrono::system_clock::now(); } catch (...) {} From 9e1c2980d4aac96f1c677a229e145c9cb53b5946 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 6 Mar 2015 13:10:44 +0100 Subject: [PATCH 312/313] Unclobber Arkadiy's exception fixes. --- libdevcore/Exceptions.h | 1 + libethcore/BlockInfo.cpp | 2 +- libethcore/Exceptions.cpp | 32 ++++++++++++++++---------------- libethcore/Exceptions.h | 7 +++---- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index 8c66cac49..3efabfced 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -35,6 +35,7 @@ struct Exception: virtual std::exception, virtual boost::exception { Exception(std::string _message = {}) : m_message(std::move(_message)) {} const char* what() const noexcept override { return m_message.c_str(); } + private: std::string m_message; }; diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index 3b4878a7d..39eadb60e 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -131,7 +131,7 @@ void BlockInfo::populateFromHeader(RLP const& _header, bool _checkNonce) BOOST_THROW_EXCEPTION(InvalidDifficulty() << RequirementError(bigint(c_minimumDifficulty), bigint(difficulty)) ); if (gasLimit < c_minGasLimit) - BOOST_THROW_EXCEPTION(InvalidGasLimit() << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); + BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, c_minGasLimit, c_minGasLimit) << RequirementError(bigint(c_minGasLimit), bigint(gasLimit)) ); if (number && extraData.size() > c_maximumExtraDataSize) BOOST_THROW_EXCEPTION(ExtraDataTooBig() << RequirementError(bigint(c_maximumExtraDataSize), bigint(extraData.size()))); diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c489c8f4a..7996a4424 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -27,20 +27,20 @@ using namespace std; using namespace dev; using namespace dev::eth; -#if ALL_COMPILERS_ARE_CPP11 -#define ETH_RETURN_STRING(S) thread_local static string s_what; s_what = S; return s_what.c_str(); -#elsif USE_BOOST_TLS -static boost::thread_specific_ptr g_exceptionMessage; -#define ETH_RETURN_STRING(S) if (!g_exceptionMessage.get()); g_exceptionMessage.reset(new string); *g_exceptionMessage.get() = S; return g_exceptionMessage.get()->c_str(); -#else -#define ETH_RETURN_STRING(S) m_message = S; return m_message.c_str(); -#endif - -const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } -const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); } -const char* InvalidTransactionsHash::what() const noexcept { ETH_RETURN_STRING("Invalid transactions hash: header says: " + toHex(m_head.ref()) + " block is:" + toHex(m_real.ref())); } -const char* InvalidGasLimit::what() const noexcept { ETH_RETURN_STRING("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"); } -const char* InvalidMinGasPrice::what() const noexcept { ETH_RETURN_STRING("Invalid minimum gas price (provided: " + toString(provided) + " limit:" + toString(limit) + ")"); } -const char* InvalidNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (r: " + toString(required) + " c:" + toString(candidate) + ")"); } -const char* InvalidBlockNonce::what() const noexcept { ETH_RETURN_STRING("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"); } +InvalidBlockFormat::InvalidBlockFormat(int _f, bytesConstRef _d): + Exception("Invalid block format: Bad field " + toString(_f) + " (" + toHex(_d) + ")"), f(_f), d(_d.toBytes()) {} +UncleInChain::UncleInChain(h256Set _uncles, h256 _block): + Exception("Uncle in block already mentioned: Uncles " + toString(_uncles) + " (" + _block.abridged() + ")"), uncles(_uncles), block(_block) {} + +InvalidTransactionsHash::InvalidTransactionsHash(h256 _head, h256 _real): + Exception("Invalid transactions hash: header says: " + toHex(_head.ref()) + " block is:" + toHex(_real.ref())), head(_head), real(_real) {} + +InvalidGasLimit::InvalidGasLimit(u256 _provided, u256 _n, u256 _x): + Exception("Invalid gas limit (provided: " + toString(provided) + " minimum:" + toString(minimum) + " max:" + toString(maximum) + ")"), provided(_provided), minimum(_n), maximum(_x) {} + +InvalidNonce::InvalidNonce(u256 _required, u256 _candidate): + Exception("Invalid nonce (r: " + toString(_required) + " c:" + toString(_candidate) + ")"), required(_required), candidate(_candidate) {} + +InvalidBlockNonce::InvalidBlockNonce(h256 _h, Nonce _n, u256 _d): + Exception("Invalid nonce (h: " + toString(h) + " n:" + toString(n) + " d:" + toString(d) + ")"), h(_h), n(_n), d(_d) {} diff --git a/libethcore/Exceptions.h b/libethcore/Exceptions.h index edf3d6b03..cf2b07292 100644 --- a/libethcore/Exceptions.h +++ b/libethcore/Exceptions.h @@ -58,15 +58,14 @@ class InvalidTransactionsHash: virtual public dev::Exception { public: InvalidTr struct InvalidTransaction: virtual dev::Exception {}; struct InvalidDifficulty: virtual dev::Exception {}; struct InvalidSeedHash: virtual dev::Exception {}; -class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided = 0, u256 _n = 0, u256 _x = 0): provided(_provided), minimum(_n), maximum(_x) {} u256 provided; u256 minimum; u256 maximum; virtual const char* what() const noexcept; }; -class InvalidMinGasPrice: virtual public dev::Exception { public: InvalidMinGasPrice(u256 _provided = 0, u256 _limit = 0): provided(_provided), limit(_limit) {} u256 provided; u256 limit; virtual const char* what() const noexcept; }; +class InvalidGasLimit: virtual public dev::Exception { public: InvalidGasLimit(u256 _provided, u256 _n, u256 _x); u256 provided; u256 minimum; u256 maximum; }; struct InvalidTransactionGasUsed: virtual dev::Exception {}; struct InvalidTransactionsStateRoot: virtual dev::Exception {}; struct InvalidReceiptsStateRoot: virtual dev::Exception {}; struct InvalidTimestamp: virtual dev::Exception {}; struct InvalidLogBloom: virtual dev::Exception {}; -class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required = 0, u256 _candidate = 0): required(_required), candidate(_candidate) {} u256 required; u256 candidate; virtual const char* what() const noexcept; }; -class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h = h256(), Nonce _n = Nonce(), u256 _d = 0): h(_h), n(_n), d(_d) {} h256 h; Nonce n; u256 d; virtual const char* what() const noexcept; }; +class InvalidNonce: virtual public dev::Exception { public: InvalidNonce(u256 _required, u256 _candidate); u256 required; u256 candidate; }; +class InvalidBlockNonce: virtual public dev::Exception { public: InvalidBlockNonce(h256 _h, Nonce _n, u256 _d); h256 h; Nonce n; u256 d; }; struct InvalidParentHash: virtual dev::Exception {}; struct InvalidNumber: virtual dev::Exception {}; struct InvalidContractAddress: virtual public dev::Exception {}; From 77b9fdcfbc27869c0534ced6f71456a00b96ba97 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 6 Mar 2015 13:44:37 +0100 Subject: [PATCH 313/313] Fix type checks for storage variable initializer. --- libsolidity/AST.cpp | 51 +++++++++++++------------- libsolidity/AST.h | 1 - test/SolidityNameAndTypeResolution.cpp | 18 +++++++++ 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 3a0aed119..79b755e97 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -328,8 +328,30 @@ bool VariableDeclaration::isLValue() const void VariableDeclaration::checkTypeRequirements() { - if (m_value) + // Variables can be declared without type (with "var"), in which case the first assignment + // sets the type. + // Note that assignments before the first declaration are legal because of the special scoping + // rules inherited from JavaScript. + if (!m_value) + return; + if (m_type) + m_value->expectType(*m_type); + else + { + // no type declared and no previous assignment, infer the type m_value->checkTypeRequirements(); + TypePointer type = m_value->getType(); + if (type->getCategory() == Type::Category::IntegerConstant) + { + auto intType = dynamic_pointer_cast(type)->getIntegerType(); + if (!intType) + BOOST_THROW_EXCEPTION(m_value->createTypeError("Invalid integer constant " + type->toString() + ".")); + type = intType; + } + else if (type->getCategory() == Type::Category::Void) + BOOST_THROW_EXCEPTION(createTypeError("Variable cannot have void type.")); + m_type = type; + } } bool VariableDeclaration::isExternalFunctionParameter() const @@ -445,32 +467,9 @@ void Return::checkTypeRequirements() void VariableDeclarationStatement::checkTypeRequirements() { - // Variables can be declared without type (with "var"), in which case the first assignment - // sets the type. - // Note that assignments before the first declaration are legal because of the special scoping - // rules inherited from JavaScript. - if (m_variable->getValue()) - { - if (m_variable->getType()) - m_variable->getValue()->expectType(*m_variable->getType()); - else - { - // no type declared and no previous assignment, infer the type - m_variable->getValue()->checkTypeRequirements(); - TypePointer type = m_variable->getValue()->getType(); - if (type->getCategory() == Type::Category::IntegerConstant) - { - auto intType = dynamic_pointer_cast(type)->getIntegerType(); - if (!intType) - BOOST_THROW_EXCEPTION(m_variable->getValue()->createTypeError("Invalid integer constant " + type->toString())); - type = intType; - } - else if (type->getCategory() == Type::Category::Void) - BOOST_THROW_EXCEPTION(m_variable->createTypeError("var cannot be void type")); - m_variable->setType(type); - } - } + m_variable->checkTypeRequirements(); } + void Assignment::checkTypeRequirements() { m_leftHandSide->checkTypeRequirements(); diff --git a/libsolidity/AST.h b/libsolidity/AST.h index c3c2cd8d3..eab53153f 100644 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -460,7 +460,6 @@ public: virtual bool isLValue() const override; - /// Calls checkTypeRequirments for all state variables. void checkTypeRequirements(); bool isLocalVariable() const { return !!dynamic_cast(getScope()); } bool isExternalFunctionParameter() const; diff --git a/test/SolidityNameAndTypeResolution.cpp b/test/SolidityNameAndTypeResolution.cpp index a48b62d0d..6e6254eba 100644 --- a/test/SolidityNameAndTypeResolution.cpp +++ b/test/SolidityNameAndTypeResolution.cpp @@ -1292,6 +1292,24 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static) BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); } +BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int) +{ + char const* text = R"( + contract c { + uint8 a = 1000; + })"; + BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); +} + +BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string) +{ + char const* text = R"( + contract c { + uint a = "abc"; + })"; + BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() }