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

Shed: Create a verifreg command for when VRK isn't a multisig #7099

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Changes from all commits
Commits
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
70 changes: 68 additions & 2 deletions cmd/lotus-shed/verifreg.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ var verifRegCmd = &cli.Command{
Usage: "Interact with the verified registry actor",
Flags: []cli.Flag{},
Subcommands: []*cli.Command{
verifRegAddVerifierCmd,
verifRegAddVerifierFromMsigCmd,
verifRegAddVerifierFromAccountCmd,
verifRegVerifyClientCmd,
verifRegListVerifiersCmd,
verifRegListClientsCmd,
Expand All @@ -37,7 +38,7 @@ var verifRegCmd = &cli.Command{
},
}

var verifRegAddVerifierCmd = &cli.Command{
var verifRegAddVerifierFromMsigCmd = &cli.Command{
Name: "add-verifier",
Usage: "make a given account a verifier",
ArgsUsage: "<message sender> <new verifier> <allowance>",
Expand Down Expand Up @@ -110,6 +111,71 @@ var verifRegAddVerifierCmd = &cli.Command{
},
}

var verifRegAddVerifierFromAccountCmd = &cli.Command{
Name: "add-verifier-from-account",
Usage: "make a given account a verifier",
ArgsUsage: "<verifier root key> <new verifier> <allowance>",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 3 {
return fmt.Errorf("must specify three arguments: sender, verifier, and allowance")
}

sender, err := address.NewFromString(cctx.Args().Get(0))
if err != nil {
return err
}

verifier, err := address.NewFromString(cctx.Args().Get(1))
if err != nil {
return err
}

allowance, err := types.BigFromString(cctx.Args().Get(2))
if err != nil {
return err
}

// TODO: ActorUpgrade: Abstract
params, err := actors.SerializeParams(&verifreg2.AddVerifierParams{Address: verifier, Allowance: allowance})
Copy link
Member

Choose a reason for hiding this comment

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

Consider requiring a non-id address for the actor, in case of reorgs.

if err != nil {
return err
}

api, closer, err := lcli.GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := lcli.ReqContext(cctx)

msg := &types.Message{
To: verifreg.Address,
From: sender,
Method: verifreg.Methods.AddVerifier,
Params: params,
}

smsg, err := api.MpoolPushMessage(ctx, msg, nil)
if err != nil {
return err
}

fmt.Printf("message sent, now waiting on cid: %s\n", smsg.Cid())

mwait, err := api.StateWaitMsg(ctx, smsg.Cid(), build.MessageConfidence)
if err != nil {
return err
}

if mwait.Receipt.ExitCode != 0 {
return fmt.Errorf("failed to add verified client: %d", mwait.Receipt.ExitCode)
}

return nil

},
}

var verifRegVerifyClientCmd = &cli.Command{
Name: "verify-client",
Usage: "make a given account a verified client",
Expand Down