Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random "signature verification failed" errors on WithdrawPosition txs #85

Open
Moreno-dev opened this issue Feb 16, 2024 · 0 comments
Open

Comments

@Moreno-dev
Copy link

Title:

Random "signature verification failed" errors on WithdrawPosition txs

Description:

When executing transactions to withdraw a position, I occasionally encounter a failure in the transaction simulation and broadcasting process. The error returned is "Failed to simulate and broadcast after 3 attempts: Error: Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (12345), sequence (123) and chain-id (osmosis-1): unauthorized." This issue arises sporadically and does not consistently reproduce with the same conditions.

Environment Details:

  • OsmoJS Version: v16.9.0
  • Node.js Version: v20.11.0

Implementation

// all imports for the signing client

async init() {
  this.signer = await Secp256k1HdWallet.fromMnemonic(
    this.accountMnemonic,
    {
      prefix: "osmo",
      hdPaths: [makeCosmoshubPath(this.accountIndex)]
    }
  );

  this.address = (await this.signer.getAccounts())[0].address

  const protoRegistry: ReadonlyArray<[string, GeneratedType]> = [
    ...cosmosProtoRegistry,
    ...cosmwasmProtoRegistry,
    ...ibcProtoRegistry,
    ...osmosisProtoRegistry
  ];

  const aminoConverters = {
    ...cosmosAminoConverters,
    ...cosmwasmAminoConverters,
    ...ibcAminoConverters,
    ...osmosisAminoConverters
  };

  const registry = new Registry(protoRegistry);
  const aminoTypes = new AminoTypes(aminoConverters);

  this.client = await SigningStargateClient.connectWithSigner(this.rpcEndpoint, this.signer, {
    registry,
    aminoTypes
  });
}

import {MsgWithdrawPosition} from "osmojs/dist/codegen/osmosis/concentratedliquidity/v1beta1/tx";
import {Position} from "osmojs/dist/codegen/osmosis/concentratedliquidity/v1beta1/position";

async withdrawPosition(position: Position): Promise<DeliverTxResponse> {
	let value: MsgWithdrawPosition = {
		positionId: position.positionId,
		sender: this.address,
		liquidityAmount: position.liquidity,
	}

	return await this.submitTx([{
		typeUrl: "/osmosis.concentratedliquidity.v1beta1.MsgWithdrawPosition",
		value
	}])
}

async submitTx() {
	const gasWanted: number = await this.client.simulate(this.address, [messages[i]])
	const fee = await this.calculateFee(gasWanted);
	const response = await this.client.signAndBroadcast(this.address, [messages[i]], fee);
}

private async calculateFee(gasWanted: number): Promise<StdFee> {
	const gas = Math.ceil(gasWanted * 1.3);
	const amount = String(Math.ceil((0.0025 * 1) * gas)); // TODO Implement EIP1559
	return {
		amount: [{denom: "uosmo", amount}],
		gas: gas.toString(),
	}
}

Actual Behavior:

The transaction intermittently fails with a signature verification error, despite extensive testing across 5 different public RPCs and accounts on the mainnet. These tests, conducted simultaneously to rule out time-related factors, yielded inconsistent results—successes mixed with failures—without any discernible pattern. The issue's sporadic nature, occurring in about half of the attempts, and the straightforward code complicate pinpointing the cause, as failures seem random and without a clear failure pattern.

Error Messages:

Failed to simulate and broadcast after 3 attempts: Error: Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (12345), sequence (123) and chain-id (osmosis-1): unauthorized.

Additional Context:

  • The issue occurs randomly and is not tied to a specific Position object or transaction payload.
  • Example payload that failed:
    messages[i]: {
      typeUrl: '/osmosis.concentratedliquidity.v1beta1.MsgWithdrawPosition',
      value: {
        positionId: 123456n,
        sender: 'osmo1qnzhuj123459uffn8uyny12345wx3x0lv12345',
        liquidityAmount: '12345678901234567890.15243459811674906'
      }
    }

I suspect this could be related to how transaction simulation and sequence numbers are handled or possibly an issue with the chain-id validation process. Any insights or suggestions on how to troubleshoot or resolve this issue would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant