Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement network version 12 state migration / actors v4 migration #1101

Merged
merged 27 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5a1bccb
initial code for nv12 state migration
creativcoder May 6, 2021
a36027a
simple root migration impl
creativcoder May 8, 2021
1be8b69
fix borrow issues with blockstore
creativcoder May 11, 2021
cfbe800
/s/v2/v3 and /s/v3/v4
creativcoder May 11, 2021
b078bdc
migration works, but incorrect
creativcoder May 11, 2021
e9490cf
few nits
creativcoder May 12, 2021
4e9cd60
try for_each_concurrent and a few refactors
creativcoder May 14, 2021
a634d89
revert to next.await and refactors
creativcoder May 17, 2021
f3b0131
migration log
creativcoder May 17, 2021
d7d4506
address code review comments
creativcoder May 17, 2021
3181b3e
Box<dyn Error> -> String
creativcoder May 18, 2021
2d13662
make blockstore Send + Sync
creativcoder May 19, 2021
0b6e59b
concurrent state migration
creativcoder Jun 3, 2021
cbc561d
chore: cargo fmt
creativcoder Jun 3, 2021
b2f7961
replace Mutex<Map<_>> with DashMap
creativcoder Jun 4, 2021
0412e3e
move common migration code out of miner migrator
creativcoder Jun 7, 2021
ace6d63
clippy fixes
creativcoder Jun 7, 2021
7f01cf1
cleanup unused
creativcoder Jun 7, 2021
fb28f60
cargo fmt
creativcoder Jun 7, 2021
bfb9e20
more clippy fixes
creativcoder Jun 7, 2021
ea55641
relocate a few comments
creativcoder Jun 8, 2021
007311e
Address code review changes
creativcoder Jun 11, 2021
dc83e1b
code review: rename arc_store to store
creativcoder Jun 21, 2021
5082c6d
more compact in_state initialization in miner.rs
creativcoder Jun 21, 2021
934d7db
migrate_state should return error when prev state not equal new state…
creativcoder Jun 21, 2021
e0e30c6
make clippy happy
creativcoder Jun 21, 2021
fe18df9
cargo fmt
creativcoder Jun 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 68 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"vm/runtime",
"vm/state_tree",
"vm/interpreter",
"vm/state_migration",
"node/clock",
"node/db",
"node/rpc",
Expand Down
18 changes: 12 additions & 6 deletions blockchain/state_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,19 @@ where
V: ProofVerifier,
CB: FnMut(&Cid, &ChainMessage, &ApplyRet) -> Result<(), String>,
{
let mut buf_store = BufferedBlockStore::new(self.blockstore());
let db = self.blockstore_cloned();
let mut buf_store = Arc::new(BufferedBlockStore::new(db.as_ref()));
let store = buf_store.as_ref();
let lb_wrapper = SMLookbackWrapper {
sm: self,
store: &buf_store,
store,
tipset,
verifier: PhantomData::<V>::default(),
};

let mut vm = VM::<_, _, _, _, _, V>::new(
p_state,
&buf_store,
store,
epoch,
rand,
base_fee,
Expand All @@ -249,14 +251,18 @@ where
)?;

// Apply tipset messages
let receipts = vm.apply_block_messages(messages, parent_epoch, epoch, callback)?;
let receipts =
vm.apply_block_messages(messages, parent_epoch, epoch, buf_store.clone(), callback)?;

// Construct receipt root from receipts
let rect_root = Amt::new_from_iter(self.blockstore(), receipts)?;
// Flush changes to blockstore
let state_root = vm.flush()?;
// Persist changes connected to root
buf_store.flush(&state_root)?;
Arc::get_mut(&mut buf_store)
.expect("failed getting store reference")
.flush(&state_root)
.expect("buffered blockstore flush failed");

Ok((state_root, rect_root))
}
Expand Down Expand Up @@ -1283,7 +1289,7 @@ impl<'sm, 'ts, DB, BS, V> LookbackStateGetter<'sm, BS> for SMLookbackWrapper<'sm
where
// Yes, both are needed, because the VM should only use the buffered store
DB: BlockStore + Send + Sync + 'static,
BS: BlockStore,
BS: BlockStore + Send + Sync,
V: ProofVerifier,
{
fn state_lookback(&self, round: ChainEpoch) -> Result<StateTree<'sm, BS>, Box<dyn StdError>> {
Expand Down
2 changes: 2 additions & 0 deletions ipld/blockstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ db = { package = "forest_db", version = "0.1" }
encoding = { package = "forest_encoding", version = "0.2.1" }
forest_ipld = { optional = true, version = "0.1" }
byteorder = "1.3.2"
dashmap = "4.0.2"

[dev-dependencies]
commcid = { path = "../../utils/commcid" }

Expand Down
Loading