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: set control address: add dump bytes option #9572

Merged
merged 1 commit into from
Nov 7, 2022
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
39 changes: 31 additions & 8 deletions cmd/lotus-shed/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"encoding/hex"
"fmt"
"os"

Expand Down Expand Up @@ -420,18 +421,18 @@ var actorControlSet = &cli.Command{
Name: "actor",
Usage: "specify the address of miner actor",
},
&cli.BoolFlag{
Name: "dump-bytes",
Usage: "Dumps the bytes of the message that would propose this change",
Value: false,
},
&cli.BoolFlag{
Name: "really-do-it",
Usage: "Actually send transaction performing the action",
Value: false,
},
},
Action: func(cctx *cli.Context) error {
if !cctx.Bool("really-do-it") {
fmt.Println("Pass --really-do-it to actually execute this action")
return nil
}

var maddr address.Address
if act := cctx.String("actor"); act != "" {
var err error
Expand Down Expand Up @@ -521,14 +522,36 @@ var actorControlSet = &cli.Command{
return xerrors.Errorf("serializing params: %w", err)
}

smsg, err := nodeAPI.MpoolPushMessage(ctx, &types.Message{
msg := &types.Message{
From: mi.Owner,
To: maddr,
Method: builtin.MethodsMiner.ChangeWorkerAddress,

Value: big.Zero(),
Params: sp,
}, nil)
}

if cctx.Bool("dump-bytes") {

msg, err = nodeAPI.GasEstimateMessageGas(ctx, msg, nil, types.EmptyTSK)
if err != nil {
return err
}

msgBytes, err := msg.Serialize()
if err != nil {
return err
}

fmt.Fprintln(cctx.App.Writer, hex.EncodeToString(msgBytes))
return nil
}

if !cctx.Bool("really-do-it") {
fmt.Fprintln(cctx.App.Writer, "Pass --really-do-it to actually execute this action")
return nil
}

smsg, err := nodeAPI.MpoolPushMessage(ctx, msg, nil)
if err != nil {
return xerrors.Errorf("mpool push: %w", err)
}
Expand Down