Skip to content

Commit 77843d9

Browse files
committed
chore: update ipld crates
- cid - multihash - ipld-core This is a major breaking change and requires a bit of a refactor.
1 parent 54a4da7 commit 77843d9

File tree

19 files changed

+153
-153
lines changed

19 files changed

+153
-153
lines changed

Cargo.lock

Lines changed: 102 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ repository = "https://github.com/filecoin-project/ref-fvm"
1515
authors = ["Protocol Labs", "Filecoin Core Devs"]
1616

1717
[workspace.dependencies]
18-
cid = { version = "0.10.1", default-features = false }
19-
multihash = { version = "0.18.1", default-features = false }
20-
fvm_ipld_hamt = { version = "0.9.0"}
21-
fvm_ipld_amt = { version = "0.6.0"}
22-
fvm_ipld_car = { version = "0.7.0" }
23-
fvm_ipld_blockstore = { version = "0.2.0" }
24-
fvm_ipld_encoding = { version = "0.4.0" }
18+
cid = { version = "0.11.1", default-features = false }
19+
multihash = { version = "0.19.2", default-features = false }
20+
multihash-codetable = { version = "0.1.4", default-features = false }
21+
multihash-derive = { version = "0.9.1", default-features = false }
22+
fvm_ipld_hamt = { version = "0.10.2"}
23+
fvm_ipld_amt = { version = "0.7.3"}
24+
fvm_ipld_car = { version = "0.8.1" }
25+
fvm_ipld_blockstore = { version = "0.3.1" }
26+
fvm_ipld_encoding = { version = "0.5.1" }
2527
wasmtime = { version = "25.0.2", default-features = false, features = ["cranelift", "pooling-allocator", "parallel-compilation", "runtime"] }
26-
wasmtime-environ = "25.0.2"
2728

2829
fvm = { path = "fvm", version = "~2.9.1", default-features = false }
2930
fvm_shared = { path = "shared", version = "~2.9.1", default-features = false }

fvm/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ num-traits = "0.2"
1818
derive_builder = "0.20.1"
1919
num-derive = "0.4.0"
2020
cid = { workspace = true, features = ["serde-codec"] }
21-
multihash = { workspace = true }
21+
multihash-codetable = { workspace = true, features = ["sha2", "sha3", "ripemd"] }
22+
multihash-derive = { workspace = true }
2223
fvm_shared = { workspace = true, features = ["crypto"] }
2324
fvm_ipld_hamt = { workspace = true }
2425
fvm_ipld_amt = { workspace = true }

fvm/src/blockstore/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ where
268268

269269
#[cfg(test)]
270270
mod tests {
271-
use cid::multihash::{Code, Multihash};
272271
use fvm_ipld_blockstore::{Blockstore, MemoryBlockstore};
273272
use fvm_ipld_encoding::CborStore;
274273
use fvm_shared::{commcid, IDENTITY_HASH};
274+
use multihash_codetable::{Code, Multihash};
275275
use serde::{Deserialize, Serialize};
276276

277277
use super::*;

fvm/src/kernel/default.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use fvm_shared::sector::SectorInfo;
2121
use fvm_shared::version::NetworkVersion;
2222
use fvm_shared::{commcid, ActorID};
2323
use lazy_static::lazy_static;
24-
use multihash::MultihashDigest;
24+
use multihash_codetable::{Code, Multihash, MultihashDigest};
2525
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
2626
use std::io::Write;
2727

@@ -293,7 +293,7 @@ where
293293
}
294294

295295
let block = self.blocks.get(id)?;
296-
let code = multihash::Code::try_from(hash_fun)
296+
let code = Code::try_from(hash_fun)
297297
.map_err(|_| syscall_error!(IllegalCid; "invalid CID codec"))?;
298298

299299
self.call_manager.charge_gas(
@@ -479,17 +479,12 @@ where
479479
})
480480
}
481481

482-
fn hash(&mut self, code: u64, data: &[u8]) -> Result<MultihashGeneric<64>> {
482+
fn hash(&mut self, code: u64, data: &[u8]) -> Result<Multihash> {
483483
self.call_manager
484484
.charge_gas(self.call_manager.price_list().on_hashing(data.len()))?;
485485

486-
let hasher = SupportedHashes::try_from(code).map_err(|e| {
487-
if let multihash::Error::UnsupportedCode(code) = e {
488-
syscall_error!(IllegalArgument; "unsupported hash code {}", code)
489-
} else {
490-
syscall_error!(AssertionFailed; "hash expected unsupported code, got {}", e)
491-
}
492-
})?;
486+
let hasher = SupportedHashes::try_from(code)
487+
.map_err(|err| syscall_error!(IllegalArgument; "unsupported hash code {}", err.0))?;
493488
Ok(hasher.digest(data))
494489
}
495490

fvm/src/kernel/hash.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use multihash::derive::Multihash;
2-
use multihash::{Blake2b256, Blake2b512, Keccak256, Ripemd160, Sha2_256};
1+
use multihash_codetable::{
2+
Blake2b256, Blake2b512, Keccak256, MultihashDigest, Ripemd160, Sha2_256,
3+
};
34

4-
#[derive(Clone, Copy, Debug, Eq, Multihash, PartialEq)]
5+
#[derive(Clone, Copy, Debug, Eq, MultihashDigest, PartialEq)]
56
#[mh(alloc_size = 64)]
67
/// Codes and hashers supported by FVM.
78
/// You _can_ use this hash directly inside of your actor,

fvm/src/kernel/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use fvm_shared::sector::{
1616
};
1717
use fvm_shared::version::NetworkVersion;
1818
use fvm_shared::{ActorID, MethodNum};
19+
use multihash_codetable::Multihash;
1920

2021
mod hash;
2122

@@ -25,7 +26,6 @@ pub mod default;
2526
mod error;
2627

2728
pub use error::{ClassifyResult, Context, ExecutionError, Result, SyscallError};
28-
use multihash::MultihashGeneric;
2929

3030
use crate::call_manager::CallManager;
3131
use crate::gas::{Gas, PriceList};
@@ -253,7 +253,7 @@ pub trait CryptoOps {
253253
/// `digest_out`, returning the size of the digest written to `digest_out`. If `digest_out` is
254254
/// to small to fit the entire digest, it will be truncated. If too large, the leftover space
255255
/// will not be overwritten.
256-
fn hash(&mut self, code: u64, data: &[u8]) -> Result<MultihashGeneric<64>>;
256+
fn hash(&mut self, code: u64, data: &[u8]) -> Result<Multihash>;
257257

258258
/// Computes an unsealed sector CID (CommD) from its constituent piece CIDs (CommPs) and sizes.
259259
fn compute_unsealed_sector_cid(

fvm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ pub mod system_actor;
4040

4141
pub mod trace;
4242

43-
use cid::multihash::{Code, MultihashDigest};
4443
use cid::Cid;
4544
use fvm_ipld_encoding::{to_vec, DAG_CBOR};
45+
use multihash_codetable::{Code, MultihashDigest};
4646

4747
lazy_static::lazy_static! {
4848
/// Cid of the empty array Cbor bytes (`EMPTY_ARR_BYTES`).
@@ -57,7 +57,7 @@ mod test {
5757
use fvm_ipld_blockstore::MemoryBlockstore;
5858
use fvm_ipld_encoding::CborStore;
5959
use fvm_shared::state::StateTreeVersion;
60-
use multihash::Code;
60+
use multihash_codetable::Code;
6161

6262
use crate::call_manager::DefaultCallManager;
6363
use crate::externs::{Consensus, Externs, Rand};

fvm/src/machine/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ pub struct Manifest {
3535
const fn id_cid(name: &[u8]) -> Cid {
3636
use std::mem;
3737

38+
use cid::multihash::Multihash;
3839
use fvm_shared::{IDENTITY_HASH, IPLD_RAW};
39-
use multihash::Multihash;
4040

4141
// This code is ugly because const fns are a bit ugly right now:
4242
//

fvm/src/state_tree.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::cell::RefCell;
55
use std::collections::HashMap;
66

77
use anyhow::{anyhow, Context as _};
8-
use cid::{multihash, Cid};
8+
use cid::Cid;
99
use fvm_ipld_blockstore::Blockstore;
1010
use fvm_ipld_encoding::tuple::*;
1111
use fvm_ipld_encoding::CborStore;
@@ -208,7 +208,10 @@ where
208208
}
209209
StateTreeVersion::V3 | StateTreeVersion::V4 => {
210210
let cid = store
211-
.put_cbor(&StateInfo0::default(), multihash::Code::Blake2b256)
211+
.put_cbor(
212+
&StateInfo0::default(),
213+
multihash_codetable::Code::Blake2b256,
214+
)
212215
.context("failed to put state info")
213216
.or_fatal()?;
214217
Some(cid)
@@ -424,7 +427,7 @@ where
424427
// Set state for init actor in store and update root Cid
425428
actor.state = self
426429
.store()
427-
.put_cbor(&state, multihash::Code::Blake2b256)
430+
.put_cbor(&state, multihash_codetable::Code::Blake2b256)
428431
.or_fatal()?;
429432

430433
self.set_actor(&crate::init_actor::INIT_ACTOR_ADDR, actor)?;
@@ -484,7 +487,7 @@ where
484487
};
485488
let root = self
486489
.store()
487-
.put_cbor(obj, multihash::Code::Blake2b256)
490+
.put_cbor(obj, multihash_codetable::Code::Blake2b256)
488491
.or_fatal()?;
489492
Ok(root)
490493
}
@@ -629,8 +632,6 @@ pub mod json {
629632

630633
#[cfg(test)]
631634
mod tests {
632-
use cid::multihash::Code::Blake2b256;
633-
use cid::multihash::Multihash;
634635
use cid::Cid;
635636
use fvm_ipld_blockstore::MemoryBlockstore;
636637
use fvm_ipld_encoding::{CborStore, DAG_CBOR};
@@ -640,6 +641,7 @@ mod tests {
640641
use fvm_shared::state::StateTreeVersion;
641642
use fvm_shared::{IDENTITY_HASH, IPLD_RAW};
642643
use lazy_static::lazy_static;
644+
use multihash_codetable::{Code::Blake2b256, Multihash};
643645

644646
use crate::init_actor;
645647
use crate::init_actor::INIT_ACTOR_ADDR;

0 commit comments

Comments
 (0)