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: migrate from sdk.Context to Context.Context (1/n) #7058

Merged
merged 22 commits into from
Aug 26, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Aug 6, 2024

Description

This pr aims to remove sdk.Context in ibcKeeper. This pr will also aim to replace many sdk imports with services from core to allow reducing the dependency graph on the sdk

ref: #5917

Example commit messages:

fix: skip emission of unpopulated memo field in ics20
deps: updating sdk to v0.46.4
chore: removed unused variables
e2e: adding e2e upgrade test for ibc-go/v6
docs: ics27 v6 documentation updates
feat: add semantic version utilities for e2e tests
feat(api)!: this is an api breaking feature
fix(statemachine)!: this is a statemachine breaking fix
-->


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.

@tac0turtle tac0turtle changed the title refactor: migrate from sdk.Context to Context.Context refactor: migrate from sdk.Context to Context.Context (1/n) Aug 6, 2024
@tac0turtle
Copy link
Member Author

ill branch off this pr to continue.

@tac0turtle
Copy link
Member Author

opening this for review so the other prs dont get blocked and build up a backlog

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

So far so good, left a couple of comments to begin with, just nits mostly. Made my way through ica and fee code, will continue reviewing tomorrow.

Thanks @tac0turtle!

I think I can also assist on pushing some follow up commits to the branch for housekeeping trivial stuff

modules/apps/29-fee/keeper/keeper.go Outdated Show resolved Hide resolved
modules/apps/29-fee/keeper/keeper.go Show resolved Hide resolved
modules/apps/29-fee/keeper/keeper.go Outdated Show resolved Hide resolved
Comment on lines 257 to 269
has, err := store.Has(key)
if err != nil {
panic(err)
}
if !has {
return "", false
}

addr := string(store.Get(key))
return addr, true
addr, err := store.Get(key)
if err != nil {
panic(err)
}
return string(addr), true // TODO: why this cast?
Copy link
Member

Choose a reason for hiding this comment

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

ditto on refactor to single Get call and check len bytes.

regarding the TODO - its stored plain string because its an address belonging to a counterparty chain and "in theory" could be non cosmos-sdk addr.

e.g. relayer submits MsgRecvPacket to chainB and looks up a stored address to encode into the acknowledgement. Ack is relayed back to source(chainA) and address is parsed from acknowledgement data and fee is paid out to the account on source chain.

Copy link
Member Author

Choose a reason for hiding this comment

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

thank you for the explanation, how come this was the design instead of storingt the raw byets?

Copy link
Member

Choose a reason for hiding this comment

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

I believe the reasoning was likely around string usage being more human readable, rather than passing around the raw bytes of a foreign address. @AdityaSripal can probably speak to it more tbh

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Made my way through the rest of the diffs. Would like to clarify the api differences in corestore vs storetypes before merging. We now need to handle a bunch of error returns that were previously not there, just wondering how/what will trigger them to be surfaced(see other comment).

Assuming there will be parity available through other service types which we can consume later, in order fully remove sdk.Context and address all the TODOs? Some of the main things that come to mind are:

  • ChainID
  • BlockTime
  • Gas Consumption
  • Tx exec mode

Otherwise lgtm! Thank you @tac0turtle. I pushed a couple of consistency and nit follow up commits

modules/core/03-connection/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/keeper.go Outdated Show resolved Hide resolved
modules/light-clients/06-solomachine/proof.go Show resolved Hide resolved
Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

think this lgtm overall, big thanks for opening this PR Marko! Only thing would be consistency with handling of errors returned for store ops. Apart from that left a minor nit for the todo's which I'd prefer seeing as an issue.

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

LGTM pending CI. Cheers @tac0turtle

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

went through keeper.go files once again and had some qs to leave. can address ourselves!

modules/core/02-client/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/03-connection/keeper/keeper.go Outdated Show resolved Hide resolved
modules/apps/29-fee/keeper/keeper.go Outdated Show resolved Hide resolved
modules/apps/29-fee/keeper/keeper.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/keeper.go Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Aug 26, 2024

@damiannolan damiannolan added this pull request to the merge queue Aug 26, 2024
Merged via the queue into main with commit 4851524 Aug 26, 2024
70 checks passed
@damiannolan damiannolan deleted the marko/context-p1 branch August 26, 2024 15:01
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.

3 participants