-
Notifications
You must be signed in to change notification settings - Fork 624
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
Pass in the codec to the Acknowledgement interface function Acknowledgement()
#905
Comments
Acknowledgement()
So it seems to me like there already is a problem with channel acks not being registered on the codec. I actually get a failure on main if I replace this line: https://github.com/cosmos/ibc-go/blob/main/modules/core/04-channel/types/codec_test.go#L26 with: which would make sense because mock acknowledgement is not registered on any codec. Acknowledgement interface needs to be registered in channel/types with the standard acknowledgement as one of the implementations. Apps using custom implementations can register their implementations in their codec functions. This still doesn't help the ICS29 case because as you said in order for ICS29 to marshal an acknowledgement coming from a different application it needs the global app codec.
This is already the codec that gets constructed in app.go and is given to every keeper. Your solution is effectively to get the global codec from the 29 keeper and give it to a function in types as a function argument.
I actually think this approach is fine, and less ugly then changing the Acknowledgement API. Let's simply leave the underlying ack as |
@colin-axner do you agree with the approach? |
I don't have the brain to think on this today, but my first feeling is to be very cautious about changing this interface. The approach of @AdityaSripal may work. But can you please frame the issue you try to solve. If I understand properly: "We want the middleware to commit atomically with the wrapped code. That is, if the wrapped code returns Is that the correct framing of your aims? Are we sure we want that behavior? With normal tx, AnteHandlers and Decorators like Fee handler may still commit even when the underlying message fails. I think a deeper discussion of the design goals of middleware would be good before discussing any API changes. Although there probably as such discussion already documented in the repo, that I just failed to read (just link me to it in that case) |
In the case of fee middleware, yes we want the wrapped acknowledgement to return the same It's possible for other middleware to fail even if the underlying ack succeeds. So they should in this case return
This is correct. We want to make sure that if the wrapped code returns false, then all middleware must also return false. This is because the wrapped code itself does not revert its state. The handler at the end will look at the success value and decide whether to discard the cached context. So if a middleware returns This should be well documented in the spec, I don't believe it currently is. |
This makes sense to me. But it isn't obvious that middleware cannot perform any logic if the undelrying app returns |
Ahh I was incorrect earlier. It is the case that we will always want the middleware to return the same Success value as the underlying application. In the case, where the underlying application returns false. Any logic performed by the middleware is irrelevant, because it will all get reverted. In the case, where the underlying application returns true. The middleware must perform a valid state transition. This may either be a valid non-trivial state transition, or it may be a no-op. If the middleware errors in its own execution, it must not change the value of In the case, where the middleware changes the This requirement should be clearly documented in the middleware developer guide. |
If we take a step back from the existing implementation (easy for me), I would say that the success value should apply to that level and all underlying levels, regardless of what the parents do. This is how we organize submessages in CosmWasm and have put heavy thought into this with many devs. Basically, if we call A, B, C. C error will revert C state. B will by default return the error one level up (in cosmwasm), or it can explicitly handle the return and choose to return success, which will commit B changes and revert C. If A returns error, then B will also be reverted, even if it returned success. Think of this simply as nested ctx.Cache() calls. You are at once tied to one (simple) use case and trying to develop a general formula, which makes it hard without more examples. In my mind, a desired behavior here is fee middleware errors if there is insufficient/malformed fees. If it succeeds, it calls the next level. The wrapped handler can revert its own state by returning success = false but the fee middleware can still charge fees... just like the sdk middleware / antehandler design. This is easy enough to do if fee middleware doesn't call the next level directly, but calls some dispatcher that handles this logic |
Closed by #952 |
Part of EPIC celestiaorg/devops#112 > Note: Before merging this the secrets `ADD_TO_PROJECT_PAT` and `PAT_FOR_AUTO_REQUEST_REVIEW` are needed to set. See the usage and explanation [here](https://github.com/celestiaorg/.github/blob/v0.1.1/.github/workflows/reusable_housekeeping.yml). Changes in the PR: - The `.github/dependabot.yml` file is updated to add `T:dependencies` label for dependency updates in both package ecosystems. - A new `.github/workflows/housekeeping.yml` file is created to automate issue and PR housekeeping tasks, such as adding issues and PRs to a project, adding grooming labels, automatically assigning reviewers, assigning issues and PRs to their creators, and requiring specific labels. - A new `.github/auto_request_review.yml` file is created to configure the automatic assignment of reviewers based on file changes and reviewer groups. <details> <summary>Reviwer rules</summary> - `code-owners` group includes: - Nashqueue - tzdybal - gupadhyaya - `rollkit` group includes: - Manav-Aggarwal - S1nus - tuxcanfly - `devops` group includes: - smuu - sysrex - jrmanes - Bidon15 - `celestia` group includes the `team:celestia` team. The file patterns and the associated reviewer groups are: - For any file (`**`), the `code-owners` and `rollkit` groups will be requested for review. - For any Dockerfile (`**/*Dockerfile`), the `devops` group will be requested for review. - For any file within the `.github` directory and its subdirectories (`.github/**`), the `devops` group will be requested for review. The options section specifies that draft PRs will be ignored (`ignore_draft: true`), PRs with "WIP" in the title will be ignored (`ignored_keywords: - WIP`), and the number of reviewers to request is 3 (`number_of_reviewers: 3`). </details> Closes celestiaorg/devops#260 --------- Signed-off-by: Smuu <[email protected]>
Summary
ICS29 is our first true middleware implementation. It has an acknowledgement which wraps the underlying acknowledgements. Every acknowledgement needs to implement two functions:
In order for us to propagate the return value of
Success()
from the underlying acknowledgements, we need to access the interface type (and not the marshaled bytes). This forces us to wrap the underlying acknowledgement as anAny
. Marshaling/Unmarshaling Any's however requires access to a codec which has all the implementations registered against the interface.The current API for
Acknowledgement
doesn't allow for this.I propose modifying the Acknowledgement interface to pass in a codec to
Acknowledgement()
so that it becomes:Would like @ethanfrey's input since he was heavily involved in designing the 04-channel Acknowledgement type/interface.
The alternative approaches are:
For Admin Use
The text was updated successfully, but these errors were encountered: