-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
@@ -1081,11 +1080,11 @@ impl BlockChain { | |||
let mut best_block = self.pending_best_block.write(); | |||
if is_best && update.info.location != BlockLocation::Branch { | |||
batch.put(db::COL_EXTRA, b"best", &update.info.hash); | |||
let block = encoded::Block::new(update.block.to_vec()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entire block was copied here
@@ -116,8 +116,6 @@ pub struct ExecutedBlock { | |||
pub traces: Tracing, | |||
/// Hashes of last 256 blocks. | |||
pub last_hashes: Arc<LastHashes>, | |||
/// Finalization flag. | |||
pub is_finalized: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag is completely redundant and is never set to true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're going to use it #9113? cc @andresilva
I think we won't implement Casper again in the short terms, so some of the #8401 refactorings might use a better interface. But I do think allowing finalized block is a feature that we may use in other engines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I see correctly, it's not used by #9113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right. Aura only finalize ancestry blocks so it only needs BlockChain::mark_finalized
. However, do we want to support instant finalization for some of our engines in the future? That's where we will need this flag.
I'm not sure whether POC-1 engine (which will replace the current Tendermint engine) will need this. The spec do mention instant finality. But I'm not really familiar with the algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, do we want to support instant finalization for some of our engines in the future? That's where we will need this flag.
Than we should add this flag in the future. Imo, we shouldn't keep in our codebase anything that is not used right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say I fully agree with this, but it sounds okay to me. 👍
Based on the above rationale, however, another thing we need to remove is metadata (https://github.com/paritytech/parity/blob/21d3de236005732253dee442cfbcb52ebcbbc1e7/ethcore/src/block.rs#L119 and https://github.com/paritytech/parity/blob/21d3de236005732253dee442cfbcb52ebcbbc1e7/ethcore/src/blockchain/extras.rs#L155). Also introduced by #8401, but not used by current engines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metadata removed! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this field as well:
Metadata or finalization has not been set by anyone, so we can just change the !is_short_version
to be 5 RLP fields. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ;)
} | ||
} | ||
|
||
impl ::parity_machine::WithMetadata for ExecutedBlock { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this interface is never used
@@ -477,8 +447,8 @@ impl<'x> OpenBlock<'x> { | |||
if s.block.header.transactions_root().is_zero() || s.block.header.transactions_root() == &KECCAK_NULL_RLP { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also get rid of these checks, cause they may lead to invalid blocks being produced. e.g
let closed_block = open_block.close();
let reopened_block = closed_block.reopen(engine);
reopened_block.push_transactions(transactions);
// close_and_lock is not recalculating `transactions_root`
let locked_block = reopened_block.close_and_lock();
@@ -298,7 +297,7 @@ impl Importer { | |||
|
|||
let transactions_len = closed_block.transactions().len(); | |||
|
|||
let route = self.commit_block(closed_block, &header, &bytes, client); | |||
let route = self.commit_block(closed_block, &header, encoded::Block::new(bytes), client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in future, I'd like this function (and blockchain.rs functions) to take as argument some MetaBlock
that contains both plain block and it's encoded version. Currently we are encoding and then decoding stuff that we just encoded. That's not efficient
// Final commit to the DB | ||
db.write_buffered(batch); | ||
chain.commit(); | ||
} | ||
db.flush().expect("DB flush failed."); | ||
Ok(hash) | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this value was never used, therefore not needed
ethcore/src/blockchain/extras.rs
Outdated
@@ -180,7 +177,8 @@ impl rlp::Decodable for BlockDetails { | |||
fn decode(rlp: &rlp::Rlp) -> Result<Self, rlp::DecoderError> { | |||
let use_short_version = match rlp.item_count()? { | |||
4 => true, | |||
6 => false, | |||
// 6, cause we used to store metadata | |||
5 | 6 => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to keep database backwards compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine but I think we actually never had any 6
cases up to this point. 6
is possible after the Aura finality PR is merged. Right now we don't have any. It's also not possible to use any custom chain spec to reach the 6
case.
The only case where 6
was used is in #8654, but we're not using that code in the short-term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set this to 5
? This was added recently and was only used in Casper FFG (which was never merged).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (but it looks like CI is broken right now!).
A final comment is on this:
The term "metadata" is used because I used to call two fields is_finalized
and metadata
with a combined term "metadata". I think we can keep that because we still use is_finalized
as a metadata. But just a note in case.
ethcore/src/blockchain/extras.rs
Outdated
@@ -180,7 +177,8 @@ impl rlp::Decodable for BlockDetails { | |||
fn decode(rlp: &rlp::Rlp) -> Result<Self, rlp::DecoderError> { | |||
let use_short_version = match rlp.item_count()? { | |||
4 => true, | |||
6 => false, | |||
// 6, cause we used to store metadata | |||
5 | 6 => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine but I think we actually never had any 6
cases up to this point. 6
is possible after the Aura finality PR is merged. Right now we don't have any. It's also not possible to use any custom chain spec to reach the 6
case.
The only case where 6
was used is in #8654, but we're not using that code in the short-term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on the cleanup and removing unnecessary copies. I have some mixed feelings about some of the stuff that was removed regarding finality and metadata that was just recently added by @sorpaas. We will need instant finality support if we want to integrate rhododendron. But I agree that we can re-add this when we need it (and also make it better since it will be the 2nd implementation 😉). LGTM, just a minor nit on BlockDetails
rlp decoding.
ethcore/src/blockchain/extras.rs
Outdated
@@ -180,7 +177,8 @@ impl rlp::Decodable for BlockDetails { | |||
fn decode(rlp: &rlp::Rlp) -> Result<Self, rlp::DecoderError> { | |||
let use_short_version = match rlp.item_count()? { | |||
4 => true, | |||
6 => false, | |||
// 6, cause we used to store metadata | |||
5 | 6 => false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set this to 5
? This was added recently and was only used in Casper FFG (which was never merged).
@andresilva please check the pr again and approve/reject changes |
🎉 |
* 'master' of https://github.com/paritytech/parity: removed client error (openethereum#9253) Implement EIP-1052 (EXTCODEHASH) and fix several issues in state account cache (openethereum#9234) Improve Tracer documentation (openethereum#9237) Update Dockerfile (openethereum#9242) block cleanup (openethereum#9117) Increase the number of sessions. (openethereum#9203) add changelog for 1.11.8 stable and 2.0.1 beta (openethereum#9230) fix typo (openethereum#9232) Fix potential as_usize overflow when casting from U256 in miner (openethereum#9221) Allow old blocks from peers with lower difficulty (openethereum#9226) Removes duplicate libudev-dev from Dockerfile (openethereum#9220) snap: remove ssl dependencies from snapcraft definition (openethereum#9222) remove ssl from dockerfiles, closes openethereum#8880 (openethereum#9195) Insert PROOF messages for some cases in blockchain (openethereum#9141) [Chain] Add more bootnodes (openethereum#9174) ethcore: update bn version (openethereum#9217) deserialize block only once during verification (openethereum#9161) Simple build instruction fix (openethereum#9215) Added --tx-queue-no-early-reject flag to disable early tx queue rejects (openethereum#9143)
the goal of this pr is to reduce number of times block data is copied or hashed