Skip to content

Commit

Permalink
Merge branch 'feat/extract_address_info' of github.com:fetchai/fetchd…
Browse files Browse the repository at this point in the history
… into feat/cudos_extending_manifest
  • Loading branch information
MissingNO57 committed Oct 17, 2024
2 parents 4b0a092 + 985d563 commit 268cf14
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
29 changes: 29 additions & 0 deletions app/upgrade_cudos.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ func CudosMergeUpgradeHandler(app *App, ctx sdk.Context, cudosCfg *CudosMergeCon
return fmt.Errorf("cudos merge: failed process accounts: %w", err)
}

err = updateMaxValidators(app, ctx, cudosCfg, manifest, false)
{
if err != nil {
return fmt.Errorf("cudos merge: failed to update active validators set: %w", err)
}
}

err = createGenesisDelegations(ctx, app, genesisData, cudosCfg, manifest)
if err != nil {
return fmt.Errorf("cudos merge: failed process delegations: %w", err)
Expand All @@ -327,6 +334,28 @@ func CudosMergeUpgradeHandler(app *App, ctx sdk.Context, cudosCfg *CudosMergeCon
return nil
}

func updateMaxValidators(app *App, ctx sdk.Context, cudosCfg *CudosMergeConfig, manifest *UpgradeManifest, allowReductionOfMaxValidators bool) error {
params := app.StakingKeeper.GetParams(ctx)

if cudosCfg.Config.NewMaxValidators != 0 && cudosCfg.Config.NewMaxValidators != params.MaxValidators {
if !allowReductionOfMaxValidators && cudosCfg.Config.NewMaxValidators < params.MaxValidators {
return fmt.Errorf("the NewMaxValidators config parameter (= %v) is smaller than the current value of MaxValidators in staking params (= %v)", cudosCfg.Config.NewMaxValidators, params.MaxValidators)
}

manifest.MaxValidatorsChange = &ParamsChange[uint32]{}

manifest.MaxValidatorsChange.OriginalVal = params.MaxValidators

params.MaxValidators = cudosCfg.Config.NewMaxValidators
// Set the new params
app.StakingKeeper.SetParams(ctx, params)

manifest.MaxValidatorsChange.NewVal = params.MaxValidators
}

return nil
}

func GetAccPrefix(jsonData map[string]interface{}) (string, error) {
// Map to verify that account exists in auth module
auth := jsonData[authtypes.ModuleName].(map[string]interface{})
Expand Down
20 changes: 13 additions & 7 deletions app/upgrade_v_11_4_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ type UpgradeManifest struct {
InitialBalances []UpgradeBalances `json:"initial_balances,omitempty"`

// Following 2 hash data members are intentionally without `omitempty` parameter in `json:...` decorator
GenesisFileSha256 string `json:"genesis_file_sha256"`
NetworkConfigFileSha256 string `json:"network_config_file_sha256"`
MergeSourceChainID string `json:"merge_source_chain_id"`
DestinationChainID string `json:"destination_chain_id"`
SourceChainBlockHeight int64 `json:"source_chain_block_height"`
DestinationChainBlockHeight int64 `json:"destination_chain_block_height"`
GovProposalUpgradePlanName string `json:"gov_proposal_upgrade_plan_name"`
GenesisFileSha256 string `json:"genesis_file_sha256"`
NetworkConfigFileSha256 string `json:"network_config_file_sha256"`
MergeSourceChainID string `json:"merge_source_chain_id"`
DestinationChainID string `json:"destination_chain_id"`
SourceChainBlockHeight int64 `json:"source_chain_block_height"`
DestinationChainBlockHeight int64 `json:"destination_chain_block_height"`
GovProposalUpgradePlanName string `json:"gov_proposal_upgrade_plan_name"`
MaxValidatorsChange *ParamsChange[uint32] `json:"max_validators_change,omitempty"`

Reconciliation *UpgradeReconciliation `json:"reconciliation,omitempty"`
Contracts *Contracts `json:"contracts,omitempty"`
Expand All @@ -41,6 +42,11 @@ func NewUpgradeManifest() *UpgradeManifest {
return &UpgradeManifest{}
}

type ParamsChange[T any] struct {
OriginalVal T `json:"original_val"`
NewVal T `json:"new_val"`
}

type Contracts struct {
StateCleaned []string `json:"contracts_state_cleaned,omitempty"`
AdminUpdated []ContractValueUpdate `json:"contracts_admin_updated,omitempty"`
Expand Down
6 changes: 4 additions & 2 deletions app/upgrade_v_11_4_network_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ var NetworkInfos = map[string]NetworkConfig{
VestingCollisionDestAddr: "fetch122j02czdt5ca8cf576wy2hassyxyx67wg5xmgc", // Replace!!
CommunityPoolBalanceDestAddr: "cudos1nj49l56x7sss5hqyvfmctxr3mq64whg273g3x5",

VestingPeriod: 3 * 30 * 24 * 60 * 60, // 3 months period
VestingPeriod: 3 * 30 * 24 * 60 * 60, // 3 months period
NewMaxValidators: 91,

BalanceConversionConstants: []Pair[string, sdk.Dec]{
{"acudos", newDec("118.344")},
Expand Down Expand Up @@ -330,7 +331,8 @@ type CudosMergeConfigJSON struct {
ExtraSupplyFetchAddr string `json:"extra_supply_fetch_addr"` // Fetch address for extra supply
VestingCollisionDestAddr string `json:"vesting_collision_dest_addr"` // This gets converted to raw address, so it can be fetch or cudos address

VestingPeriod int64 `json:"vesting_period"` // Vesting period
VestingPeriod int64 `json:"vesting_period"` // Vesting period
NewMaxValidators uint32 `json:"new_max_validators,omitempty"` // Set new value for staking params max validators

BalanceConversionConstants []Pair[string, sdk.Dec] `json:"balance_conversion_constants,omitempty"`

Expand Down

0 comments on commit 268cf14

Please sign in to comment.