Fix Goerli syncing (#11604)
The Clique engine changes the header during the call to `check_and_lock_block()` and so when the block is committed we need to use the original header from the `PreverifiedBlock`, so we're back to cloning the `Header`. Fixes https://github.com/openethereum/openethereum/issues/11603
This commit is contained in:
parent
51e4a6dcbc
commit
b8e4f142d1
@ -297,6 +297,12 @@ impl Importer {
|
|||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
for (block, block_bytes) in blocks {
|
for (block, block_bytes) in blocks {
|
||||||
|
// Some engines may change the header such that the header hash
|
||||||
|
// is different in the LockedBlock from what it was in the
|
||||||
|
// PreverifiedBlock. When committing the block we need the
|
||||||
|
// header from the Preverified block and not the one from the
|
||||||
|
// LockedBlock. See https://github.com/openethereum/openethereum/issues/11603
|
||||||
|
let preverified_header = block.header.clone();
|
||||||
let hash = block.header.hash();
|
let hash = block.header.hash();
|
||||||
|
|
||||||
let is_invalid = invalid_blocks.contains(block.header.parent_hash());
|
let is_invalid = invalid_blocks.contains(block.header.parent_hash());
|
||||||
@ -310,7 +316,13 @@ impl Importer {
|
|||||||
imported_blocks.push(hash);
|
imported_blocks.push(hash);
|
||||||
let transactions_len = locked_block.transactions.len();
|
let transactions_len = locked_block.transactions.len();
|
||||||
let gas_used = *locked_block.header.gas_used();
|
let gas_used = *locked_block.header.gas_used();
|
||||||
let route = self.commit_block(locked_block, encoded::Block::new(block_bytes), pending, client);
|
let route = self.commit_block(
|
||||||
|
locked_block,
|
||||||
|
&preverified_header,
|
||||||
|
encoded::Block::new(block_bytes),
|
||||||
|
pending,
|
||||||
|
client
|
||||||
|
);
|
||||||
import_results.push(route);
|
import_results.push(route);
|
||||||
client.report.write().accrue_block(gas_used, transactions_len);
|
client.report.write().accrue_block(gas_used, transactions_len);
|
||||||
}
|
}
|
||||||
@ -488,6 +500,7 @@ impl Importer {
|
|||||||
fn commit_block<B>(
|
fn commit_block<B>(
|
||||||
&self,
|
&self,
|
||||||
block: B,
|
block: B,
|
||||||
|
header: &Header,
|
||||||
block_data: encoded::Block,
|
block_data: encoded::Block,
|
||||||
pending: Option<PendingTransition>,
|
pending: Option<PendingTransition>,
|
||||||
client: &Client
|
client: &Client
|
||||||
@ -495,7 +508,6 @@ impl Importer {
|
|||||||
where B: Drain
|
where B: Drain
|
||||||
{
|
{
|
||||||
let block = block.drain();
|
let block = block.drain();
|
||||||
let header = block.header;
|
|
||||||
let hash = &header.hash();
|
let hash = &header.hash();
|
||||||
let number = header.number();
|
let number = header.number();
|
||||||
let parent = header.parent_hash();
|
let parent = header.parent_hash();
|
||||||
@ -2412,6 +2424,7 @@ impl ImportSealedBlock for Client {
|
|||||||
)?;
|
)?;
|
||||||
let route = self.importer.commit_block(
|
let route = self.importer.commit_block(
|
||||||
block,
|
block,
|
||||||
|
&header,
|
||||||
encoded::Block::new(block_bytes),
|
encoded::Block::new(block_bytes),
|
||||||
pending,
|
pending,
|
||||||
self
|
self
|
||||||
|
Loading…
Reference in New Issue
Block a user