Skip to content

Commit

Permalink
fix: unused code after remove deleg_cns
Browse files Browse the repository at this point in the history
  • Loading branch information
aatifsyed committed Jun 26, 2023
1 parent d763780 commit d9b5c60
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 126 deletions.
80 changes: 1 addition & 79 deletions src/chain/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ use crate::metrics;
use crate::networks::{ChainConfig, NetworkChain};
use crate::shim::clock::ChainEpoch;
use crate::shim::{
address::Address,
crypto::{Signature, SignatureType},
econ::TokenAmount,
executor::Receipt,
message::Message,
state_tree::StateTree,
address::Address, econ::TokenAmount, executor::Receipt, message::Message, state_tree::StateTree,
};
use crate::utils::{
db::{
Expand All @@ -31,7 +26,6 @@ use crate::utils::{
use ahash::{HashMap, HashMapExt, HashSet};
use anyhow::{Context, Result};
use async_compression::futures::write::ZstdEncoder;
use bls_signatures::Serialize as SerializeBls;
use cid::Cid;
use digest::Digest;
use futures::{io::BufWriter, AsyncWrite};
Expand Down Expand Up @@ -868,78 +862,6 @@ pub mod headchange_json {
}
}

/// Result of persisting a vector of `SignedMessage`s that are to be included in
/// a block.
///
/// The fields are public so they can be partially moved, but they should not be
/// modified.
pub struct PersistedBlockMessages {
/// Overall CID to be included in the `BlockHeader`.
pub msg_cid: Cid,
/// All CIDs of SECP messages, to be included in `BlockMsg`.
pub secp_cids: Vec<Cid>,
/// All CIDs of BLS messages, to be included in `BlockMsg`.
pub bls_cids: Vec<Cid>,
/// Aggregated signature of all BLS messages, to be included in the
/// `BlockHeader`.
pub bls_agg: Signature,
}

/// Partition the messages into SECP and BLS variants, store them individually
/// in the IPLD store, and the corresponding `TxMeta` as well, returning its CID
/// so that it can be put in a block header. Also return the aggregated BLS
/// signature of all BLS messages.
pub fn persist_block_messages<DB: Blockstore>(
db: &DB,
messages: Vec<&SignedMessage>,
) -> anyhow::Result<PersistedBlockMessages> {
let mut bls_cids = Vec::new();
let mut secp_cids = Vec::new();

let mut bls_sigs = Vec::new();
for msg in messages {
if msg.signature().signature_type() == SignatureType::Bls {
let c = db.put_cbor_default(&msg.message)?;
bls_cids.push(c);
bls_sigs.push(&msg.signature);
} else {
let c = db.put_cbor_default(&msg)?;
secp_cids.push(c);
}
}

let bls_msg_root = Amt::new_from_iter(db, bls_cids.iter().copied())?;
let secp_msg_root = Amt::new_from_iter(db, secp_cids.iter().copied())?;

let mmcid = db.put_cbor_default(&TxMeta {
bls_message_root: bls_msg_root,
secp_message_root: secp_msg_root,
})?;

let bls_agg = if bls_sigs.is_empty() {
Signature::new_bls(vec![])
} else {
Signature::new_bls(
bls_signatures::aggregate(
&bls_sigs
.iter()
.map(|s| s.bytes())
.map(bls_signatures::Signature::from_bytes)
.collect::<Result<Vec<_>, _>>()?,
)
.unwrap()
.as_bytes(),
)
};

Ok(PersistedBlockMessages {
msg_cid: mmcid,
secp_cids,
bls_cids,
bls_agg,
})
}

#[cfg(test)]
mod tests {
use crate::shim::address::Address;
Expand Down
3 changes: 0 additions & 3 deletions src/chain/store/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ pub enum Error {
/// Key was not found
#[error("Invalid tipset: {0}")]
UndefinedKey(String),
/// Tipset contains no blocks
#[error("No blocks for tipset")]
NoBlocks,
/// Key not found in database
#[error("{0} not found")]
NotFound(String),
Expand Down
34 changes: 4 additions & 30 deletions src/chain_sync/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ use std::{
sync::Arc,
};

use crate::blocks::{Block, GossipBlock, Tipset};
use crate::blocks::{Block, Tipset};
use crate::chain::Scale;
use crate::libp2p::{NetworkMessage, Topic, PUBSUB_BLOCK_STR};
use crate::message::SignedMessage;
use crate::message_pool::MessagePool;
use crate::state_manager::StateManager;
use async_trait::async_trait;
use futures::{stream::FuturesUnordered, StreamExt};
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::Cbor;
use nonempty::NonEmpty;
use tokio::task::JoinSet;

Expand Down Expand Up @@ -167,34 +165,10 @@ where
///
/// Similar to `sync_api::sync_submit_block` but assumes that the block is
/// correct and already persisted.
pub struct SyncGossipSubmitter {
network_name: String,
network_tx: flume::Sender<NetworkMessage>,
tipset_tx: flume::Sender<Arc<Tipset>>,
}
pub struct SyncGossipSubmitter {}

impl SyncGossipSubmitter {
pub fn new(
network_name: String,
network_tx: flume::Sender<NetworkMessage>,
tipset_tx: flume::Sender<Arc<Tipset>>,
) -> Self {
Self {
network_name,
network_tx,
tipset_tx,
}
}

pub async fn submit_block(&self, block: GossipBlock) -> anyhow::Result<()> {
let data = block.marshal_cbor()?;
let ts = Arc::new(Tipset::from(&block.header));
let msg = NetworkMessage::PubsubMessage {
topic: Topic::new(format!("{}/{}", PUBSUB_BLOCK_STR, self.network_name)),
message: data,
};
self.tipset_tx.send_async(ts).await?;
self.network_tx.send_async(msg).await?;
Ok(())
pub fn new() -> Self {
Self {}
}
}
6 changes: 1 addition & 5 deletions src/daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,7 @@ pub(super) async fn start(

// For consensus types that do mining, create a component to submit their
// proposals.
let submitter = SyncGossipSubmitter::new(
network_name.clone(),
network_send.clone(),
tipset_sink.clone(),
);
let submitter = SyncGossipSubmitter::new();

// Initialize Consensus. Mining may or may not happen, depending on type.
let consensus =
Expand Down
9 changes: 0 additions & 9 deletions src/state_manager/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ pub enum Error {
/// Error originating from state
#[error("{0}")]
State(String),
/// Error from VM execution
#[error("{0}")]
VM(String),
/// Actor for given address not found
#[error("Actor for address: {0} does not exist")]
ActorNotFound(String),
/// Actor state not found at given CID
#[error("Actor state with cid {0} not found")]
ActorStateNotFound(String),
/// Error originating from key-value store
#[error(transparent)]
DB(#[from] DbErr),
Expand Down

0 comments on commit d9b5c60

Please sign in to comment.