Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

state tree examiner #227

Closed
wants to merge 7 commits into from
Closed

state tree examiner #227

wants to merge 7 commits into from

Conversation

willscott
Copy link
Contributor

@willscott willscott commented Aug 13, 2020

Standalone tool for visualization of diff's between state trees.

Two subcommands:

  • vector - takes in a json test vector and presents a visualization of what changes in the pre and post stateroots of the car
  • diff - takes in a CID object (message or block) or pair (block1..block2) and presents a visualization of the change over them.

By default, expands to the actor level (balances, which actors change), as full expansion/retrieval is quite slow. Full actor expansion is enabled with --expand-actors all. Specific actors can be expanded with --expand-actors reward,cron or --expand-actors bafkqaetgnfwc6mjpon2g64tbm5sw22lomvza (either the class of the builtin actor, the code Cids, or actor head Cids)

@willscott willscott mentioned this pull request Aug 13, 2020
2 tasks
@@ -0,0 +1 @@
../tvx/schema.go
Copy link
Member

Choose a reason for hiding this comment

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

is this some Go magic trick I don't know about? 😮

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a git symbolic link :)

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

I can't claim I understand everything that's going on here ;-) I'm gonna take it out for a spin now and will report more back.

One proposal I'd like to make is to follow the standard golang packaging, as far as possible. I would move the contents of lib to the root, and move the command to a main package in cmd/statediff.

This makes it easy to import as (in the future):

import "github.com/filecoin-project/lotus/statediff"

Instead of the more awkward import (that also requires an import alias):

import statediff "github.com/filecoin-project/lotus/statediff/lib"

It also paves the way for integration in Lotus, where you'll want the command to live inside lotus/cmd/statediff, and call out to github.com/filecoin-project/lotus/statediff.


replace github.com/filecoin-project/filecoin-ffi => ../extra/filecoin-ffi

replace github.com/filecoin-project/sector-storage => github.com/filecoin-project/lotus/extern/sector-storage v0.0.0-20200814115354-002e972f7535
Copy link
Member

Choose a reason for hiding this comment

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

After filecoin-project/lotus#3089, we should no longer require this.


type Option func(c *config)

func ExpandActors(c *config) {
Copy link
Member

Choose a reason for hiding this comment

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

Godocs, please?

Copy link
Member

Choose a reason for hiding this comment

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

An example of the same diff with and without this option would be 🔝

c.ExpandActors = true
}

func ExpandActorByCid(cids []cid.Cid) Option {
Copy link
Member

Choose a reason for hiding this comment

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

Godocs, please?

}
}

// Parse a user entered fuzzy definition for actor expansion.
Copy link
Member

Choose a reason for hiding this comment

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

I have no clue what this sentence means :-)

Copy link
Member

Choose a reason for hiding this comment

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

Examples of well-formed arguments would be welcome.

return m
}

initHampTransformer := func(n *hamtNode) map[string]string {
Copy link
Member

Choose a reason for hiding this comment

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

hamppt? Or is there something I'm missing?

cidMap[".*\\(miner\\.State\\).*Partitions$"] = reflect.TypeOf(make([]*storageMinerActor.Partition, 0))
cidMap["miner\\.Deadline\\)\\.ExpirationsEpochs$"] = reflect.TypeOf(make([]*bitfield.BitField, 0))
cidMap[".*\\(miner\\.State\\).*Partitions.*ExpirationsEpochs$"] = reflect.TypeOf(make([]*storageMinerActor.ExpirationSet, 0))
cidMap[".*\\(miner\\.State\\).*EarlyTerminated$"] = reflect.TypeOf(make([]*bitfield.BitField, 0))
Copy link
Member

Choose a reason for hiding this comment

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

Can we use backticks to avoid the escaping within the regex?

}

func cidTransformer(ctx context.Context, store blockstore.Blockstore, cborStore cbor.IpldStore, atlas map[string]reflect.Type) []cmp.Option {
options := make([]cmp.Option, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
options := make([]cmp.Option, 0)
var options []cmp.Option

"verifiedRegistry": builtin.VerifiedRegistryActorCodeID,
}

func Diff(ctx context.Context, store blockstore.Blockstore, a, b cid.Cid, opts ...Option) {
Copy link
Member

Choose a reason for hiding this comment

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

Having this print straight to stdout is a bit inconvenient. Can we make it return a string? Or provide an alternate Sdiff that returns a string?

willscott added a commit to filecoin-project/statediff that referenced this pull request Aug 20, 2020
@willscott
Copy link
Contributor Author

ported to github.com/filecoin-project/statediff

@willscott willscott closed this Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants