Skip to content

Commit

Permalink
Merge pull request #8120 from filecoin-project/travis/set-current-net…
Browse files Browse the repository at this point in the history
…work-version

feat: cli: set current network version from params
  • Loading branch information
arajasek authored Feb 17, 2022
2 parents ee69899 + ca9bcc9 commit 4767f3d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions cmd/lotus-seed/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,19 @@ var genesisSetRemainderCmd = &cli.Command{
}

var genesisSetActorVersionCmd = &cli.Command{
Name: "set-network-version",
Usage: "Set the version that this network will start from",
ArgsUsage: "<genesisFile> <actorVersion>",
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 {
if cctx.Args().Len() != 2 {
return fmt.Errorf("must specify genesis file and network version (e.g. '0'")
if cctx.Args().Len() != 1 {
return fmt.Errorf("must specify genesis file")
}

genf, err := homedir.Expand(cctx.Args().First())
Expand All @@ -531,16 +538,12 @@ var genesisSetActorVersionCmd = &cli.Command{
return xerrors.Errorf("unmarshal genesis template: %w", err)
}

nv, err := strconv.ParseUint(cctx.Args().Get(1), 10, 64)
if err != nil {
return xerrors.Errorf("parsing network version: %w", err)
}

if nv > uint64(build.NewestNetworkVersion) {
nv := network.Version(cctx.Int("network-version"))
if nv > build.NewestNetworkVersion {
return xerrors.Errorf("invalid network version: %d", nv)
}

template.NetworkVersion = network.Version(nv)
template.NetworkVersion = nv

b, err = json.MarshalIndent(&template, "", " ")
if err != nil {
Expand Down

0 comments on commit 4767f3d

Please sign in to comment.