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: emit events for KYVE governance proposals #24

Merged
merged 8 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@

### State Machine Breaking

- (`x/pool`) [#24](https://github.com/KYVENetwork/chain/pull/24) For KYVE governance proposals the following new events are emitted, when the corresponding proposal passes:
- EventPoolEnabled
- EventPoolDisabled
- EventRuntimeUpgradeScheduled
- EventRuntimeUpgradeCancelled
- EventPoolUpdated
- EventStartUndelegation
- (`x/bundles`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `NetworkFee` param to type `sdk.Dec`.
- (`x/delegation`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `VoteSlash`, `UploadSlash`, `TimeoutSlash` params to type `sdk.Dec`.
- (`x/stakers`) [#19](https://github.com/KYVENetwork/chain/pull/19) Migrate `Commission` to type `sdk.Dec`.
- (`x/bundles`) [#22](https://github.com/KYVENetwork/chain/pull/22) use non-manipulable pseudo-random source seed for uploader selection.


## [v1.0.0](https://github.com/KYVENetwork/chain/releases/tag/v1.0.0) - 2023-03-10

Release for the KYVE network launch.
Expand Down
40 changes: 22 additions & 18 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,48 @@ accounts:
deliver fat happy ghost visa recall usual path purity junior ring ordinary stove
- name: alice
coins:
- 2000000000000000000tkyve
- 2000000000000000tkyve
mnemonic: worry grief loyal smoke pencil arrow trap focus high pioneer tomato hedgehog
essence purchase dove pond knee custom phone gentle sunset addict mother fabric
- name: bob
coins:
- 1000000000000000000tkyve
- 1000000000000000tkyve
mnemonic: crash sick toilet stumble join cash erode glory door weird diagram away
lizard solid segment apple urge joy annual able tank define candy demise
- name: charlie
coins:
- 1000000000000000000tkyve
- 1000000000000000tkyve
mnemonic: shoot inject fragile width trend satisfy army enact volcano crowd message
strike true divorce search rich office shoulder sport relax rhythm symbol gadget
size
- name: faucet
coins:
- 1000000000000000000tkyve
- 1000000000000000tkyve
mnemonic: open home share route party lake room solution quantum pact model avocado
humor dilemma review desert turtle total humor produce rate keen eagle fee
# - name: team
# coins:
# - 165000000000000000tkyve
# - 165000000000000tkyve
# address: kyve1e29j95xmsw3zmvtrk4st8e89z5n72v7nf70ma4
- name: foundation
coins:
# for fees
- 1000000000tkyve
- 1000000tkyve
mnemonic: evidence taxi material cabin annual phrase practice unhappy safe jealous
section drink illness panther bread aim mouse dolphin deliver ready doll finger search cheap
# address: kyve1fd4qu868n7arav8vteghcppxxa0p2vna5f5ep8
- name: foundation_inflation
coins:
# for fees
- 1000000000tkyve
- 1000000tkyve
mnemonic: hold urge sustain chef furnace foam oven fall harsh core anchor during crew secret
craft rhythm choose gold soft aisle sort phrase enter orphan
# address: kyve1tuxsc7ez79aydyee86qxm05zyx0l7d78c2zzsn

faucet:
name: faucet
coins:
- 1000000000000000tkyve
- 1000000000000tkyve
host: 0.0.0.0:4500
client:
openapi:
Expand Down Expand Up @@ -88,47 +88,47 @@ genesis:
account_count: "8"
account_list:
- id: "0"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1686693600"
commencement: "1663106400"
- id: "1"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1749852000"
commencement: "1694642400"
- id: "2"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1694642400"
commencement: "1615676400"
- id: "3"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1702508400"
commencement: "1647212400"
- id: "4"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1741906800"
commencement: "1663106400"
- id: "5"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1804978800"
commencement: "1710370800"
- id: "6"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1741906800"
commencement: "1615676400"
- id: "7"
total_allocation: "1000000000000000"
total_allocation: "1000000000000"
unlocked_claimed: "0"
clawback: "1804978800"
commencement: "1647212400"
pool:
pool_count: "1"
pool_count: "2"
pool_list:
- config: "ar://tMTrJ8E3QgBNLz0-lyn6QrxasEIX46d14QFVmBWshSI"
current_compression_id: "1"
Expand Down Expand Up @@ -167,4 +167,8 @@ genesis:
chain_id: kyve-local
validators:
- name: alice
bonded: 1000000000000000tkyve
bonded: 1000000000000tkyve
config:
consensus:
timeout_commit: "2s"
timeout_propose: "2s"
14 changes: 14 additions & 0 deletions proto/kyve/delegation/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ message EventDelegate {
uint64 amount = 3;
}

// EventStartUndelegation is an event emitted when someone starts an undelegation from a protocol node.
// emitted_by: EndBlock
message EventStartUndelegation {
// address is the account address of the delegator.
string address = 1;
// staker is the account address of the protocol node.
string staker = 2;
// amount to be undelegated
uint64 amount = 3;
// estimated_undelegation_date is the data in UNIX seconds on when the undelegation will be performed.
// This number will be wrong if a governance proposal changes `UnbondingDelegationTime` during the unbonding.
uint64 estimated_undelegation_date = 4;
}

// EventUndelegate is an event emitted when someone undelegates from a protocol node.
// emitted_by: EndBlock
message EventUndelegate {
Expand Down
78 changes: 78 additions & 0 deletions proto/kyve/pool/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,84 @@ message EventCreatePool {
uint32 compression_id = 14;
}

// EventPoolEnabled ...
// emitted_by: EndBlock(gov)
message EventPoolEnabled {
// id is the unique ID of the affected pool.
uint64 id = 1;
}

// EventPoolDisabled ...
// emitted_by: EndBlock(gov)
message EventPoolDisabled {
// id is the unique ID of the affected pool.
uint64 id = 1;
}

// EventRuntimeUpgradeScheduled ...
// emitted_by: EndBlock(gov)
message EventRuntimeUpgradeScheduled {
// runtime is the name of the runtime that will be upgraded. (e.g. evm)
string runtime = 1;
// version is the new version the runtime will be upgraded to
string version = 2;
// scheduled_at is the UTC timestamp in seconds
uint64 scheduled_at = 3;
// duration is the amount of seconds to pool will be paused after the
// scheduled time is reached. This will give node operators time to upgrade
// their node.
uint64 duration = 4;
// binaries contain download links for prebuilt binaries (in JSON)
string binaries = 5;
// affected_pools contains all poolIds of the pools which will be affected by the runtime upgrade.
repeated uint64 affected_pools = 6;
}

// EventRuntimeUpgradeCancelled ...
// emitted_by: EndBlock(gov)
message EventRuntimeUpgradeCancelled {
// runtime is the name of the runtime that will be upgraded. (e.g. evm)
string runtime = 1;
// affected_pools contains all poolIds of the pools which will be affected by the cancellation of the runtime upgrade.
repeated uint64 affected_pools = 2;
}

// EventPoolUpdated ...
// emitted_by: EndBlock(gov)
message EventPoolUpdated {
// id is the unique ID of the pool.
uint64 id = 1;
// raw update string
string raw_update_string = 2;
// name is the human readable name of the pool
string name = 3;
// runtime is the runtime name of the pool
string runtime = 4;
// logo is the logo url of the pool
string logo = 5;
// config is either a json stringified config or an
// external link pointing to the config
string config = 6;
// upload_interval is the interval the pool should validate
// bundles with
uint64 upload_interval = 7;
// operating_cost is the fixed cost which gets paid out
// to every successful uploader
uint64 operating_cost = 8;
// min_delegation is the minimum amount of $KYVE the pool has
// to have in order to produce bundles
uint64 min_delegation = 9;
// max_bundle_size is the max size a data bundle can have
// (amount of data items)
uint64 max_bundle_size = 10;
// storage_provider_id is the unique id of the storage provider
// the pool is archiving the data on
uint32 storage_provider_id = 11;
// compression_id is the unique id of the compression type the bundles
// get compressed with
uint32 compression_id = 12;
}

// EventFundPool is an event emitted when a pool is funded.
// emitted_by: MsgFundPool
message EventFundPool {
Expand Down
7 changes: 7 additions & 0 deletions x/delegation/keeper/msg_server_undelegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (
// Create and insert unbonding queue entry.
k.StartUnbondingDelegator(ctx, msg.Staker, msg.Creator, msg.Amount)

_ = ctx.EventManager().EmitTypedEvent(&types.EventStartUndelegation{
Address: msg.Creator,
Staker: msg.Staker,
Amount: msg.Amount,
EstimatedUndelegationDate: uint64(ctx.BlockTime().Unix()) + k.GetUnbondingDelegationTime(ctx),
})

return &types.MsgUndelegateResponse{}, nil
}
18 changes: 18 additions & 0 deletions x/delegation/spec/05_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ message EventUpdateParams {
}
```

## EventStartUndelegation

EventStartUndelegation is emitted when the user schedules a protocol unbonding.

```protobuf
message EventStartUndelegation {
// address is the account address of the delegator.
string address = 1;
// staker is the account address of the protocol node.
string staker = 2;
// amount to be undelegated
uint64 amount = 3;
// estimated_undelegation_date is the data in UNIX seconds on when the undelegation will be performed.
// This number will be wrong if a governance proposal changes `UnbondingDelegationTime` during the unbonding.
uint64 estimated_undelegation_date = 4;
}
```

## EndBlocker

| Type | Attribute Key | Attribute Value |
Expand Down
Loading