From 82f3972fda53fa2d3e7ee590eaee522e3bf214a6 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 21 Nov 2024 03:39:12 +0000 Subject: [PATCH] chore: update cid/multihash (#239) Pull in a large breaking change to cid & multihash, updating the FVM to handle these changes as well. --- Cargo.toml | 23 ++++++++++--------- frc46_token/Cargo.toml | 1 + frc46_token/src/token/state.rs | 10 ++++---- frc53_nft/Cargo.toml | 1 + frc53_nft/src/state.rs | 2 +- fvm_actor_utils/Cargo.toml | 1 + fvm_actor_utils/src/blockstore.rs | 2 +- testing/integration/Cargo.toml | 2 +- testing/integration/tests/common/mod.rs | 2 +- testing/integration/tests/frc46_tokens.rs | 2 +- .../actors/basic_transfer_actor/Cargo.toml | 1 + .../actors/basic_transfer_actor/src/lib.rs | 3 ++- .../frc46_factory_token/token_impl/Cargo.toml | 1 + .../frc46_factory_token/token_impl/src/lib.rs | 3 ++- 14 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e91e576d..d2c0cf3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/frc46_token/Cargo.toml b/frc46_token/Cargo.toml index d54d703b..4d828b3d 100644 --- a/frc46_token/Cargo.toml +++ b/frc46_token/Cargo.toml @@ -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 } diff --git a/frc46_token/src/token/state.rs b/frc46_token/src/token/state.rs index 6a16c695..7cbbf501 100644 --- a/frc46_token/src/token/state.rs +++ b/frc46_token/src/token/state.rs @@ -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; @@ -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- @@ -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}; @@ -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:?}"), } } diff --git a/frc53_nft/Cargo.toml b/frc53_nft/Cargo.toml index 33f0d331..87866037 100644 --- a/frc53_nft/Cargo.toml +++ b/frc53_nft/Cargo.toml @@ -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 } diff --git a/frc53_nft/src/state.rs b/frc53_nft/src/state.rs index e3c5ab3e..d7e3dc32 100644 --- a/frc53_nft/src/state.rs +++ b/frc53_nft/src/state.rs @@ -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; @@ -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; diff --git a/fvm_actor_utils/Cargo.toml b/fvm_actor_utils/Cargo.toml index 6a92b6e4..b7380ead 100644 --- a/fvm_actor_utils/Cargo.toml +++ b/fvm_actor_utils/Cargo.toml @@ -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 } diff --git a/fvm_actor_utils/src/blockstore.rs b/fvm_actor_utils/src/blockstore.rs index bb2ec7e5..3255ad4a 100644 --- a/fvm_actor_utils/src/blockstore.rs +++ b/fvm_actor_utils/src/blockstore.rs @@ -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)] diff --git a/testing/integration/Cargo.toml b/testing/integration/Cargo.toml index 268be3aa..88fe2b2b 100644 --- a/testing/integration/Cargo.toml +++ b/testing/integration/Cargo.toml @@ -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" } diff --git a/testing/integration/tests/common/mod.rs b/testing/integration/tests/common/mod.rs index d5b1e56c..84a8077a 100644 --- a/testing/integration/tests/common/mod.rs +++ b/testing/integration/tests/common/mod.rs @@ -65,7 +65,7 @@ pub fn load_actor_wasm(path: &str) -> Vec { /// This mainly cuts down on noise with importing the built-in actor bundle and network/state tree /// versions. pub fn construct_tester(blockstore: &BS) -> Tester { - 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() } diff --git a/testing/integration/tests/frc46_tokens.rs b/testing/integration/tests/frc46_tokens.rs index 1ea519ab..8cbdd3cf 100644 --- a/testing/integration/tests/frc46_tokens.rs +++ b/testing/integration/tests/frc46_tokens.rs @@ -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(); diff --git a/testing/test_actors/actors/basic_transfer_actor/Cargo.toml b/testing/test_actors/actors/basic_transfer_actor/Cargo.toml index fac833c7..caa21804 100644 --- a/testing/test_actors/actors/basic_transfer_actor/Cargo.toml +++ b/testing/test_actors/actors/basic_transfer_actor/Cargo.toml @@ -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 } diff --git a/testing/test_actors/actors/basic_transfer_actor/src/lib.rs b/testing/test_actors/actors/basic_transfer_actor/src/lib.rs index e1249770..30d73b1a 100644 --- a/testing/test_actors/actors/basic_transfer_actor/src/lib.rs +++ b/testing/test_actors/actors/basic_transfer_actor/src/lib.rs @@ -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; @@ -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. diff --git a/testing/test_actors/actors/frc46_factory_token/token_impl/Cargo.toml b/testing/test_actors/actors/frc46_factory_token/token_impl/Cargo.toml index 50e76f2b..8480aca3 100644 --- a/testing/test_actors/actors/frc46_factory_token/token_impl/Cargo.toml +++ b/testing/test_actors/actors/frc46_factory_token/token_impl/Cargo.toml @@ -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 } diff --git a/testing/test_actors/actors/frc46_factory_token/token_impl/src/lib.rs b/testing/test_actors/actors/frc46_factory_token/token_impl/src/lib.rs index a1ed5611..0c8f423e 100644 --- a/testing/test_actors/actors/frc46_factory_token/token_impl/src/lib.rs +++ b/testing/test_actors/actors/frc46_factory_token/token_impl/src/lib.rs @@ -1,4 +1,4 @@ -use cid::{multihash::Code, Cid}; +use cid::Cid; use frc42_dispatch::match_method; use frc46_token::token::{ state::{StateError, TokenState}, @@ -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;