cosmjs
cosmjs copied to clipboard
Some CosmJs-Types Txs Don't Work (e.g. Unjail)
A simple Unjail doesn't work, even when I add a custom Registry and AminoConverter
{
typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail",
value: {
validatorAddr: "osmovaloper1wqx3uvz9xry82jy2suppg57mpeg50dwd6qldu8",
},
}
However, some txs do work, like msgEdit
{
typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator",
value: {
description: {
moniker: "New-Moniker",
identity: "[do-not-modify]",
website: "[do-not-modify]",
securityContact: "[do-not-modify]",
details: "[do-not-modify]",
},
validatorAddress: "osmovaloper1wqx3uvz9xry82jy2suppg57mpeg50dwd6qldu8",
commissionRate: null,
minSelfDelegation: null,
},
}
Here is a gist of my minimal working example
Possibly related:
- why does direct signing fail for multisigs? Only amino seems to work with cosmjs. Replacing
Secp256k1HdWallet
withDirectSecp256k1HdWallet
breaks it - why does
toBase64(signature)
return a different value than this cli command? I would expect them to be the same:
-
osmosisd tx sign unjail_unsigned.json --multisig=osmo1wqx3uvz9xry82jy2suppg57mpeg50dwdqhhwtq --from fourth --chain-id osmo-test-5 --node=https://rpc.osmotest5.osmosis.zone:443 --output-document signed.json && cat signed.json | jq '.signatures[0].data.single.signature'
- is there a good way to get mnemonic(s) for the validator created by the simd genesis file - src?
- this would allow inclusion & unit testing of more validator-related messages like Unjail etc
Found a related issues for #1 - https://github.com/cosmos/cosmjs/issues/1273 , https://github.com/cosmos/cosmjs/issues/1097#issuecomment-1069169749
tangentially related - https://github.com/cosmos/cosmjs/issues/837
Similar issues
https://github.com/cosmology-tech/cosmos-kit/issues/187
https://github.com/cosmos/cosmjs/issues/1414
Thanks a lot for bringing this up.
This looks good as far as I can tell. However, it looks like the field is renamed to just address
in the Amino JSON. I found this in cosmos-sdk code:
func TestMsgUnjailGetSignBytes(t *testing.T) {
addr := sdk.AccAddress("abcd")
msg := NewMsgUnjail(sdk.ValAddress(addr))
bytes := msg.GetSignBytes()
require.Equal(
t,
`{"type":"cosmos-sdk/MsgUnjail","value":{"address":"cosmosvaloper1v93xxeqhg9nn6"}}`,
string(bytes),
)
}
Would you submit your Amino converter as an implementation for https://github.com/cosmos/cosmjs/blob/main/packages/stargate/src/modules/slashing/aminomessages.ts#L21-L23 and fix AminoMsgUnjail
?
why does direct signing fail for multisigs? Only amino seems to work with cosmjs. Replacing
Secp256k1HdWallet
withDirectSecp256k1HdWallet
breaks it
Because multisigs work fundamentally different in sign mode direct. See https://github.com/cosmos/cosmjs/pull/1400 for a proof of concept how this can be done. For now I'd consider it unsupported in CosmJS.
why does toBase64(signature) return a different value than this cli command? I would expect them to be the same:
secp256k1 signatures are not unique. I.e. different signing libraries can produce different signatures what are all valid.
is there a good way to get mnemonic(s) for the validator created by the simd genesis file - src?
Yeah, this was changed recently to a hardcoded mnemonic: https://github.com/cosmos/cosmjs/blob/v0.31.0/scripts/simapp44/setup.sh#L26-L27
this would allow inclusion & unit testing of more validator-related messages like Unjail etc
👍 but right now there is only one validator running the test chains. If this gets jailed, the chain probably halts.