Skip to content

Commit

Permalink
Merge branch 'main' into cason/250-spec-reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-widder authored Dec 6, 2024
2 parents 23822ac + 75f244d commit 6498991
Show file tree
Hide file tree
Showing 39 changed files with 1,987 additions and 946 deletions.
800 changes: 544 additions & 256 deletions code/Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions code/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"crates/gossip-mempool",
"crates/metrics",
"crates/node",
"crates/peer",
"crates/proto",
"crates/round",
"crates/vote",
Expand Down Expand Up @@ -71,6 +72,7 @@ malachite-gossip-consensus = { version = "0.1.0", path = "crates/gossip-consensu
malachite-gossip-mempool = { version = "0.1.0", path = "crates/gossip-mempool" }
malachite-metrics = { version = "0.1.0", path = "crates/metrics" }
malachite-node = { version = "0.1.0", path = "crates/node" }
malachite-peer = { version = "0.1.0", path = "crates/peer" }
malachite-proto = { version = "0.1.0", path = "crates/proto" }
malachite-round = { version = "0.1.0", path = "crates/round" }
malachite-vote = { version = "0.1.0", path = "crates/vote" }
Expand All @@ -97,6 +99,7 @@ async-recursion = "1.1"
async-trait = "0.1.83"
axum = "0.7"
base64 = "0.22.0"
bs58 = "0.5.1"
bytes = { version = "1", default-features = false }
byteorder = "1.5"
bytesize = "1.3"
Expand Down Expand Up @@ -124,6 +127,7 @@ libp2p = { version = "0.54.1", features = ["macros", "identify", "to
libp2p-identity = "0.2.10"
libp2p-broadcast = { version = "0.1.1", package = "libp2p-scatter" }
multiaddr = "0.18.2"
multihash = { version = "0.19.2", default-features = false }
nix = { version = "0.29.0", features = ["signal"] }
num-bigint = "0.4.4"
num-traits = "0.2.17"
Expand Down
2 changes: 1 addition & 1 deletion code/crates/actors/src/block_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use bytes::Bytes;
use derive_where::derive_where;
use eyre::eyre;
use libp2p::request_response::InboundRequestId;
use libp2p::PeerId;
use ractor::{Actor, ActorProcessingErr, ActorRef};
use rand::SeedableRng;
use tokio::task::JoinHandle;
Expand All @@ -15,6 +14,7 @@ use tracing::{debug, error, warn};
use malachite_blocksync::{self as blocksync, OutboundRequestId};
use malachite_blocksync::{Request, SyncedBlock};
use malachite_common::{CertificateError, CommitCertificate, Context, Height};
use malachite_consensus::PeerId;

use crate::gossip_consensus::{GossipConsensusMsg, GossipConsensusRef, GossipEvent, Status};
use crate::host::{HostMsg, HostRef};
Expand Down
18 changes: 9 additions & 9 deletions code/crates/actors/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::time::Duration;

use async_trait::async_trait;
use eyre::eyre;
use libp2p::PeerId;
use ractor::{Actor, ActorProcessingErr, ActorRef, RpcReplyPort};
use tokio::time::Instant;
use tracing::{debug, error, info, warn};
Expand All @@ -13,7 +12,7 @@ use malachite_common::{
Context, Round, SignedExtension, Timeout, TimeoutStep, ValidatorSet, ValueOrigin,
};
use malachite_config::TimeoutConfig;
use malachite_consensus::{Effect, Resume, SignedConsensusMsg, ValueToPropose};
use malachite_consensus::{Effect, PeerId, Resume, SignedConsensusMsg, ValueToPropose};
use malachite_metrics::Metrics;

use crate::block_sync::BlockSyncRef;
Expand Down Expand Up @@ -213,6 +212,7 @@ where
match msg {
Msg::StartHeight(height, validator_set) => {
state.phase = Phase::Running;

let result = self
.process_input(
&myself,
Expand All @@ -225,19 +225,19 @@ where
error!(%height, "Error when starting height: {e}");
}

self.tx_event.send(|| Event::StartedHeight(height));

if let Err(e) = self.check_and_replay_wal(&myself, state, height).await {
error!(%height, "Error when checking and replaying WAL: {e}");
}

// Notify the BlockSync actor that we have started a new height
if let Some(block_sync) = &self.block_sync {
if let Err(e) = block_sync.cast(BlockSyncMsg::StartedHeight(height)) {
error!(%height, "Error when notifying BlockSync of started height: {e}")
}
}

self.tx_event.send(|| Event::StartedHeight(height));

if let Err(e) = self.check_and_replay_wal(&myself, state, height).await {
error!(%height, "Error when checking and replaying WAL: {e}");
}

Ok(())
}

Expand Down Expand Up @@ -592,7 +592,7 @@ where
|reply| HostMsg::GetValue {
height,
round,
timeout_duration,
timeout: timeout_duration,
address: self.params.address.clone(),
reply_to: reply,
},
Expand Down
4 changes: 2 additions & 2 deletions code/crates/actors/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use bytes::Bytes;
use std::time::Duration;

use derive_where::derive_where;
use libp2p::PeerId;
use ractor::{ActorRef, RpcReplyPort};

use malachite_blocksync::SyncedBlock;
use malachite_common::{CommitCertificate, Context, Round, SignedExtension, ValueId};
use malachite_consensus::PeerId;

use crate::consensus::ConsensusRef;
use crate::util::streaming::StreamMessage;
Expand Down Expand Up @@ -61,7 +61,7 @@ pub enum HostMsg<Ctx: Context> {
GetValue {
height: Ctx::Height,
round: Round,
timeout_duration: Duration,
timeout: Duration,
address: Ctx::Address,
reply_to: RpcReplyPort<LocallyProposedValue<Ctx>>,
},
Expand Down
6 changes: 5 additions & 1 deletion code/crates/app-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rust-version.workspace = true
[dependencies]
bytes.workspace = true
derive-where.workspace = true
libp2p-identity.workspace = true
ractor.workspace = true
tokio.workspace = true
tracing.workspace = true
Expand All @@ -24,6 +23,11 @@ malachite-consensus.workspace = true
malachite-gossip-consensus.workspace = true
malachite-metrics.workspace = true
malachite-node.workspace = true
malachite-peer.workspace = true

[lints]
workspace = true

[dev-dependencies]
malachite-test.workspace = true
rand.workspace = true
3 changes: 1 addition & 2 deletions code/crates/app-channel/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use std::time::Duration;

use bytes::Bytes;
use derive_where::derive_where;
use libp2p_identity::PeerId;
use tokio::sync::oneshot;

use malachite_actors::host::LocallyProposedValue;
use malachite_actors::util::streaming::StreamMessage;
use malachite_blocksync::SyncedBlock;
use malachite_common::{CommitCertificate, Context, Round, ValueId};
use malachite_consensus::ProposedValue;
use malachite_consensus::{PeerId, ProposedValue};

/// Messages that will be sent on the channel.
#[derive_where(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion code/crates/app-channel/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
HostMsg::GetValue {
height,
round,
timeout_duration,
timeout: timeout_duration,
address,
reply_to,
} => {
Expand Down
5 changes: 2 additions & 3 deletions code/crates/app-channel/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ use crate::spawn::{
spawn_wal_actor,
};

// Todo: Remove clippy exception when the function signature is finalized
#[allow(clippy::too_many_arguments)]
pub async fn run<Ctx, Node, Codec>(
pub async fn run<Node, Ctx, Codec>(
cfg: NodeConfig,
start_height: Option<Ctx::Height>,
ctx: Ctx,
node: Node,
codec: Codec,
node: Node,
keypair: Keypair, // Todo: see note in code
address: Ctx::Address, // Todo: remove it when Node was properly implemented
initial_validator_set: Ctx::ValidatorSet,
Expand Down
1 change: 1 addition & 0 deletions code/crates/blocksync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version.workspace = true
[dependencies]
malachite-common = { workspace = true }
malachite-metrics = { workspace = true }
malachite-peer = { workspace = true }

async-trait = { workspace = true }
bytes = { workspace = true, features = ["serde"] }
Expand Down
4 changes: 2 additions & 2 deletions code/crates/blocksync/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::BTreeMap;

use libp2p::PeerId;
use rand::seq::IteratorRandom;

use malachite_common::Context;
use rand::seq::IteratorRandom;
use malachite_peer::PeerId;

use crate::Status;

Expand Down
5 changes: 3 additions & 2 deletions code/crates/blocksync/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use derive_where::derive_where;
use displaydoc::Display;
use serde::{Deserialize, Serialize};

use malachite_common::{CommitCertificate, Context};
use malachite_common::Context;

pub use libp2p::identity::PeerId;
pub use libp2p::request_response::{InboundRequestId, OutboundRequestId};
pub use malachite_common::CommitCertificate;
pub use malachite_peer::PeerId;

pub type ResponseChannel = libp2p::request_response::ResponseChannel<RawResponse>;

Expand Down
2 changes: 1 addition & 1 deletion code/crates/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ debug = ["std", "malachite-driver/debug"]
malachite-common.workspace = true
malachite-driver.workspace = true
malachite-metrics.workspace = true
malachite-peer.workspace = true

async-recursion = { workspace = true }
genawaiter = { workspace = true }
derive-where = { workspace = true }
libp2p-identity = { workspace = true, features = ["peerid"] }
multiaddr = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion code/crates/consensus/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use malachite_common::{
Context, Proposal, Round, SignedExtension, SignedProposal, SignedVote, Validity, Vote,
};

pub use libp2p_identity::PeerId;
pub use malachite_peer::PeerId;
pub use multiaddr::Multiaddr;

/// A signed consensus message, ie. a signed vote or a signed proposal.
Expand Down
1 change: 1 addition & 0 deletions code/crates/gossip-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ workspace = true
malachite-metrics = { workspace = true }
malachite-blocksync = { workspace = true }
malachite-discovery = { workspace = true }
malachite-peer = { workspace = true }

bytes = { workspace = true }
either = { workspace = true }
Expand Down
5 changes: 3 additions & 2 deletions code/crates/gossip-consensus/src/handle.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use bytes::Bytes;
use libp2p::request_response::InboundRequestId;
use libp2p::PeerId;
use malachite_blocksync::OutboundRequestId;
use tokio::sync::{mpsc, oneshot};
use tokio::task;

use malachite_blocksync::OutboundRequestId;
use malachite_peer::PeerId;

use crate::{Channel, CtrlMsg, Event};

pub struct RecvHandle {
Expand Down
Loading

0 comments on commit 6498991

Please sign in to comment.