Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

JSON-RPC #382

Merged
merged 121 commits into from
Oct 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
770d6f9
jsonrpc refactor in progress
debris Oct 10, 2014
b970673
new abstractstub && before changes
debris Oct 11, 2014
e4dd2c0
jsonrpcstubs in progres
debris Oct 11, 2014
00bbca9
jsonrpc in progress
debris Oct 11, 2014
dd41908
jsonrpc in progress
debris Oct 12, 2014
2c58f14
few more jsonrpc methods
debris Oct 12, 2014
1fc7e1b
preparing for tests
debris Oct 13, 2014
3c4da0e
ethrpc separated && first tests
debris Oct 13, 2014
a378709
jsornrpc tests in progress
debris Oct 13, 2014
4ad6113
Merge branch 'develop' into mk_jsonrpc
debris Oct 13, 2014
8816dde
jsonrpc tests
debris Oct 13, 2014
daa23e4
corshttpserver
debris Oct 13, 2014
178d80d
common changes
debris Oct 13, 2014
aa9f34e
Merge branch 'develop' into mk_jsonrpc
debris Oct 14, 2014
008fd25
common changes in jsonrpc && tests
debris Oct 14, 2014
d1205fa
fixed jsonrpc param types
debris Oct 14, 2014
d632a3a
Merge branch 'develop' into mk_jsonrpc
debris Oct 14, 2014
cd0a1c4
stateless tests
debris Oct 14, 2014
1b21fa4
common changes
debris Oct 14, 2014
83f286a
value in messages
debris Oct 14, 2014
bfb05d0
isMining changes to mining
debris Oct 14, 2014
21b5e88
default params temporarily remode
debris Oct 14, 2014
18ce0e9
setCoinbase method
debris Oct 14, 2014
8ccc593
listening and mining param names
debris Oct 14, 2014
6826f08
proprties of jsonrpc eth object are working like in docs
debris Oct 14, 2014
57bd143
properties access unified
debris Oct 14, 2014
3342a69
updated eth.js
debris Oct 15, 2014
fbd70ac
jsonrpc renaming properties in request
debris Oct 15, 2014
e645900
getMessage in QEthereum made async
debris Oct 15, 2014
acf9bdc
Merge branch 'develop' into mk_jsonrpc
debris Oct 15, 2014
0f304c1
async qethereum api methods
debris Oct 15, 2014
94b83b9
separating sync and async transaction and call in qethereum
debris Oct 15, 2014
672e56c
common changes to unify apis
debris Oct 16, 2014
df55718
jsonrpc http watch
debris Oct 16, 2014
702f283
updated eth.js
debris Oct 16, 2014
1bb1b0f
ethstubserver listening and peerCount
debris Oct 16, 2014
3b9ac15
listening and peer count separated to QPeer2Peer
debris Oct 16, 2014
875a5dc
missing tests
debris Oct 16, 2014
f9e2c8e
removed empty lines
debris Oct 16, 2014
defcdcb
added headers to ethrpc cmake
debris Oct 16, 2014
a54b6b1
libethrpc retab
debris Oct 16, 2014
24a13ec
retab
debris Oct 16, 2014
5001c19
retab
debris Oct 16, 2014
982ef81
retab
debris Oct 16, 2014
1c9ca3d
jsonrpc offset method
debris Oct 16, 2014
a2cf4d9
few missing methods api
debris Oct 16, 2014
e48f5e0
doTransact and doCall
debris Oct 16, 2014
3689a36
removed build errors
debris Oct 16, 2014
a50ab8b
fixed for CommonJS
debris Oct 16, 2014
4633dff
EthStubServer renamed to WebThreeStubServer
debris Oct 16, 2014
55b9949
fixed spaces in WebThreeStubServer
debris Oct 16, 2014
deabe1b
_private_ replaced with Impl
debris Oct 16, 2014
4d70abf
codding standards
debris Oct 17, 2014
4395c68
fixed numberOrHash method
debris Oct 17, 2014
9b24956
Merge branch 'develop' into mk_jsonrpc
debris Oct 17, 2014
da7f2ae
Merge branch 'develop' into mk_jsonrpc
debris Oct 20, 2014
d7e4416
coding standards
debris Oct 20, 2014
bd42cb1
reindent lines in eth.js
debris Oct 20, 2014
b649457
key, keys -> accounts populated to WebThreeStubServer
debris Oct 20, 2014
92c1d6e
common changes in tests
debris Oct 20, 2014
8fd09e8
removed unused includes
debris Oct 20, 2014
c0e7ac4
merge branch 'develop' into mk_jsonrpc
debris Oct 20, 2014
692426f
changes from Generic JSON-RPC
debris Oct 22, 2014
70447d1
Merge branch 'develop' into mk_jsonrpc
debris Oct 22, 2014
d8e132c
block, transaction, uncle by hash and number separately
debris Oct 22, 2014
3b84093
QWebThreeConnector
debris Oct 22, 2014
7de3f8a
removed unused code, watched and polling not working yet
debris Oct 22, 2014
29e959f
removed unused js files
debris Oct 22, 2014
a51e493
common style changes
debris Oct 23, 2014
8ca8ac7
Merge branch 'develop' into mk_jsonrpc
debris Oct 23, 2014
4d1e8e8
json-rpc generic api
debris Oct 23, 2014
64acc3c
changes populated to third
debris Oct 23, 2014
da2ad4b
Merge branch 'develop' into mk_jsonrpc
debris Oct 23, 2014
b7b7601
removed outdated tests
debris Oct 23, 2014
b62e74b
propert format of response
debris Oct 23, 2014
5ec00a8
qethereum polling through rpc
debris Oct 23, 2014
74e43cf
jsonrpc library dependency made mandatory
debris Oct 23, 2014
0e87d5c
Merge branch 'develop' into mk_jsonrpc
debris Oct 23, 2014
a8a7a15
explicitly inserting Qstring cause of compiler errors
debris Oct 23, 2014
4879133
Merge branch 'develop' into mk_jsonrpc
debris Oct 23, 2014
e8c4d68
issues fixes
debris Oct 24, 2014
d76a44f
ethrpc -> web3jsonrpc, other issues fixed
debris Oct 24, 2014
d9baba2
Merge branch 'develop' into mk_jsonrpc
debris Oct 24, 2014
46f278c
checked headless builds with and without jsonrpc
debris Oct 24, 2014
9815909
qwebconnector is not being recreated
debris Oct 24, 2014
18bf38c
Merge branch 'develop' into mk_jsonrpc
debris Oct 24, 2014
8e71bd1
Merge branch 'develop' into mk_jsonrpc
debris Oct 27, 2014
c1eaa1c
common changes in tests
debris Oct 27, 2014
3b5e120
js in qresources
debris Oct 27, 2014
6fefb43
setup default provider
debris Oct 27, 2014
59fc988
Merge branch 'develop' into mk_jsonrpc
debris Oct 27, 2014
c5a1df4
missing setDefaultBlock method
debris Oct 27, 2014
b5b3eb3
ldb access from api
debris Oct 28, 2014
d54a2f8
whisper in web3jsonrpc
debris Oct 28, 2014
79ee791
merging changes from mainwin
debris Oct 28, 2014
95a2c1a
merging changes from mainwin
debris Oct 28, 2014
7d24ae8
common changes
debris Oct 28, 2014
943d624
Merge branch 'develop' into mk_jsonrpc
debris Oct 28, 2014
8287012
Merge branch 'develop' into mk_jsonrpc
debris Oct 28, 2014
3462f60
whisper polling, not finished
debris Oct 29, 2014
bb5ba2d
whisper in js
debris Oct 29, 2014
bab05f0
whisper in alethzero
debris Oct 29, 2014
f5a9c9a
Merge branch 'develop' into mk_jsonrpc
debris Oct 30, 2014
f4af551
newkey signal
debris Oct 30, 2014
cab4784
common changes
debris Oct 30, 2014
53edf6d
make identity from alethzero
debris Oct 30, 2014
eb12c3c
javascript resources moved to separate target
debris Oct 30, 2014
5688ae4
fixed jsqrc cmake
debris Oct 30, 2014
0d353de
fixed libjsqrc cmake
debris Oct 30, 2014
617a8ae
Merge branch 'develop' into mk_jsonrpc
debris Oct 31, 2014
a014e77
applied changes from ethereum.js 5538ff725235f30a9afbbedc098fd18dfd9f…
debris Oct 31, 2014
aaf1bfc
style changes
debris Oct 31, 2014
c26e564
updated README.md
debris Oct 31, 2014
c2095d4
clientDieing is called QWebThree dealloc
debris Oct 31, 2014
fafd0ae
common fixes
debris Oct 31, 2014
cebfa35
license for setup.js
debris Oct 31, 2014
8c6af7f
m_qwebConnector is not a pointer
debris Oct 31, 2014
1bf6713
fixed cmake
debris Oct 31, 2014
2ee556e
fixed style issue
debris Oct 31, 2014
8a568f3
Merge branch 'develop' into mk_jsonrpc
debris Oct 31, 2014
8d1ad00
boost_auto_test_suite for jsonrpc && @brief description for WebThreeS…
debris Oct 31, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ipch
*.opensdf
*.suo

# VIM stuff
*.swp

#Xcode stuff
build_xc

Expand Down
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ endif()
add_subdirectory(lllc)
add_subdirectory(solc)
add_subdirectory(sc)
if (JSONRPC_LS)
add_subdirectory(libweb3jsonrpc)
endif()
if (NOT LANGUAGES)
add_subdirectory(secp256k1)
add_subdirectory(libp2p)
Expand Down Expand Up @@ -147,7 +150,11 @@ if (NOT LANGUAGES)
if ("${TARGET_PLATFORM}" STREQUAL "w64")
cmake_policy(SET CMP0020 NEW)
endif ()

if (NOT JSONRPC_LS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to if (NOT HEADLESS)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is correct as it is, if (NOT HEADLES) is checked earlier

message(FATAL_ERROR "Alethzero requires jsonrpc.")
endif()

add_subdirectory(libjsqrc)
add_subdirectory(libqethereum)
add_subdirectory(alethzero)
add_subdirectory(third)
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ All development goes in develop branch - please don't submit pull requests to ma

Please read [CodingStandards.txt](CodingStandards.txt) thoroughly before making alterations to the code base. Please do *NOT* use an editor that automatically reformats whitespace away from astylerc or the formatting guidelines as described in [CodingStandards.txt](CodingStandards.txt).

When altering eth/spec.json, mirror the changes to eth/eth.js. This should simply be cutting and pasting the relevant part from spec.json into eth.js. Don't alter the spec part from eth.js independently.
libweb3jsonrpc/abstractwebthreestubserver.h is autogenerated from the jsonrpcstub executable that comes with the libjsonrpc library (json-rpc-cpp project). It shouldn't be maually altered.

eth/abstractethstubserver.h is autogenerated from the jsonrpcstub executable that comes with the libjsonrpc library (json-rpc-cpp project). It shouldn't be maually altered.
```bash
jsonrpcstub -s -c spec.json WebThreeStub
```
2 changes: 1 addition & 1 deletion alethzero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ else ()
endif ()

qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)
target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore)
target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore devcrypto secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore web3jsonrpc jsqrc)

if (APPLE)
# First have qt5 install plugins and frameworks
Expand Down
76 changes: 42 additions & 34 deletions alethzero/MainWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <libserpent/funcs.h>
#include <libserpent/util.h>
#include <libdevcrypto/FileSystem.h>
#include <libdevcore/CommonJS.h>
#include <liblll/Compiler.h>
#include <liblll/CodeFragment.h>
#include <libevm/VM.h>
Expand All @@ -41,6 +42,7 @@
#include <libethereum/Client.h>
#include <libethereum/EthereumHost.h>
#include <libethereum/DownloadMan.h>
#include <libweb3jsonrpc/WebThreeStubServer.h>
#include "DownloadView.h"
#include "MiningView.h"
#include "BuildInfo.h"
Expand Down Expand Up @@ -83,6 +85,21 @@ static QString fromRaw(dev::h256 _n, unsigned* _inc = nullptr)
return QString();
}

static std::vector<dev::KeyPair> keysAsVector(QList<dev::KeyPair> const& keys)
{
auto list = keys.toStdList();
return {begin(list), end(list)};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit std::


static QString contentsOfQResource(std::string const& res)
{
QFile file(QString::fromStdString(res));
if (!file.open(QFile::ReadOnly))
BOOST_THROW_EXCEPTION(FileError());
QTextStream in(&file);
return in.readAll();
}

Address c_config = Address("661005d2720d855f1d9976f88bb10c1a3398c77f");

Main::Main(QWidget *parent) :
Expand Down Expand Up @@ -131,32 +148,28 @@ Main::Main(QWidget *parent) :
connect(ui->ourAccounts->model(), SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(ourAccountsRowsMoved()));

m_webThree.reset(new WebThreeDirect(string("AlethZero/v") + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), getDataDir() + "/AlethZero", false, {"eth", "shh"}));
m_ldb = new QLDB(this);

m_server = unique_ptr<WebThreeStubServer>(new WebThreeStubServer(&m_qwebConnector, *web3(), keysAsVector(m_myKeys)));
m_server->setIdentities(keysAsVector(owned()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please confirm: Is owned() keys+identities? Or should there be an identities() method? I don't believe shh and eth keys will be interchangeable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does do that for now, yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, owned() are keys+identities. I dont know if it is correct. It is the same as in develop branch

m_server->StartListening();

connect(ui->webView, &QWebView::loadStarted, [this]()
{
m_ethereum = nullptr;
m_whisper = nullptr;
// NOTE: no need to delete as QETH_INSTALL_JS_NAMESPACE adopts it.
m_dev = new QDev(this);
m_ethereum = new QEthereum(this, ethereum(), m_myKeys);
m_whisper = new QWhisper(this, whisper(), owned());
m_qweb = new QWebThree(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a conflict with m_qweb being re-allocated within loadStarted. That is, when main is deallocated it will call ->clientDieing() on m_qweb. However, QWebThree instances which are implicitly deallocated will not have clientDieing() called on them.
Can m_qweb be reset between loads instead of reallocated each load? If not, can clientDieing be called when it's deallocated or via a QWebView callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c2095d4 . clientDieing is now called when QWebView is deallocated

auto qweb = m_qweb;
m_qwebConnector.setQWeb(qweb);

QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
QWebFrame* f = ui->webView->page()->mainFrame();
f->disconnect(SIGNAL(javaScriptWindowObjectCleared()));
auto qdev = m_dev;
auto qeth = m_ethereum;
auto qshh = m_whisper;
auto qldb = m_ldb;
connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qdev, qeth, qshh, qldb));
connect(m_whisper, SIGNAL(newIdToAdd(QString)), this, SLOT(addNewId(QString)));
connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qweb));
connect(m_qweb, SIGNAL(onNewId(QString)), this, SLOT(addNewId(QString)));
});

connect(ui->webView, &QWebView::loadFinished, [=]()
{
m_ethereum->poll();
m_whisper->poll();
m_qweb->poll();
});

connect(ui->webView, &QWebView::titleChanged, [=]()
Expand All @@ -165,9 +178,7 @@ Main::Main(QWidget *parent) :
});

readSettings();

installWatches();

startTimer(100);

{
Expand All @@ -184,19 +195,17 @@ Main::~Main()
{
// Must do this here since otherwise m_ethereum'll be deleted (and therefore clearWatches() called by the destructor)
// *after* the client is dead.
m_ethereum->clientDieing();
m_whisper->faceDieing();

m_qweb->clientDieing();
g_logPost = simpleDebugOut;
writeSettings();
}

void Main::addNewId(QString _ids)
{
Secret _id = toSecret(_ids);
Secret _id = jsToSecret(_ids.toStdString());
KeyPair kp(_id);
m_myIdentities.push_back(kp);
m_whisper->setIdentities(owned());
m_server->setIdentities(keysAsVector(owned()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owned() returning keys+identities (see previous comment)

}

dev::p2p::NetworkPreferences Main::netPrefs() const
Expand Down Expand Up @@ -1056,10 +1065,8 @@ void Main::timerEvent(QTimerEvent*)
else
interval += 100;

if (m_ethereum)
m_ethereum->poll();
if (m_whisper)
m_whisper->poll();
if (m_qweb)
m_qweb->poll();

for (auto const& i: m_handlers)
if (ethereum()->checkWatch(i.first))
Expand Down Expand Up @@ -1182,8 +1189,9 @@ void Main::ourAccountsRowsMoved()
myKeys.push_back(i);
}
m_myKeys = myKeys;
if (m_ethereum)
m_ethereum->setAccounts(myKeys);

if (m_server.get())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: Line 47

m_server->setAccounts(keysAsVector(m_myKeys));
}

void Main::on_inject_triggered()
Expand Down Expand Up @@ -1629,7 +1637,6 @@ void Main::on_killBlockchain_triggered()
ui->net->setChecked(false);
web3()->stopNetwork();
ethereum()->killChain();
m_ethereum->setClient(ethereum());
readSettings(true);
installWatches();
refreshAll();
Expand Down Expand Up @@ -1785,7 +1792,6 @@ void Main::on_debug_clicked()
t.gasPrice = gasPrice();
t.gas = ui->gas->value();
t.data = m_data;
t.type = isCreation() ? Transaction::ContractCreation : Transaction::MessageCall;
t.receiveAddress = isCreation() ? Address() : fromString(ui->destination->currentText());
t.sign(s);
auto r = t.rlp();
Expand Down Expand Up @@ -2139,20 +2145,22 @@ void Main::on_post_clicked()
m.setPayload(dataFromText(ui->shhData->toPlainText()));
Public f = stringToPublic(ui->shhFrom->currentText());
Secret from;
if (m_whisper->ids().count(f))
from = m_whisper->ids().at(f);
if (m_server->ids().count(f))
from = m_server->ids().at(f);
whisper()->inject(m.seal(from, topicFromText(ui->shhTopic->toPlainText()), ui->shhTtl->value(), ui->shhWork->value()));
}

void Main::on_newIdentity_triggered()
{
m_whisper->makeIdentity();
KeyPair kp = KeyPair::create();
m_myIdentities.append(kp);
m_server->setIdentities(keysAsVector(owned()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owned() returning keys+identities (see previous comment)

}

void Main::refreshWhisper()
{
ui->shhFrom->clear();
for (auto i: m_whisper->ids())
for (auto i: m_server ->ids())
ui->shhFrom->addItem(QString::fromStdString(toHex(i.first.ref())));
}

Expand All @@ -2163,7 +2171,7 @@ void Main::refreshWhispers()
{
shh::Envelope const& e = w.second;
shh::Message m;
for (pair<Public, Secret> const& i: m_whisper->ids())
for (pair<Public, Secret> const& i: m_server->ids())
if (!!(m = e.open(i.second)))
break;
if (!m)
Expand Down
15 changes: 7 additions & 8 deletions alethzero/MainWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MessageFilter;
}}

class QQuickView;
class WebThreeStubServer;

struct WorldState
{
Expand Down Expand Up @@ -153,11 +154,10 @@ private slots:
void on_newIdentity_triggered();

void refreshWhisper();
void addNewId(QString);
void addNewId(QString _ids);

signals:
void poll();
void idsChanged();

private:
dev::p2p::NetworkPreferences netPrefs() const;
Expand All @@ -181,8 +181,6 @@ private slots:
void readSettings(bool _skipGeometry = false);
void writeSettings();

void keysChanged();

bool isCreation() const;
dev::u256 fee() const;
dev::u256 total() const;
Expand All @@ -193,6 +191,8 @@ private slots:
unsigned installWatch(dev::h256 _tf, std::function<void()> const& _f);
void uninstallWatch(unsigned _w);

void keysChanged();

void onNewPending();
void onNewBlock();
void onNameRegChange();
Expand Down Expand Up @@ -255,8 +255,7 @@ private slots:
QString m_logHistory;
bool m_logChanged = true;

QDev* m_dev = nullptr;
QEthereum* m_ethereum = nullptr;
QWhisper* m_whisper = nullptr;
QLDB* m_ldb = nullptr;
std::unique_ptr<WebThreeStubServer> m_server;
QWebThreeConnector m_qwebConnector;
QWebThree* m_qweb = nullptr;
};
1 change: 1 addition & 0 deletions alethzero/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Q_INIT_RESOURCE(js);
Main w;
w.show();

Expand Down
Loading