cosmos / cosmos-multisig-ui

Create multisigs and multisig transactions on Cosmos chains
https://multisig.confio.run
Apache License 2.0
82 stars 109 forks source link

Bug: Account or sequence error when broadcasting transaction #60

Closed nooomski closed 1 year ago

nooomski commented 2 years ago

Trying to broadcast this Tx and getting the following error:

Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (1126996), sequence (0) and chain-id (cosmoshub-4): unauthorized

I can't tell for sure, but I believe this is from a multisig that I've used before and have submitted a tx for in the past, or even have unsubmitted txs in the DB somewhere. I'm guessing something is going wrong with the sequence number there.

samepant commented 2 years ago

Ya I'm seeing this as well. Looking into it

webmaster128 commented 2 years ago

The multisig account has no outgoing transactions, so sequence 0 is correct.

So it can be an signature verification problem, which is very hard to debug.

arunsybex commented 2 years ago

@webmaster128 I'm also facing the same issue.

Can you please share signing multisig tx with mnemonic( using cosmosJs not kepler).

webmaster128 commented 2 years ago

I don't know what the problem is and don't have and testing keys available. I'm just saying the sequence in the original report looks alright.

arunsybex commented 2 years ago

@webmaster128 instead of Kepler how to sign with mnemonic?

` const M1 = "swear buyer security impulse public stereo peasant correct cross tornado bid discover anchor float venture deal patch property cool wreck eight dwarf december surface"

const wallet = await Secp256k1HdWallet.fromMnemonic(M1, { hdPaths: [makeCosmoshubPath(0)], });

const pubkey = encodeSecp256k1Pubkey((await wallet.getAccounts())[0].pubkey); const address = (await wallet.getAccounts())[0].address; const signingClient_w1 = await SigningStargateClient.offline(wallet);

const signerData: SignerData = { accountNumber: signingInstruction.accountNumber, sequence: signingInstruction.sequence, chainId: signingInstruction.chainId, };

const { bodyBytes: bb, signatures : sig1 } = await signingClient_w1.sign( address, signingInstruction.msgs, signingInstruction.fee, signingInstruction.memo, signerData, );

let ledger = { "bodyBytes": "CosBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEmsKLGZldGNoMXFzOTJkbGpnYWM1cXNlN3VyZXpzMHJ2ZG5lcXU3bG13OW1zaGN3EixmZXRjaDFxcGh4MmtuenJrZ3Z4cWV2NmgzOWRtd2x5aGg0bDl4cnI0d3BsMBoNCghhdGVzdGZldBIBMRIWVXNlIHlvdXIgdG9rZW5zIHdpc2VseQ==", "signature": "Yi0sC7F8slJLPlVPhLL0gHpMiZvhkQgKSl8I/Pmmv3UAmoiMpgewKdeZp1P5XJTtpHDbw/kJh3M+RefnSQMC7g==", "address": "fetch1sr4jyvtk4kfwljywdnuzjurqlzlunsmvemhx55" } const broadcaster = await StargateClient.connect(data.rpc); const signedTx = makeMultisignedTx( multisigPubkey, signingInstruction.sequence, signingInstruction.fee, bodyBytes, new Map<string, Uint8Array>([ [ledger.address, fromBase64(ledger.signature)], [address, sig1[0]] ]), );

const result = await broadcaster.broadcastTx(Uint8Array.from(TxRaw.encode(signedTx).finish()));
console.log(result);

`

I tried form your code but getting signature error :(

nooomski commented 2 years ago

Hey @arunsybex , your question isn't really relevant to this issue. I would suggest you learn how to sign with a mnemonic here so that we can keep the discussion about the issue here.

webmaster128 commented 2 years ago

Also please see https://github.com/cosmos/cosmjs/blob/d63eba99dce35be37d9267899489906ee77d9f3f/packages/stargate/src/multisignature.spec.ts#L172-L274. Feel free to open a ticket in cosmjs if this is not working.

arunsybex commented 2 years ago

@webmaster128 above one is working fine with mnemonics but I'm facing an issue while adding the ledger signature.

webmaster128 commented 1 year ago

Unclear what the issue was. signature verification failed can have many different reasons such as signed by a wrong signer. Closing for now as it might already be covered.

mperklin commented 1 year ago

I ran into this bug earlier today while trying to sign a multisig transaction with a ledger nano s device, and had an opportunity to do some debugging.

I was able to extract the encoded transaction from the browser debugger, and then decode that transaction back into JSON to inspect it.

I noted that both the chain-id (cosmoshub-4) and the account number were not present in the resultant JSON, but the sequence value was. After trying to sign in different ways (via webusb and via keplr2) it seemed that signing with keplr2 failed to include those 2 fields, however signing with webusb produced a transaction that correctly included the chainid and account number.

It's my hope that this information may assist some developer in identifying a bug involving this multisig webapp and keplr2.

Good luck!