diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index ff04428ae..630006698 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -200,6 +200,7 @@ Main::Main(QWidget *parent) : #endif cerr << "State root: " << BlockInfo::genesis().stateRoot << endl << "Block Hash: " << sha3(BlockInfo::createGenesisBlock()) << endl << "Block RLP: " << RLP(BlockInfo::createGenesisBlock()) << endl << "Block Hex: " << toHex(BlockInfo::createGenesisBlock()) << endl; + cerr << "Network protocol version: " << eth::c_protocolVersion << endl; ui->configDock->close(); diff --git a/libethcore/TrieDB.h b/libethcore/TrieDB.h index ad19ef275..35aecdcb7 100644 --- a/libethcore/TrieDB.h +++ b/libethcore/TrieDB.h @@ -191,10 +191,13 @@ public: } if (!(rlp.isList() && (rlp.itemCount() == 2 || rlp.itemCount() == 17))) { + cwarn << "BIG FAT ERROR. STATE TRIE CORRUPTED!!!!!"; cdebug << b.rlp.size() << toHex(b.rlp); cdebug << rlp; auto c = rlp.itemCount(); cdebug << c; + m_that = nullptr; + return; assert(rlp.isList() && (rlp.itemCount() == 2 || rlp.itemCount() == 17)); } if (rlp.itemCount() == 2) diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 36a75064a..72ad36346 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -158,9 +158,14 @@ struct CachedAddressState std::map ret; if (r) { + cdebug << "MemDB: " << r[2].toHash(); TrieDB memdb(const_cast(o), r[2].toHash()); // promise we won't alter the overlay! :) + cdebug << memdb.root(); for (auto const& j: memdb) + { + cdebug << j.first; ret[j.first] = RLP(j.second).toInt(); + } } if (s) for (auto const& j: s->storage()) diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index f0bfbe6df..2c4925e4c 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -256,6 +256,7 @@ void QEthereum::setup(QWebFrame* _e) _e->evaluateJavaScript("String.prototype.unbin = function(l) { return eth.fromBinary(this) }"); _e->evaluateJavaScript("String.prototype.unpad = function(l) { return eth.unpad(this) }"); _e->evaluateJavaScript("String.prototype.dec = function() { return eth.toDecimal(this) }"); + _e->evaluateJavaScript("String.prototype.sha3 = function() { return eth.sha3(this) }"); } void QEthereum::teardown(QWebFrame*) @@ -274,11 +275,21 @@ QString QEthereum::lll(QString _s) const return asQString(ret); } +QString QEthereum::sha3(QString _s) const +{ + return toQJS(eth::sha3(asBytes(_s))); +} + QString QEthereum::coinbase() const { return toQJS(client()->address()); } +QString QEthereum::number() const +{ + return QString::number(client()->blockChain().number() + 1); +} + QString QEthereum::account() const { if (m_accounts.empty()) diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h index 1387731c1..37064ef2c 100644 --- a/libqethereum/QEthereum.h +++ b/libqethereum/QEthereum.h @@ -375,6 +375,7 @@ public: Q_INVOKABLE QString secretToAddress(QString _s) const; Q_INVOKABLE QString lll(QString _s) const; + Q_INVOKABLE QString sha3(QString _s) const; Q_INVOKABLE QString pad(QString _s, unsigned _l) const { return padded(_s, _l); } Q_INVOKABLE QString pad(QString _s, unsigned _l, unsigned _r) const { return padded(_s, _l, _r); } Q_INVOKABLE QString unpad(QString _s) const { return unpadded(_s); } @@ -396,6 +397,7 @@ public: QString/*eth::Address*/ coinbase() const; QString/*eth::u256*/ gasPrice() const { return toQJS(10 * eth::szabo); } + QString number() const; eth::u256 balanceAt(eth::Address _a) const; double txCountAt(eth::Address _a) const; bool isContractAt(eth::Address _a) const; @@ -418,6 +420,7 @@ signals: // void miningChanged(); private: + Q_PROPERTY(QString number READ number NOTIFY changed) Q_PROPERTY(QString coinbase READ coinbase WRITE setCoinbase NOTIFY changed) Q_PROPERTY(bool listening READ isListening WRITE setListening) Q_PROPERTY(bool mining READ isMining WRITE setMining)