Skip to content

Commit

Permalink
chore: update multihash & cid
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Nov 21, 2024
1 parent ca31c60 commit d42ee06
Show file tree
Hide file tree
Showing 34 changed files with 1,103 additions and 840 deletions.
1,768 changes: 1,014 additions & 754 deletions Cargo.lock

Large diffs are not rendered by default.

68 changes: 35 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,30 @@ rlp = { version = "0.5.1", default-features = false }
substrate-bn = { version = "0.6.0", default-features = false }

# IPLD/Encoding
cid = { version = "0.10.1", default-features = false, features = [
"serde-codec",
cid = { version = "0.11.1", default-features = false, features = [
"serde",
"std",
] }
multihash = { version = "0.18.1", default-features = false, features = [
"multihash-impl",
] }
libipld-core = { version = "0.13.1", features = ["serde-codec"] }
multihash = { version = "0.19.1", default-features = false }
multihash-codetable = { version = "0.1.4", default-features = false }
multihash-derive = { version = "0.9.1", default-features = false }
ipld-core = { version = "0.4.1", features = ["serde"] }
integer-encoding = { version = "3.0.3", default-features = false }

# helix-onchain
fvm_actor_utils = "11.0.0"
frc42_dispatch = "7.0.0"
frc46_token = "11.0.0"
# actor-utils
fvm_actor_utils = "12.0.0"
frc42_dispatch = "8.0.0"
frc46_token = "12.0.0"

# FVM
fvm_sdk = "4.3.0"
fvm_shared = "4.3.0"
fvm_ipld_encoding = "0.4.0"
fvm_ipld_blockstore = "0.2.0"
fvm_ipld_hamt = "0.9.0"
fvm_ipld_kamt = "0.3.0"
fvm_ipld_amt = { version = "0.6.2" }
fvm_ipld_bitfield = "0.6.0"
fvm_sdk = "4.5.1"
fvm_shared = "4.5.1"
fvm_ipld_encoding = "0.5.0"
fvm_ipld_blockstore = "0.3.0"
fvm_ipld_hamt = "0.10.2"
fvm_ipld_kamt = "0.4.2"
fvm_ipld_amt = { version = "0.7.3" }
fvm_ipld_bitfield = "0.7.0"

# workspace
fil_actor_account = { path = "actors/account" }
Expand All @@ -165,17 +165,17 @@ fil_actors_integration_tests = { version = "1.0.0", path = "integration_tests" }
vm_api = { version = "1.0.0", path = "vm_api" }
test_vm = { path = "test_vm" }

[patch.crates-io]
#[patch.crates-io]
#fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_sdk = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_ipld_hamt = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_ipld_amt = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_ipld_bitfield = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_ipld_encoding = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_ipld_blockstore = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
#fvm_actor_utils = { git = "https://github.com/helix-onchain/filecoin", branch = "main" }
#frc42_dispatch = { git = "https://github.com/helix-onchain/filecoin", branch = "main" }
#frc46_token = { git = "https://github.com/helix-onchain/filecoin", branch = "main" }
#fvm_actor_utils = { git = "https://github.com/filecoin-project/actors-utils", branch = "main" }
#frc42_dispatch = { git = "https://github.com/filecoin-project/actors-utils", branch = "main" }
#frc46_token = { git = "https://github.com/filecoin-project/actors-utils", branch = "main" }

## Uncomment when working locally on ref-fvm and this repo simultaneously.
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
Expand All @@ -192,17 +192,19 @@ test_vm = { path = "test_vm" }
## Uncomment entries below when working locally on ref-fvm and this repo simultaneously.
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
## (Valid once FVM modules are published to crates.io)
# [patch.crates-io]
# fvm_shared = { path = "../ref-fvm/shared" }
# fvm_sdk = { path = "../ref-fvm/sdk" }
# fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
# fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
# fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
# fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
# fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
#fvm_actor_utils = { path = "../../filecoin/fvm_actor_utils"}
#frc42_dispatch = { path = "../../filecoin/frc42_dispatch"}
#frc46_token = { path = "../../filecoin/frc46_token"}
#[patch.crates-io]
#fvm_shared = { path = "../ref-fvm/shared" }
#fvm_sdk = { path = "../ref-fvm/sdk" }
#fvm_ipld_car = { path = "../ref-fvm/ipld/car" }
#fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
#fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
#fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
#fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
#fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
#fvm_actor_utils = { path = "../actors-utils/fvm_actor_utils"}
#fil_actor_bundler = { path = "../builtin-actors-bundler"}
#frc42_dispatch = { path = "../actors-utils/frc42_dispatch"}
#frc46_token = { path = "../actors-utils/frc46_token"}

[profile.wasm]
inherits = "release"
Expand Down
2 changes: 1 addition & 1 deletion actors/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ anyhow = { workspace = true }
log = { workspace = true }
fvm_ipld_blockstore = { workspace = true }
fvm_ipld_encoding = { workspace = true }
multihash = { workspace = true }
multihash-codetable = { workspace = true }
frc42_dispatch = { workspace = true }
fil_actors_evm_shared = { workspace = true }
hex = { workspace = true }
Expand Down
7 changes: 3 additions & 4 deletions actors/evm/src/interpreter/instructions/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub fn base_fee(
#[cfg(test)]
mod tests {
use crate::evm_unit_test;
use cid::multihash::Multihash;
use cid::Cid;
use fil_actors_evm_shared::uints::U256;
use fil_actors_runtime::EAM_ACTOR_ID;
Expand All @@ -160,12 +161,10 @@ mod tests {
fn test_blockhash() {
// truncate to 32 bytes
let counting_byte_hash: Vec<u8> = (0..40u8).collect();
let long_unknown =
Cid::new_v1(IPLD_RAW, multihash::Multihash::wrap(0, &counting_byte_hash).unwrap());
let long_unknown = Cid::new_v1(IPLD_RAW, Multihash::wrap(0, &counting_byte_hash).unwrap());
let long_expect = counting_byte_hash[..32].try_into().unwrap();
// multihash code ignored
let cbor_odd_hash =
Cid::new_v1(DAG_CBOR, multihash::Multihash::wrap(123, &[0xfe; 32]).unwrap());
let cbor_odd_hash = Cid::new_v1(DAG_CBOR, Multihash::wrap(123, &[0xfe; 32]).unwrap());
let cbor_odd_expect = [0xfe; 32];

let nothing = [0; 32];
Expand Down
2 changes: 1 addition & 1 deletion actors/evm/src/interpreter/system.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::borrow::Cow;

use cid::multihash::Code;
use fil_actors_evm_shared::{address::EthAddress, uints::U256};
use fil_actors_runtime::{
actor_error, extract_send_result, runtime::EMPTY_ARR_CID, AsActorError, EAM_ACTOR_ID,
Expand All @@ -15,6 +14,7 @@ use fvm_shared::econ::TokenAmount;
use fvm_shared::error::{ErrorNumber, ExitCode};
use fvm_shared::sys::SendFlags;
use fvm_shared::{MethodNum, Response, IPLD_RAW, METHOD_SEND};
use multihash_codetable::Code;

use crate::state::{State, Tombstone};
use crate::BytecodeHash;
Expand Down
4 changes: 2 additions & 2 deletions actors/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const EVM_WORD_SIZE: usize = 32;
#[test]
fn test_method_selector() {
// We could just _generate_ this method selector with a proc macro, but this is easier.
use cid::multihash::MultihashDigest;
let hash = cid::multihash::Code::Keccak256.digest(NATIVE_METHOD_SIGNATURE.as_bytes());
use multihash_codetable::MultihashDigest;
let hash = multihash_codetable::Code::Keccak256.digest(NATIVE_METHOD_SIGNATURE.as_bytes());
let computed_selector = &hash.digest()[..4];
assert_eq!(computed_selector, NATIVE_METHOD_SELECTOR);
}
Expand Down
4 changes: 2 additions & 2 deletions actors/market/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ fvm_ipld_encoding = { workspace = true }
fvm_ipld_hamt = { workspace = true }
fvm_shared = { workspace = true }
integer-encoding = { workspace = true }
libipld-core = { workspace = true }
ipld-core = { workspace = true }
log = { workspace = true }
num-derive = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true }
lazy_static = { workspace = true }
multihash-codetable = { workspace = true }

[dev-dependencies]
fil_actors_runtime = { workspace = true, features = ["test_utils", "sector-default"] }
fil_actor_power = { workspace = true }
fil_actor_reward = { workspace = true }
fil_actor_verifreg = { workspace = true }
fvm_ipld_amt = { workspace = true }
multihash = { workspace = true }
regex = { workspace = true }
itertools = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion actors/market/src/deal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use fvm_shared::crypto::signature::Signature;
use fvm_shared::econ::TokenAmount;
use fvm_shared::piece::PaddedPieceSize;
use fvm_shared::sector::SectorNumber;
use libipld_core::ipld::Ipld;
use ipld_core::ipld::Ipld;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::convert::{TryFrom, TryInto};

Expand Down
5 changes: 3 additions & 2 deletions actors/market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::cmp::min;
use std::collections::{BTreeMap, BTreeSet, HashSet};

use cid::multihash::{Code, MultihashGeneric};
use cid::multihash::Multihash;
use cid::Cid;
use fil_actors_runtime::reward::ThisEpochRewardReturn;
use frc46_token::token::types::{BalanceReturn, TransferFromParams, TransferFromReturn};
Expand All @@ -16,6 +16,7 @@ use fvm_ipld_hamt::BytesKey;
use fvm_shared::address::Address;
use fvm_shared::bigint::BigInt;
use fvm_shared::clock::{ChainEpoch, EPOCH_UNDEFINED};
use fvm_shared::crypto::hash::SupportedHashes;
use fvm_shared::deal::DealID;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
Expand Down Expand Up @@ -1723,7 +1724,7 @@ pub fn deal_cid(rt: &impl Runtime, proposal: &DealProposal) -> Result<Cid, Actor
/// Compute a deal CID from serialized proposal using the runtime
pub(crate) fn serialized_deal_cid(rt: &impl Runtime, data: &[u8]) -> Result<Cid, ActorError> {
const DIGEST_SIZE: u32 = 32;
let hash = MultihashGeneric::wrap(Code::Blake2b256.into(), &rt.hash_blake2b(data))
let hash = Multihash::wrap(SupportedHashes::Blake2b256.into(), &rt.hash_blake2b(data))
.map_err(|e| actor_error!(illegal_argument; "failed to take cid of proposal {}", e))?;
debug_assert_eq!(u32::from(hash.size()), DIGEST_SIZE, "expected 32byte digest");
Ok(Cid::new_v1(DAG_CBOR, hash))
Expand Down
2 changes: 1 addition & 1 deletion actors/market/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
convert::TryFrom,
};

use cid::multihash::{Code, MultihashDigest};
use cid::Cid;
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::DAG_CBOR;
Expand All @@ -18,6 +17,7 @@ use fvm_shared::{
ActorID,
};
use integer_encoding::VarInt;
use multihash_codetable::{Code, MultihashDigest};
use num_traits::Zero;

use fil_actors_runtime::builtin::HAMT_BIT_WIDTH;
Expand Down
3 changes: 1 addition & 2 deletions actors/market/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,7 @@ pub fn assert_deal_deleted(
sector_number: SectorNumber,
empty_sector_deals: bool,
) {
use cid::multihash::Code;
use cid::multihash::MultihashDigest;
use multihash_codetable::{Code, MultihashDigest};

let st: State = rt.get_state();

Expand Down
3 changes: 1 addition & 2 deletions actors/market/tests/sector_content_changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use fvm_shared::deal::DealID;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
use fvm_shared::piece::PaddedPieceSize;
use multihash::Code::Sha2_256;
use multihash::MultihashDigest;
use multihash_codetable::{Code::Sha2_256, MultihashDigest};
use num_traits::Zero;

use fil_actor_market::ext::miner::{
Expand Down
2 changes: 2 additions & 0 deletions actors/miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ lazy_static = { workspace = true }
log = { workspace = true }
byteorder = { workspace = true }
itertools = { workspace = true }
multihash-codetable = { workspace = true }

[dev-dependencies]
fil_actors_runtime = { workspace = true, features = ["test_utils", "sector-default"] }
Expand All @@ -43,6 +44,7 @@ fil_actor_market = { workspace = true }
rand = { workspace = true }
test-case = { workspace = true }
const-hex = { workspace = true }
multihash-derive = { workspace = true }

[features]
fil-actor = ["fil_actors_runtime/fil-actor"]
2 changes: 1 addition & 1 deletion actors/miner/src/deadline_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::cmp;
use std::collections::BTreeSet;

use anyhow::anyhow;
use cid::multihash::Code;
use cid::Cid;
use fvm_ipld_bitfield::BitField;
use fvm_ipld_blockstore::Blockstore;
Expand All @@ -15,6 +14,7 @@ use fvm_shared::clock::ChainEpoch;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
use fvm_shared::sector::{PoStProof, SectorSize};
use multihash_codetable::Code;
use num_traits::{Signed, Zero};

use fil_actors_runtime::runtime::Policy;
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::ops::Neg;

use anyhow::{anyhow, Error};
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
use cid::multihash::Code::Blake2b256;
use cid::Cid;
use fvm_ipld_bitfield::{BitField, Validate};
use fvm_ipld_blockstore::Blockstore;
Expand All @@ -32,6 +31,7 @@ use fvm_shared::sector::{
use fvm_shared::{ActorID, MethodNum, METHOD_CONSTRUCTOR, METHOD_SEND};
use itertools::Itertools;
use log::{error, info, warn};
use multihash_codetable::Code::Blake2b256;
use num_derive::FromPrimitive;
use num_traits::{Signed, Zero};

Expand Down
2 changes: 1 addition & 1 deletion actors/miner/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::cmp;
use std::ops::Neg;

use anyhow::{anyhow, Error};
use cid::multihash::Code;
use cid::Cid;
use fvm_ipld_amt::Error as AmtError;
use fvm_ipld_bitfield::BitField;
Expand All @@ -20,6 +19,7 @@ use fvm_shared::error::ExitCode;
use fvm_shared::sector::{RegisteredPoStProof, SectorNumber, SectorSize};
use fvm_shared::{ActorID, HAMT_BIT_WIDTH};
use itertools::Itertools;
use multihash_codetable::Code;
use num_traits::Zero;

use fil_actors_runtime::runtime::policy_constants::MAX_SECTOR_NUMBER;
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/state_harness.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(dead_code)]
use cid::multihash::Code::Blake2b256;
use fil_actor_miner::{
BitFieldQueue, CollisionPolicy, MinerInfo, QuantSpec, SectorOnChainInfo,
SectorPreCommitOnChainInfo, State, VestSpec, VestingFunds,
Expand All @@ -12,6 +11,7 @@ use fvm_ipld_encoding::CborStore;
use fvm_shared::econ::TokenAmount;
use fvm_shared::sector::{SectorNumber, SectorSize};
use fvm_shared::{clock::ChainEpoch, sector::RegisteredPoStProof};
use multihash_codetable::Code::Blake2b256;

use fil_actors_runtime::test_utils::*;

Expand Down
9 changes: 4 additions & 5 deletions actors/miner/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::iter;
use std::ops::Neg;

use anyhow::anyhow;
use cid::multihash::MultihashDigest;
use cid::Cid;
use fil_actors_runtime::reward::FilterEstimate;
use fvm_ipld_amt::Amt;
Expand Down Expand Up @@ -38,7 +37,7 @@ use fvm_shared::sector::{
use fvm_shared::{ActorID, HAMT_BIT_WIDTH, METHOD_SEND};
use itertools::Itertools;
use lazy_static::lazy_static;
use multihash::derive::Multihash;
use multihash_codetable::MultihashDigest;
use num_traits::Signed;

use fil_actor_account::Method as AccountMethod;
Expand Down Expand Up @@ -3297,12 +3296,12 @@ pub fn make_prove_commit_aggregate(sector_nos: &BitField) -> ProveCommitAggregat
}

// multihash library doesn't support poseidon hashing, so we fake it
#[derive(Clone, Copy, Debug, Eq, Multihash, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, MultihashDigest, PartialEq)]
#[mh(alloc_size = 64)]
enum MhCode {
#[mh(code = 0xb401, hasher = multihash::Sha2_256)]
#[mh(code = 0xb401, hasher = multihash_codetable::Sha2_256)]
PoseidonFake,
#[mh(code = 0x1012, hasher = multihash::Sha2_256)]
#[mh(code = 0x1012, hasher = multihash_codetable::Sha2_256)]
Sha256TruncPaddedFake,
}

Expand Down
1 change: 1 addition & 0 deletions actors/system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ crate-type = ["cdylib", "lib"]
fil_actors_runtime = { workspace = true }
fvm_shared = { workspace = true }
fvm_ipld_encoding = { workspace = true }
multihash-codetable = { workspace = true }
fvm_ipld_blockstore = { workspace = true }
num-traits = { workspace = true }
anyhow = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions actors/system/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2019-2022 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use cid::{multihash, Cid};
use cid::Cid;
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::tuple::*;
use fvm_ipld_encoding::CborStore;
Expand Down Expand Up @@ -33,7 +33,7 @@ pub struct State {
impl State {
pub fn new<BS: Blockstore>(store: &BS) -> Result<Self, ActorError> {
let c = store
.put_cbor(&Vec::<(String, Cid)>::new(), multihash::Code::Blake2b256)
.put_cbor(&Vec::<(String, Cid)>::new(), multihash_codetable::Code::Blake2b256)
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to store system state")?;
Ok(Self { builtin_actors: c })
}
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ thiserror = { workspace = true }
libsecp256k1 = { workspace = true }
export_macro = { path = "./macro" }
ctor = "0.2.5"
multihash-codetable = { workspace = true }

[dev-dependencies]
multihash = { workspace = true }
test-case = { workspace = true }
hex-literal = { workspace = true }
Loading

0 comments on commit d42ee06

Please sign in to comment.