Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
317370c137
  1. 55
      alethzero/DappLoader.cpp
  2. 7
      alethzero/DappLoader.h
  3. 27
      alethzero/MainWin.cpp
  4. 1
      alethzero/MainWin.h
  5. 4
      evmjit/libevmjit/ExecutionEngine.cpp
  6. 4
      mix/qml/DebugInfoList.qml
  7. 75
      mix/qml/Debugger.qml
  8. 21
      mix/qml/StatusPane.qml
  9. 12
      mix/qml/html/cm/solarized.css
  10. BIN
      mix/qml/img/closedtriangleindicator.png
  11. BIN
      mix/qml/img/closedtriangleindicator@2x.png
  12. BIN
      mix/qml/img/opentriangleindicator.png
  13. BIN
      mix/qml/img/opentriangleindicator@2x.png
  14. BIN
      mix/qml/img/signerroricon32.png
  15. BIN
      mix/qml/img/warningicon.png
  16. BIN
      mix/qml/img/warningicon@2x.png
  17. 5
      mix/res.qrc
  18. 2
      test/state.cpp
  19. 2
      test/vm.cpp

55
alethzero/DappLoader.cpp

@ -25,6 +25,7 @@
#include <QStringList>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QMimeDatabase>
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libdevcrypto/CryptoPP.h>
@ -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 = "<script>\n";
content.append(web3Content());
content.append("</script>\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<unsigned char const*>(data.constData()), reinterpret_cast<unsigned char const*>(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);
}

7
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<QUrl, dev::h256> m_uriHashes;
std::set<QUrl> m_pageUrls;
QByteArray m_web3Js;
};

27
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);
}

1
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();

4
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(), " ");

4
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
}

75
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
{

21
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
}
}
}
}
}
}

12
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; }

BIN
mix/qml/img/closedtriangleindicator.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

After

Width:  |  Height:  |  Size: 242 B

BIN
mix/qml/img/closedtriangleindicator@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

BIN
mix/qml/img/opentriangleindicator.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 257 B

BIN
mix/qml/img/opentriangleindicator@2x.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 429 B

BIN
mix/qml/img/signerroricon32.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

BIN
mix/qml/img/warningicon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

BIN
mix/qml/img/warningicon@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

5
mix/res.qrc

@ -20,6 +20,7 @@
<file>qml/img/bugiconactive.png</file>
<file>qml/img/bugiconinactive.png</file>
<file>qml/img/closedtriangleindicator.png</file>
<file>qml/img/closedtriangleindicator@2x.png</file>
<file>qml/img/closedtriangleindicator_filesproject.png</file>
<file>qml/img/console.png</file>
<file>qml/img/copy.png</file>
@ -43,6 +44,7 @@
<file>qml/img/note.png</file>
<file>qml/img/openedfolder.png</file>
<file>qml/img/opentriangleindicator.png</file>
<file>qml/img/opentriangleindicator@2x.png</file>
<file>qml/img/opentriangleindicator_filesproject.png</file>
<file>qml/img/plus.png</file>
<file>qml/img/projecticon.png</file>
@ -63,6 +65,7 @@
<file>qml/img/copyiconactive.png</file>
<file>qml/img/searchicon.png</file>
<file>qml/img/stop_button2x.png</file>
<file>qml/img/signerroricon32.png</file>
<file>qml/img/warningicon.png</file>
<file>qml/img/warningicon@2x.png</file>
</qresource>
</RCC>

2
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";

2
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";

Loading…
Cancel
Save