telescope icon indicating copy to clipboard operation
telescope copied to clipboard

Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (37), sequence (4) and chain-id (lava-testnet-2): unauthorized

Open ranlavanet opened this issue 1 year ago • 5 comments

we are encountering this on every transaction on lava network we recently upgrade to cosmos 47 but i can confirm this also happened on 46

snippet of the code causing this issue:

  let wallet = await Secp256k1Wallet.fromKey(fromHex(privKey), "lava@")
  const [firstAccount] = await wallet.getAccounts();
  console.log(firstAccount)
  let signingClient = await getSigningLavanetClient({
    rpcEndpoint: publicRpc,
    signer: wallet,
  })
  
  const msg = lavanet.lava.subscription.MessageComposer.withTypeUrl.buy({
    creator: firstAccount.address,
    consumer: firstAccount.address,
    index: "explorer",
    duration: new Long(1), /* in months */
  })
  
  const fee = {
    amount: [{ amount: "1", denom: "ulava" }], // Replace with the desired fee amount and token denomination
    gas: "50000000", // Replace with the desired gas limit
  }
  
  await signingClient.signAndBroadcast(firstAccount.address,[msg], fee, "Buying subscription on Lava blockchain!")

Results:

BroadcastTxError: Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (37), sequence (4) and chain-id (lava-staging-4): unauthorized
  at SigningStargateClient.broadcastTx (/home/user/telescope-test/lavajs/node_modules/@cosmjs/stargate/src/stargateclient.ts:449:9)
  at processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async run (/home/user/telescope-test/lavajs/test.ts:45:3) {
code: 4,
codespace: 'sdk',
log: 'signature verification failed; please verify account number (37), sequence (4) and chain-id (lava-staging-4): unauthorized'
}```


Important to note I've also tried other message construction options which used to work for cosmos v45.11 and stopped working for the lava stargate client on the latest release. 

ranlavanet avatar Aug 21 '23 17:08 ranlavanet

I think this is due to the new tendermint client! I believe the latest cosmjs may have fixed this issue

pyramation avatar Aug 23 '23 19:08 pyramation

so I just need to update my package.json file?

ranlavanet avatar Aug 27 '23 08:08 ranlavanet

@pyramation

updated the cosmjs in out package.json file

 "devDependencies": {
    "@cosmology/telescope": "^0.105.0",
    "@protobufs/amino": "^0.0.11",
    "@protobufs/cosmos": "^0.1.0",
    "@protobufs/cosmos_proto": "^0.0.10",
    "@protobufs/gogoproto": "^0.0.10",
    "@protobufs/google": "^0.0.10",
    "@protobufs/tendermint": "^0.0.10",
    "@types/jest": "^29.5.0",
    "eslint": "8.45.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "jest": "^29.5.0",
    "jest-in-case": "^1.0.2",
    "prettier": "^2.8.7",
    "publish-scripts": "0.1.0",
    "rimraf": "^5.0.1",
    "ts-jest": "^29.1.0",
    "typescript": "^5.0.4"
  },
  "dependencies": {
    "@cosmjs/amino": "^0.31.1",
    "@cosmjs/proto-signing": "^0.31.1",
    "@cosmjs/stargate": "^0.31.1",
    "@cosmjs/tendermint-rpc": "^0.31.1",
    "@cosmology/lcd": "^0.12.0"
  }

we still encounter the same issue when trying to send a transaction

BroadcastTxError: Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (37), sequence (4) and chain-id (lava-staging-4): unauthorized
  at SigningStargateClient.broadcastTxSync (/home/user/sdk/lavajs-test/node_modules/@cosmjs/stargate/src/stargateclient.ts:499:9)
  at processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async SigningStargateClient.broadcastTx (/home/user/sdk/lavajs-test/node_modules/@cosmjs/stargate/src/stargateclient.ts:467:27) {
code: 4,
codespace: 'sdk',
log: 'signature verification failed; please verify account number (37), sequence (4) and chain-id (lava-staging-4): unauthorized'
}

any idea what can we do?

ranlavanet avatar Aug 29 '23 13:08 ranlavanet

Update: @pyramation Running with the direct signer solved this issue any idea why the amino signer would fail and the direct would succeed? we prefer using the private key initialization flow.

ranlavanet avatar Sep 03 '23 15:09 ranlavanet

@ranlavanet can you check if the amino signer have type of the above msg type registered and reload ?

hoangdv2429 avatar Nov 08 '23 11:11 hoangdv2429