Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Jan 25, 2024
1 parent 3033f41 commit 1e50f4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions dan_layer/consensus/src/hotstuff/on_receive_local_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ impl<TConsensusSpec: ConsensusSpec> OnReceiveLocalProposalHandler<TConsensusSpec
let local_committee_shard = self.epoch_manager.get_local_committee_shard(block.epoch()).await?;

let maybe_high_qc_and_block = self.store.with_write_tx(|tx| {
let Some(valid_block) =
self.validate_block(tx.deref_mut(), block, &local_committee, &local_committee_shard)?
else {
let Some(valid_block) = self.validate_block(tx, block, &local_committee, &local_committee_shard)? else {
return Ok(None);
};

Expand Down Expand Up @@ -161,7 +159,7 @@ impl<TConsensusSpec: ConsensusSpec> OnReceiveLocalProposalHandler<TConsensusSpec

fn validate_block(
&self,
tx: &mut <TConsensusSpec::StateStore as StateStore>::ReadTransaction<'_>,
tx: &mut <TConsensusSpec::StateStore as StateStore>::WriteTransaction<'_>,
block: Block,
local_committee: &Committee<TConsensusSpec::Addr>,
local_committee_shard: &CommitteeShard,
Expand Down Expand Up @@ -258,12 +256,12 @@ impl<TConsensusSpec: ConsensusSpec> OnReceiveLocalProposalHandler<TConsensusSpec
#[allow(clippy::too_many_lines)]
fn validate_local_proposed_block(
&self,
tx: &mut <TConsensusSpec::StateStore as StateStore>::ReadTransaction<'_>,
tx: &mut <TConsensusSpec::StateStore as StateStore>::WriteTransaction<'_>,
candidate_block: Block,
local_committee: &Committee<TConsensusSpec::Addr>,
local_committee_shard: &CommitteeShard,
) -> Result<ValidBlock, HotStuffError> {
if Block::has_been_processed(tx, candidate_block.id())? {
if Block::has_been_processed(tx.deref_mut(), candidate_block.id())? {
return Err(ProposalValidationError::BlockAlreadyProcessed {
block_id: *candidate_block.id(),
height: candidate_block.height(),
Expand All @@ -272,7 +270,7 @@ impl<TConsensusSpec: ConsensusSpec> OnReceiveLocalProposalHandler<TConsensusSpec
}

// Check that details included in the justify match previously added blocks
let Some(justify_block) = candidate_block.justify().get_block(tx).optional()? else {
let Some(justify_block) = candidate_block.justify().get_block(tx.deref_mut()).optional()? else {
// This will trigger a sync
return Err(ProposalValidationError::JustifyBlockNotFound {
proposed_by: candidate_block.proposed_by().to_string(),
Expand Down Expand Up @@ -360,7 +358,7 @@ impl<TConsensusSpec: ConsensusSpec> OnReceiveLocalProposalHandler<TConsensusSpec

// Now that we have all dummy blocks (if any) in place, we can check if the candidate block is safe.
// Specifically, it should extend the locked block via the dummy blocks.
if !candidate_block.is_safe(tx)? {
if !candidate_block.is_safe(tx.deref_mut())? {
return Err(ProposalValidationError::NotSafeBlock {
proposed_by: candidate_block.proposed_by().to_string(),
hash: *candidate_block.id(),
Expand Down
2 changes: 1 addition & 1 deletion dan_layer/state_store_sqlite/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl<TAddr: NodeAddressable + Serialize + DeserializeOwned> StateStoreReadTransa

let foreign_proposals = foreign_proposals::table
.filter(foreign_proposals::state.eq("Mined"))
.filter(foreign_proposals::mined_at.le(to_height.0 as i64))
.filter(foreign_proposals::proposed_height.le(to_height.0 as i64))
.load::<sql_models::ForeignProposal>(self.connection())
.map_err(|e| SqliteStorageError::DieselError {
operation: "foreign_proposal_get_all",
Expand Down

0 comments on commit 1e50f4e

Please sign in to comment.