Skip to content

Commit

Permalink
Merge pull request #63 from cita-cloud/bump_version
Browse files Browse the repository at this point in the history
update deps; opt log; rm gpt review
  • Loading branch information
rink1969 authored Feb 27, 2024
2 parents 2bb624f + 1543ac5 commit 532d72e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 111 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/gpt-review.yml

This file was deleted.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "consensus"
version = "6.7.2"
version = "6.7.3"
authors = ["Rivtower Technologies <[email protected]>"]
license = "Apache-2.0"
edition = "2021"

[dependencies]
overlord = "0.4"
clap = { version = "4.4", features = ["derive"] }
tonic = "0.10"
clap = { version = "4.5", features = ["derive"] }
tonic = "0.11"
prost = "0.12"
tokio = { version = "1.32", features = ["full"] }
tokio = { version = "1.36", features = ["full"] }
toml = "0.8"
serde = "1.0"
serde_derive = "1.0"
Expand All @@ -22,7 +22,7 @@ ophelia-secp256k1 = "0.3"
hex = "0.4"
derive_more = "0.99"
creep = "0.2" # match with overlord
libsm = "0.5"
libsm = "0.6"
rlp = "0.5"
tower = "0.4"
tracing = "0.1"
Expand Down
90 changes: 53 additions & 37 deletions src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ impl Consensus {

#[instrument(skip_all)]
pub async fn proc_network_msg(&self, msg: NetworkMsg) {
info!("proc_network_msg {}!", msg.r#type.as_str());

if msg.r#type.as_str() == "SignedVote" {
if let Ok(vote) = SignedVote::decode(&Rlp::new(&msg.msg)) {
let ret = self
Expand Down Expand Up @@ -525,7 +523,7 @@ impl OverlordConsensus<ConsensusProposal> for Brain {
_ctx: Context,
height: u64,
) -> Result<(ConsensusProposal, Hash), Box<dyn Error + Send>> {
info!("get_block!");
info!("get_proposal {}!", height);
match controller_client().get_proposal(Empty {}).await {
Ok(response) => {
let status_code = response.status.unwrap();
Expand Down Expand Up @@ -676,26 +674,35 @@ impl OverlordConsensus<ConsensusProposal> for Brain {
_ctx: Context,
words: OverlordMsg<ConsensusProposal>,
) -> Result<(), Box<dyn Error + Send>> {
info!("broadcast_to_other!");
let network_msg = match words {
OverlordMsg::SignedProposal(proposal) => NetworkMsg {
module: "consensus".to_owned(),
r#type: "SignedProposal".to_string(),
origin: 0,
msg: proposal.rlp_bytes().to_vec(),
},
OverlordMsg::SignedChoke(choke) => NetworkMsg {
module: "consensus".to_owned(),
r#type: "SignedChoke".to_string(),
origin: 0,
msg: choke.rlp_bytes().to_vec(),
},
OverlordMsg::AggregatedVote(agg_vote) => NetworkMsg {
module: "consensus".to_owned(),
r#type: "AggregatedVote".to_string(),
origin: 0,
msg: agg_vote.rlp_bytes().to_vec(),
},
let (network_msg, type_str) = match words {
OverlordMsg::SignedProposal(proposal) => (
NetworkMsg {
module: "consensus".to_owned(),
r#type: "SignedProposal".to_string(),
origin: 0,
msg: proposal.rlp_bytes().to_vec(),
},
"SignedProposal",
),

OverlordMsg::SignedChoke(choke) => (
NetworkMsg {
module: "consensus".to_owned(),
r#type: "SignedChoke".to_string(),
origin: 0,
msg: choke.rlp_bytes().to_vec(),
},
"SignedChoke",
),
OverlordMsg::AggregatedVote(agg_vote) => (
NetworkMsg {
module: "consensus".to_owned(),
r#type: "AggregatedVote".to_string(),
origin: 0,
msg: agg_vote.rlp_bytes().to_vec(),
},
"AggregatedVote",
),
_ => {
warn!("broadcast_to_other unexpected network msg!");
return Err(Box::new(ConsensusError::Other(
Expand All @@ -704,6 +711,8 @@ impl OverlordConsensus<ConsensusProposal> for Brain {
}
};

info!("broadcast {} to other!", type_str);

let resp = network_client().broadcast(network_msg).await;
if let Err(e) = resp {
warn!("net client broadcast error {:?}", e);
Expand All @@ -721,20 +730,25 @@ impl OverlordConsensus<ConsensusProposal> for Brain {
name: Bytes,
words: OverlordMsg<ConsensusProposal>,
) -> Result<(), Box<dyn Error + Send>> {
info!("transmit_to_relayer!");
let network_msg = match words {
OverlordMsg::SignedVote(vote) => NetworkMsg {
module: "consensus".to_owned(),
r#type: "SignedVote".to_owned(),
origin: validator_to_origin(&name),
msg: vote.rlp_bytes().to_vec(),
},
OverlordMsg::AggregatedVote(agg_vote) => NetworkMsg {
module: "consensus".to_owned(),
r#type: "AggregatedVote".to_owned(),
origin: validator_to_origin(&name),
msg: agg_vote.rlp_bytes().to_vec(),
},
let (network_msg, type_str) = match words {
OverlordMsg::SignedVote(vote) => (
NetworkMsg {
module: "consensus".to_owned(),
r#type: "SignedVote".to_owned(),
origin: validator_to_origin(&name),
msg: vote.rlp_bytes().to_vec(),
},
"SignedVote",
),
OverlordMsg::AggregatedVote(agg_vote) => (
NetworkMsg {
module: "consensus".to_owned(),
r#type: "AggregatedVote".to_owned(),
origin: validator_to_origin(&name),
msg: agg_vote.rlp_bytes().to_vec(),
},
"AggregatedVote",
),
_ => {
warn!("transmit_to_relayer unexpected network msg!");
return Err(Box::new(ConsensusError::Other(
Expand All @@ -743,6 +757,8 @@ impl OverlordConsensus<ConsensusProposal> for Brain {
}
};

info!("transmit {} to relayer!", type_str);

let resp = network_client().send_msg(network_msg).await;
if let Err(e) = resp {
warn!("net client send_msg error {:?}", e);
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ impl NetworkMsgHandlerService for ConsensusServer {
Err(Status::invalid_argument("wrong module"))
} else {
info!(
"get network message module {:?} type {:?}",
msg.module, msg.r#type
"get network message type {:?} from {}",
msg.r#type,
hex::encode(msg.origin.to_be_bytes())
);
self.consensus.proc_network_msg(msg).await;
let reply = StatusCode {
Expand Down

0 comments on commit 532d72e

Please sign in to comment.