Browse Source

Fixups for blooms and crashes.

cl-refactor
Gav Wood 10 years ago
parent
commit
fef48ad83b
  1. 24
      alethzero/MainWin.cpp
  2. 19
      libethereum/BlockChain.cpp
  3. 7
      libethereum/Client.cpp
  4. 2
      libethereum/LogFilter.cpp
  5. 4
      libevm/ExtVMFace.h

24
alethzero/MainWin.cpp

@ -1012,7 +1012,7 @@ void Main::refreshBlockChain()
h256 h(f.toStdString());
if (bc.isKnown(h))
blocks.insert(h);
for (auto const& b: bc.withBlockBloom(LogBloom().shiftBloom<3, 32>(sha3(h)), 0, -1))
for (auto const& b: bc.withBlockBloom(LogBloom().shiftBloom<3>(sha3(h)), 0, -1))
blocks.insert(bc.numberHash(b));
}
else if (f.toLongLong() <= bc.number())
@ -1020,7 +1020,7 @@ void Main::refreshBlockChain()
else if (f.size() == 40)
{
Address h(f.toStdString());
for (auto const& b: bc.withBlockBloom(LogBloom().shiftBloom<3, 32>(sha3(h)), 0, -1))
for (auto const& b: bc.withBlockBloom(LogBloom().shiftBloom<3>(sha3(h)), 0, -1))
blocks.insert(bc.numberHash(b));
}
@ -1351,7 +1351,7 @@ void Main::on_blocks_currentItemChanged()
s << "<h3>" << h << "</h3>";
s << "<h4>#" << info.number;
s << "&nbsp;&emsp;&nbsp;<b>" << timestamp << "</b></h4>";
s << "<br/>D/TD: <b>2^" << log2((double)info.difficulty) << "</b>/<b>2^" << log2((double)details.totalDifficulty) << "</b>";
s << "<br/>D/TD: <b>" << info.difficulty << "</b>/<b>" << details.totalDifficulty << "</b> = 2^" << log2((double)info.difficulty) << "/2^" << log2((double)details.totalDifficulty);
s << "&nbsp;&emsp;&nbsp;Children: <b>" << details.children.size() << "</b></h5>";
s << "<br/>Gas used/limit: <b>" << info.gasUsed << "</b>/<b>" << info.gasLimit << "</b>";
s << "<br/>Coinbase: <b>" << pretty(info.coinbaseAddress).toHtmlEscaped().toStdString() << "</b> " << info.coinbaseAddress;
@ -1364,10 +1364,13 @@ void Main::on_blocks_currentItemChanged()
{
auto e = Ethasher::eval(info);
s << "<br/>Proof-of-Work: <b>" << e.value << " &lt;= " << (h256)u256((bigint(1) << 256) / info.difficulty) << "</b> (mixhash: " << e.mixHash.abridged() << ")";
s << "<br/>Parent: <b>" << info.parentHash << "</b>";
}
else
{
s << "<br/>Proof-of-Work: <i>Phil has nothing to prove</i>";
s << "<br/>Parent: <b>" << info.parentHash << "</b>";
s << "<br/>Parent: <i>It was a virgin birth</i>";
}
// s << "<br/>Bloom: <b>" << details.bloom << "</b>";
s << "<br/>Log Bloom: <b>" << info.logBloom << "</b>";
s << "<br/>Transactions: <b>" << block[1].itemCount() << "</b> @<b>" << info.transactionsRoot << "</b>";
@ -1426,15 +1429,12 @@ void Main::on_blocks_currentItemChanged()
s << "<br/>R: <b>" << hex << nouppercase << tx.signature().r << "</b>";
s << "<br/>S: <b>" << hex << nouppercase << tx.signature().s << "</b>";
s << "<br/>Msg: <b>" << tx.sha3(eth::WithoutSignature) << "</b>";
if (tx.isCreation())
if (!tx.data().empty())
{
if (tx.data().size())
if (tx.isCreation())
s << "<h4>Code</h4>" << disassemble(tx.data());
}
else
{
if (tx.data().size())
s << dev::memDump(tx.data(), 16, true);
else
s << "<h4>Data</h4>" << dev::memDump(tx.data(), 16, true);
}
s << "<div>Hex: " Span(Mono) << toHex(block[1][txi].data()) << "</span></div>";
s << "<hr/>";
@ -1442,7 +1442,7 @@ void Main::on_blocks_currentItemChanged()
auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "</span></div>";
s << renderDiff(ethereum()->diff(txi, h));
s << "<h4>Diff</h4>" << renderDiff(ethereum()->diff(txi, h));
ui->debugCurrent->setEnabled(true);
ui->debugDumpState->setEnabled(true);
ui->debugDumpStatePre->setEnabled(true);

19
libethereum/BlockChain.cpp

@ -324,20 +324,22 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db)
WriteGuard l(x_blockHashes);
m_blockHashes[h256(bi.number)].value = newHash;
}
h256s alteredBlooms;
{
WriteGuard l(x_blocksBlooms);
LogBloom blockBloom = bi.logBloom;
blockBloom.shiftBloom<3, 32>(sha3(bi.coinbaseAddress.ref()));
blockBloom.shiftBloom<3>(sha3(bi.coinbaseAddress.ref()));
unsigned index = (unsigned)bi.number;
for (unsigned level = 0; level < c_bloomIndexLevels; level++, index /= c_bloomIndexSize)
{
unsigned i = index / c_bloomIndexSize % c_bloomIndexSize;
unsigned i = index / c_bloomIndexSize;
unsigned o = index % c_bloomIndexSize;
m_blocksBlooms[chunkId(level, i)].blooms[o] |= blockBloom;
alteredBlooms.push_back(chunkId(level, i));
m_blocksBlooms[alteredBlooms.back()].blooms[o] |= blockBloom;
}
}
// Collate transaction hashes and remember who they were.
h256s tas;
h256s newTransactionAddresses;
{
RLP blockRLP(_block);
TransactionAddress ta;
@ -345,8 +347,8 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db)
WriteGuard l(x_transactionAddresses);
for (ta.index = 0; ta.index < blockRLP[1].itemCount(); ++ta.index)
{
tas.push_back(sha3(blockRLP[1][ta.index].data()));
m_transactionAddresses[tas.back()] = ta;
newTransactionAddresses.push_back(sha3(blockRLP[1][ta.index].data()));
m_transactionAddresses[newTransactionAddresses.back()] = ta;
}
}
{
@ -369,11 +371,12 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db)
m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[newHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(bi.parentHash, ExtraDetails), (ldb::Slice)dev::ref(m_details[bi.parentHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(h256(bi.number), ExtraBlockHash), (ldb::Slice)dev::ref(m_blockHashes[h256(bi.number)].rlp()));
for (auto const& h: tas)
for (auto const& h: newTransactionAddresses)
m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraTransactionAddress), (ldb::Slice)dev::ref(m_transactionAddresses[h].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraLogBlooms), (ldb::Slice)dev::ref(m_logBlooms[newHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraReceipts), (ldb::Slice)dev::ref(m_receipts[newHash].rlp()));
m_extrasDB->Put(m_writeOptions, toSlice(newHash, ExtraBlocksBlooms), (ldb::Slice)dev::ref(m_blocksBlooms[newHash].rlp()));
for (auto const& h: alteredBlooms)
m_extrasDB->Put(m_writeOptions, toSlice(h, ExtraBlocksBlooms), (ldb::Slice)dev::ref(m_blocksBlooms[h].rlp()));
}
#if ETH_PARANOIA

7
libethereum/Client.cpp

@ -846,10 +846,13 @@ TransactionHashes Client::transactionHashes(h256 _blockHash) const
LocalisedLogEntries Client::logs(unsigned _watchId) const
{
LogFilter f;
try {
try
{
Guard l(m_filterLock);
f = m_filters.at(m_watches.at(_watchId).id).filter;
} catch (...) {
}
catch (...)
{
return LocalisedLogEntries();
}
return logs(f);

2
libethereum/LogFilter.cpp

@ -79,7 +79,7 @@ vector<LogBloom> LogFilter::bloomPossibilities() const
vector<LogBloom> ret;
// TODO proper combinatorics.
for (auto i: m_addresses)
ret.push_back(LogBloom().shiftBloom<3, 32>(dev::sha3(i)));
ret.push_back(LogBloom().shiftBloom<3>(dev::sha3(i)));
return ret;
}

4
libevm/ExtVMFace.h

@ -47,9 +47,9 @@ struct LogEntry
LogBloom bloom() const
{
LogBloom ret;
ret.shiftBloom<3, 32>(sha3(address.ref()));
ret.shiftBloom<3>(sha3(address.ref()));
for (auto t: topics)
ret.shiftBloom<3, 32>(sha3(t.ref()));
ret.shiftBloom<3>(sha3(t.ref()));
return ret;
}

Loading…
Cancel
Save