Browse Source

Avoid crash over trie dodginess.

cl-refactor
Gav Wood 11 years ago
parent
commit
bfa4c8fbe4
  1. 1
      alethzero/MainWin.cpp
  2. 3
      libethcore/TrieDB.h
  3. 5
      libethereum/State.cpp
  4. 11
      libqethereum/QEthereum.cpp
  5. 3
      libqethereum/QEthereum.h

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

3
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)

5
libethereum/State.cpp

@ -158,9 +158,14 @@ struct CachedAddressState
std::map<u256, u256> ret;
if (r)
{
cdebug << "MemDB: " << r[2].toHash<h256>();
TrieDB<h256, Overlay> memdb(const_cast<Overlay*>(o), r[2].toHash<h256>()); // 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<u256>();
}
}
if (s)
for (auto const& j: s->storage())

11
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())

3
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)

Loading…
Cancel
Save