From 601ba43e00276dc793048ea8247f673ed387c8f7 Mon Sep 17 00:00:00 2001 From: Jordan Schalm Date: Thu, 27 Apr 2023 14:06:56 -0400 Subject: [PATCH] remove payout flag, arg from resetEpoch cmd In https://github.com/onflow/flow-core-contracts/pull/365, we removed the payout argument from the resetEpoch transaction and function. Here, we update the CLI tool which generates arguments for this transaction accordingly. --- cmd/util/cmd/epochs/cmd/flags.go | 1 - cmd/util/cmd/epochs/cmd/reset.go | 23 ++--------------- cmd/util/cmd/epochs/cmd/reset_test.go | 37 --------------------------- 3 files changed, 2 insertions(+), 59 deletions(-) diff --git a/cmd/util/cmd/epochs/cmd/flags.go b/cmd/util/cmd/epochs/cmd/flags.go index 13d3f712fe5..f818542f99d 100644 --- a/cmd/util/cmd/epochs/cmd/flags.go +++ b/cmd/util/cmd/epochs/cmd/flags.go @@ -3,7 +3,6 @@ package cmd var ( flagBootDir string - flagPayout string flagBucketNetworkName string flagFlowSupplyIncreasePercentage string diff --git a/cmd/util/cmd/epochs/cmd/reset.go b/cmd/util/cmd/epochs/cmd/reset.go index 48a49e32e49..2a1469dab35 100644 --- a/cmd/util/cmd/epochs/cmd/reset.go +++ b/cmd/util/cmd/epochs/cmd/reset.go @@ -7,7 +7,6 @@ import ( "net/http" "os" "path/filepath" - "strings" "github.com/spf13/cobra" @@ -44,7 +43,6 @@ func init() { } func addResetCmdFlags() { - resetCmd.Flags().StringVar(&flagPayout, "payout", "", "the payout eg. 10000.0") resetCmd.Flags().StringVar(&flagBucketNetworkName, "bucket-network-name", "", "when retrieving the root snapshot from a GCP bucket, the network name portion of the URL (eg. \"mainnet-13\")") } @@ -132,7 +130,7 @@ func extractResetEpochArgs(snapshot *inmem.Snapshot) []cadence.Value { log.Fatal().Err(err).Msg("could not get final view from epoch") } - return convertResetEpochArgs(epochCounter, randomSource, flagPayout, firstView, stakingEndView, finalView) + return convertResetEpochArgs(epochCounter, randomSource, firstView, stakingEndView, finalView) } // getStakingAuctionEndView determines the staking auction end view from the @@ -169,7 +167,7 @@ func getStakingAuctionEndView(epoch protocol.Epoch) (uint64, error) { // convertResetEpochArgs converts the arguments required by `resetEpoch` to cadence representations // Contract Method: https://github.com/onflow/flow-core-contracts/blob/master/contracts/epochs/FlowEpoch.cdc#L413 // Transaction: https://github.com/onflow/flow-core-contracts/blob/master/transactions/epoch/admin/reset_epoch.cdc -func convertResetEpochArgs(epochCounter uint64, randomSource []byte, payout string, firstView, stakingEndView, finalView uint64) []cadence.Value { +func convertResetEpochArgs(epochCounter uint64, randomSource []byte, firstView, stakingEndView, finalView uint64) []cadence.Value { args := make([]cadence.Value, 0) @@ -183,23 +181,6 @@ func convertResetEpochArgs(epochCounter uint64, randomSource []byte, payout stri } args = append(args, cdcRandomSource) - // add payout - var cdcPayout cadence.Value - if payout != "" { - index := strings.Index(payout, ".") - if index == -1 { - log.Fatal().Msg("invalid --payout, eg: 10000.0") - } - - cdcPayout, err = cadence.NewUFix64(payout) - if err != nil { - log.Fatal().Err(err).Msg("could not convert payout to cadence type") - } - } else { - cdcPayout = cadence.NewOptional(nil) - } - args = append(args, cdcPayout) - // add first view args = append(args, cadence.NewUInt64(firstView)) diff --git a/cmd/util/cmd/epochs/cmd/reset_test.go b/cmd/util/cmd/epochs/cmd/reset_test.go index 680e9eb9e0f..25983e5cf61 100644 --- a/cmd/util/cmd/epochs/cmd/reset_test.go +++ b/cmd/util/cmd/epochs/cmd/reset_test.go @@ -37,39 +37,6 @@ func TestReset_LocalSnapshot(t *testing.T) { // set initial flag values flagBootDir = bootDir - flagPayout = "" - - // run command with overwritten stdout - stdout := bytes.NewBuffer(nil) - resetCmd.SetOut(stdout) - resetRun(resetCmd, nil) - - // read output from stdout - var outputTxArgs []interface{} - err = json.NewDecoder(stdout).Decode(&outputTxArgs) - require.NoError(t, err) - - // compare to expected values - expectedArgs := extractResetEpochArgs(rootSnapshot) - verifyArguments(t, expectedArgs, outputTxArgs) - }) - }) - - // tests that given the root snapshot file and payout, the command - // writes the expected arguments to stdout. - t.Run("with payout flag set", func(t *testing.T) { - unittest.RunWithTempDir(t, func(bootDir string) { - - // create a root snapshot - rootSnapshot := unittest.RootSnapshotFixture(unittest.IdentityListFixture(10, unittest.WithAllRoles())) - - // write snapshot to correct path in bootDir - err := writeRootSnapshot(bootDir, rootSnapshot) - require.NoError(t, err) - - // set initial flag values - flagBootDir = bootDir - flagPayout = "10.0" // run command with overwritten stdout stdout := bytes.NewBuffer(nil) @@ -97,7 +64,6 @@ func TestReset_LocalSnapshot(t *testing.T) { // set initial flag values flagBootDir = bootDir - flagPayout = "" // run command resetRun(resetCmd, nil) @@ -117,7 +83,6 @@ func TestReset_BucketSnapshot(t *testing.T) { t.Run("happy path", func(t *testing.T) { // set initial flag values flagBucketNetworkName = "mainnet-13" - flagPayout = "" // run command with overwritten stdout stdout := bytes.NewBuffer(nil) @@ -140,7 +105,6 @@ func TestReset_BucketSnapshot(t *testing.T) { t.Run("happy path - with payout", func(t *testing.T) { // set initial flag values flagBucketNetworkName = "mainnet-13" - flagPayout = "10.0" // run command with overwritten stdout stdout := bytes.NewBuffer(nil) @@ -167,7 +131,6 @@ func TestReset_BucketSnapshot(t *testing.T) { // set initial flag values flagBucketNetworkName = "not-a-real-network-name" - flagPayout = "" // run command resetRun(resetCmd, nil)