Skip to content

Commit

Permalink
Merge branch 'ChainSafe:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
virajbhartiya authored Nov 28, 2024
2 parents e44fff7 + 0fc577e commit 94d934f
Show file tree
Hide file tree
Showing 31 changed files with 281 additions and 180 deletions.
151 changes: 83 additions & 68 deletions Cargo.lock

Large diffs are not rendered by default.

39 changes: 24 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@ license = "MIT OR Apache-2.0"
description = "Rust Filecoin implementation."
exclude = [".config", ".github", ".maintain", "documentation", "scripts", "interop-tests", "go.work*"]

[workspace.dependencies]
anyhow = "1"
cid = { version = "0.10", default-features = false, features = ["std"] }
flume = "0.11"
futures = "0.3"
libp2p = { version = "0.54", default-features = false }
libp2p-swarm-test = "0.4"
rust2go = "0.3"
tokio = "1"

[dependencies]
ahash = "0.8"
anes = "0.2"
anyhow = "1.0"
anyhow = { workspace = true }
argon2 = "0.5"
async-compression = { version = "0.4", features = ["tokio", "zstd"] }
async-fs = "2"
async-trait = "0.1"
asynchronous-codec = "0.7"
axum = "0.7"
backon = "1.2.0"
backon = "1"
base64 = "0.22"
bigdecimal = "=0.4.2" # TODO(forest): https://github.com/ChainSafe/forest/issues/4035
blake2b_simd = "1.0"
Expand All @@ -33,7 +43,8 @@ cbor4ii = { version = "0.2", default-features = false, features = ["use_alloc",
cfg-if = "1"
cfg-vis = "0.3"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
cid = { version = "0.10", default-features = false, features = ["std"] }
cid = { workspace = true }
cid_0_11 = { package = "cid", version = "0.11", default-features = false, features = ["std"] }
clap = { version = "4", features = ["derive"] }
colored = "2.0"
crypto_secretbox = "0.1"
Expand All @@ -60,9 +71,9 @@ fil_actor_reward_state = { version = "17.0.3" }
fil_actor_system_state = { version = "17.0.3" }
fil_actor_verifreg_state = { version = "17.0.3" }
fil_actors_shared = { version = "17.0.3", features = ["json"] }
flume = "0.11"
flume = { workspace = true }
fs_extra = "1"
futures = "0.3"
futures = { workspace = true }
fvm2 = { package = "fvm", version = "~2.9", default-features = false }
fvm3 = { package = "fvm", default-features = false, version = "~3.11", features = ["arb"] }
fvm4 = { package = "fvm", default-features = false, version = "~4.3.3", features = ["arb", "verify-signature"] }
Expand All @@ -81,19 +92,17 @@ human-repr = "1"
human_bytes = "0.4"
humantime = "2"
indexmap = { version = "2", features = ["serde"] }
indicatif = { version = "0.17.9", features = ["tokio"] }
indicatif = { version = "0.17", features = ["tokio"] }
integer-encoding = "4.0"
ipld-core = { version = "0.4", features = ["serde", "arb"] }
is-terminal = "0.4"
itertools = "0.13"
jsonrpsee = { version = "0.24", features = ["server", "ws-client", "http-client"] }
jsonwebtoken = "9"
keccak-hash = "0.11"
kubert-prometheus-process = "0.1"
lazy-regex = "3"
libipld = { version = "0.16", default-features = false, features = ["dag-cbor", "dag-json", "derive", "serde-codec"] }
libipld-core = { version = "0.16", features = ['arb', 'serde-codec'] }
libipld-macro = "0.16"
libp2p = { version = "0.54", default-features = false, features = [
libp2p = { workspace = true, features = [
'autonat',
'gossipsub',
'kad',
Expand Down Expand Up @@ -155,13 +164,13 @@ reqwest = { version = "0.12", default-features = false, features = [
rlimit = "0.10"
rlp = "0.6"
rs-car-ipfs = "0.3"
rust2go = { version = "0.3" }
rust2go = { workspace = true }
sailfish = "0.9"
schemars = { version = "0.8", features = ["chrono", "uuid1"] }
scopeguard = "1"
semver = "1"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_ipld_dagcbor = "0.4"
serde_ipld_dagcbor = "0.6"
serde_json = { version = "1.0", features = ["raw_value"] }
serde_tuple = "1"
serde_with = { version = "3", features = ["chrono_0_4"] }
Expand Down Expand Up @@ -201,7 +210,7 @@ zstd = "0.13"
# optional dependencies
console-subscriber = { version = "0.4", features = ["parking_lot"], optional = true }
mimalloc = { version = "0.1", optional = true, default-features = false }
paste = "1.0.15"
paste = "1"
tikv-jemallocator = { version = "0.6", optional = true }
tracing-chrome = { version = "0.7", optional = true }
tracing-loki = { version = "0.2", default-features = false, features = ["compat-0-2-1", "rustls"], optional = true }
Expand All @@ -222,7 +231,7 @@ fvm_shared4 = { package = "fvm_shared", version = "~4.3.3", features = ["arb", "
glob = "0.3"
http-range-header = "0.4"
insta = { version = "1", features = ["yaml"] }
libp2p-swarm-test = "0.4"
libp2p-swarm-test = { workspace = true }
num-bigint = { version = "0.4", features = ['quickcheck'] }
petgraph = "0.6"
predicates = "3"
Expand All @@ -236,7 +245,7 @@ syn = { version = "2", default-features = false, features = ["full", "parsing",
tokio-test = "0.4"

[build-dependencies]
rust2go = { version = "0.3", features = ["build"] }
rust2go = { workspace = true, features = ["build"] }

# This needs to be set as default. Otherwise, a regular build or test will produce
# gargantuan artifacts (around 70G for all tests). For a debugging session, you can
Expand Down
18 changes: 9 additions & 9 deletions interop-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ publish = false
[dependencies]

[dev-dependencies]
anyhow = "1"
flume = "0.11"
anyhow = { workspace = true }
cid = { workspace = true }
flume = { workspace = true }
forest-filecoin = { path = "../", default-features = false, features = ["interop-tests-private", "no-f3-sidecar"] }
futures = "0.3"
libipld = { version = "0.16", default-features = false }
libp2p = { version = "0.54", default-features = false, features = [
futures = { workspace = true }
libp2p = { workspace = true, features = [
'kad',
'identify',
'noise',
Expand All @@ -30,9 +30,9 @@ libp2p = { version = "0.54", default-features = false, features = [
'ed25519',
'secp256k1',
] }
libp2p-swarm-test = "0.4"
rust2go = { version = "0.3" }
tokio = { version = "1", features = ['full'] }
libp2p-swarm-test = { workspace = true }
rust2go = { workspace = true }
tokio = { workspace = true, features = ['full'] }

[build-dependencies]
rust2go = { version = "0.3", features = ["build"] }
rust2go = { workspace = true, features = ["build"] }
1 change: 1 addition & 0 deletions interop-tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0, MIT

fn main() {
println!("cargo::rerun-if-changed=src/tests/go_app");
rust2go::Builder::default()
.with_go_src("./src/tests/go_app")
.with_regen_arg(rust2go::RegenArgs {
Expand Down
12 changes: 5 additions & 7 deletions interop-tests/src/tests/bitswap_go_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use super::go_ffi::*;

use std::time::Duration;

use forest_filecoin::interop_tests_private::libp2p_bitswap::{
BitswapBehaviour, BitswapBehaviourEvent, BitswapMessage, BitswapRequest, BitswapResponse,
};
use libipld::{
use cid::{
multihash::{self, MultihashDigest as _},
Cid,
};
use forest_filecoin::interop_tests_private::libp2p_bitswap::{
BitswapBehaviour, BitswapBehaviourEvent, BitswapMessage, BitswapRequest, BitswapResponse,
};
use libp2p::{
futures::StreamExt as _, noise, request_response, swarm::SwarmEvent, tcp, yamux, Multiaddr,
Swarm, SwarmBuilder,
};
use std::time::Duration;

const TIMEOUT: Duration = Duration::from_secs(60);
const LISTEN_ADDR: &str = "/ip4/127.0.0.1/tcp/0";
Expand Down
4 changes: 2 additions & 2 deletions src/chain/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ impl<DB> BitswapStoreReadWrite for ChainStore<DB>
where
DB: BitswapStoreReadWrite,
{
type Params = <DB as BitswapStoreReadWrite>::Params;
type Hashes = <DB as BitswapStoreReadWrite>::Hashes;

fn insert(&self, block: &libipld::Block<Self::Params>) -> anyhow::Result<()> {
fn insert(&self, block: &crate::libp2p_bitswap::Block64<Self::Hashes>) -> anyhow::Result<()> {
self.db.insert(block)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/db/car/many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ impl<WriterT: BitswapStoreRead + Blockstore> BitswapStoreRead for ManyCar<Writer
}

impl<WriterT: BitswapStoreReadWrite + Blockstore> BitswapStoreReadWrite for ManyCar<WriterT> {
type Params = libipld::DefaultParams;
type Hashes = cid::multihash::Code;

fn insert(&self, block: &libipld::Block<Self::Params>) -> anyhow::Result<()> {
Blockstore::put_keyed(self, block.cid(), block.data())
fn insert(&self, block: &crate::libp2p_bitswap::Block64<Self::Hashes>) -> anyhow::Result<()> {
self.put_keyed(block.cid(), block.data())
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/db/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ impl BitswapStoreRead for MemoryDB {
}

impl BitswapStoreReadWrite for MemoryDB {
type Params = libipld::DefaultParams;
type Hashes = cid::multihash::Code;

fn insert(&self, block: &libipld::Block<Self::Params>) -> anyhow::Result<()> {
fn insert(&self, block: &crate::libp2p_bitswap::Block64<Self::Hashes>) -> anyhow::Result<()> {
self.put_keyed(block.cid(), block.data())
}
}
6 changes: 2 additions & 4 deletions src/db/parity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,9 @@ impl BitswapStoreRead for ParityDb {
}

impl BitswapStoreReadWrite for ParityDb {
/// `fvm_ipld_encoding::DAG_CBOR(0x71)` is covered by
/// [`libipld::DefaultParams`] under feature `dag-cbor`
type Params = libipld::DefaultParams;
type Hashes = cid::multihash::Code;

fn insert(&self, block: &libipld::Block<Self::Params>) -> anyhow::Result<()> {
fn insert(&self, block: &crate::libp2p_bitswap::Block64<Self::Hashes>) -> anyhow::Result<()> {
self.put_keyed(block.cid(), block.data())
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/documentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
/// which is a representation of all Filecoin state at a point in time.
/// For each actor, the `StateTree` holds the CID for its state: [`ActorState.state`](fvm4::state_tree::ActorState::state).
///
/// Actor state is serialized and stored as [`Ipld`](libipld::Ipld).
/// Actor state is serialized and stored as [`Ipld`](ipld_core::ipld::Ipld).
/// Think of this as "JSON with links ([`Cid`](cid::Cid)s)".
/// So the `cron` actor's state mentioned above will be ultimately serialized into `Ipld`
/// and stored in the `StateStore`, per
Expand Down Expand Up @@ -169,7 +169,7 @@
///
/// With respect to a particular IPLD [`Blockstore`](fvm_ipld_blockstore::Blockstore):
/// - An item such a list is _fully inhabited_ if all its recursive
/// [`Ipld::Link`](libipld::Ipld::Link)s exist in the blockstore.
/// [`Ipld::Link`](ipld_core::ipld::Ipld::Link)s exist in the blockstore.
/// - Otherwise, an item is only _partially inhabited_.
/// The links are said to be "dead links".
///
Expand Down
2 changes: 1 addition & 1 deletion src/ipld/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub mod selector;
pub mod util;

pub use libipld_core::ipld::Ipld;
pub use ipld_core::ipld::Ipld;
pub use util::*;

#[cfg(test)]
Expand Down
10 changes: 6 additions & 4 deletions src/ipld/tests/cbor_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use crate::{ipld::Ipld, utils::encoding::from_slice_with_fallback};
use crate::utils::encoding::from_slice_with_fallback;
use cid::{
multihash::{
Code::{Blake2b256, Identity},
Expand All @@ -10,19 +10,19 @@ use cid::{
Cid,
};
use fvm_ipld_encoding::{to_vec, DAG_CBOR};
use libipld_core::serde::to_ipld;
use libipld_macro::ipld;
use ipld_core::{ipld, ipld::Ipld, serde::to_ipld};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone)]
struct TestStruct {
name: String,
details: Cid,
details: cid_0_11::Cid,
}

#[test]
fn encode_new_type() {
let details = Cid::new_v1(DAG_CBOR, Blake2b256.digest(&[1, 2, 3]));
let details = crate::utils::cid::cid_10_to_11(&details);
let name = "Test".to_string();
let t_struct = TestStruct {
name: name.clone(),
Expand All @@ -46,6 +46,7 @@ fn encode_new_type() {
#[test]
fn cid_conversions_ipld() {
let cid = Cid::new_v1(DAG_CBOR, Blake2b256.digest(&[1, 2, 3]));
let cid = crate::utils::cid::cid_10_to_11(&cid);
let m_s = TestStruct {
name: "s".to_owned(),
details: cid,
Expand All @@ -63,6 +64,7 @@ fn cid_conversions_ipld() {

// Test with identity hash (different length prefix for cbor)
let cid = Cid::new_v1(DAG_CBOR, Identity.digest(&[1, 2]));
let cid = crate::utils::cid::cid_10_to_11(&cid);
let ipld = ipld!(Ipld::Link(cid));
let ipld2 = to_ipld(cid).unwrap();
assert_eq!(ipld, ipld2);
Expand Down
4 changes: 2 additions & 2 deletions src/ipld/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl DfsIter {

impl From<Cid> for DfsIter {
fn from(cid: Cid) -> Self {
DfsIter::new(Ipld::Link(cid))
DfsIter::new(Ipld::Link(crate::utils::cid::cid_10_to_11(&cid)))
}
}

Expand Down Expand Up @@ -181,7 +181,7 @@ impl<DB: Blockstore, T: Iterator<Item = Tipset> + Unpin> Stream for ChainStream<

let ipld_to_cid = |ipld| {
if let Ipld::Link(cid) = ipld {
return Some(cid);
return Some(crate::utils::cid::cid_11_to_10(&cid));
}
None
};
Expand Down
8 changes: 3 additions & 5 deletions src/libp2p_bitswap/internals/prefix.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use std::convert::TryFrom;

use libipld::cid::{
use crate::libp2p_bitswap::*;
use cid::{
multihash::{Code, MultihashDigest},
Version,
};
use std::convert::TryFrom;
use unsigned_varint::{decode as varint_decode, encode as varint_encode};

use crate::libp2p_bitswap::*;

/// Prefix represents all metadata of a CID, without the actual content.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Prefix {
Expand Down
2 changes: 1 addition & 1 deletion src/libp2p_bitswap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use std::io::Result as IOResult;

use libipld::{cid::Cid, prelude::*};
use cid::Cid;
use tracing::*;

mod bitswap_pb;
Expand Down
2 changes: 1 addition & 1 deletion src/libp2p_bitswap/request_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use std::{

use crate::cid_collections::CidHashMap;
use ahash::{HashSet, HashSetExt};
use cid::Cid;
use flume::TryRecvError;
use futures::StreamExt;
use libipld::{Block, Cid};
use libp2p::PeerId;
use parking_lot::RwLock;

Expand Down
Loading

0 comments on commit 94d934f

Please sign in to comment.