lotus/cmd/lotus-seed/genesis.go

671 lines
16 KiB
Go
Raw Normal View History

2020-02-21 20:56:30 +00:00
package main
import (
2020-07-16 09:32:13 +00:00
"encoding/csv"
2020-02-21 20:56:30 +00:00
"encoding/json"
"fmt"
2020-02-21 20:56:30 +00:00
"io/ioutil"
2020-07-16 09:32:13 +00:00
"os"
"strconv"
"strings"
2020-02-21 20:56:30 +00:00
"github.com/google/uuid"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
2020-06-05 22:59:01 +00:00
"golang.org/x/xerrors"
2020-02-21 20:56:30 +00:00
"github.com/filecoin-project/go-address"
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
2022-06-14 15:00:51 +00:00
"github.com/filecoin-project/go-state-types/network"
2020-02-21 20:56:30 +00:00
2022-06-14 15:00:51 +00:00
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
2020-07-24 09:22:50 +00:00
"github.com/filecoin-project/lotus/chain/gen"
2020-02-21 20:56:30 +00:00
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
"github.com/filecoin-project/lotus/chain/types"
2022-06-14 15:00:51 +00:00
"github.com/filecoin-project/lotus/chain/vm"
2020-02-21 20:56:30 +00:00
"github.com/filecoin-project/lotus/genesis"
2022-06-14 15:00:51 +00:00
"github.com/filecoin-project/lotus/journal"
"github.com/filecoin-project/lotus/node/modules/testing"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
2020-02-21 20:56:30 +00:00
)
var genesisCmd = &cli.Command{
Name: "genesis",
Description: "manipulate lotus genesis template",
Subcommands: []*cli.Command{
genesisNewCmd,
genesisAddMinerCmd,
genesisAddMsigsCmd,
genesisSetVRKCmd,
genesisSetRemainderCmd,
genesisSetActorVersionCmd,
genesisCarCmd,
genesisSetVRKSignersCmd,
2020-02-21 20:56:30 +00:00
},
}
var genesisNewCmd = &cli.Command{
Name: "new",
Description: "create new genesis template",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "network-name",
},
},
Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() {
return xerrors.New("seed genesis new [genesis.json]")
}
out := genesis.Template{
2022-05-30 16:58:00 +00:00
NetworkVersion: build.GenesisNetworkVersion,
2020-08-18 21:34:35 +00:00
Accounts: []genesis.Actor{},
Miners: []genesis.Miner{},
VerifregRootKey: gen.DefaultVerifregRootkeyActor,
RemainderAccount: gen.DefaultRemainderAccountActor,
NetworkName: cctx.String("network-name"),
2020-02-21 20:56:30 +00:00
}
if out.NetworkName == "" {
out.NetworkName = "localnet-" + uuid.New().String()
}
2020-02-23 00:47:47 +00:00
genb, err := json.MarshalIndent(&out, "", " ")
2020-02-21 20:56:30 +00:00
if err != nil {
return err
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, genb, 0644); err != nil {
return err
}
return nil
},
}
var genesisAddMinerCmd = &cli.Command{
Name: "add-miner",
Description: "add genesis miner",
2020-02-23 00:47:47 +00:00
Flags: []cli.Flag{},
2020-02-21 20:56:30 +00:00
Action: func(cctx *cli.Context) error {
2022-09-14 18:33:29 +00:00
if cctx.NArg() != 2 {
2020-02-21 20:56:30 +00:00
return xerrors.New("seed genesis add-miner [genesis.json] [preseal.json]")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
var template genesis.Template
genb, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(genb, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
minf, err := homedir.Expand(cctx.Args().Get(1))
if err != nil {
return xerrors.Errorf("expand preseal file path: %w", err)
}
miners := map[string]genesis.Miner{}
minb, err := ioutil.ReadFile(minf)
if err != nil {
return xerrors.Errorf("read preseal file: %w", err)
}
if err := json.Unmarshal(minb, &miners); err != nil {
return xerrors.Errorf("unmarshal miner info: %w", err)
}
for mn, miner := range miners {
log.Infof("Adding miner %s to genesis template", mn)
{
id := uint64(genesis2.MinerStart) + uint64(len(template.Miners))
maddr, err := address.NewFromString(mn)
if err != nil {
return xerrors.Errorf("parsing miner address: %w", err)
}
mid, err := address.IDFromAddress(maddr)
if err != nil {
return xerrors.Errorf("getting miner id from address: %w", err)
}
if mid != id {
return xerrors.Errorf("tried to set miner t0%d as t0%d", mid, id)
}
}
template.Miners = append(template.Miners, miner)
log.Infof("Giving %s some initial balance", miner.Owner)
template.Accounts = append(template.Accounts, genesis.Actor{
Type: genesis.TAccount,
Balance: big.Mul(big.NewInt(50_000_000), big.NewInt(int64(build.FilecoinPrecision))),
2020-02-21 20:56:30 +00:00
Meta: (&genesis.AccountMeta{Owner: miner.Owner}).ActorMeta(),
})
}
2020-02-23 00:47:47 +00:00
genb, err = json.MarshalIndent(&template, "", " ")
2020-02-21 20:56:30 +00:00
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, genb, 0644); err != nil {
return err
}
return nil
},
}
type GenAccountEntry struct {
Version int
ID string
Amount types.FIL
VestingMonths int
CustodianID int
M int
N int
Addresses []address.Address
Type string
Sig1 string
Sig2 string
}
var genesisAddMsigsCmd = &cli.Command{
Name: "add-msigs",
Action: func(cctx *cli.Context) error {
2022-09-14 18:33:29 +00:00
if cctx.NArg() < 2 {
return fmt.Errorf("must specify template file and csv file with accounts")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
2020-07-16 09:32:13 +00:00
csvf, err := homedir.Expand(cctx.Args().Get(1))
if err != nil {
return err
}
var template genesis.Template
b, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(b, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
entries, err := parseMultisigCsv(csvf)
2020-07-16 09:32:13 +00:00
if err != nil {
return xerrors.Errorf("parsing multisig csv file: %w", err)
2020-07-16 09:32:13 +00:00
}
for i, e := range entries {
if len(e.Addresses) != e.N {
return fmt.Errorf("entry %d had mismatch between 'N' and number of addresses", i)
}
msig := &genesis.MultisigMeta{
Signers: e.Addresses,
Threshold: e.M,
VestingDuration: monthsToBlocks(e.VestingMonths),
VestingStart: 0,
}
act := genesis.Actor{
Type: genesis.TMultisig,
Balance: abi.TokenAmount(e.Amount),
Meta: msig.ActorMeta(),
}
template.Accounts = append(template.Accounts, act)
}
b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
return err
}
return nil
},
}
func monthsToBlocks(nmonths int) int {
days := uint64((365 * nmonths) / 12)
return int(days * 24 * 60 * 60 / build.BlockDelaySecs)
}
func parseMultisigCsv(csvf string) ([]GenAccountEntry, error) {
fileReader, err := os.Open(csvf)
if err != nil {
return nil, xerrors.Errorf("read multisig csv: %w", err)
}
2020-07-23 10:21:13 +00:00
defer fileReader.Close() //nolint:errcheck
r := csv.NewReader(fileReader)
records, err := r.ReadAll()
if err != nil {
return nil, xerrors.Errorf("read multisig csv: %w", err)
}
var entries []GenAccountEntry
for i, e := range records[1:] {
var addrs []address.Address
addrStrs := strings.Split(strings.TrimSpace(e[7]), ":")
for j, a := range addrStrs {
addr, err := address.NewFromString(a)
if err != nil {
return nil, xerrors.Errorf("failed to parse address %d in row %d (%q): %w", j, i, a, err)
}
addrs = append(addrs, addr)
}
balance, err := types.ParseFIL(strings.TrimSpace(e[2]))
if err != nil {
return nil, xerrors.Errorf("failed to parse account balance: %w", err)
}
vesting, err := strconv.Atoi(strings.TrimSpace(e[3]))
if err != nil {
return nil, xerrors.Errorf("failed to parse vesting duration for record %d: %w", i, err)
}
custodianID, err := strconv.Atoi(strings.TrimSpace(e[4]))
if err != nil {
return nil, xerrors.Errorf("failed to parse custodianID in record %d: %w", i, err)
}
threshold, err := strconv.Atoi(strings.TrimSpace(e[5]))
if err != nil {
return nil, xerrors.Errorf("failed to parse multisigM in record %d: %w", i, err)
}
num, err := strconv.Atoi(strings.TrimSpace(e[6]))
if err != nil {
return nil, xerrors.Errorf("Number of addresses be integer: %w", err)
}
if e[0] != "1" {
return nil, xerrors.Errorf("record version must be 1")
}
entries = append(entries, GenAccountEntry{
Version: 1,
ID: e[1],
Amount: balance,
CustodianID: custodianID,
VestingMonths: vesting,
M: threshold,
N: num,
Type: e[8],
Sig1: e[9],
Sig2: e[10],
Addresses: addrs,
})
}
return entries, nil
}
var genesisSetVRKCmd = &cli.Command{
Name: "set-vrk",
Usage: "Set the verified registry's root key",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "multisig",
Usage: "CSV file to parse the multisig that will be set as the root key",
},
&cli.StringFlag{
Name: "account",
Usage: "pubkey address that will be set as the root key (must NOT be declared anywhere else, since it must be given ID 80)",
},
},
Action: func(cctx *cli.Context) error {
2022-09-14 18:33:29 +00:00
if cctx.NArg() != 1 {
return fmt.Errorf("must specify template file")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
var template genesis.Template
b, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(b, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
if cctx.IsSet("account") {
addr, err := address.NewFromString(cctx.String("account"))
if err != nil {
return err
}
am := genesis.AccountMeta{Owner: addr}
template.VerifregRootKey = genesis.Actor{
Type: genesis.TAccount,
Balance: big.Zero(),
Meta: am.ActorMeta(),
}
} else if cctx.IsSet("multisig") {
2021-03-17 04:18:50 +00:00
csvf, err := homedir.Expand(cctx.String("multisig"))
if err != nil {
return err
}
entries, err := parseMultisigCsv(csvf)
if err != nil {
return xerrors.Errorf("parsing multisig csv file: %w", err)
}
if len(entries) == 0 {
return xerrors.Errorf("no msig entries in csv file: %w", err)
}
e := entries[0]
if len(e.Addresses) != e.N {
return fmt.Errorf("entry had mismatch between 'N' and number of addresses")
}
msig := &genesis.MultisigMeta{
Signers: e.Addresses,
Threshold: e.M,
VestingDuration: monthsToBlocks(e.VestingMonths),
VestingStart: 0,
}
act := genesis.Actor{
Type: genesis.TMultisig,
Balance: abi.TokenAmount(e.Amount),
Meta: msig.ActorMeta(),
}
template.VerifregRootKey = act
} else {
return xerrors.Errorf("must include either --account or --multisig flag")
}
b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
return err
}
return nil
},
}
var genesisSetRemainderCmd = &cli.Command{
Name: "set-remainder",
Usage: "Set the remainder actor",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "multisig",
Usage: "CSV file to parse the multisig that will be set as the remainder actor",
},
&cli.StringFlag{
Name: "account",
Usage: "pubkey address that will be set as the remainder key (must NOT be declared anywhere else, since it must be given ID 90)",
},
},
Action: func(cctx *cli.Context) error {
2022-09-14 18:33:29 +00:00
if cctx.NArg() != 1 {
return fmt.Errorf("must specify template file")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
var template genesis.Template
b, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(b, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
if cctx.IsSet("account") {
addr, err := address.NewFromString(cctx.String("account"))
if err != nil {
return err
}
am := genesis.AccountMeta{Owner: addr}
template.RemainderAccount = genesis.Actor{
Type: genesis.TAccount,
Balance: big.Zero(),
Meta: am.ActorMeta(),
}
} else if cctx.IsSet("multisig") {
2021-03-17 04:18:50 +00:00
csvf, err := homedir.Expand(cctx.String("multisig"))
if err != nil {
return err
}
entries, err := parseMultisigCsv(csvf)
if err != nil {
return xerrors.Errorf("parsing multisig csv file: %w", err)
}
if len(entries) == 0 {
return xerrors.Errorf("no msig entries in csv file: %w", err)
}
e := entries[0]
if len(e.Addresses) != e.N {
return fmt.Errorf("entry had mismatch between 'N' and number of addresses")
}
msig := &genesis.MultisigMeta{
Signers: e.Addresses,
Threshold: e.M,
VestingDuration: monthsToBlocks(e.VestingMonths),
VestingStart: 0,
}
act := genesis.Actor{
Type: genesis.TMultisig,
Balance: abi.TokenAmount(e.Amount),
Meta: msig.ActorMeta(),
}
template.RemainderAccount = act
} else {
return xerrors.Errorf("must include either --account or --multisig flag")
}
b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
return err
}
return nil
},
}
var genesisSetActorVersionCmd = &cli.Command{
Name: "set-network-version",
Usage: "Set the version that this network will start from",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "network-version",
Usage: "network version to start genesis with",
Value: int(build.GenesisNetworkVersion),
},
},
ArgsUsage: "<genesisFile>",
Action: func(cctx *cli.Context) error {
2022-09-14 18:33:29 +00:00
if cctx.NArg() != 1 {
return fmt.Errorf("must specify genesis file")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
var template genesis.Template
b, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(b, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
nv := network.Version(cctx.Int("network-version"))
build: release: v1.18.0 (#9652) * build: Bump version to v1.17.3-dev * build: set version to v1.18.0-dev * chore: actors: Allow builtin-actors to return a map of methods (#9342) * Allow builtin-actors to return a map of methods * go mod * Fix tests * Fix tests, check carefully please * Delete lotus-pond (#9352) * feat: add StateNetworkVersion to mpool API * chore: refactor: rename NewestNetworkVersion * feat: actors: Integrate datacap actor into lotus (#9348) * Integrate datacap actor * Implement datacap actor in chain/builtin * feat: support typed errors over RPC * chore: deps: update to go-jsonrpc 0.1.8 * remove duplicate import * fix: itest: check for closed connection * chore: refactor: move retry test to API * address magik supernit * Add ability to only have single partition per msg for partitions with recovery sectors * doc gen * Address comments * Return beneficiary info from miner state Info() * Update builtin-actors to dev/20220922-v9 which includes FIP-0045 changes in progress * Integrate verifreg changes to lotus * Setup datacap actor * Update builtin-actors to dev/20220922-v9-1 * Update datacap actor to query datacap instead of verifreg * update gst * update markets * update actors with hamt fix * update gst * Update datacap to parse tokens * Update bundles * datacap and verifreg actors use ID addresses without protocol byte * update builtin-actors to rc1 * update go-fil-markets * Update bundles to rc2 * Integrate the v9 migration * Add api for getting allocation * Add upgrade epoch for butterfly * Tweak PreSeal struct to be infra-friendly * docsgen * More tweaking of PreSeal for genesis * review fixes * Use fake cid for test * add butterfly artifacts for oct 5 upgrade * check datacaps for v8 verifreg match v9 datacap actor * Remove print statements * Update to go-state-types master * Update to go-state-types v0.9.0-rc1 * review fixes * use go-fil-markets v1.24.0-v17 * Add accessors for allocations and claims maps * fix: missing permissions tag * butterfly * update butterfly artifacts * sealing pipeline: Prepare deal assigning logic for FIP-45 * sealing pipeline: Get allocationId with StateApi * use NoAllocationID instead of nil AllocationId * address review * Add datacap actor to registry.go * Add cli for listing allocations and removing expired allocations * Update to go-state-types master * deps: upgrade go-merkledag to 0.8.0 * shark params * Update cli/filplus.go Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> * revert change to verifreg util * docsgen-cli * miss the stuff * Update FFI * Update go-state-types to v0.9.0 * Update builtin-actors to v9.0.0 * add calib upgrade epcoh * update the upgrade envvar * kill shark * Remove fvm splash banner from nv17 upgrade * check invariance for pending deals and allocations * check pending verified deal proposal migrated to allocation * Add check for unsealed CID in precommit sectors * Fix counting of allocations in nv17 migration test * make gen * pass state trees as pointers * Add assertion that migrations with & without cache are the same * compare allocation to verified deal proposal * Fix miner state precommit info * fix migration test tool * add changelog * Update to go-state-types v0.9.1 * Integrate builtin-actors v9.0.1 * chore: ver: bump version for rc3 (#9512) * Bump version to 1.18.0-rc3 * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> * Update CHANGELOG.md Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com> * Migration: Use autobatch bs * Fix autobatch Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai> * Invoker: Use MethodMeta from go-state-types * Add a second premigration for nv17 * Add more shed tools for migration checking * address review * Lotus release v1.18.0-rc4 * fix: ci: fix app-image build on ci (#9527) * Remove old go version first * Add GO_VERSION file * Use GO_VERSION to set / verify go version * mv GO_VERSION GO_VERSION_MIN * Use GO_VERSION_MIN in Makefile check Co-authored-by: Ian Davis <jungziege@gmail.com> * Update to latest go-state-types for migration fixes * go mod tidy * fix: use api.ErrActorNotFound instead of types.ErrActorNotFound * fix: add fields to ForkUpgradeParams * docs: update actors_version_checklist.md * chore: fix lint * update to go state type v0.9.6 with market migration fix (#9545) * update go-state-types to v-0.9.7 * Add invariant checks to migration * fix invariant check: number of entries in datacap actor should include verifreg * Invariant checks: Only include not-activated deals * test: nv17 migration * Address review * add lotus-shed invariance method * Migration cli takes a stateroot cid and a height * make gen * Update to builtin-actors v9.0.2 * Failing test that shows that notaries can remove datacap from the verifreg actor * Test that should pass when the problem is solved * make gen * Review fixes * statemanager call function will return call information even if call errors * update go-state-types * update builtin-actors * bubble up errors properly from ApplyImplicitMessage * bump to rc5 * set new upgrade heights for calibnet * set new upgrade height for butterfly * tweak calibnet upgrade schedule * clarify changelog note about calibnet * butterfly * update calibnet artifacts * Allow setting local bundles for Debug FVM for av 9+ * fix: autobatch: remove potential deadlock when a block is missing Check the _underlying_ blockstore instead of recursing. Also, drop the lock before we do that. * fix imports * build: set shark mainnet epoch (#9640) * chore: build: Lotus release v1.18.0 (#9641) * Lotus release v1.18.0 * add changelog * address review * changelog improvement Co-authored-by: Jennifer Wang <jiayingw703@gmail.com> Co-authored-by: Jiaying Wang <42981373+jennijuju@users.noreply.github.com> Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai> Co-authored-by: Łukasz Magiera <magik6k@gmail.com> Co-authored-by: Łukasz Magiera <magik6k@users.noreply.github.com> Co-authored-by: Aayush <arajasek94@gmail.com> Co-authored-by: Geoff Stuart <geoff.vball@gmail.com> Co-authored-by: Shrenuj Bansal <shrenuj.bansal@protocol.ai> Co-authored-by: simlecode <69969590+simlecode@users.noreply.github.com> Co-authored-by: Rod Vagg <rod@vagg.org> Co-authored-by: Jakub Sztandera <kubuxu@protocol.ai> Co-authored-by: Ian Davis <jungziege@gmail.com> Co-authored-by: zenground0 <ZenGround0@users.noreply.github.com> Co-authored-by: Steven Allen <steven@stebalien.com>
2022-11-16 01:57:23 +00:00
if nv > build.TestNetworkVersion {
return xerrors.Errorf("invalid network version: %d", nv)
}
template.NetworkVersion = nv
b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
return err
}
return nil
},
}
var genesisCarCmd = &cli.Command{
Name: "car",
Description: "write genesis car file",
ArgsUsage: "genesis template `FILE`",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "out",
Aliases: []string{"o"},
Value: "genesis.car",
Usage: "write output to `FILE`",
},
},
Action: func(c *cli.Context) error {
if c.Args().Len() != 1 {
return xerrors.Errorf("Please specify a genesis template. (i.e, the one created with `genesis new`)")
}
ofile := c.String("out")
jrnl := journal.NilJournal()
bstor := blockstore.WrapIDStore(blockstore.NewMemorySync())
sbldr := vm.Syscalls(ffiwrapper.ProofVerifier)
_, err := testing.MakeGenesis(ofile, c.Args().First())(bstor, sbldr, jrnl)()
2021-02-10 01:05:56 +00:00
return err
},
}
var genesisSetVRKSignersCmd = &cli.Command{
Name: "set-signers",
Usage: "",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "threshold",
Usage: "change the verifreg signer threshold",
},
&cli.StringSliceFlag{
Name: "signers",
Usage: "verifreg signers",
},
},
Action: func(cctx *cli.Context) error {
2022-09-14 18:33:29 +00:00
if cctx.NArg() != 1 {
return fmt.Errorf("must specify template file")
}
genf, err := homedir.Expand(cctx.Args().First())
if err != nil {
return err
}
var template genesis.Template
b, err := ioutil.ReadFile(genf)
if err != nil {
return xerrors.Errorf("read genesis template: %w", err)
}
if err := json.Unmarshal(b, &template); err != nil {
return xerrors.Errorf("unmarshal genesis template: %w", err)
}
var signers []address.Address
var rootkeyMultisig genesis.MultisigMeta
if cctx.IsSet("signers") {
for _, s := range cctx.StringSlice("signers") {
signer, err := address.NewFromString(s)
if err != nil {
return err
}
signers = append(signers, signer)
template.Accounts = append(template.Accounts, genesis.Actor{
Type: genesis.TAccount,
Balance: big.Mul(big.NewInt(50_000), big.NewInt(int64(build.FilecoinPrecision))),
Meta: (&genesis.AccountMeta{Owner: signer}).ActorMeta(),
})
}
rootkeyMultisig = genesis.MultisigMeta{
Signers: signers,
Threshold: 1,
VestingDuration: 0,
VestingStart: 0,
}
}
if cctx.IsSet("threshold") {
rootkeyMultisig = genesis.MultisigMeta{
Signers: signers,
Threshold: cctx.Int("threshold"),
VestingDuration: 0,
VestingStart: 0,
}
}
newVrk := genesis.Actor{
Type: genesis.TMultisig,
Balance: big.NewInt(0),
Meta: rootkeyMultisig.ActorMeta(),
}
template.VerifregRootKey = newVrk
b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
return err
}
if err := ioutil.WriteFile(genf, b, 0644); err != nil {
return err
}
return nil
},
}