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

Import/Export StateTree for Testing #1114

Merged
merged 7 commits into from
Jun 1, 2021
Merged

Import/Export StateTree for Testing #1114

merged 7 commits into from
Jun 1, 2021

Conversation

ec2
Copy link
Member

@ec2 ec2 commented May 25, 2021

Summary of changes
Changes introduced in this pull request:

  • Allows writing and reading the StateTree in CAR format. This allows for ease of testing where we need a live StateTree

Reference issue to close (if applicable)

Closes

Other information and links

@ec2 ec2 requested a review from a user May 25, 2021 13:53
Copy link
Contributor

@creativcoder creativcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will shave a lot of time on our state migration testing. Thanks a lot @ec2

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ErrorType::Other variants strike me as shortcut around defining proper error types. Otherwise, this LGTM, just wanted to flag for a future error refactoring effort.

let state_root = forest_car::load_car(self.blockstore(), reader)
.await
.map_err(|e| Error::Other(format!("Import StateTree failed: {}", e.to_string())))?;
if state_root.len() != 1 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use pop and if it returns a None variant return the error. This will get rid of indexing.

@creativcoder
Copy link
Contributor

creativcoder commented May 27, 2021

I guess, we need to move these methods out of chain. We require the import/export methods in interpreter crate (vm.rs), but chain crate itself depends on interpreter. I get the following error when using ChainStore from vm.rs:

error: cyclic package dependency: package `chain v0.1.0 (/home/ubuntu/forest/blockchain/chain)` depends on itself. Cycle:
package `chain v0.1.0 (/home/ubuntu/forest/blockchain/chain)`
    ... which is depended on by `interpreter v0.1.0 (/home/ubuntu/forest/vm/interpreter)`
    ... which is depended on by `chain v0.1.0 (/home/ubuntu/forest/blockchain/chain)`

@ec2 ec2 merged commit 8108017 into main Jun 1, 2021
@ec2 ec2 deleted the ec2/export-tree branch June 1, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants