Skip to content

Commit

Permalink
add epoch-length and epoch-staking-phase-length
Browse files Browse the repository at this point in the history
- infer start view, staking phase end view, and epoch end view from curr epoch final view
  • Loading branch information
kc1116 committed Apr 2, 2024
1 parent d9db0eb commit 884fdbf
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions cmd/util/cmd/epochs/cmd/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ var (
Run: generateRecoverEpochTxArgs(getSnapshot),
}

flagAnAddress string
flagAnPubkey string
flagInternalNodePrivInfoDir string
flagNodeConfigJson string
flagCollectionClusters int
flagStartView uint64
flagStakingEndView uint64
flagEndView uint64
flagEpochCounter uint64
flagAnAddress string
flagAnPubkey string
flagInternalNodePrivInfoDir string
flagNodeConfigJson string
flagCollectionClusters int
flagStartView uint64
flagNumViewsInEpoch uint64
flagNumViewsInStakingAuction uint64
flagEpochCounter uint64
)

func init() {
Expand All @@ -51,9 +51,10 @@ func addGenerateRecoverEpochTxArgsCmdFlags() {
"path to a JSON file containing multiple node configurations (fields Role, Address, Weight)")
generateRecoverEpochTxArgsCmd.Flags().StringVar(&flagInternalNodePrivInfoDir, "internal-priv-dir", "", "path to directory "+
"containing the output from the `keygen` command for internal nodes")

generateRecoverEpochTxArgsCmd.Flags().Uint64Var(&flagStartView, "start-view", 0, "start view of the recovery epoch")
generateRecoverEpochTxArgsCmd.Flags().Uint64Var(&flagStakingEndView, "staking-end-view", 0, "end view of the staking phase of the recovery epoch")
generateRecoverEpochTxArgsCmd.Flags().Uint64Var(&flagEndView, "end-view", 0, "end view of the recovery epoch")
generateRecoverEpochTxArgsCmd.Flags().Uint64Var(&flagNumViewsInEpoch, "epoch-length", 4000, "length of each epoch measured in views")
generateRecoverEpochTxArgsCmd.Flags().Uint64Var(&flagNumViewsInStakingAuction, "epoch-staking-phase-length", 100, "length of the epoch staking phase measured in views")
generateRecoverEpochTxArgsCmd.Flags().Uint64Var(&flagEpochCounter, "epoch-counter", 0, "the epoch counter used to generate the root cluster block")
}

Expand Down Expand Up @@ -183,11 +184,21 @@ func extractRecoverEpochArgs(snapshot *inmem.Snapshot) []cadence.Value {
log.Fatal().Err(err).Msg("failed to convert cluster qcs to cadence type")
}

currEpochFinalView, err := epoch.FinalView()
if err != nil {
log.Fatal().Err(err).Msg("failed to get final view of current epoch")
}

args := []cadence.Value{
cadence.NewUInt64(flagStartView),
cadence.NewUInt64(flagStakingEndView),
cadence.NewUInt64(flagEndView),
// epoch start view
cadence.NewUInt64(currEpochFinalView + 1),
// staking phase end view
cadence.NewUInt64(currEpochFinalView + flagNumViewsInStakingAuction),
// epoch end view
cadence.NewUInt64(currEpochFinalView + flagNumViewsInEpoch),
// dkg pub keys
cadence.NewArray(dkgPubKeys),
// node ids
cadence.NewArray(nodeIds),
//common.ConvertClusterAssignmentsCdc(assignments),
}
Expand Down

0 comments on commit 884fdbf

Please sign in to comment.