cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

add dynamic gasfee pricing as a signing client option - Feemarket/Osmosis

Open ertemann opened this issue 3 months ago • 6 comments

Summary

Adds automatic gas price discovery for chains with dynamic feemarket modules (Osmosis EIP-1559 and Skip feemarket). Instead of manually setting static gas prices, CosmJS can now query current prices from the chain, preventing transaction failures from outdated pricing.

Changes

  • New feemarket.ts: Query dynamic gas prices from Osmosis EIP-1559 and Skip feemarket modules
  • Updated clients: SigningStargateClient and SigningCosmWasmClient now support DynamicGasPriceConfig
  • Refactoring: Extracted calculateFeeForTransaction() helper
  • Tests: Some unit tests and an end-to-end validation on Osmosis and Neutron testnets

Usage

const client = await SigningStargateClient.connectWithSigner(rpc, signer, {
  gasPrice: {
    denom: "uosmo",
    multiplier: 1.3,
    minGasPrice: GasPrice.fromString("0.0025uosmo"),
    maxGasPrice: GasPrice.fromString("0.1uosmo"),
  }
});

// Gas price queried automatically per transaction
await client.signAndBroadcast(address, messages, "auto");

Features

Graceful fallback to minGasPrice if feemarket query fails Min/max constraint enforcement with configurable multiplier backward compatible - existing code unchanged Automatic chain detection for Osmosis variants

Inspired by Hermes relayer PR #4004.

ertemann avatar Nov 18 '25 14:11 ertemann

Thanks for the comments @webmaster128 will resolve remaining issues tomorrow, didnt have time this week yet.

ertemann avatar Nov 28 '25 13:11 ertemann

changes made, ready for merge.

ertemann avatar Dec 14 '25 08:12 ertemann

The commit cab1af03797ebbe5d9eaed6ea85d49cb4fc5b584 contains copies of a lot of dependencies. This is not needed and should not be done. Did you setup git-lfs? See also https://github.com/cosmos/cosmjs/blob/main/HACKING.md#checking-out-code. We need to ensure the code changes in here are separate from those things.

webmaster128 avatar Dec 16 '25 13:12 webmaster128

The last commit (the uncommitted dependency change) is not needed. See https://github.com/cosmos/cosmjs/issues/1922

webmaster128 avatar Dec 16 '25 13:12 webmaster128

The commit cab1af0 contains copies of a lot of dependencies. This is not needed and should not be done. Did you setup git-lfs? See also main/HACKING.md#checking-out-code. We need to ensure the code changes in here are separate from those things.

The commits here are simply the result of a yarn install, if that is not correct then id suggest you do it however you want it but I don't see what there is to fix for me.

I have reset the yarn cache to main, with that state i cannot locally build this change.

ertemann avatar Dec 16 '25 14:12 ertemann

Looks good overall, thank you. I will take care of linting and stuff to make CI happy tomorrow and then merge it

webmaster128 avatar Dec 16 '25 14:12 webmaster128

thanks for taking it over the line, hadnt worked with committing cache before and the issues it creates.

ertemann avatar Dec 18 '25 13:12 ertemann