diff --git a/alethzero/DappLoader.cpp b/alethzero/DappLoader.cpp index 9baf0c82e..69555521d 100644 --- a/alethzero/DappLoader.cpp +++ b/alethzero/DappLoader.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -96,13 +97,31 @@ DappLocation DappLoader::resolveAppUri(QString const& _uri) void DappLoader::downloadComplete(QNetworkReply* _reply) { + QUrl requestUrl = _reply->request().url(); + if (m_pageUrls.count(requestUrl) != 0) + { + //inject web3 js + QByteArray content = "\n"); + content.append(_reply->readAll()); + QString contentType = _reply->header(QNetworkRequest::ContentTypeHeader).toString(); + if (contentType.isEmpty()) + { + QMimeDatabase db; + contentType = db.mimeTypeForUrl(requestUrl).name(); + } + pageReady(content, contentType, requestUrl); + return; + } + try { //try to interpret as rlp QByteArray data = _reply->readAll(); _reply->deleteLater(); - h256 expected = m_uriHashes[_reply->request().url()]; + h256 expected = m_uriHashes[requestUrl]; bytes package(reinterpret_cast(data.constData()), reinterpret_cast(data.constData() + data.size())); Secp256k1 dec; dec.decrypt(expected, package); @@ -144,15 +163,7 @@ void DappLoader::loadDapp(RLP const& _rlp) if (entry->path == "/deployment.js") { //inject web3 code - QString code; - code += contentsOfQResource(":/js/bignumber.min.js"); - code += "\n"; - code += contentsOfQResource(":/js/webthree.js"); - code += "\n"; - code += contentsOfQResource(":/js/setup.js"); - code += "\n"; - QByteArray res = code.toLatin1(); - bytes b(res.data(), res.data() + res.size()); + bytes b(web3Content().data(), web3Content().data() + web3Content().size()); b.insert(b.end(), content.begin(), content.end()); dapp.content[hash] = b; } @@ -165,6 +176,22 @@ void DappLoader::loadDapp(RLP const& _rlp) emit dappReady(dapp); } +QByteArray const& DappLoader::web3Content() +{ + if (m_web3Js.isEmpty()) + { + QString code; + code += contentsOfQResource(":/js/bignumber.min.js"); + code += "\n"; + code += contentsOfQResource(":/js/webthree.js"); + code += "\n"; + code += contentsOfQResource(":/js/setup.js"); + code += "\n"; + m_web3Js = code.toLatin1(); + } + return m_web3Js; +} + Manifest DappLoader::loadManifest(std::string const& _manifest) { /// https://github.com/ethereum/go-ethereum/wiki/URL-Scheme @@ -216,3 +243,11 @@ void DappLoader::loadDapp(QString const& _uri) m_net.get(request); } +void DappLoader::loadPage(QString const& _uri) +{ + QUrl uri(_uri); + QNetworkRequest request(uri); + m_pageUrls.insert(uri); + m_net.get(request); +} + diff --git a/alethzero/DappLoader.h b/alethzero/DappLoader.h index 463b65d0a..deba62c68 100644 --- a/alethzero/DappLoader.h +++ b/alethzero/DappLoader.h @@ -73,9 +73,13 @@ public: ///Load a new DApp. Resolves a name with a name reg contract. Asynchronous. dappReady is emitted once everything is read, dappError othervise ///@param _uri Eth name path void loadDapp(QString const& _uri); + ///Load a regular html page + ///@param _uri Page Uri + void loadPage(QString const& _uri); signals: void dappReady(Dapp& _dapp); + void pageReady(QByteArray const& _content, QString const& _mimeType, QUrl const& _uri); void dappError(); private slots: @@ -86,9 +90,12 @@ private: DappLocation resolveAppUri(QString const& _uri); void loadDapp(dev::RLP const& _rlp); Manifest loadManifest(std::string const& _manifest); + QByteArray const& web3Content(); dev::WebThreeDirect* m_web3; QNetworkAccessManager m_net; std::map m_uriHashes; + std::set m_pageUrls; + QByteArray m_web3Js; }; diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 94a58dec0..bbacaf539 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -183,13 +183,6 @@ Main::Main(QWidget *parent) : m_webPage = webPage; connect(webPage, &WebPage::consoleMessage, [this](QString const& _msg) { Main::addConsoleMessage(_msg, QString()); }); ui->webView->setPage(m_webPage); - connect(ui->webView, &QWebEngineView::loadFinished, [this]() - { - 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, &QWebEngineView::titleChanged, [=]() { @@ -199,6 +192,7 @@ Main::Main(QWidget *parent) : m_dappHost.reset(new DappHost(8081)); m_dappLoader = new DappLoader(this, web3()); connect(m_dappLoader, &DappLoader::dappReady, this, &Main::dappLoaded); + connect(m_dappLoader, &DappLoader::pageReady, this, &Main::pageLoaded); // ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); // QWebEngineInspector* inspector = new QWebEngineInspector(); // inspector->setPage(page); @@ -264,7 +258,7 @@ NetworkPreferences Main::netPrefs() const { listenIP.clear(); } - + auto publicIP = ui->forcePublicIP->text().toStdString(); try { @@ -274,7 +268,7 @@ NetworkPreferences Main::netPrefs() const { publicIP.clear(); } - + if (isPublicAddress(publicIP)) return NetworkPreferences(publicIP, listenIP, ui->port->value(), ui->upnp->isChecked()); else @@ -918,6 +912,7 @@ void Main::on_urlEdit_returnPressed() { //try do resolve dapp url m_dappLoader->loadDapp(s); + return; } catch (...) { @@ -931,8 +926,7 @@ void Main::on_urlEdit_returnPressed() else url.setScheme("http"); else {} - qDebug() << url.toString(); - ui->webView->page()->setUrl(url); + m_dappLoader->loadPage(url.toString()); } void Main::on_nameReg_textChanged() @@ -1799,7 +1793,7 @@ void Main::on_connect_triggered() ui->net->setChecked(true); on_net_triggered(); } - + m_connect.setEnvironment(m_servers); if (m_connect.exec() == QDialog::Accepted) { @@ -1811,9 +1805,9 @@ void Main::on_connect_triggered() nodeID = NodeId(fromHex(m_connect.nodeId().toStdString())); } catch (BadHexCharacter&) {} - + m_connect.reset(); - + if (required) web3()->requirePeer(nodeID, host); else @@ -2016,3 +2010,8 @@ void Main::dappLoaded(Dapp& _dapp) QUrl url = m_dappHost->hostDapp(std::move(_dapp)); ui->webView->page()->setUrl(url); } + +void Main::pageLoaded(QByteArray const& _content, QString const& _mimeType, QUrl const& _uri) +{ + ui->webView->page()->setContent(_content, _mimeType, _uri); +} diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index fccbc855d..a5c74eeaa 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -179,6 +179,7 @@ private slots: // Dapps void dappLoaded(Dapp& _dapp); //qt does not support rvalue refs for signals + void pageLoaded(QByteArray const& _content, QString const& _mimeType, QUrl const& _uri); signals: void poll(); diff --git a/evmjit/libevmjit/ExecutionEngine.cpp b/evmjit/libevmjit/ExecutionEngine.cpp index 0ed4a65b5..e15dad969 100644 --- a/evmjit/libevmjit/ExecutionEngine.cpp +++ b/evmjit/libevmjit/ExecutionEngine.cpp @@ -88,10 +88,10 @@ void parseOptions() //cl::ParseEnvironmentOptions("evmjit", "EVMJIT", "Ethereum EVM JIT Compiler"); // FIXME: LLVM workaround: - // Manually select instruction scheduler other than "source". + // Manually select instruction scheduler. Confirmed bad schedulers: source, list-burr, list-hybrid. // "source" scheduler has a bug: http://llvm.org/bugs/show_bug.cgi?id=22304 auto envLine = std::getenv("EVMJIT"); - auto commandLine = std::string{"evmjit "} + (envLine ? envLine : "") + " -pre-RA-sched=list-burr\0"; + auto commandLine = std::string{"evmjit "} + (envLine ? envLine : "") + " -pre-RA-sched=list-ilp\0"; static const auto c_maxArgs = 20; char const* argv[c_maxArgs] = {nullptr, }; auto arg = std::strtok(&*commandLine.begin(), " "); diff --git a/mix/qml/DebugInfoList.qml b/mix/qml/DebugInfoList.qml index 5b1a67519..b479d6d28 100644 --- a/mix/qml/DebugInfoList.qml +++ b/mix/qml/DebugInfoList.qml @@ -40,11 +40,9 @@ ColumnLayout { height: 25 id: header Image { - source: "qrc:/qml/img/opentriangleindicator.png" + source: "img/closedtriangleindicator.png" width: 15 height: 15 - sourceSize.width: 15 - sourceSize.height: 15 id: storageImgArrow } diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index e5c7e576d..ef83ef390 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -206,8 +206,8 @@ Rectangle { anchors.top: parent.top anchors.topMargin: 15 anchors.left: parent.left; - anchors.leftMargin: machineStates.sideMargin - width: debugScrollArea.width - machineStates.sideMargin * 2 - 20; + anchors.leftMargin: machineStates.sideMargin + width: debugScrollArea.width - machineStates.sideMargin * 2 - 20 ; spacing: machineStates.sideMargin Rectangle { @@ -218,15 +218,13 @@ Rectangle { color: "transparent" Rectangle { - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left + anchors.fill: parent color: "transparent" - width: parent.width * 0.4 RowLayout { - anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent id: jumpButtons spacing: 3 + layoutDirection: Qt.LeftToRight StepActionImage { @@ -239,6 +237,7 @@ Rectangle { buttonShortcut: "Ctrl+Shift+F8" buttonTooltip: qsTr("Start Debugging") visible: true + Layout.alignment: Qt.AlignLeft } StepActionImage @@ -351,35 +350,38 @@ Rectangle { buttonTooltip: qsTr("Run Forward") visible: false } - } - } - Rectangle { - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: parent.right - width: parent.width * 0.6 - color: "transparent" - Slider { - id: statesSlider - anchors.fill: parent - tickmarksEnabled: true - stepSize: 1.0 - onValueChanged: Debugger.jumpTo(value); - style: SliderStyle { - groove: Rectangle { - implicitHeight: 3 - color: "#7da4cd" - radius: 8 - } - handle: Rectangle { - anchors.centerIn: parent - color: control.pressed ? "white" : "lightgray" - border.color: "gray" - border.width: 2 - implicitWidth: 10 - implicitHeight: 10 - radius: 12 + Rectangle { + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + color: "transparent" + Layout.fillWidth: true + Layout.minimumWidth: parent.width * 0.2 + Layout.alignment: Qt.AlignRight + + Slider { + id: statesSlider + anchors.fill: parent + tickmarksEnabled: true + stepSize: 1.0 + onValueChanged: Debugger.jumpTo(value); + style: SliderStyle { + groove: Rectangle { + implicitHeight: 3 + color: "#7da4cd" + radius: 8 + } + handle: Rectangle { + anchors.centerIn: parent + color: control.pressed ? "white" : "lightgray" + border.color: "gray" + border.width: 2 + implicitWidth: 10 + implicitHeight: 10 + radius: 12 + } + } } } } @@ -480,7 +482,7 @@ Rectangle { anchors.top : parent.top anchors.bottom: parent.bottom anchors.right: parent.right - height: parent.height //- 2 * stateListContainer.border.width + height: parent.height color: "transparent" ColumnLayout { @@ -520,7 +522,6 @@ Rectangle { title : qsTr("Stack") itemDelegate: Item { id: renderedItem - //height: 25 width: parent.width RowLayout { diff --git a/mix/qml/StatusPane.qml b/mix/qml/StatusPane.qml index f3bde4a04..75a2edd4f 100644 --- a/mix/qml/StatusPane.qml +++ b/mix/qml/StatusPane.qml @@ -230,13 +230,26 @@ Rectangle { Button { z: 4 - anchors.right: parent.right - anchors.rightMargin: 9 - anchors.verticalCenter: parent.verticalCenter + anchors.centerIn: parent id: goToLineBtn text: "" - iconSource: "qrc:/qml/img/signerroricon32.png" + width: 30 + height: 30 action: goToCompilationError + style: ButtonStyle { + background: Rectangle { + color: "transparent" + + Image { + source: "qrc:/qml/img/warningicon.png" + height: 30 + width: 30 + sourceSize.width: 30 + sourceSize.height: 30 + anchors.centerIn: parent + } + } + } } } } diff --git a/mix/qml/html/cm/solarized.css b/mix/qml/html/cm/solarized.css index d8c31bfb5..b8cede806 100644 --- a/mix/qml/html/cm/solarized.css +++ b/mix/qml/html/cm/solarized.css @@ -154,8 +154,10 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png } /* + Active line. Negative margin compensates left padding of the text in the view-port + */ .cm-s-solarized.cm-s-dark .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.10); @@ -166,20 +168,24 @@ view-port /* Code execution */ .CodeMirror-exechighlight { - background: #eee8d5; + border-bottom: double 1px #94A2A2; } + /* Error annotation */ .CodeMirror-errorannotation { - border-bottom: 1px solid #b58900; + border-bottom: 1px solid #DD3330; + margin-bottom: 4px; } .CodeMirror-errorannotation-context { font-family: monospace; font-size: small; - color: #586e75; + color: #EEE9D5; background: #b58900; padding: 2px; + text-shadow: none !important; + border-top: solid 2px #063742; } span.CodeMirror-selectedtext { color: #586e75 !important; } diff --git a/mix/qml/img/closedtriangleindicator.png b/mix/qml/img/closedtriangleindicator.png index 440adb711..ccf6c66d4 100644 Binary files a/mix/qml/img/closedtriangleindicator.png and b/mix/qml/img/closedtriangleindicator.png differ diff --git a/mix/qml/img/closedtriangleindicator@2x.png b/mix/qml/img/closedtriangleindicator@2x.png new file mode 100644 index 000000000..b12cfef9c Binary files /dev/null and b/mix/qml/img/closedtriangleindicator@2x.png differ diff --git a/mix/qml/img/opentriangleindicator.png b/mix/qml/img/opentriangleindicator.png index 591a932e0..5da188206 100644 Binary files a/mix/qml/img/opentriangleindicator.png and b/mix/qml/img/opentriangleindicator.png differ diff --git a/mix/qml/img/opentriangleindicator@2x.png b/mix/qml/img/opentriangleindicator@2x.png index fd948d73b..320749684 100644 Binary files a/mix/qml/img/opentriangleindicator@2x.png and b/mix/qml/img/opentriangleindicator@2x.png differ diff --git a/mix/qml/img/signerroricon32.png b/mix/qml/img/signerroricon32.png deleted file mode 100644 index 703ac5e2c..000000000 Binary files a/mix/qml/img/signerroricon32.png and /dev/null differ diff --git a/mix/qml/img/warningicon.png b/mix/qml/img/warningicon.png new file mode 100644 index 000000000..0215030da Binary files /dev/null and b/mix/qml/img/warningicon.png differ diff --git a/mix/qml/img/warningicon@2x.png b/mix/qml/img/warningicon@2x.png new file mode 100644 index 000000000..e41615f37 Binary files /dev/null and b/mix/qml/img/warningicon@2x.png differ diff --git a/mix/res.qrc b/mix/res.qrc index f5798ca58..f175fab1f 100644 --- a/mix/res.qrc +++ b/mix/res.qrc @@ -20,6 +20,7 @@ qml/img/bugiconactive.png qml/img/bugiconinactive.png qml/img/closedtriangleindicator.png + qml/img/closedtriangleindicator@2x.png qml/img/closedtriangleindicator_filesproject.png qml/img/console.png qml/img/copy.png @@ -43,6 +44,7 @@ qml/img/note.png qml/img/openedfolder.png qml/img/opentriangleindicator.png + qml/img/opentriangleindicator@2x.png qml/img/opentriangleindicator_filesproject.png qml/img/plus.png qml/img/projecticon.png @@ -63,6 +65,7 @@ qml/img/copyiconactive.png qml/img/searchicon.png qml/img/stop_button2x.png - qml/img/signerroricon32.png + qml/img/warningicon.png + qml/img/warningicon@2x.png diff --git a/test/state.cpp b/test/state.cpp index 813c3b4d7..65f333538 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -218,6 +218,8 @@ BOOST_AUTO_TEST_CASE(stCreateTest) BOOST_AUTO_TEST_CASE(stRandom) { + test::Options::get(); // parse command line options, e.g. to enable JIT + string testPath = dev::test::getTestPath(); testPath += "/StateTests/RandomTests"; diff --git a/test/vm.cpp b/test/vm.cpp index d92989133..4728b8a53 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -524,6 +524,8 @@ BOOST_AUTO_TEST_CASE(vmInputLimitsLightTest) BOOST_AUTO_TEST_CASE(vmRandom) { + test::Options::get(); // parse command line options, e.g. to enable JIT + string testPath = getTestPath(); testPath += "/VMTests/RandomTests";