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

🐛 Fix inconsistent gas multiplier value between signAndBroadcast and signAndBroadcastSync methods #1584

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to

## [Unreleased]

### Changed

- @cosmjs/stargate, @cosmjs/cosmwasm-stargate: Synchronize the default gas
multiplier value between the `signAndBroadcast` and `signAndBroadcastSync`
methods so that it is equal to 1.4 everywhere. ([#1584])

## [0.32.3] - 2024-03-08

### Changed
Expand Down
9 changes: 5 additions & 4 deletions packages/cosmwasm-stargate/src/signingcosmwasmclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ export class SigningCosmWasmClient extends CosmWasmClient {
private readonly signer: OfflineSigner;
private readonly aminoTypes: AminoTypes;
private readonly gasPrice: GasPrice | undefined;
// Starting with Cosmos SDK 0.47, we see many cases in which 1.3 is not enough anymore
// E.g. https://github.com/cosmos/cosmos-sdk/issues/16020
private readonly defaultGasMultiplier = 1.4;

/**
* Creates an instance by connecting to the given CometBFT RPC endpoint.
Expand Down Expand Up @@ -614,9 +617,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
if (fee == "auto" || typeof fee === "number") {
assertDefined(this.gasPrice, "Gas price must be set in the client options when auto gas is used.");
const gasEstimation = await this.simulate(signerAddress, messages, memo);
// Starting with Cosmos SDK 0.47, we see many cases in which 1.3 is not enough anymore
// E.g. https://github.com/cosmos/cosmos-sdk/issues/16020
const multiplier = typeof fee === "number" ? fee : 1.4;
const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier;
usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
} else {
usedFee = fee;
Expand Down Expand Up @@ -652,7 +653,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
if (fee == "auto" || typeof fee === "number") {
assertDefined(this.gasPrice, "Gas price must be set in the client options when auto gas is used.");
const gasEstimation = await this.simulate(signerAddress, messages, memo);
const multiplier = typeof fee === "number" ? fee : 1.3;
const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier;
usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
} else {
usedFee = fee;
Expand Down
9 changes: 5 additions & 4 deletions packages/stargate/src/signingstargateclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ export class SigningStargateClient extends StargateClient {
private readonly signer: OfflineSigner;
private readonly aminoTypes: AminoTypes;
private readonly gasPrice: GasPrice | undefined;
// Starting with Cosmos SDK 0.47, we see many cases in which 1.3 is not enough anymore
// E.g. https://github.com/cosmos/cosmos-sdk/issues/16020
private readonly defaultGasMultiplier = 1.4;

/**
* Creates an instance by connecting to the given CometBFT RPC endpoint.
Expand Down Expand Up @@ -308,9 +311,7 @@ export class SigningStargateClient extends StargateClient {
if (fee == "auto" || typeof fee === "number") {
assertDefined(this.gasPrice, "Gas price must be set in the client options when auto gas is used.");
const gasEstimation = await this.simulate(signerAddress, messages, memo);
// Starting with Cosmos SDK 0.47, we see many cases in which 1.3 is not enough anymore
// E.g. https://github.com/cosmos/cosmos-sdk/issues/16020
const multiplier = typeof fee === "number" ? fee : 1.4;
const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier;
usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
} else {
usedFee = fee;
Expand All @@ -337,7 +338,7 @@ export class SigningStargateClient extends StargateClient {
if (fee == "auto" || typeof fee === "number") {
assertDefined(this.gasPrice, "Gas price must be set in the client options when auto gas is used.");
const gasEstimation = await this.simulate(signerAddress, messages, memo);
const multiplier = typeof fee === "number" ? fee : 1.3;
const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier;
usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
} else {
usedFee = fee;
Expand Down