fix(client/tx): populate multisig bit array in simulation tx - #26776
Open
riba2534 wants to merge 1 commit into
Open
fix(client/tx): populate multisig bit array in simulation tx#26776riba2534 wants to merge 1 commit into
riba2534 wants to merge 1 commit into
Conversation
Contributor
|
PR author is not in the allowed authors list. |
cursor
Bot
force-pushed
the
cursor/fix-multisig-gas-auto-simulation-547d
branch
from
August 26, 2026 02:03
722c4f5 to
c5af681
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26776 +/- ##
==========================================
- Coverage 65.27% 64.96% -0.31%
==========================================
Files 830 785 -45
Lines 58577 55399 -3178
==========================================
- Hits 38235 35992 -2243
+ Misses 20342 19407 -935
🚀 New features to boost your workflow:
|
swift1337
requested changes
Sep 4, 2026
| // set, otherwise the ante handler rejects the simulation tx before estimating gas. | ||
| subKeys := multisigPubKey.PubKeys | ||
| bitArray := cryptotypes.NewCompactBitArray(len(subKeys)) | ||
| multiSignatureData := make([]signing.SignatureData, 0, multisigPubKey.Threshold) |
Member
There was a problem hiding this comment.
Ensure that multisigPubKey.Threshold <= len(subKeys)
| multiSignatureData = append(multiSignatureData, &signing.SingleSignatureData{ | ||
| SignMode: f.SignMode(), | ||
| }) | ||
| for i := 0; i < len(subKeys) && i < int(multisigPubKey.Threshold); i++ { |
Member
There was a problem hiding this comment.
then
Suggested change
| for i := 0; i < len(subKeys) && i < int(multisigPubKey.Threshold); i++ { | |
| for i := 0; i < int(multisigPubKey.Threshold); i++ { |
| }) | ||
| for i := 0; i < len(subKeys) && i < int(multisigPubKey.Threshold); i++ { | ||
| bitArray.SetIndex(i, true) | ||
| subKey, _ := subKeys[i].GetCachedValue().(cryptotypes.PubKey) |
Member
There was a problem hiding this comment.
fail if !ok
Suggested change
| subKey, _ := subKeys[i].GetCachedValue().(cryptotypes.PubKey) | |
| subKey, ok := subKeys[i].GetCachedValue().(cryptotypes.PubKey) |
cursor
Bot
force-pushed
the
cursor/fix-multisig-gas-auto-simulation-547d
branch
from
September 4, 2026 11:10
0c8daea to
54ade17
Compare
Factory.getSimSignatureData built a dummy MultiSignatureData with the Signatures slice populated but BitArray left nil. Since cosmos#26515 hardened ConsumeMultisignatureVerificationGas to require the bit array to be sized to the key set, a nil bit array (which counts as 0) makes every multisig simulation fail with "bit array size is incorrect, expecting: N", so --gas auto is unusable for multisig senders. Size the bit array to the full key set and set the first Threshold bits, and recurse into sub-keys so a nested multisig sub-key gets multisig dummy signature data instead of single-signature data (which the gas consumer also rejects). Validate that Threshold does not exceed the key set and fail when a sub-key cannot be decoded as a public key. Fixes cosmos#26759
cursor
Bot
force-pushed
the
cursor/fix-multisig-gas-auto-simulation-547d
branch
from
September 4, 2026 11:12
54ade17 to
799080c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #26759
--gas autois broken for any multisig sender since #26515:Factory.getSimSignatureDatabuilt the dummysigning.MultiSignatureDatafor the simulation tx withSignaturespopulated butBitArrayleft nil. #26515 then requiredsig.BitArray.Count() == len(pubkey.GetPubKeys()). A nil bit array counts as 0, so simulation always fails before gas is estimated.Before that check, the nil bit array meant the gas-consumer loop never ran, so multisig simulation "worked" but charged zero signature-verification gas.
Fix
Size the simulation bit array to the full key set and set the first
Thresholdbits, matching the dummy sub-signatures already created. The ante-handler bounds check is left untouched.The loop also recurses into selected sub-keys. Without that, a nested multisig sub-key would get
SingleSignatureDataandDefaultSigVerificationGasConsumerwould reject it.As a side effect, multisig gas estimation now accounts for the
Thresholdsub-signature verifications instead of silently charging zero.Tests
Both fail before the fix and pass after.
TestFactory_getSimSignatureDataMultisig— 1-of-1, 2-of-3, and a nested-multisig sub-keyTestBuildSimTxMultisig— end-to-end--gas autopath; reproducesbit array size is incorrect, expecting: 3without the fixVerified:
make build,go test ./client/... ./x/auth/... ./crypto/...,cd tests && go test ./integration/auth/..., lint clean on the root module.