Skip to content

Commit 7308289

Browse files
authored
chore: update multihash & cid (filecoin-project#1589)
* chore: update multihash & cid * test: use valid CIDs in the state_control test
1 parent ca31c60 commit 7308289

35 files changed

+1110
-860
lines changed

Cargo.lock

+1,014-754
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+35-33
Original file line numberDiff line numberDiff line change
@@ -116,30 +116,30 @@ rlp = { version = "0.5.1", default-features = false }
116116
substrate-bn = { version = "0.6.0", default-features = false }
117117

118118
# IPLD/Encoding
119-
cid = { version = "0.10.1", default-features = false, features = [
120-
"serde-codec",
119+
cid = { version = "0.11.1", default-features = false, features = [
120+
"serde",
121121
"std",
122122
] }
123-
multihash = { version = "0.18.1", default-features = false, features = [
124-
"multihash-impl",
125-
] }
126-
libipld-core = { version = "0.13.1", features = ["serde-codec"] }
123+
multihash = { version = "0.19.1", default-features = false }
124+
multihash-codetable = { version = "0.1.4", default-features = false }
125+
multihash-derive = { version = "0.9.1", default-features = false }
126+
ipld-core = { version = "0.4.1", features = ["serde"] }
127127
integer-encoding = { version = "3.0.3", default-features = false }
128128

129-
# helix-onchain
130-
fvm_actor_utils = "11.0.0"
131-
frc42_dispatch = "7.0.0"
132-
frc46_token = "11.0.0"
129+
# actor-utils
130+
fvm_actor_utils = "12.0.0"
131+
frc42_dispatch = "8.0.0"
132+
frc46_token = "12.0.0"
133133

134134
# FVM
135-
fvm_sdk = "4.3.0"
136-
fvm_shared = "4.3.0"
137-
fvm_ipld_encoding = "0.4.0"
138-
fvm_ipld_blockstore = "0.2.0"
139-
fvm_ipld_hamt = "0.9.0"
140-
fvm_ipld_kamt = "0.3.0"
141-
fvm_ipld_amt = { version = "0.6.2" }
142-
fvm_ipld_bitfield = "0.6.0"
135+
fvm_sdk = "4.5.1"
136+
fvm_shared = "4.5.1"
137+
fvm_ipld_encoding = "0.5.0"
138+
fvm_ipld_blockstore = "0.3.0"
139+
fvm_ipld_hamt = "0.10.2"
140+
fvm_ipld_kamt = "0.4.2"
141+
fvm_ipld_amt = { version = "0.7.3" }
142+
fvm_ipld_bitfield = "0.7.0"
143143

144144
# workspace
145145
fil_actor_account = { path = "actors/account" }
@@ -165,17 +165,17 @@ fil_actors_integration_tests = { version = "1.0.0", path = "integration_tests" }
165165
vm_api = { version = "1.0.0", path = "vm_api" }
166166
test_vm = { path = "test_vm" }
167167

168-
[patch.crates-io]
168+
#[patch.crates-io]
169169
#fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
170170
#fvm_sdk = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
171171
#fvm_ipld_hamt = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
172172
#fvm_ipld_amt = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
173173
#fvm_ipld_bitfield = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
174174
#fvm_ipld_encoding = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
175175
#fvm_ipld_blockstore = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" }
176-
#fvm_actor_utils = { git = "https://github.com/helix-onchain/filecoin", branch = "main" }
177-
#frc42_dispatch = { git = "https://github.com/helix-onchain/filecoin", branch = "main" }
178-
#frc46_token = { git = "https://github.com/helix-onchain/filecoin", branch = "main" }
176+
#fvm_actor_utils = { git = "https://github.com/filecoin-project/actors-utils", branch = "main" }
177+
#frc42_dispatch = { git = "https://github.com/filecoin-project/actors-utils", branch = "main" }
178+
#frc46_token = { git = "https://github.com/filecoin-project/actors-utils", branch = "main" }
179179

180180
## Uncomment when working locally on ref-fvm and this repo simultaneously.
181181
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
@@ -192,17 +192,19 @@ test_vm = { path = "test_vm" }
192192
## Uncomment entries below when working locally on ref-fvm and this repo simultaneously.
193193
## Assumes the ref-fvm checkout is in a sibling directory with the same name.
194194
## (Valid once FVM modules are published to crates.io)
195-
# [patch.crates-io]
196-
# fvm_shared = { path = "../ref-fvm/shared" }
197-
# fvm_sdk = { path = "../ref-fvm/sdk" }
198-
# fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
199-
# fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
200-
# fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
201-
# fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
202-
# fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
203-
#fvm_actor_utils = { path = "../../filecoin/fvm_actor_utils"}
204-
#frc42_dispatch = { path = "../../filecoin/frc42_dispatch"}
205-
#frc46_token = { path = "../../filecoin/frc46_token"}
195+
#[patch.crates-io]
196+
#fvm_shared = { path = "../ref-fvm/shared" }
197+
#fvm_sdk = { path = "../ref-fvm/sdk" }
198+
#fvm_ipld_car = { path = "../ref-fvm/ipld/car" }
199+
#fvm_ipld_hamt = { path = "../ref-fvm/ipld/hamt" }
200+
#fvm_ipld_amt = { path = "../ref-fvm/ipld/amt" }
201+
#fvm_ipld_bitfield = { path = "../ref-fvm/ipld/bitfield"}
202+
#fvm_ipld_encoding = { path = "../ref-fvm/ipld/encoding"}
203+
#fvm_ipld_blockstore = { path = "../ref-fvm/ipld/blockstore"}
204+
#fvm_actor_utils = { path = "../actors-utils/fvm_actor_utils"}
205+
#fil_actor_bundler = { path = "../builtin-actors-bundler"}
206+
#frc42_dispatch = { path = "../actors-utils/frc42_dispatch"}
207+
#frc46_token = { path = "../actors-utils/frc46_token"}
206208

207209
[profile.wasm]
208210
inherits = "release"

actors/evm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ anyhow = { workspace = true }
2626
log = { workspace = true }
2727
fvm_ipld_blockstore = { workspace = true }
2828
fvm_ipld_encoding = { workspace = true }
29-
multihash = { workspace = true }
29+
multihash-codetable = { workspace = true }
3030
frc42_dispatch = { workspace = true }
3131
fil_actors_evm_shared = { workspace = true }
3232
hex = { workspace = true }

actors/evm/src/interpreter/instructions/context.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub fn base_fee(
150150
#[cfg(test)]
151151
mod tests {
152152
use crate::evm_unit_test;
153+
use cid::multihash::Multihash;
153154
use cid::Cid;
154155
use fil_actors_evm_shared::uints::U256;
155156
use fil_actors_runtime::EAM_ACTOR_ID;
@@ -160,12 +161,10 @@ mod tests {
160161
fn test_blockhash() {
161162
// truncate to 32 bytes
162163
let counting_byte_hash: Vec<u8> = (0..40u8).collect();
163-
let long_unknown =
164-
Cid::new_v1(IPLD_RAW, multihash::Multihash::wrap(0, &counting_byte_hash).unwrap());
164+
let long_unknown = Cid::new_v1(IPLD_RAW, Multihash::wrap(0, &counting_byte_hash).unwrap());
165165
let long_expect = counting_byte_hash[..32].try_into().unwrap();
166166
// multihash code ignored
167-
let cbor_odd_hash =
168-
Cid::new_v1(DAG_CBOR, multihash::Multihash::wrap(123, &[0xfe; 32]).unwrap());
167+
let cbor_odd_hash = Cid::new_v1(DAG_CBOR, Multihash::wrap(123, &[0xfe; 32]).unwrap());
169168
let cbor_odd_expect = [0xfe; 32];
170169

171170
let nothing = [0; 32];

actors/evm/src/interpreter/system.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::borrow::Cow;
22

3-
use cid::multihash::Code;
43
use fil_actors_evm_shared::{address::EthAddress, uints::U256};
54
use fil_actors_runtime::{
65
actor_error, extract_send_result, runtime::EMPTY_ARR_CID, AsActorError, EAM_ACTOR_ID,
@@ -15,6 +14,7 @@ use fvm_shared::econ::TokenAmount;
1514
use fvm_shared::error::{ErrorNumber, ExitCode};
1615
use fvm_shared::sys::SendFlags;
1716
use fvm_shared::{MethodNum, Response, IPLD_RAW, METHOD_SEND};
17+
use multihash_codetable::Code;
1818

1919
use crate::state::{State, Tombstone};
2020
use crate::BytecodeHash;

actors/evm/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const EVM_WORD_SIZE: usize = 32;
5050
#[test]
5151
fn test_method_selector() {
5252
// We could just _generate_ this method selector with a proc macro, but this is easier.
53-
use cid::multihash::MultihashDigest;
54-
let hash = cid::multihash::Code::Keccak256.digest(NATIVE_METHOD_SIGNATURE.as_bytes());
53+
use multihash_codetable::MultihashDigest;
54+
let hash = multihash_codetable::Code::Keccak256.digest(NATIVE_METHOD_SIGNATURE.as_bytes());
5555
let computed_selector = &hash.digest()[..4];
5656
assert_eq!(computed_selector, NATIVE_METHOD_SELECTOR);
5757
}

actors/market/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ fvm_ipld_encoding = { workspace = true }
2626
fvm_ipld_hamt = { workspace = true }
2727
fvm_shared = { workspace = true }
2828
integer-encoding = { workspace = true }
29-
libipld-core = { workspace = true }
29+
ipld-core = { workspace = true }
3030
log = { workspace = true }
3131
num-derive = { workspace = true }
3232
num-traits = { workspace = true }
3333
serde = { workspace = true }
3434
lazy_static = { workspace = true }
35+
multihash-codetable = { workspace = true }
3536

3637
[dev-dependencies]
3738
fil_actors_runtime = { workspace = true, features = ["test_utils", "sector-default"] }
3839
fil_actor_power = { workspace = true }
3940
fil_actor_reward = { workspace = true }
4041
fil_actor_verifreg = { workspace = true }
4142
fvm_ipld_amt = { workspace = true }
42-
multihash = { workspace = true }
4343
regex = { workspace = true }
4444
itertools = { workspace = true }
4545

actors/market/src/deal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use fvm_shared::crypto::signature::Signature;
1111
use fvm_shared::econ::TokenAmount;
1212
use fvm_shared::piece::PaddedPieceSize;
1313
use fvm_shared::sector::SectorNumber;
14-
use libipld_core::ipld::Ipld;
14+
use ipld_core::ipld::Ipld;
1515
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
1616
use std::convert::{TryFrom, TryInto};
1717

actors/market/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use std::cmp::min;
55
use std::collections::{BTreeMap, BTreeSet, HashSet};
66

7-
use cid::multihash::{Code, MultihashGeneric};
7+
use cid::multihash::Multihash;
88
use cid::Cid;
99
use fil_actors_runtime::reward::ThisEpochRewardReturn;
1010
use frc46_token::token::types::{BalanceReturn, TransferFromParams, TransferFromReturn};
@@ -16,6 +16,7 @@ use fvm_ipld_hamt::BytesKey;
1616
use fvm_shared::address::Address;
1717
use fvm_shared::bigint::BigInt;
1818
use fvm_shared::clock::{ChainEpoch, EPOCH_UNDEFINED};
19+
use fvm_shared::crypto::hash::SupportedHashes;
1920
use fvm_shared::deal::DealID;
2021
use fvm_shared::econ::TokenAmount;
2122
use fvm_shared::error::ExitCode;
@@ -1723,7 +1724,7 @@ pub fn deal_cid(rt: &impl Runtime, proposal: &DealProposal) -> Result<Cid, Actor
17231724
/// Compute a deal CID from serialized proposal using the runtime
17241725
pub(crate) fn serialized_deal_cid(rt: &impl Runtime, data: &[u8]) -> Result<Cid, ActorError> {
17251726
const DIGEST_SIZE: u32 = 32;
1726-
let hash = MultihashGeneric::wrap(Code::Blake2b256.into(), &rt.hash_blake2b(data))
1727+
let hash = Multihash::wrap(SupportedHashes::Blake2b256.into(), &rt.hash_blake2b(data))
17271728
.map_err(|e| actor_error!(illegal_argument; "failed to take cid of proposal {}", e))?;
17281729
debug_assert_eq!(u32::from(hash.size()), DIGEST_SIZE, "expected 32byte digest");
17291730
Ok(Cid::new_v1(DAG_CBOR, hash))

actors/market/src/testing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{
44
convert::TryFrom,
55
};
66

7-
use cid::multihash::{Code, MultihashDigest};
87
use cid::Cid;
98
use fvm_ipld_blockstore::Blockstore;
109
use fvm_ipld_encoding::DAG_CBOR;
@@ -18,6 +17,7 @@ use fvm_shared::{
1817
ActorID,
1918
};
2019
use integer_encoding::VarInt;
20+
use multihash_codetable::{Code, MultihashDigest};
2121
use num_traits::Zero;
2222

2323
use fil_actors_runtime::builtin::HAMT_BIT_WIDTH;

actors/market/tests/harness.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,7 @@ pub fn assert_deal_deleted(
12071207
sector_number: SectorNumber,
12081208
empty_sector_deals: bool,
12091209
) {
1210-
use cid::multihash::Code;
1211-
use cid::multihash::MultihashDigest;
1210+
use multihash_codetable::{Code, MultihashDigest};
12121211

12131212
let st: State = rt.get_state();
12141213

actors/market/tests/sector_content_changed.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use fvm_shared::deal::DealID;
55
use fvm_shared::econ::TokenAmount;
66
use fvm_shared::error::ExitCode;
77
use fvm_shared::piece::PaddedPieceSize;
8-
use multihash::Code::Sha2_256;
9-
use multihash::MultihashDigest;
8+
use multihash_codetable::{Code::Sha2_256, MultihashDigest};
109
use num_traits::Zero;
1110

1211
use fil_actor_market::ext::miner::{

actors/miner/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ lazy_static = { workspace = true }
3333
log = { workspace = true }
3434
byteorder = { workspace = true }
3535
itertools = { workspace = true }
36+
multihash-codetable = { workspace = true }
3637

3738
[dev-dependencies]
3839
fil_actors_runtime = { workspace = true, features = ["test_utils", "sector-default"] }
@@ -43,6 +44,7 @@ fil_actor_market = { workspace = true }
4344
rand = { workspace = true }
4445
test-case = { workspace = true }
4546
const-hex = { workspace = true }
47+
multihash-derive = { workspace = true }
4648

4749
[features]
4850
fil-actor = ["fil_actors_runtime/fil-actor"]

actors/miner/src/deadline_state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::cmp;
55
use std::collections::BTreeSet;
66

77
use anyhow::anyhow;
8-
use cid::multihash::Code;
98
use cid::Cid;
109
use fvm_ipld_bitfield::BitField;
1110
use fvm_ipld_blockstore::Blockstore;
@@ -15,6 +14,7 @@ use fvm_shared::clock::ChainEpoch;
1514
use fvm_shared::econ::TokenAmount;
1615
use fvm_shared::error::ExitCode;
1716
use fvm_shared::sector::{PoStProof, SectorSize};
17+
use multihash_codetable::Code;
1818
use num_traits::{Signed, Zero};
1919

2020
use fil_actors_runtime::runtime::Policy;

actors/miner/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::ops::Neg;
99

1010
use anyhow::{anyhow, Error};
1111
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
12-
use cid::multihash::Code::Blake2b256;
1312
use cid::Cid;
1413
use fvm_ipld_bitfield::{BitField, Validate};
1514
use fvm_ipld_blockstore::Blockstore;
@@ -32,6 +31,7 @@ use fvm_shared::sector::{
3231
use fvm_shared::{ActorID, MethodNum, METHOD_CONSTRUCTOR, METHOD_SEND};
3332
use itertools::Itertools;
3433
use log::{error, info, warn};
34+
use multihash_codetable::Code::Blake2b256;
3535
use num_derive::FromPrimitive;
3636
use num_traits::{Signed, Zero};
3737

actors/miner/src/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::cmp;
66
use std::ops::Neg;
77

88
use anyhow::{anyhow, Error};
9-
use cid::multihash::Code;
109
use cid::Cid;
1110
use fvm_ipld_amt::Error as AmtError;
1211
use fvm_ipld_bitfield::BitField;
@@ -20,6 +19,7 @@ use fvm_shared::error::ExitCode;
2019
use fvm_shared::sector::{RegisteredPoStProof, SectorNumber, SectorSize};
2120
use fvm_shared::{ActorID, HAMT_BIT_WIDTH};
2221
use itertools::Itertools;
22+
use multihash_codetable::Code;
2323
use num_traits::Zero;
2424

2525
use fil_actors_runtime::runtime::policy_constants::MAX_SECTOR_NUMBER;

actors/miner/tests/state_harness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(dead_code)]
2-
use cid::multihash::Code::Blake2b256;
32
use fil_actor_miner::{
43
BitFieldQueue, CollisionPolicy, MinerInfo, QuantSpec, SectorOnChainInfo,
54
SectorPreCommitOnChainInfo, State, VestSpec, VestingFunds,
@@ -12,6 +11,7 @@ use fvm_ipld_encoding::CborStore;
1211
use fvm_shared::econ::TokenAmount;
1312
use fvm_shared::sector::{SectorNumber, SectorSize};
1413
use fvm_shared::{clock::ChainEpoch, sector::RegisteredPoStProof};
14+
use multihash_codetable::Code::Blake2b256;
1515

1616
use fil_actors_runtime::test_utils::*;
1717

actors/miner/tests/util.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::iter;
66
use std::ops::Neg;
77

88
use anyhow::anyhow;
9-
use cid::multihash::MultihashDigest;
109
use cid::Cid;
1110
use fil_actors_runtime::reward::FilterEstimate;
1211
use fvm_ipld_amt::Amt;
@@ -38,7 +37,7 @@ use fvm_shared::sector::{
3837
use fvm_shared::{ActorID, HAMT_BIT_WIDTH, METHOD_SEND};
3938
use itertools::Itertools;
4039
use lazy_static::lazy_static;
41-
use multihash::derive::Multihash;
40+
use multihash_codetable::MultihashDigest;
4241
use num_traits::Signed;
4342

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

32993298
// multihash library doesn't support poseidon hashing, so we fake it
3300-
#[derive(Clone, Copy, Debug, Eq, Multihash, PartialEq)]
3299+
#[derive(Clone, Copy, Debug, Eq, MultihashDigest, PartialEq)]
33013300
#[mh(alloc_size = 64)]
33023301
enum MhCode {
3303-
#[mh(code = 0xb401, hasher = multihash::Sha2_256)]
3302+
#[mh(code = 0xb401, hasher = multihash_codetable::Sha2_256)]
33043303
PoseidonFake,
3305-
#[mh(code = 0x1012, hasher = multihash::Sha2_256)]
3304+
#[mh(code = 0x1012, hasher = multihash_codetable::Sha2_256)]
33063305
Sha256TruncPaddedFake,
33073306
}
33083307

actors/system/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ crate-type = ["cdylib", "lib"]
1717
fil_actors_runtime = { workspace = true }
1818
fvm_shared = { workspace = true }
1919
fvm_ipld_encoding = { workspace = true }
20+
multihash-codetable = { workspace = true }
2021
fvm_ipld_blockstore = { workspace = true }
2122
num-traits = { workspace = true }
2223
anyhow = { workspace = true }

actors/system/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright 2019-2022 ChainSafe Systems
22
// SPDX-License-Identifier: Apache-2.0, MIT
3-
use cid::{multihash, Cid};
3+
use cid::Cid;
44
use fvm_ipld_blockstore::Blockstore;
55
use fvm_ipld_encoding::tuple::*;
66
use fvm_ipld_encoding::CborStore;
@@ -33,7 +33,7 @@ pub struct State {
3333
impl State {
3434
pub fn new<BS: Blockstore>(store: &BS) -> Result<Self, ActorError> {
3535
let c = store
36-
.put_cbor(&Vec::<(String, Cid)>::new(), multihash::Code::Blake2b256)
36+
.put_cbor(&Vec::<(String, Cid)>::new(), multihash_codetable::Code::Blake2b256)
3737
.context_code(ExitCode::USR_ILLEGAL_STATE, "failed to store system state")?;
3838
Ok(Self { builtin_actors: c })
3939
}

integration_tests/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ thiserror = { workspace = true }
6060
libsecp256k1 = { workspace = true }
6161
export_macro = { path = "./macro" }
6262
ctor = "0.2.5"
63+
multihash-codetable = { workspace = true }
6364

6465
[dev-dependencies]
65-
multihash = { workspace = true }
6666
test-case = { workspace = true }
6767
hex-literal = { workspace = true }

0 commit comments

Comments
 (0)