Skip to content

Commit

Permalink
Revert non functional modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Oct 31, 2024
1 parent 2f8159f commit 0f959fc
Show file tree
Hide file tree
Showing 40 changed files with 499 additions and 506 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
merge_group:
push:
branches: [v1.1.0-taiko]
branches: [main]

env:
CARGO_TERM_COLOR: always
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: book

on:
push:
branches: [v1.1.0-taiko]
branches: [main]
pull_request:
branches: [v1.1.0-taiko]
branches: [main]
merge_group:

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deny.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ name: deny

on:
push:
branches: [v1.1.0-taiko]
branches: [main]
paths: [Cargo.lock]
pull_request:
branches: [v1.1.0-taiko]
branches: [main]
paths: [Cargo.lock]
merge_group:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
merge_group:
push:
branches: [v1.1.0-taiko]
branches: [main]

env:
CARGO_TERM_COLOR: always
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
merge_group:
push:
branches: [v1.1.0-taiko]
branches: [main]

env:
CARGO_TERM_COLOR: always
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
merge_group:
push:
branches: [v1.1.0-taiko]
branches: [main]

env:
CARGO_TERM_COLOR: always
Expand Down
6 changes: 3 additions & 3 deletions crates/blockchain-tree/src/block_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl BlockIndices {
added.push(new.into());
new_hash = new_hashes.next();
}
break;
break
};
let Some(new_block_value) = new_hash else {
// Old canonical chain had more block than new chain.
Expand All @@ -164,7 +164,7 @@ impl BlockIndices {
removed.push(rem);
old_hash = old_hashes.next();
}
break;
break
};
// compare old and new canonical block number
match new_block_value.0.cmp(&old_block_value.0) {
Expand Down Expand Up @@ -251,7 +251,7 @@ impl BlockIndices {
/// It is assumed that blocks are interconnected and that they connect to canonical chain
pub fn canonicalize_blocks(&mut self, blocks: &BTreeMap<BlockNumber, SealedBlockWithSenders>) {
if blocks.is_empty() {
return;
return
}

// Remove all blocks from canonical chain
Expand Down
62 changes: 31 additions & 31 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ where
) -> Result<Option<BlockStatus>, InsertBlockErrorKind> {
// check if block is canonical
if self.is_block_hash_canonical(&block.hash)? {
return Ok(Some(BlockStatus::Valid(BlockAttachment::Canonical)));
return Ok(Some(BlockStatus::Valid(BlockAttachment::Canonical)))
}

let last_finalized_block = self.block_indices().last_finalized_block();
// check db if block is finalized.
if block.number <= last_finalized_block {
// check if block is inside database
if self.externals.provider_factory.provider()?.block_number(block.hash)?.is_some() {
return Ok(Some(BlockStatus::Valid(BlockAttachment::Canonical)));
return Ok(Some(BlockStatus::Valid(BlockAttachment::Canonical)))
}

#[cfg(not(feature = "taiko"))]
Expand All @@ -204,15 +204,15 @@ where

// is block inside chain
if let Some(attachment) = self.is_block_inside_sidechain(&block) {
return Ok(Some(BlockStatus::Valid(attachment)));
return Ok(Some(BlockStatus::Valid(attachment)))
}

// check if block is disconnected
if let Some(block) = self.state.buffered_blocks.block(&block.hash) {
return Ok(Some(BlockStatus::Disconnected {
head: self.state.block_indices.canonical_tip(),
missing_ancestor: block.parent_num_hash(),
}));
}))
}

Ok(None)
Expand Down Expand Up @@ -288,7 +288,7 @@ where
let Some((first_pending_block_number, _)) = parent_block_hashes.first_key_value()
else {
debug!(target: "blockchain_tree", ?chain_id, "No block hashes stored");
return None;
return None
};
let canonical_chain = canonical_chain
.iter()
Expand All @@ -298,7 +298,7 @@ where

// get canonical fork.
let canonical_fork = self.canonical_fork(chain_id)?;
return Some(ExecutionData { execution_outcome, parent_block_hashes, canonical_fork });
return Some(ExecutionData { execution_outcome, parent_block_hashes, canonical_fork })
}

// check if there is canonical block
Expand All @@ -308,7 +308,7 @@ where
canonical_fork: ForkBlock { number: canonical_number, hash: block_hash },
execution_outcome: ExecutionOutcome::default(),
parent_block_hashes: canonical_chain.inner().clone(),
});
})
}

None
Expand All @@ -331,12 +331,12 @@ where
// check if block parent can be found in any side chain.
if let Some(chain_id) = self.block_indices().get_block_chain_id(&parent.hash) {
// found parent in side tree, try to insert there
return self.try_insert_block_into_side_chain(block, chain_id, block_validation_kind);
return self.try_insert_block_into_side_chain(block, chain_id, block_validation_kind)
}

// if not found, check if the parent can be found inside canonical chain.
if self.is_block_hash_canonical(&parent.hash)? {
return self.try_append_canonical_chain(block.clone(), block_validation_kind);
return self.try_append_canonical_chain(block.clone(), block_validation_kind)
}

// this is another check to ensure that if the block points to a canonical block its block
Expand All @@ -350,7 +350,7 @@ where
parent_block_number: canonical_parent_number,
block_number: block.number,
}
.into());
.into())
}
}

Expand Down Expand Up @@ -411,7 +411,7 @@ where
return Err(BlockExecutionError::Validation(BlockValidationError::BlockPreMerge {
hash: block.hash(),
})
.into());
.into())
}

let parent_header = provider
Expand Down Expand Up @@ -549,7 +549,7 @@ where
} else {
// if there is no fork block that point to other chains, break the loop.
// it means that this fork joins to canonical block.
break;
break
}
}
hashes
Expand All @@ -570,9 +570,9 @@ where
// get fork block chain
if let Some(fork_chain_id) = self.block_indices().get_block_chain_id(&fork.hash) {
chain_id = fork_chain_id;
continue;
continue
}
break;
break
}
(self.block_indices().canonical_hash(&fork.number) == Some(fork.hash)).then_some(fork)
}
Expand Down Expand Up @@ -687,7 +687,7 @@ where
pub fn buffer_block(&mut self, block: SealedBlockWithSenders) -> Result<(), InsertBlockError> {
// validate block consensus rules
if let Err(err) = self.validate_block(&block) {
return Err(InsertBlockError::consensus_error(err, block.block));
return Err(InsertBlockError::consensus_error(err, block.block))
}

self.state.buffered_blocks.insert_block(block);
Expand All @@ -705,17 +705,17 @@ where
"Failed to validate total difficulty for block {}: {e}",
block.header.hash()
);
return Err(e);
return Err(e)
}

if let Err(e) = self.externals.consensus.validate_header(block) {
error!(?block, "Failed to validate header {}: {e}", block.header.hash());
return Err(e);
return Err(e)
}

if let Err(e) = self.externals.consensus.validate_block_pre_execution(block) {
error!(?block, "Failed to validate block {}: {e}", block.header.hash());
return Err(e);
return Err(e)
}

Ok(())
Expand All @@ -740,7 +740,7 @@ where
Some(BlockAttachment::Canonical)
} else {
Some(BlockAttachment::HistoricalFork)
};
}
}
None
}
Expand Down Expand Up @@ -781,7 +781,7 @@ where

// validate block consensus rules
if let Err(err) = self.validate_block(&block) {
return Err(InsertBlockError::consensus_error(err, block.block));
return Err(InsertBlockError::consensus_error(err, block.block))
}

let status = self
Expand Down Expand Up @@ -988,7 +988,7 @@ where
}

if header.is_none() && self.sidechain_block_by_hash(*hash).is_some() {
return Ok(None);
return Ok(None)
}

if header.is_none() {
Expand Down Expand Up @@ -1051,18 +1051,18 @@ where
{
return Err(CanonicalError::from(BlockValidationError::BlockPreMerge {
hash: block_hash,
}));
}))
}

let head = self.state.block_indices.canonical_tip();
return Ok(CanonicalOutcome::AlreadyCanonical { header, head });
return Ok(CanonicalOutcome::AlreadyCanonical { header, head })
}

let Some(chain_id) = self.block_indices().get_block_chain_id(&block_hash) else {
debug!(target: "blockchain_tree", ?block_hash, "Block hash not found in block indices");
return Err(CanonicalError::from(BlockchainTreeError::BlockHashNotFoundInChain {
block_hash,
}));
}))
};

// we are splitting chain at the block hash that we want to make canonical
Expand Down Expand Up @@ -1246,7 +1246,7 @@ where
block_number: tip.number,
block_hash: tip.hash(),
}))
.into());
.into())
}
self.metrics.trie_updates_insert_recomputed.increment(1);
trie_updates
Expand Down Expand Up @@ -1275,7 +1275,7 @@ where
pub fn unwind(&mut self, unwind_to: BlockNumber) -> Result<(), CanonicalError> {
// nothing to be done if unwind_to is higher then the tip
if self.block_indices().canonical_tip().number <= unwind_to {
return Ok(());
return Ok(())
}
// revert `N` blocks from current canonical chain and put them inside BlockchainTree
let old_canon_chain = self.revert_canonical_from_database(unwind_to)?;
Expand Down Expand Up @@ -1309,15 +1309,15 @@ where
.provider_factory
.static_file_provider()
.get_highest_static_file_block(StaticFileSegment::Headers)
.unwrap_or_default()
> revert_until
.unwrap_or_default() >
revert_until
{
trace!(
target: "blockchain_tree",
"Reverting optimistic canonical chain to block {}",
revert_until
);
return Err(CanonicalError::OptimisticTargetRevert(revert_until));
return Err(CanonicalError::OptimisticTargetRevert(revert_until))
}

// read data that is needed for new sidechain
Expand Down Expand Up @@ -1614,8 +1614,8 @@ mod tests {
signer,
(
AccountInfo {
balance: initial_signer_balance
- (single_tx_cost * U256::from(num_of_signer_txs)),
balance: initial_signer_balance -
(single_tx_cost * U256::from(num_of_signer_txs)),
nonce: num_of_signer_txs,
..Default::default()
},
Expand Down
4 changes: 2 additions & 2 deletions crates/blockchain-tree/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl TreeState {
/// Caution: This will not return blocks from the canonical chain.
pub(crate) fn receipts_by_block_hash(&self, block_hash: BlockHash) -> Option<Vec<&Receipt>> {
let id = self.block_indices.get_block_chain_id(&block_hash)?;
let chain: &AppendableChain = self.chains.get(&id)?;
let chain = self.chains.get(&id)?;
chain.receipts_by_block_hash(block_hash)
}

Expand All @@ -87,7 +87,7 @@ impl TreeState {
/// Inserts a chain into the tree and builds the block indices.
pub(crate) fn insert_chain(&mut self, chain: AppendableChain) -> Option<BlockchainId> {
if chain.is_empty() {
return None;
return None
}
let chain_id = self.next_id();

Expand Down
10 changes: 5 additions & 5 deletions crates/consensus/auto-seal/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where
if this.insert_task.is_none() {
if this.queued.is_empty() {
// nothing to insert
break;
break
}

// ready to queue in new insert task
Expand Down Expand Up @@ -172,18 +172,18 @@ where
ForkchoiceStatus::Valid => break,
ForkchoiceStatus::Invalid => {
error!(target: "consensus::auto", ?fcu_response, "Forkchoice update returned invalid response");
return None;
return None
}
ForkchoiceStatus::Syncing => {
debug!(target: "consensus::auto", ?fcu_response, "Forkchoice update returned SYNCING, waiting for VALID");
// wait for the next fork choice update
continue;
continue
}
}
}
Err(err) => {
error!(target: "consensus::auto", %err, "Autoseal fork choice update failed");
return None;
return None
}
}
}
Expand All @@ -209,7 +209,7 @@ where
}
Poll::Pending => {
this.insert_task = Some(fut);
break;
break
}
}
}
Expand Down
Loading

0 comments on commit 0f959fc

Please sign in to comment.