Skip to content

Commit 076159d

Browse files
committed
fix: explicitly specify HAMT bitwidths everywhere
This _doesn't_ migrate to the new `Map2` interface everywhere, it just avoids the use of `Hamt::load` and `Hamt::new`, which will be deprecated in the next release of `fvm_ipld_hamt`. part of #1346
1 parent 7e11334 commit 076159d

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

actors/miner/src/testing.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
SectorOnChainInfo, SectorPreCommitOnChainInfo, Sectors, State,
44
};
55
use fil_actors_runtime::runtime::Policy;
6-
use fil_actors_runtime::{parse_uint_key, Map, MessageAccumulator};
6+
use fil_actors_runtime::{parse_uint_key, Map, MessageAccumulator, DEFAULT_HAMT_CONFIG};
77
use fvm_ipld_bitfield::BitField;
88
use fvm_ipld_blockstore::Blockstore;
99
use fvm_ipld_encoding::CborStore;
@@ -343,8 +343,11 @@ fn check_precommits<BS: Blockstore>(
343343

344344
let mut precommit_total = TokenAmount::zero();
345345

346-
let precommited_sectors =
347-
Map::<_, SectorPreCommitOnChainInfo>::load(&state.pre_committed_sectors, store);
346+
let precommited_sectors = Map::<_, SectorPreCommitOnChainInfo>::load_with_config(
347+
&state.pre_committed_sectors,
348+
store,
349+
DEFAULT_HAMT_CONFIG,
350+
);
348351

349352
match precommited_sectors {
350353
Ok(precommited_sectors) => {

state/src/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use fil_actor_reward::State as RewardState;
2222
use fil_actor_verifreg::{DataCap, State as VerifregState};
2323

2424
use fil_actors_runtime::runtime::Policy;
25+
use fil_actors_runtime::DEFAULT_HAMT_CONFIG;
2526
use fil_actors_runtime::VERIFIED_REGISTRY_ACTOR_ADDR;
2627

2728
use fil_actors_runtime::Map;
@@ -82,7 +83,7 @@ where
8283
impl<'a, BS: Blockstore> Tree<'a, BS> {
8384
/// Loads a tree from a root CID and store
8485
pub fn load(store: &'a BS, root: &Cid) -> anyhow::Result<Self> {
85-
let map = Map::load(root, store)?;
86+
let map = Map::load_with_config(root, store, DEFAULT_HAMT_CONFIG)?;
8687

8788
Ok(Tree { map, store })
8889
}

test_vm/src/lib.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use fil_actor_verifreg::State as VerifRegState;
1414
use fil_actors_runtime::cbor::serialize;
1515
use fil_actors_runtime::runtime::builtins::Type;
1616
use fil_actors_runtime::runtime::{Policy, Primitives, EMPTY_ARR_CID};
17-
use fil_actors_runtime::test_utils::*;
1817
use fil_actors_runtime::DATACAP_TOKEN_ACTOR_ADDR;
18+
use fil_actors_runtime::{test_utils::*, DEFAULT_HAMT_CONFIG};
1919
use fil_actors_runtime::{
2020
BURNT_FUNDS_ACTOR_ADDR, CRON_ACTOR_ADDR, EAM_ACTOR_ADDR, INIT_ACTOR_ADDR, REWARD_ACTOR_ADDR,
2121
STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, SYSTEM_ACTOR_ADDR,
@@ -70,7 +70,11 @@ where
7070
BS: Blockstore,
7171
{
7272
pub fn new(store: &'bs MemoryBlockstore) -> TestVM<'bs, MemoryBlockstore> {
73-
let mut actors = Hamt::<&'bs MemoryBlockstore, ActorState, BytesKey, Sha256>::new(store);
73+
let mut actors =
74+
Hamt::<&'bs MemoryBlockstore, ActorState, BytesKey, Sha256>::new_with_config(
75+
store,
76+
DEFAULT_HAMT_CONFIG,
77+
);
7478
TestVM {
7579
primitives: FakePrimitives {},
7680
store,
@@ -240,9 +244,10 @@ where
240244

241245
pub fn checkpoint(&self) -> Cid {
242246
// persist cache on top of latest checkpoint and clear
243-
let mut actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load(
247+
let mut actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load_with_config(
244248
&self.state_root.borrow(),
245249
self.store,
250+
DEFAULT_HAMT_CONFIG,
246251
)
247252
.unwrap();
248253
for (addr, act) in self.actors_cache.borrow().iter() {
@@ -383,9 +388,10 @@ where
383388
return Some(act.clone());
384389
}
385390
// go to persisted map
386-
let actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load(
391+
let actors = Hamt::<&'bs BS, ActorState, BytesKey, Sha256>::load_with_config(
387392
&self.state_root.borrow(),
388393
self.store,
394+
DEFAULT_HAMT_CONFIG,
389395
)
390396
.unwrap();
391397
let actor = actors.get(&address.to_bytes()).unwrap().cloned();

0 commit comments

Comments
 (0)