Skip to content

Commit

Permalink
chore: update cid/multihash (#239)
Browse files Browse the repository at this point in the history
Pull in a large breaking change to cid & multihash, updating the FVM to
handle these changes as well.
  • Loading branch information
Stebalien authored Nov 21, 2024
1 parent 0f83651 commit 82f3972
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 23 deletions.
23 changes: 12 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ members = [
[workspace.dependencies]
blake2b_simd = { version = "1.0.0" }
clap = { version = "4.3.21", features = ["derive"] }
cid = { version = "0.10.1", default-features = false, features = [
"serde-codec",
cid = { version = "0.11.1", default-features = false, features = [
"serde",
] }
fvm = { version = "~4.4", default-features = false }
fvm_integration_tests = "~4.4"
fvm_ipld_amt = "0.6.0"
fvm_ipld_bitfield = "0.6.0"
fvm_ipld_blockstore = "0.2.0"
fvm_ipld_encoding = "0.4.0"
fvm_ipld_hamt = "0.9.0"
fvm_sdk = "~4.4"
fvm_shared = "~4.4"
fvm = { version = "~4.5", default-features = false }
fvm_integration_tests = "~4.5"
fvm_ipld_amt = "0.7.3"
fvm_ipld_bitfield = "0.7.0"
fvm_ipld_blockstore = "0.3.0"
fvm_ipld_encoding = "0.5.0"
fvm_ipld_hamt = "0.10.2"
fvm_sdk = "~4.5"
fvm_shared = "~4.5"
serde = { version = "1.0.136", features = ["derive"] }
serde_tuple = { version = "0.5.0" }
thiserror = { version = "1.0.31" }
integer-encoding = { version = "4.0.0" }
num-traits = { version = "0.2.15" }
anyhow = { version = "1.0.56" }
multihash-codetable = { version = "0.1.4" }

# internal deps of published packages
frc42_dispatch = { version = "7.0.0", path = "./frc42_dispatch", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions frc46_token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fvm_ipld_hamt = { workspace = true }
fvm_ipld_encoding = { workspace = true }
fvm_sdk = { workspace = true }
fvm_shared = { workspace = true }
multihash-codetable = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true }
serde_tuple = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions frc46_token/src/token/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;
use std::ops::Neg;

use cid::multihash::Code;
use cid::Cid;
use fvm_ipld_blockstore::Block;
use fvm_ipld_blockstore::Blockstore;
Expand All @@ -16,6 +15,7 @@ use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
use fvm_shared::ActorID;
use integer_encoding::VarInt;
use multihash_codetable::Code;
use thiserror::Error;

/// This value has been chosen to optimise to reduce gas-costs when accessing the balances map. Non-
Expand Down Expand Up @@ -788,12 +788,11 @@ pub struct StateSummary {

#[cfg(test)]
mod test {
use cid::multihash::Code;
use cid::Cid;
use fvm_ipld_blockstore::{Block, Blockstore, MemoryBlockstore};
use fvm_ipld_encoding::DAG_CBOR;
use fvm_shared::econ::TokenAmount;
use fvm_shared::{bigint::Zero, ActorID};
use multihash_codetable::Code;

use super::TokenState;
use crate::token::state::{actor_id_key, OwnerAllowanceMap, StateError, StateInvariantError};
Expand All @@ -811,11 +810,12 @@ mod test {
fn it_handles_missing_data_load() {
// try to load from an empty blockstore (and default Cid)
let bs = &MemoryBlockstore::new();
let cid = Cid::default();
let block = Block { codec: DAG_CBOR, data: Vec::new() };
let cid = block.cid(Code::Blake2b256);
let res = TokenState::load(bs, &cid);
match res {
Err(StateError::MissingState(_)) => {}
_ => panic!("unexpected result"),
r => panic!("unexpected result {r:?}"),
}
}

Expand Down
1 change: 1 addition & 0 deletions frc53_nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fvm_ipld_encoding = { workspace = true }
fvm_sdk = { workspace = true }
fvm_shared = { workspace = true }
integer-encoding = { workspace = true }
multihash-codetable = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true }
serde_tuple = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion frc53_nft/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::collections::HashMap;
use std::mem;
use std::vec;

use cid::multihash::Code;
use cid::Cid;
use fvm_actor_utils::receiver::ReceiverHookError;
use fvm_ipld_amt::Amt;
Expand All @@ -20,6 +19,7 @@ use fvm_ipld_hamt::Error as HamtError;
use fvm_ipld_hamt::Hamt;
use fvm_shared::ActorID;
use integer_encoding::VarInt;
use multihash_codetable::Code;
use thiserror::Error;

use crate::types::ActorIDSet;
Expand Down
1 change: 1 addition & 0 deletions fvm_actor_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fvm_ipld_blockstore = { workspace = true }
fvm_ipld_encoding = { workspace = true }
fvm_shared = { workspace = true }
fvm_sdk = { workspace = true }
multihash-codetable = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true }
serde_tuple = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion fvm_actor_utils/src/blockstore.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::anyhow;
use anyhow::Result;
use cid::multihash::Code;
use cid::Cid;
use fvm_ipld_blockstore::Block;
use fvm_sdk::ipld;
use multihash_codetable::Code;

/// A blockstore that delegates to IPLD syscalls.
#[derive(Default, Debug, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion testing/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ serde = { workspace = true }
serde_tuple = { workspace = true }

[dev-dependencies]
actors-v12 = { package = "fil_builtin_actors_bundle", git = "https://github.com/filecoin-project/builtin-actors", branch = "fvm-next" }
actors = { package = "fil_builtin_actors_bundle", git = "https://github.com/filecoin-project/builtin-actors", branch = "steb/update-multihash" }
helix_test_actors = { path = "../test_actors" }
token_impl = { path = "../test_actors/actors/frc46_factory_token/token_impl" }
2 changes: 1 addition & 1 deletion testing/integration/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn load_actor_wasm(path: &str) -> Vec<u8> {
/// This mainly cuts down on noise with importing the built-in actor bundle and network/state tree
/// versions.
pub fn construct_tester<BS: Blockstore + Clone, E: Externs>(blockstore: &BS) -> Tester<BS, E> {
let bundle_root = bundle::import_bundle(&blockstore, actors_v12::BUNDLE_CAR).unwrap();
let bundle_root = bundle::import_bundle(&blockstore, actors::BUNDLE_CAR).unwrap();

Tester::new(NetworkVersion::V21, StateTreeVersion::V5, bundle_root, blockstore.clone()).unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion testing/integration/tests/frc46_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct MintParams {
#[test]
fn it_mints_tokens() {
let blockstore = MemoryBlockstore::default();
let bundle_root = bundle::import_bundle(&blockstore, actors_v12::BUNDLE_CAR).unwrap();
let bundle_root = bundle::import_bundle(&blockstore, actors::BUNDLE_CAR).unwrap();
let mut tester =
Tester::new(NetworkVersion::V21, StateTreeVersion::V5, bundle_root, blockstore.clone())
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions testing/test_actors/actors/basic_transfer_actor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fvm_ipld_blockstore = { workspace = true }
fvm_ipld_encoding = { workspace = true }
fvm_sdk = { workspace = true }
fvm_shared = { workspace = true }
multihash-codetable = { workspace = true }
serde = { workspace = true }
serde_tuple = { workspace = true }

Expand Down
3 changes: 2 additions & 1 deletion testing/test_actors/actors/basic_transfer_actor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cid::{multihash::Code, Cid};
use cid::Cid;
use frc42_dispatch::{match_method, method_hash};
use frc46_token::receiver::{FRC46TokenReceived, FRC46_TOKEN_TYPE};
use frc46_token::token::types::TransferParams;
Expand All @@ -10,6 +10,7 @@ use fvm_ipld_encoding::{de::DeserializeOwned, RawBytes, DAG_CBOR};
use fvm_sdk as sdk;
use fvm_shared::sys::SendFlags;
use fvm_shared::{address::Address, bigint::Zero, econ::TokenAmount, error::ExitCode};
use multihash_codetable::Code;
use sdk::NO_DATA_BLOCK_ID;

/// Grab the incoming parameters and convert from [`RawBytes`] to the deserialized struct.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fvm_ipld_blockstore = { workspace = true }
fvm_ipld_encoding = { workspace = true }
fvm_sdk = { workspace = true }
fvm_shared = { workspace = true }
multihash-codetable = { workspace = true }
serde = { workspace = true }
serde_tuple = { workspace = true }
thiserror = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cid::{multihash::Code, Cid};
use cid::Cid;
use frc42_dispatch::match_method;
use frc46_token::token::{
state::{StateError, TokenState},
Expand All @@ -24,6 +24,7 @@ use fvm_ipld_encoding::{
use fvm_sdk::error::{StateReadError, StateUpdateError};
use fvm_sdk::{self as sdk, sys::ErrorNumber, NO_DATA_BLOCK_ID};
use fvm_shared::{address::Address, econ::TokenAmount, error::ExitCode, ActorID};
use multihash_codetable::Code;
use serde::{de::DeserializeOwned, ser::Serialize};
use thiserror::Error;

Expand Down

0 comments on commit 82f3972

Please sign in to comment.