-
Notifications
You must be signed in to change notification settings - Fork 46
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 Visor Vector Builder & Executor #370
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c82e6c
feat(vector lens): implement vector lens
frrist e5fdf5d
feat(vector): implement vector build and run
frrist f1ab952
temp-fix: strawman for #374
frrist 9dc646c
fix(model): PowerActorClaim missing from model list
frrist 0733e65
polish(vector): add vector fetching script and unit test
frrist ee65592
docs(vector): add readme with example usage
frrist 4a9b539
Revert "temp-fix: strawman for #374"
frrist 69afaa0
hack: hacky fix for #374
frrist 176f1aa
test(vector): generate new message vector after rebase onto #389
frrist 6dcf1ec
fix lint errors
iand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ visor | |
sentinel-visor | ||
|
||
build/.* | ||
vector/data/*.json | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package chain | ||
|
||
func NewAddressFilter(addr string) *AddressFilter { | ||
return &AddressFilter{address: addr} | ||
} | ||
|
||
type AddressFilter struct { | ||
address string | ||
} | ||
|
||
func (f *AddressFilter) Allow(addr string) bool { | ||
return f.address == addr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package commands | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"os/signal" | ||
"strings" | ||
"syscall" | ||
|
||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/filecoin-project/sentinel-visor/chain" | ||
"github.com/filecoin-project/sentinel-visor/vector" | ||
) | ||
|
||
var Vector = &cli.Command{ | ||
Name: "vector", | ||
Usage: "Vector tooling for Visor.", | ||
Subcommands: []*cli.Command{ | ||
BuildVector, | ||
ExecuteVector, | ||
}, | ||
} | ||
|
||
var BuildVector = &cli.Command{ | ||
Name: "build", | ||
Usage: "Create a vector.", | ||
Flags: []cli.Flag{ | ||
&cli.Int64Flag{ | ||
Name: "from", | ||
Usage: "Limit actor and message processing to tipsets at or above `HEIGHT`", | ||
EnvVars: []string{"VISOR_HEIGHT_FROM"}, | ||
}, | ||
&cli.Int64Flag{ | ||
Name: "to", | ||
Usage: "Limit actor and message processing to tipsets at or below `HEIGHT`", | ||
Value: estimateCurrentEpoch(), | ||
DefaultText: "current epoch", | ||
EnvVars: []string{"VISOR_HEIGHT_TO"}, | ||
}, | ||
&cli.StringFlag{ | ||
Name: "tasks", | ||
Usage: "Comma separated list of tasks to build. Each task is reported separately in the database.", | ||
Value: strings.Join([]string{chain.BlocksTask}, ","), | ||
EnvVars: []string{"VISOR_VECTOR_TASKS"}, | ||
}, | ||
&cli.StringFlag{ | ||
Name: "actor-address", | ||
Usage: "Address of an actor.", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "vector-file", | ||
Usage: "Path of vector file.", | ||
Required: true, | ||
}, | ||
&cli.StringFlag{ | ||
Name: "vector-desc", | ||
Usage: "Short description of the test vector.", | ||
Required: true, | ||
}, | ||
}, | ||
Action: build, | ||
} | ||
|
||
func build(cctx *cli.Context) error { | ||
// Set up a context that is canceled when the command is interrupted | ||
ctx, cancel := context.WithCancel(cctx.Context) | ||
|
||
// Set up a signal handler to cancel the context | ||
go func() { | ||
interrupt := make(chan os.Signal, 1) | ||
signal.Notify(interrupt, syscall.SIGTERM, syscall.SIGINT) | ||
select { | ||
case <-interrupt: | ||
cancel() | ||
case <-ctx.Done(): | ||
} | ||
}() | ||
|
||
if err := setupLogging(cctx); err != nil { | ||
return xerrors.Errorf("setup logging: %w", err) | ||
} | ||
|
||
builder, err := vector.NewBuilder(cctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
schema, err := builder.Build(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return schema.Persist(cctx.String("vector-file")) | ||
} | ||
|
||
var ExecuteVector = &cli.Command{ | ||
Name: "execute", | ||
Usage: "execute a test vector", | ||
Flags: []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "vector-file", | ||
Usage: "Path to vector file.", | ||
Required: true, | ||
}, | ||
}, | ||
Action: execute, | ||
} | ||
|
||
func execute(cctx *cli.Context) error { | ||
// Set up a context that is canceled when the command is interrupted | ||
ctx, cancel := context.WithCancel(cctx.Context) | ||
|
||
// Set up a signal handler to cancel the context | ||
go func() { | ||
interrupt := make(chan os.Signal, 1) | ||
signal.Notify(interrupt, syscall.SIGTERM, syscall.SIGINT) | ||
select { | ||
case <-interrupt: | ||
cancel() | ||
case <-ctx.Done(): | ||
} | ||
}() | ||
|
||
if err := setupLogging(cctx); err != nil { | ||
return xerrors.Errorf("setup logging: %w", err) | ||
} | ||
runner, err := vector.NewRunner(ctx, cctx.String("vector-file"), 0) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = runner.Run(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return runner.Validate(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the vector files don't get pushed to github.