Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add security_contact, details and identity; remove logo #23

Merged
merged 12 commits into from
Apr 11, 2023
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@

- [#20](https://github.com/KYVENetwork/chain/pull/20) Adjust investor vesting schedules from second funding round.

### Client Breaking

- (`x/query`) [#23](https://github.com/KYVENetwork/chain/pull/23) Update the `StakerMetadata` query to reflect the new `Identity` and metadata fields.
- (`x/stakers`) [#23](https://github.com/KYVENetwork/chain/pull/23) Update `MsgUpdateMetadata` to reflect the new `Identity` and metadata fields.

### API Breaking

- [#22](https://github.com/KYVENetwork/chain/pull/22) Emit an event when updating module parameters.
- (`x/delegation`) [#24](https://github.com/KYVENetwork/chain/pull/24) Emit an event when a user initiates a protocol unbonding.
- (`x/pool`) [#24](https://github.com/KYVENetwork/chain/pull/24) Emit events for all module governance actions.
- (`x/stakers`) [#23](https://github.com/KYVENetwork/chain/pull/23) Update the event emitted when updating protocol node metadata.

### State Machine Breaking

- (`x/stakers`) [#23](https://github.com/KYVENetwork/chain/pull/23) Improve metadata by adding `Identity`, `SecurityContact`, `Details` fields, deprecating `Logo`.
- (`x/bundles`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `NetworkFee` param to type `sdk.Dec`.
- (`x/bundles`) [#22](https://github.com/KYVENetwork/chain/pull/22) Switch to a non-manipulable pseudo-random source seed for uploader selection.
- (`x/delegation`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `VoteSlash`, `UploadSlash`, `TimeoutSlash` params to type `sdk.Dec`.
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ func NewKYVEApp(
app.mm,
app.configurator,
app.AccountKeeper,
app.StakersKeeper,
),
)

Expand Down
20 changes: 17 additions & 3 deletions app/upgrades/v1_1/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
authTypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingExported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
vestingTypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
// Stakers
stakersKeeper "github.com/KYVENetwork/chain/x/stakers/keeper"
// Upgrade
upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
Expand All @@ -17,6 +19,7 @@ func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
accountKeeper authKeeper.AccountKeeper,
stakerKeeper stakersKeeper.Keeper,
) upgradeTypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
if ctx.ChainID() == MainnetChainID {
Expand All @@ -25,15 +28,17 @@ func CreateUpgradeHandler(
}
}

MigrateStakerMetadata(ctx, stakerKeeper)

return mm.RunMigrations(ctx, configurator, vm)
}
}

// AdjustInvestorVesting correctly adjusts the vesting schedules of investors
// from our second funding round. In genesis, the accounts were set up with an
// 18-month cliff instead of a 6-month cliff.
func AdjustInvestorVesting(ctx sdk.Context, accountKeeper authKeeper.AccountKeeper, address sdk.AccAddress) {
rawAccount := accountKeeper.GetAccount(ctx, address)
func AdjustInvestorVesting(ctx sdk.Context, keeper authKeeper.AccountKeeper, address sdk.AccAddress) {
rawAccount := keeper.GetAccount(ctx, address)
account := rawAccount.(vestingExported.VestingAccount)

baseAccount := authTypes.NewBaseAccount(
Expand All @@ -43,5 +48,14 @@ func AdjustInvestorVesting(ctx sdk.Context, accountKeeper authKeeper.AccountKeep
baseAccount, account.GetOriginalVesting(), StartTime, EndTime,
)

accountKeeper.SetAccount(ctx, updatedAccount)
keeper.SetAccount(ctx, updatedAccount)
}

// MigrateStakerMetadata migrates all existing staker metadata. The `Logo`
// field has been deprecated and replaced by the `Identity` field. This new
// field must be a valid hex string; therefore, must be set to empty for now.
func MigrateStakerMetadata(ctx sdk.Context, keeper stakersKeeper.Keeper) {
for _, staker := range keeper.GetAllStakers(ctx) {
keeper.UpdateStakerMetadata(ctx, staker.Address, staker.Moniker, staker.Website, "", "", "")
}
}
66 changes: 48 additions & 18 deletions docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,15 @@ paths:
title: >-
website is a https-link to the website of the
staker
logo:
identity:
type: string
title: >-
logo is a link to an image file (like jpg or
png)
title: identity from keybase.io
security_contact:
type: string
description: security_contact ...
details:
type: string
description: details ...
pending_commission_change:
description: >-
pending_commission_change shows if the staker
Expand Down Expand Up @@ -4032,11 +4036,15 @@ paths:
title: >-
website is a https-link to the website of the
staker
logo:
identity:
type: string
title: >-
logo is a link to an image file (like jpg or
png)
title: identity from keybase.io
security_contact:
type: string
description: security_contact ...
details:
type: string
description: details ...
pending_commission_change:
description: >-
pending_commission_change shows if the staker
Expand Down Expand Up @@ -6052,9 +6060,15 @@ paths:
website:
type: string
title: website is a https-link to the website of the staker
logo:
identity:
type: string
title: identity from keybase.io
security_contact:
type: string
description: security_contact ...
details:
type: string
title: logo is a link to an image file (like jpg or png)
description: details ...
pending_commission_change:
description: >-
pending_commission_change shows if the staker plans
Expand Down Expand Up @@ -6469,9 +6483,15 @@ paths:
website:
type: string
title: website is a https-link to the website of the staker
logo:
identity:
type: string
title: identity from keybase.io
security_contact:
type: string
description: security_contact ...
details:
type: string
title: logo is a link to an image file (like jpg or png)
description: details ...
pending_commission_change:
description: >-
pending_commission_change shows if the staker plans
Expand Down Expand Up @@ -6985,11 +7005,15 @@ paths:
title: >-
website is a https-link to the website of the
staker
logo:
identity:
type: string
title: >-
logo is a link to an image file (like jpg or
png)
title: identity from keybase.io
security_contact:
type: string
description: security_contact ...
details:
type: string
description: details ...
pending_commission_change:
description: >-
pending_commission_change shows if the staker
Expand Down Expand Up @@ -7460,9 +7484,15 @@ paths:
website:
type: string
title: website is a https-link to the website of the staker
logo:
identity:
type: string
title: identity from keybase.io
security_contact:
type: string
description: security_contact ...
details:
type: string
title: logo is a link to an image file (like jpg or png)
description: details ...
pending_commission_change:
description: >-
pending_commission_change shows if the staker plans
Expand Down
12 changes: 9 additions & 3 deletions proto/kyve/query/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,21 @@ message StakerMetadata {
// website is a https-link to the website of the staker
string website = 3;

// logo is a link to an image file (like jpg or png)
string logo = 4;
// identity from keybase.io
string identity = 4;

// security_contact ...
string security_contact = 5;

// details ...
string details = 6;

// pending_commission_change shows if the staker plans
// to change its commission. Delegators will see a warning in
// the UI. A Commission change takes some time until
// the commission is applied. Users have time to redelegate
// if they not agree with the new commission.
CommissionChangeEntry pending_commission_change = 5;
CommissionChangeEntry pending_commission_change = 7;
}

// CommissionChangeEntry shows when the old commission
Expand Down
13 changes: 11 additions & 2 deletions proto/kyve/stakers/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ message EventCreateStaker {
string staker = 1;
// amount ...
uint64 amount = 2;
// commission
string commission = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// EventUpdateMetadata is an event emitted when a protocol node updates their metadata.
Expand All @@ -36,8 +41,12 @@ message EventUpdateMetadata {
string moniker = 2;
// website ...
string website = 3;
// logo ...
string logo = 4;
// identity ...
string identity = 4;
// security_contact ...
string security_contact = 5;
// details ...
string details = 6;
}

// EventUpdateCommission ...
Expand Down
8 changes: 6 additions & 2 deletions proto/kyve/stakers/v1beta1/stakers.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ message Staker {
string moniker = 3;
// website ...
string website = 4;
// logo ...
string logo = 5;
// identity is the 64 bit keybase.io identity string
string identity = 5;
// security_contact ...
string security_contact = 6;
// details are some additional notes the staker finds important
string details = 7;
}

// Valaccount gets authorized by a staker to
Expand Down
8 changes: 6 additions & 2 deletions proto/kyve/stakers/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ message MsgUpdateMetadata {
string moniker = 2;
// website ...
string website = 3;
// logo
string logo = 4;
// identity from keybase.io
string identity = 4;
// security_contact ...
string security_contact = 5;
// details ...
string details = 6;
}

// MsgUpdateMetadataResponse defines the Msg/MsgUpdateMetadata response type.
Expand Down
4 changes: 3 additions & 1 deletion testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ func (suite *KeeperTestSuite) verifyFullStaker(fullStaker querytypes.FullStaker,
}

Expect(fullStaker.SelfDelegationUnbonding).To(Equal(selfDelegationUnbonding))
Expect(fullStaker.Metadata.Logo).To(Equal(staker.Logo))
Expect(fullStaker.Metadata.Identity).To(Equal(staker.Identity))
Expect(fullStaker.Metadata.SecurityContact).To(Equal(staker.SecurityContact))
Expect(fullStaker.Metadata.Details).To(Equal(staker.Details))
Expect(fullStaker.Metadata.Website).To(Equal(staker.Website))
Expect(fullStaker.Metadata.Commission).To(Equal(staker.Commission))
Expect(fullStaker.Metadata.Moniker).To(Equal(staker.Moniker))
Expand Down
38 changes: 21 additions & 17 deletions x/query/keeper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ func (k Keeper) GetFullStaker(ctx sdk.Context, stakerAddress string) *types.Full
Commission: staker.Commission,
Moniker: staker.Moniker,
Website: staker.Website,
Logo: staker.Logo,
Identity: staker.Identity,
SecurityContact: staker.SecurityContact,
Details: staker.Details,
PendingCommissionChange: commissionChangeEntry,
}

Expand All @@ -38,23 +40,25 @@ func (k Keeper) GetFullStaker(ctx sdk.Context, stakerAddress string) *types.Full
accountValaddress, _ := sdk.AccAddressFromBech32(valaccount.Valaddress)
balanceValaccount := k.bankKeeper.GetBalance(ctx, accountValaddress, globalTypes.Denom).Amount.Uint64()

poolMemberships = append(poolMemberships, &types.PoolMembership{
Pool: &types.BasicPool{
Id: pool.Id,
Name: pool.Name,
Runtime: pool.Runtime,
Logo: pool.Logo,
OperatingCost: pool.OperatingCost,
UploadInterval: pool.UploadInterval,
TotalFunds: pool.TotalFunds,
TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id),
Status: k.GetPoolStatus(ctx, &pool),
poolMemberships = append(
poolMemberships, &types.PoolMembership{
Pool: &types.BasicPool{
Id: pool.Id,
Name: pool.Name,
Runtime: pool.Runtime,
Logo: pool.Logo,
OperatingCost: pool.OperatingCost,
UploadInterval: pool.UploadInterval,
TotalFunds: pool.TotalFunds,
TotalDelegation: k.delegationKeeper.GetDelegationOfPool(ctx, pool.Id),
Status: k.GetPoolStatus(ctx, &pool),
},
Points: valaccount.Points,
IsLeaving: valaccount.IsLeaving,
Valaddress: valaccount.Valaddress,
Balance: balanceValaccount,
},
Points: valaccount.Points,
IsLeaving: valaccount.IsLeaving,
Valaddress: valaccount.Valaddress,
Balance: balanceValaccount,
})
)
}

// Iterate all UnbondingDelegation entries to get total delegation unbonding amount
Expand Down
Loading