add dynamic gasfee pricing as a signing client option - Feemarket/Osmosis#1911
add dynamic gasfee pricing as a signing client option - Feemarket/Osmosis#1911ertemann wants to merge 10 commits intocosmos:mainfrom
Conversation
| @@ -0,0 +1,278 @@ | |||
| #!/usr/bin/env node | |||
There was a problem hiding this comment.
Just a complete integration test to validate the PR, can be removed once merged
There was a problem hiding this comment.
No idea to be honest. We don't have example scripts in here usually. For now it can just be there
45ed0de to
713f6bb
Compare
webmaster128
left a comment
There was a problem hiding this comment.
Nice stuff. Some first thoughts here
| const product = (BigInt(normalizedValue.atomics) * BigInt(multiplierDecimal.atomics)) / factor; | ||
|
|
||
| return Decimal.fromAtomics(product.toString(), fractionalDigits); | ||
| } |
There was a problem hiding this comment.
This implementation might be correct. But as we do not need decimal math here we can also use float math more or less like this:
const x = value.toFloatApproximation() * multiplier; // the value we want
// now convert x to DecimalNow exactly as the Decimal API is limited but I think you get the idea
There was a problem hiding this comment.
do you prefer float math? current impl works and is precise and testable so kept it for now.
There was a problem hiding this comment.
Yeah that's fine. The reason I brought it up is you have a float -> Decimal conversion in here which is not necessarily safe:
const multiplierDecimal = Decimal.fromUserInput(multiplier.toString(), fractionalDigits);
As there are many number string representatations which are not supported by the Decimal constructor. E.g.
> a = 1/10**15
1e-15
> typeof a
'number'
> a.toString()
'1e-15'
There was a problem hiding this comment.
I think using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed gives us better strings in most cases and reduces the likelihood of errors here.
|
Thanks for the comments @webmaster128 will resolve remaining issues tomorrow, didnt have time this week yet. |
|
changes made, ready for merge. |
|
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 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. |
|
The last commit (the uncommitted dependency change) is not needed. See #1922 |
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. |
|
Looks good overall, thank you. I will take care of linting and stuff to make CI happy tomorrow and then merge it |
This is the diff from #1911
webmaster128
left a comment
There was a problem hiding this comment.
Alsright cool, thanks.
I habe a follow-up PR in #1926 including your work and a bunch of improvements. I could not use the existing PRs because of all of the cache related changed. I tried but rebasing was impossible. This happens when git-lfs is not set up during the work. Then the cache files change from pointers to full git blobs and this creates a bit mess. Super annoying, I know. But using the .diff it was no problem.
| } | ||
| if ( | ||
| !(gasPriceConfig instanceof GasPrice) && | ||
| !("amount" in gasPriceConfig && "denom" in gasPriceConfig) |
There was a problem hiding this comment.
An object with {amount: "1234", denom: "blub"} was never a valid input. Maybe it worked though. So I'll just change this to an assertion assert(gasPriceConfig instanceof GasPrice).
| const product = (BigInt(normalizedValue.atomics) * BigInt(multiplierDecimal.atomics)) / factor; | ||
|
|
||
| return Decimal.fromAtomics(product.toString(), fractionalDigits); | ||
| } |
There was a problem hiding this comment.
I think using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed gives us better strings in most cases and reduces the likelihood of errors here.
| @@ -0,0 +1,278 @@ | |||
| #!/usr/bin/env node | |||
There was a problem hiding this comment.
No idea to be honest. We don't have example scripts in here usually. For now it can just be there
This is the diff from #1911
|
thanks for taking it over the line, hadnt worked with committing cache before and the issues it creates. |
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
Usage
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.