forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR cosmos#4865: Add security contact to Validator description
- Loading branch information
1 parent
a6e776c
commit 771f8a0
Showing
21 changed files
with
247 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#4814 Add security contact to Validator description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// DONTCOVER | ||
// nolint | ||
package v0_37 | ||
|
||
import ( | ||
v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_36" | ||
) | ||
|
||
// Migrate accepts exported genesis state from v0.34 and migrates it to v0.36 | ||
// genesis state. All entries are identical except for validator slashing events | ||
// which now include the period. | ||
func Migrate(oldGenState v036staking.GenesisState) GenesisState { | ||
return NewGenesisState( | ||
oldGenState.Params, | ||
oldGenState.LastTotalPower, | ||
oldGenState.LastValidatorPowers, | ||
migrateValidators(oldGenState.Validators), | ||
oldGenState.Delegations, | ||
oldGenState.UnbondingDelegations, | ||
oldGenState.Redelegations, | ||
oldGenState.Exported, | ||
) | ||
} | ||
|
||
func migrateValidators(oldValidators v036staking.Validators) Validators { | ||
validators := make(Validators, len(oldValidators)) | ||
|
||
for i, val := range oldValidators { | ||
validators[i] = Validator{ | ||
OperatorAddress: val.OperatorAddress, | ||
ConsPubKey: val.ConsPubKey, | ||
Jailed: val.Jailed, | ||
Status: val.Status, | ||
Tokens: val.Tokens, | ||
DelegatorShares: val.DelegatorShares, | ||
Description: NewDescription( | ||
val.Description.Moniker, | ||
val.Description.Identity, | ||
val.Description.Website, | ||
"", // security contact field | ||
val.Description.Details, | ||
), | ||
UnbondingHeight: val.UnbondingHeight, | ||
UnbondingCompletionTime: val.UnbondingCompletionTime, | ||
Commission: val.Commission, | ||
MinSelfDelegation: val.MinSelfDelegation, | ||
} | ||
} | ||
|
||
return validators | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// DONTCOVER | ||
// nolint | ||
package v0_37 | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/tendermint/tendermint/crypto" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_34" | ||
v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v0_36" | ||
) | ||
|
||
const ( | ||
ModuleName = "staking" | ||
) | ||
|
||
type ( | ||
Description struct { | ||
Moniker string `json:"moniker" yaml:"moniker"` | ||
Identity string `json:"identity" yaml:"identity"` | ||
Website string `json:"website" yaml:"website"` | ||
SecurityContact string `json:"security_contact" yaml:"security_contact"` | ||
Details string `json:"details" yaml:"details"` | ||
} | ||
|
||
Validator struct { | ||
OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` | ||
ConsPubKey crypto.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` | ||
Jailed bool `json:"jailed" yaml:"jailed"` | ||
Status sdk.BondStatus `json:"status" yaml:"status"` | ||
Tokens sdk.Int `json:"tokens" yaml:"tokens"` | ||
DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` | ||
Description Description `json:"description" yaml:"description"` | ||
UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` | ||
UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` | ||
Commission v036staking.Commission `json:"commission" yaml:"commission"` | ||
MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` | ||
} | ||
|
||
Validators []Validator | ||
|
||
GenesisState struct { | ||
Params v034staking.Params `json:"params"` | ||
LastTotalPower sdk.Int `json:"last_total_power"` | ||
LastValidatorPowers []v034staking.LastValidatorPower `json:"last_validator_powers"` | ||
Validators Validators `json:"validators"` | ||
Delegations v034staking.Delegations `json:"delegations"` | ||
UnbondingDelegations []v034staking.UnbondingDelegation `json:"unbonding_delegations"` | ||
Redelegations []v034staking.Redelegation `json:"redelegations"` | ||
Exported bool `json:"exported"` | ||
} | ||
) | ||
|
||
// NewDescription creates a new Description object | ||
func NewDescription(moniker, identity, website, | ||
securityContact, details string) Description { | ||
|
||
return Description{ | ||
Moniker: moniker, | ||
Identity: identity, | ||
Website: website, | ||
SecurityContact: securityContact, | ||
Details: details, | ||
} | ||
} | ||
|
||
// NewGenesisState creates a new GenesisState object | ||
func NewGenesisState( | ||
params v034staking.Params, lastTotalPower sdk.Int, lastValPowers []v034staking.LastValidatorPower, | ||
validators Validators, delegations v034staking.Delegations, | ||
ubds []v034staking.UnbondingDelegation, reds []v034staking.Redelegation, exported bool, | ||
) GenesisState { | ||
|
||
return GenesisState{ | ||
Params: params, | ||
LastTotalPower: lastTotalPower, | ||
LastValidatorPowers: lastValPowers, | ||
Validators: validators, | ||
Delegations: delegations, | ||
UnbondingDelegations: ubds, | ||
Redelegations: reds, | ||
Exported: exported, | ||
} | ||
} |
Oops, something went wrong.