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

UnpackAny limit exceeded for historical txs #4370

Open
rootulp opened this issue Mar 3, 2025 · 6 comments · May be fixed by #4373
Open

UnpackAny limit exceeded for historical txs #4370

rootulp opened this issue Mar 3, 2025 · 6 comments · May be fixed by #4373
Assignees
Labels
bug Something isn't working

Comments

@rootulp
Copy link
Collaborator

rootulp commented Mar 3, 2025

Context

Hey! We think there might be a bug in Cosmos SDK. A few months ago, a constant MaxUnpackAnySubCalls‎ = 100 was added, which - if we understand correctly - sets a limit on the number of calls inside MsgExec. However, in this transaction (link), there seem to be around 175 calls. As a result, when trying to parse the transaction, we get a call limit exceeded error. For now, we’ve rolled back to version v1.25.0-sdk-v0.46.16, where this change wasn’t present. But if there are breaking changes in the future, we won’t be able to re-index using the newer versions. Is this expected behavior or a bug? And what would be the best way to handle this?

From @vvuwei

Problem

https://github.com/celestiaorg/cosmos-sdk/releases/tag/v1.25.1-sdk-v0.46.16 included a fix that addressed a security vulnerability but celestia-app releases with that change won't be able to process https://www.mintscan.io/celestia/block/7013 because https://www.mintscan.io/celestia/tx/999b89260b384256f32722f7a1c54b319889cc6dd34c73b99ec1f47e560c5b66?height=7013. This effectively breaks single-binary syncs.

Options

  1. Identify txs included on-chain with a UnpackAny >= 100. If it's not that many, consider modifying the constant in celestia-app v4 to handle the max UnpackAnys already included on-chain.
  2. Consider wrapping fix: transaction decoding may result in a stack overflow or resource exhaustion cosmos-sdk#422 in a version gate so that it only applies to app version >= 3
  3. Consider wrapping fix: transaction decoding may result in a stack overflow or resource exhaustion cosmos-sdk#422 in a block height gate so that it only applies to block heights >= N
@rootulp rootulp added the bug Something isn't working label Mar 3, 2025
@rootulp rootulp self-assigned this Mar 3, 2025
@tac0turtle
Copy link
Contributor

height gating seems sufficient. You shouldnt need to worry about the vulnerability in the historical context

@rootulp
Copy link
Collaborator Author

rootulp commented Mar 3, 2025

Height based gating has the downside that we must add height constants for each supported chain-id (arabica, mocha, mainnet beta). If we pursue option 2 then we can avoid any chain-id specific logic.

Given we bumped to cosmos-sdk v1.25.1 in https://github.com/celestiaorg/celestia-app/releases/tag/v3.1.1, we need to verify that all celestia-app v3 blocks adhere to the 100 UnpackAny limit and then we can add the version gate into the binary.

@evan-forbes
Copy link
Member

imo we should simply add the version gate like all other consensus breaking changes, even if that means adding the gate in the fork of the sdk.

@adlerjohn
Copy link
Member

I would add the height gating alone, at least to start. That at least guarantees nothing can go wrong. The gating can be loosened to a version gating in the future without breaking anything if we determine there are no such txs in the history.

@rootulp
Copy link
Collaborator Author

rootulp commented Mar 3, 2025

On Mainnet Beta celestia-app v3 there have been no transactions with > 50 MsgExecs (see query). Numia doesn't support Arabica or Mocha (yet, I just submitted a feature request) so I can't easily verify the same claim on those networks.

@rootulp rootulp linked a pull request Mar 3, 2025 that will close this issue
@cmwaters
Copy link
Contributor

cmwaters commented Mar 4, 2025

How difficult will it be to apply the limit based on either of the app version or height? On the surface it doesn't look like a simple change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants