cosmology-tech / telescope

A TypeScript Transpiler for Cosmos Protobufs ⚛️
https://cosmology.zone/products/telescope
Apache License 2.0
145 stars 43 forks source link

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 #453

Open ranlavanet opened 1 year ago

ranlavanet commented 1 year ago

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. 
pyramation commented 1 year ago

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

ranlavanet commented 1 year ago

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

ranlavanet commented 1 year ago

@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 commented 1 year ago

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.

hoangdv2429 commented 1 year ago

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