-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Application] Add missing (un)staking events #867
base: issues/612/application/burning
Are you sure you want to change the base?
[Application] Add missing (un)staking events #867
Conversation
ea2ce03
to
2bd52fc
Compare
…application * issues/612/application/burning: (94 commits) fix: linter error chore: quick fixes [DifficultyHash] Prepare for difficulty multiplier usage (#836) [Application] Enforce minimum stake when staking (#847) Empty commit [Tokenomics] Prevent GMR to produce zero values (#866) Empty commit chore: regenerate protobufs fix: linter error Empty commit chore: review feedback improvements Empty commit Empty commit fix: linter errors fix: typo chore: review feedback improvements chore: reconcile PreGeneratedAccountIterator#MustNext() chore: add review feedback TODOs Empty commit test: simplify coin equality assertions ... # Conflicts: # x/application/keeper/msg_server_stake_application_test.go # x/application/keeper/msg_server_unstake_application.go # x/application/keeper/msg_server_unstake_application_test.go # x/application/keeper/unbond_applications.go
|
||
// EventApplicationUnbondingCanceled is emitted when an application which was unbonding | ||
// successfully (re-)stakes before the unbonding period has elapsed. An EventApplicationStaked | ||
// event will also be emmitted immediatly after this event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// event will also be emmitted immediatly after this event. | |
// event will also be emitted immediately after this event. |
for _, event := range events { | ||
if err = sdkCtx.EventManager().EmitTypedEvent(event); err != nil { | ||
err = types.ErrAppEmitEvent.Wrapf("(%+v): %s", event, err) | ||
logger.Error(err.Error()) | ||
return nil, status.Error(codes.Internal, err.Error()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, event := range events { | |
if err = sdkCtx.EventManager().EmitTypedEvent(event); err != nil { | |
err = types.ErrAppEmitEvent.Wrapf("(%+v): %s", event, err) | |
logger.Error(err.Error()) | |
return nil, status.Error(codes.Internal, err.Error()) | |
} | |
} | |
if err = sdkCtx.EventManager().EmitTypedEvents(events...); err != nil { | |
err = types.ErrAppEmitEvent.Wrapf("(%+v): %s", events, err) | |
logger.Error(err.Error()) | |
return nil, status.Error(codes.Internal, err.Error()) | |
} |
// EventApplicationUnbondingBegin is emitted when an application unstake message | ||
// is committed, indicating that an application has begun unbonding. | ||
message EventApplicationUnbondingBegin { | ||
string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unbonding_height
field for consistency with EventSupplierUnbondingBegin
.
// unbonding. The unbonding period is determined by the shared param, | ||
// application_unbonding_period_sessions. | ||
message EventApplicationUnbondingEnd { | ||
string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unbonding_height
field for consistency with EventSupplierUnbondingEnd
.
// unbonded during settlement because their post-settlement stake dropped below | ||
// the minimum application stake requirement. | ||
message EventApplicationUnbondedBelowMinStake { | ||
string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unbonding_height
and application_min_stake
fields.
// successfully (re-)stakes before the unbonding period has elapsed. An EventApplicationStaked | ||
// event will also be emmitted immediatly after this event. | ||
message EventApplicationUnbondingCanceled { | ||
string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add session_end_height
field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An important milestone achieved! 😄
Left some comments w.r.t. the events content but looks good otherwise 👍
import "poktroll/application/types.proto"; | ||
|
||
// EventApplicationStaked is emitted when an application is staked or up-staked. | ||
message EventApplicationStaked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just embed the whole application?
// such that prior event emissions are cleared. | ||
func ResetEventManager(ctx context.Context) context.Context { | ||
return cosmostypes.UnwrapSDKContext(ctx). | ||
WithEventManager(cosmostypes.NewEventManager()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
@@ -283,6 +283,16 @@ func (k Keeper) ProcessTokenLogicModules( | |||
// TODO_CONSIDERATION: If we support multiple native tokens, we will need to | |||
// start checking the denom here. | |||
if application.Stake.Amount.LT(apptypes.DefaultMinStake.Amount) { | |||
sdkCtx := sdk.UnwrapSDKContext(ctx) | |||
unbondedBelowMinStakeEvent := &apptypes.EventApplicationUnbondedBelowMinStake{ | |||
AppAddress: application.GetAddress(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any opinion on sending the whole application? (at least the stake amount)
// TODO_UPNEXT(@bryanchriswhite): emit a new EventApplicationUnbondingEnd event. | ||
sdkCtx := sdk.UnwrapSDKContext(ctx) | ||
unbondingBeginEvent := &apptypes.EventApplicationUnbondingEnd{ | ||
AppAddress: application.GetAddress(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to see the stake being returned to the app account. IMO Adding the whole app to the event is OK.
// TODO_UPNEXT:(@bryanchriswhite): emit a new EventApplicationUnbondingBegin event. | ||
sdkCtx = sdk.UnwrapSDKContext(ctx) | ||
unbondingBeginEvent := &types.EventApplicationUnbondingBegin{ | ||
AppAddress: foundApp.GetAddress(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, having a "snapshot" of the application state (current stake) could be useful, in conjunction with the unbonding end event having the same.
We would be able to see how much stake has been deducted in between. We probably have other means to know it though.
events = sdkCtx.EventManager().Events() | ||
require.Equal(t, 1, len(events)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was appearing because the events did not get cleared right?
Summary
Adds:
EventApplicationStake
EventApplicationUnbondingBegin
EventApplicationUnbondingEnd
EventApplicationUnbondingCanceled
EventApplicationUnbondedBelowMinStake
Issue
Type of change
Select one or more from the following:
consensus-breaking
label if so. See [Infra] Automatically add theconsensus-breaking
label #791 for detailsTesting
make docusaurus_start
; only needed if you make doc changesmake go_develop_and_test
make test_e2e
devnet-test-e2e
label to the PR.Sanity Checklist