-
Notifications
You must be signed in to change notification settings - Fork 358
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
Handle begin & end block channel events #1801
Conversation
… a tendermint NewBlock event
Tested diff --git a/x/staking/module.go b/x/staking/module.go
index b5e778755..624b33a49 100644
--- a/x/staking/module.go
+++ b/x/staking/module.go
@@ -23,6 +23,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/simulation"
"github.com/cosmos/cosmos-sdk/x/staking/types"
+ channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
)
var (
@@ -171,12 +172,21 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
// EndBlock returns the end blocker for the staking module. It returns no validator
// updates.
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
- // FIGME: Raise an event in end block.
- AttributeValueCategory := "ibc_channel"
+ ctx.EventManager().EmitEvents(sdk.Events{
+ sdk.NewEvent(
+ channeltypes.EventTypeChannelOpenInit,
+ sdk.NewAttribute(channeltypes.AttributeKeyPortID, "transfer"),
+ sdk.NewAttribute(channeltypes.AttributeKeyChannelID, "channel-0"),
+ sdk.NewAttribute(channeltypes.AttributeCounterpartyPortID, "transfer"),
+ sdk.NewAttribute(channeltypes.AttributeCounterpartyChannelID, "channel-0"),
+ sdk.NewAttribute(channeltypes.AttributeKeyConnectionID, "connection-0"),
+ ),
+ })
+
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
- sdk.NewAttribute(sdk.AttributeKeyModule /* channeltypes. */, AttributeValueCategory),
+ sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
),
})
return EndBlocker(ctx, am.keeper) |
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.
great stuff! LGTM!
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.
Very clear explanation, thank you Shoaib!
I think the PR is ready, but let's let @michaelfig test it out against Agoric devnet and give the final approval.
Thanks, everybody, for your work on this! This is high up on my list of priorities. @dckc and I are doing IBC testing, so we'll be able to try a programmatic outbound channel init from an Agoric (dynamic IBC) smart contract in the next day or three. Will keep you posted! |
good news / bad news: We were able to initiate a channel using JavaScript:
but then
full log: https://gist.github.com/39d6fb688ae566dc83fefb85b7c3fa3c |
In short, this particular PR looks good and does what it says it should. Go ahead and land! |
* Implement conversions for channel events * Implement conversions for packets * Resurrect code (from PR informalsystems#1172) to extract begin/end-block events from a tendermint NewBlock event * Add channel events in the right order * Remove redundant clones * Minor refactoring * Fix failing CI tests * Extract block events without depending on message.action * Cleanup * Add .changelog entry * Document event extraction
Closes: #1793
Description
This PR is mostly based on the code that was removed in PR #1172.
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.