Closed outofforest closed 10 months ago
Taking a key from the keystore for gas simulation doesn't seem correct to me. Unless something changed, gas estimation used a fake sentinel public key: https://github.com/cosmos/cosmos-sdk/blob/main/x/auth/ante/sigverify.go#L85-L91
But the code I linked does exactly that - it takes the key from the keystore
Interesting. I had no idea we did that and it seems new-ish. On the original v0.45 version we didn't do that: https://github.com/cosmos/cosmos-sdk/blob/v0.45.0/client/tx/tx.go#L264
I'd have to defer to the author or someone who's more familiar. It seems to have been added in this PR: https://github.com/cosmos/cosmos-sdk/pull/11282
Agree that approach taken there is "intriguing"
Interesting. I had no idea we did that and it seems new-ish. On the original v0.45 version we didn't do that: https://github.com/cosmos/cosmos-sdk/blob/v0.45.0/client/tx/tx.go#L264
I'd have to defer to the author or someone who's more familiar. It seems to have been added in this PR: #11282
could you look into this @alexanderbez otherwise this will sit and never get closed until Julien or I have time.
Yeah sure.
My proposal is to revert https://github.com/cosmos/cosmos-sdk/pull/11282 (sorry @fedekunze). This isn't a clean solution IMO. You shouldn't have to rely on the keyring to do this (hence this issue!).
I instead propose we add a WithSimPubKey(pk PubKey)
to Factory
. Then BuildSimTx
will simply use that field. LMK what you think.
@tac0turtle can we take this issue?
That would be 🔥 @educlerici-zondax
I instead propose we add a
WithSimPubKey(pk PubKey)
toFactory
. ThenBuildSimTx
will simply use that field. LMK what you think.
hey! @alexanderbez
would adding a fromName
field to the Factory
populated at construction time from clientCtx
work? Then we can get the Pubkey from keyring
TBH, I'm not sure, but possibly, yes. I didn't spend a ton of time looking into the specifics of my proposed solution, but the general idea should work, yeah.
Is there an existing issue for this?
What happened?
According to what I've found here: https://github.com/cosmos/cosmos-sdk/blob/1a62d774bb3240a7cd8c28fee01a5db369235908/client/tx/factory.go#L446
When gas is simulated (using
--gas=auto
) the first public key found in the keystore is used. This behavior might break the simulation process giving this or similar error:I was able to trigger this by:
aaa
to the keystorebbb
to the keystore`bbb
(multisig account)In this case transaction is simulated using
aaa
public key, which is wrong because the node expects multisig public key.Same things applies the other way:
aaa
keybbb
keybbb
(normal account)This time multisig key
aaa
is used for simulation, which is wrong again, because node expects normal public key.How to solve it: Instead of taking the first key from the store, put the right empty signature there. I've already implemented possible fix in the past, it's available here: https://github.com/CoreumFoundation/coreum/blob/3634317320c464f3eae766929952ae943205cce2/pkg/client/tx.go#L145
Cosmos SDK Version
0.47
How to reproduce?
No response