fix(x/auth/tx): propagate signing options from codec to NewTxConfig#26422
fix(x/auth/tx): propagate signing options from codec to NewTxConfig#26422ozpool wants to merge 2 commits into
Conversation
NewTxConfig built a fresh SigningContext from NewDefaultSigningOptions whenever the caller did not pass ConfigOptions.SigningOptions, dropping any CustomGetSigners that had been applied to the codec's InterfaceRegistry via NewInterfaceRegistryWithOptions. The resulting txConfig.SigningContext().Validate() then failed for messages that relied on custom getters. Reuse the InterfaceRegistry's SigningContext when neither SigningOptions nor SigningContext were supplied, so options applied at registry construction time carry through to txConfig consumers without forcing them to switch to NewTxConfigWithOptions. Closes cosmos#22200
|
@greptile review |
Greptile SummaryThis PR fixes a bug where
Confidence Score: 4/5Safe to merge; the core bug is correctly fixed and the regression test is solid. The fix correctly threads the IR's signing context through to txConfig, resolving the CustomGetSigners propagation failure. The one side-effect to watch is that the new path leaves SigningOptions nil, so NewSigningHandlerMap provisions a fresh set of default options for the amino JSON and textual handlers — those handlers get HybridResolver as their file resolver rather than the IR's ProtoFiles. For every known caller this is equivalent, but callers using a custom ProtoFiles in NewInterfaceRegistryWithOptions would silently lose that resolver for amino/textual signing. x/auth/tx/config.go — specifically the interaction between the new signing-context reuse path and the downstream NewSigningHandlerMap call, which leaves SigningOptions nil. Important Files Changed
|
| if ir := protoCodec.InterfaceRegistry(); ir != nil { | ||
| configOptions.SigningContext = ir.SigningContext() | ||
| } else { | ||
| configOptions.SigningOptions, err = NewDefaultSigningOptions() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| configOptions.SigningContext, err = txsigning.NewContext(*configOptions.SigningOptions) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| } |
There was a problem hiding this comment.
Amino JSON / Textual sign modes lose IR file resolver
When ir != nil the new path sets configOptions.SigningContext but leaves configOptions.SigningOptions as nil. NewSigningHandlerMap (called at line 224) checks SigningOptions == nil first and allocates a fresh NewDefaultSigningOptions() — with a nil FileResolver — before it consults SigningContext. The SIGN_MODE_LEGACY_AMINO_JSON and SIGN_MODE_TEXTUAL handlers therefore receive a nil FileResolver and fall back to gogoproto.HybridResolver, whereas before this PR they received protoCodec.InterfaceRegistry() as their resolver.
For the common case (NewInterfaceRegistry() embeds HybridResolver as its ProtoFiles) the two are functionally equivalent, but callers who pass a custom ProtoFiles via NewInterfaceRegistryWithOptions will silently lose that resolver for amino/textual signing. The SigningContext itself retains the correct resolver (via ir.SigningContext()), so SIGN_MODE_DIRECT_AUX — which reads the resolver directly from the context via signersContext.FileResolver() — is unaffected.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26422 +/- ##
==========================================
- Coverage 64.89% 64.88% -0.02%
==========================================
Files 792 792
Lines 54970 54977 +7
==========================================
- Hits 35674 35673 -1
- Misses 19296 19304 +8
🚀 New features to boost your workflow:
|
Summary
NewTxConfigbuilt a freshSigningContextfromNewDefaultSigningOptionswhenever the caller did not passConfigOptions.SigningOptions, dropping anyCustomGetSignersthat had been applied to the codec'sInterfaceRegistryviaNewInterfaceRegistryWithOptions.txConfig.SigningContext().Validate()then failed for messages relying on custom getters with:```
no cosmos.msg.v1.signer option found for message ; use DefineCustomGetSigners to specify a custom getter
```
Reuse the
InterfaceRegistry'sSigningContextwhen neitherSigningOptionsnorSigningContextwere supplied, so options applied at registry construction time carry through totxConfigconsumers without forcing them to switch toNewTxConfigWithOptions.Closes #22200
Test plan