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

imp(core): allow huckleberry events with a prefix #5541

Merged
merged 21 commits into from
Jan 11, 2024

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Jan 8, 2024

Description

Event emissions on erroneous IBC application callbacks were removed due to the huckleberry security advisory. Since then, many users have been unable to debug their IBC applications effectively causing a considerable uptick in support requests across many chains.

This PR enables emission of events on erroneous IBC application callbacks by appending a prefix to all event attribute keys

closes: #5284

Commit Message / Changelog Entry

imp(core): allow huckleberry events with a prefix

see the guidelines for commit messages. (view raw markdown for examples)


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f9b918f) 81.19% compared to head (4f9acf3) 81.20%.
Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5541      +/-   ##
==========================================
+ Coverage   81.19%   81.20%   +0.01%     
==========================================
  Files         197      197              
  Lines       15253    15268      +15     
==========================================
+ Hits        12384    12399      +15     
  Misses       2404     2404              
  Partials      465      465              
Files Coverage Δ
...les/apps/27-interchain-accounts/host/ibc_module.go 84.12% <100.00%> (ø)
modules/apps/transfer/ibc_module.go 69.10% <100.00%> (ø)
modules/core/keeper/msg_server.go 67.00% <100.00%> (+0.57%) ⬆️

Comment on lines 23 to 25
// no need to append the error attribute prefix to the event type because
// the event type is not associated to a value that can be misinterpreted
newEvents[i] = sdk.NewEvent(event.Type, newAttributes...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we elaborate on this reasoning? I feel it is safer to prefix the type as well. Is there a direct benefit to not prefixing the type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might be easier for users to index events by module that emitted the event. In that it wouldn't break their pre-existing clients too much.

The reasoning isn't solid but what I meant was that event types are only used for indexing attributes by module. Event types aren't the key to some value, they are only used to retrieve the attributes.

But I'm open to prefixing this too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yea. My main concern is accidental misuse, that is using the event type to indicate an action occurred without caring about particular values. But I think you make a fair point that event types aren't the key to some value. I'm not too concerned about breaking pre-existing clients as pre-existing clients currently cannot access error events. If the primary use case here is simply for debugging, I'm not sure I see much benefit in not error prefixing the type defensively, but I don't feel strongly, just feel slightly uncomfortable allowing any surface area for misinterpretation of events

Copy link
Member Author

@srdtrk srdtrk Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah fair enough. Added the prefix here as well

modules/core/types/events.go Outdated Show resolved Hide resolved
modules/core/keeper/msg_server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this looks like a solid implementation, thank you for putting this together! I just had a few minor nits but otherwise looks great!

@@ -419,6 +445,14 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() {
// replay should not error as it is treated as a no-op
_, err := keeper.Keeper.Acknowledgement(*suite.chainA.App.GetIBCKeeper(), suite.chainA.GetContext(), msg)
suite.Require().NoError(err)

if replay {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit, to be more consistent maybe we could make this a tc.replay, we seem to be mixing things like tc.expPass and standalone bools like replay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

modules/core/keeper/msg_server_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@charleenfei charleenfei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick changes!

@@ -57,15 +58,15 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() {
suite.Require().NoError(err)

packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, 0)
}, true, false},
}, true, false, false, false},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should open an issue to make these named args in a followup (4 booleans are hard to process what they indicate without a name)

modules/core/keeper/msg_server_test.go Show resolved Hide resolved
Comment on lines 23 to 25
// no need to append the error attribute prefix to the event type because
// the event type is not associated to a value that can be misinterpreted
newEvents[i] = sdk.NewEvent(event.Type, newAttributes...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yea. My main concern is accidental misuse, that is using the event type to indicate an action occurred without caring about particular values. But I think you make a fair point that event types aren't the key to some value. I'm not too concerned about breaking pre-existing clients as pre-existing clients currently cannot access error events. If the primary use case here is simply for debugging, I'm not sure I see much benefit in not error prefixing the type defensively, but I don't feel strongly, just feel slightly uncomfortable allowing any surface area for misinterpretation of events

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks very great to me! My only hesitation is not prefixing the event type, which I have left my thoughts on. I'm happy to go with whichever direction you think is best

It might be a good idea to mention this change in behaviour to relayers in case it causes unexpected behaviour in their code (parsing an event for which the expected key they want is missing)

@srdtrk srdtrk changed the title imp(core): allow huckleberry events with an attribute prefix imp(core): allow huckleberry events with a prefix Jan 11, 2024
@srdtrk srdtrk merged commit 2375109 into main Jan 11, 2024
62 checks passed
@srdtrk srdtrk deleted the serdar/issue#5284-error-event-suffix branch January 11, 2024 09:54
mergify bot pushed a commit that referenced this pull request Jan 11, 2024
* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

# Conflicts:
#	modules/core/keeper/msg_server.go
#	modules/core/keeper/msg_server_test.go
mergify bot pushed a commit that referenced this pull request Jan 11, 2024
* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

# Conflicts:
#	modules/core/keeper/msg_server.go
#	modules/core/keeper/msg_server_test.go
mergify bot pushed a commit that referenced this pull request Jan 11, 2024
* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

# Conflicts:
#	modules/core/keeper/msg_server.go
mergify bot pushed a commit that referenced this pull request Jan 11, 2024
* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)
@colin-axner colin-axner mentioned this pull request Jan 11, 2024
9 tasks
charleenfei pushed a commit that referenced this pull request Jan 11, 2024
* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items
charleenfei pushed a commit that referenced this pull request Jan 11, 2024
* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items
srdtrk added a commit that referenced this pull request Jan 11, 2024
…5573)

* imp(core): allow huckleberry events with a prefix (#5541)

* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

# Conflicts:
#	modules/core/keeper/msg_server.go
#	modules/core/keeper/msg_server_test.go

* fix: merge conflicts

* ci: removed link checker

---------

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <srdtrk@hotmail.com>
srdtrk added a commit that referenced this pull request Jan 11, 2024
…5574)

* imp(core): allow huckleberry events with a prefix (#5541)

* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

# Conflicts:
#	modules/core/keeper/msg_server.go
#	modules/core/keeper/msg_server_test.go

* fix: merge conflicts

* nit

* ci: removed link checker

---------

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <srdtrk@hotmail.com>
srdtrk added a commit that referenced this pull request Jan 11, 2024
…5575)

* imp(core): allow huckleberry events with a prefix (#5541)

* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

# Conflicts:
#	modules/core/keeper/msg_server.go

* fix: merge conflicts

* nit

---------

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <srdtrk@hotmail.com>
srdtrk added a commit that referenced this pull request Jan 11, 2024
…5576)

* imp(core): allow huckleberry events with a prefix (#5541)

* feat: initial impl

* imp: moved event helpers to types and added tests

* imp(testing): added mock events to mock module

* test: added msg_server tests for application events

* imp: converted suffix to prefix

* docs: updated inline comments

* imp: review item

* test: review items

* imp: review items

(cherry picked from commit 2375109)

* nit

---------

Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: srdtrk <srdtrk@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICA host packet failure events not being emitted
6 participants