Skip to content

Commit

Permalink
fix(consensus): Makes sure that proposer is this node. (nervosnetwork…
Browse files Browse the repository at this point in the history
  • Loading branch information
yejiayu authored and mohanson committed Jun 13, 2019
1 parent f6a58d0 commit d7f4e50
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions components/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ where
sig_txs.push(tx);
} else if let Some(tx) = callback_cache.get(hash) {
sig_txs.push(tx);
} else {
return Err(TransactionPoolError::NotExpected);
}
}

Expand Down
3 changes: 1 addition & 2 deletions core/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ tokio = "0.1"
futures-timer = "0.1"
# compat is required for tokio timer
futures-preview = { version = "0.3.0-alpha.16", features = [ "compat" ] }
# TODO: upgrade bft-rs
bft-rs = { git = "https://github.com/cryptape/bft-rs.git", features = [ "verify_req" ], rev = "861aa4f" }
bft-rs = { git = "https://github.com/cryptape/bft-rs.git", features = [ "verify_req" ], branch = "bft_for_muta" }
rayon = "1.0"

[dev-dependencies]
Expand Down
10 changes: 3 additions & 7 deletions core/consensus/src/bft/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ where
.await?
.try_into()?;

// Ignore the self proposal
let status = self.engine.get_status();
if proposal.proposer == status.node_address {
return Ok(());
}

let ctx = Context::new();
self.engine.verify_proposal(ctx.clone(), &proposal)?;
Ok(())
Expand All @@ -121,6 +115,7 @@ where
signed_proposal_hash: &[u8],
_height: u64,
_round: u64,
proposer: &[u8],
) -> Result<(), Self::Error> {
let fut = async move {
let proposal: Proposal = AsyncCodec::decode::<SerProposal>(proposal.to_vec())
Expand All @@ -132,8 +127,9 @@ where
}

// Ignore the self proposal
let proposer = Address::from_bytes(proposer)?;
let status = self.engine.get_status();
if proposal.proposer == status.node_address {
if proposer == status.node_address {
return Ok(());
}

Expand Down
3 changes: 1 addition & 2 deletions core/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ core-serialization = { path = "../serialization" }

bytes = "0.4"
cita-vm = "0.1"
# TODO: upgrade bft-rs
bft-rs = { git = "https://github.com/cryptape/bft-rs.git", features = [ "verify_req" ], rev = "861aa4f" }
bft-rs = { git = "https://github.com/cryptape/bft-rs.git", features = [ "verify_req" ], branch = "bft_for_muta" }

0 comments on commit d7f4e50

Please sign in to comment.