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

refactor: use branch service in recv packet (wip) #7752

Draft
wants to merge 104 commits into
base: main
Choose a base branch
from

Conversation

damiannolan
Copy link
Member

Description

closes: #XXXX


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/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@damiannolan
Copy link
Member Author

damiannolan commented Dec 19, 2024

It seems that we can't maintain backwards compatibility here with error prefixing events from the cached context passed to the ibc app in RecvPacket.

A potential solution could be to do something like this, if we added the Events() api back to EventService / EventManager - as the underlying implementation is the same as it used to be on the sdk.Context.

If we do not shadow the context variable passed to the func in BranchService.Execute(), we may be able to do something like the following:

if err := k.BranchService.Execute(ctx, func(cacheCtx context.Context) error {
	// Perform application logic callback
	ack = cbs.OnRecvPacket(cacheCtx, channelVersion, msg.Packet, relayer)
	if ack == nil || ack.Success() {
		// write application state changes for asynchronous and successful acknowledgements
		return nil
	} else {
		events := k.EventService.EventManager(cacheCtx).Events()
		for _, evt := range events {
			k.EventService.EventManager(ctx).EmitKV(evt.EventType, evt.Attributes...)
		}
	}

	// we must return an error here so that false positive events are not emitted
	return channeltypes.ErrFailedAcknowledgement
}); err != nil {
...
}

@damiannolan damiannolan mentioned this pull request Dec 19, 2024
10 tasks
Base automatically changed from damian/core-runtime-env to main December 20, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants