osmojs icon indicating copy to clipboard operation
osmojs copied to clipboard

Osmosis testnet was upgraded to Cosmos SDK 0.47 which is incompatible with Tendermint34Client

Open chasevoorhees opened this issue 1 year ago • 13 comments

@cosmjs/tendermint-rpc - I suddenly started getting an error after broadcastTx->decodeTx "Error: Invalid string. Length must be a multiple of 4"

I opened an issue with cosmjs and they told me this:

Osmosis testnet was upgraded to Cosmos SDK 0.47 as far as I can tell. In that case, using the Tendermint34Client won't work anymore. You need the Tendermint37Client. Can you report this to osmojs where those things are defined?

It looks like we need to be able to specify whether we want to use Tendermint34Client or Tendermint37Client when calling getSigningOsmosisClient()

I'm looking into this personally to see if there's an easy fix but wanted to post this as it's a blocking issue for hummingbot's Osmosis connector

chasevoorhees avatar Dec 07 '23 20:12 chasevoorhees

I assume this error happens because testnest is on SDK 0.47 (Tendermint 0.37) and mainnet is on 0.45 (Tendermint 0.34). In the latest version of CosmJS there is connectComet(endpoint) which does the auto-detectsion and returns a type CometClient = Tendermint34Client | Tendermint37Client | Comet38Client

webmaster128 avatar Dec 09 '23 09:12 webmaster128

@webmaster128 do we need to do something in the config, or won't cosmjs detect it?

Maybe the devs can temporarily manage this by using resolutions in your package and including a newer version of cosmjs if we've baked an older version in

pyramation avatar Dec 11 '23 18:12 pyramation

How do you currently create that client? Tendermint34Client is expected to not support SDK 0.47. Using connectComet is the recommended way to create the client if you are creating the Tendermint/Comet client manually. Otherwise the higher level StargateClient does the detection internally.

webmaster128 avatar Dec 11 '23 18:12 webmaster128

ok — so this clearly may be the isssue @webmaster128

https://github.com/osmosis-labs/osmojs/blob/d4a3defc14c09d66c9201511a42b655f0d6aad47/packages/osmojs/src/codegen/cosmos/rpc.query.ts#L8

can you provide a small snippet of what we should change this too? I think we went a little lower level and are using the client directly

cc @Zetazzz

pyramation avatar Dec 12 '23 01:12 pyramation

Hi, Hoang's almost got this PR done: https://github.com/cosmology-tech/telescope/pull/503

We're working on getting this PR merged, hopefully we'll publish soon

Zetazzz avatar Dec 12 '23 15:12 Zetazzz

Yes, confirming that https://github.com/cosmology-tech/telescope/pull/503 is the right solution

webmaster128 avatar Dec 12 '23 17:12 webmaster128

I merged my PR. This should be okay now.

hoangdv2429 avatar Dec 12 '23 18:12 hoangdv2429

@cosmology/[email protected] published useConnectComet option will be deprecated and made the logic default after a trial period.

Zetazzz avatar Dec 13 '23 01:12 Zetazzz

Sorry guys - here was my (well, mostly the Kujira connector dev's) solution to manually instantiate Osmosis with Tendermint37Client

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);

  private async osmosisGetSigningStargateClient(
    rpcEndpoint: string,
    signer: any,
  ){
    this.osmosisGetHttpBatchClient(rpcEndpoint);
    await this.osmosisGetTendermint37Client();

    const signingStargateClient = await SigningStargateClient.createWithSigner(this.tendermint37Client!, signer, {
      registry: registry,
      aminoTypes: aminoTypes
    });

    return signingStargateClient;
  }

  private async osmosisGetTendermint37Client() {
    this.tendermint37Client = await Tendermint37Client.create(
      this.httpBatchClient!
    );
  }

  private osmosisGetHttpBatchClient(rpcEndpoint: string) {
    this.httpBatchClient = new HttpBatchClient(rpcEndpoint, {
      dispatchInterval: 2000,
    });
  }

chasevoorhees avatar Dec 13 '23 01:12 chasevoorhees

Closed with 2 solutions

chasevoorhees avatar Dec 13 '23 01:12 chasevoorhees

@chasevoorhees while cosmology might have published a new version(which comes with it's own challenges) that does not fix this issue in the osmojs package unless someone explicitly regenerates the lib from telescope again. @pyramation is there any active working solution using osmojs?

haroondilshad avatar Dec 30 '23 02:12 haroondilshad

we're on it!

pyramation avatar Jan 04 '24 22:01 pyramation

In the meanwhile, do you recommend using package.json resolutions to temporarily resolve all @cosmjs packages to the latest versions?

haroondilshad avatar Jan 14 '24 13:01 haroondilshad