From 4d1f2e1a0ee17348448c2e2ec2918de817999839 Mon Sep 17 00:00:00 2001 From: AlexanderFSP Date: Mon, 29 Apr 2024 17:28:59 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20inconsistent=20gas=20m?= =?UTF-8?q?ultiplier=20value=20between=20`signAndBroadcast`=20and=20`signA?= =?UTF-8?q?ndBroadcastSync`=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cosmwasm-stargate/src/signingcosmwasmclient.ts | 9 +++++---- packages/stargate/src/signingstargateclient.ts | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index 6d1b9fd2d6..545eb01def 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -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 gasMultiplier = 1.4; /** * Creates an instance by connecting to the given CometBFT RPC endpoint. @@ -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.gasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; @@ -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.gasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index 13e4461f16..840d3148f9 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -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 gasMultiplier = 1.4; /** * Creates an instance by connecting to the given CometBFT RPC endpoint. @@ -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.gasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; @@ -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.gasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; From 26258f8d529fa59541a3408e2a65b6a863145719 Mon Sep 17 00:00:00 2001 From: AlexanderFSP Date: Tue, 30 Apr 2024 10:13:58 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Update=20changelog=20&=20ren?= =?UTF-8?q?ame=20`gasMultiplier`=20to=20`defaultGasMultiplier`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ packages/cosmwasm-stargate/src/signingcosmwasmclient.ts | 6 +++--- packages/stargate/src/signingstargateclient.ts | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index beb3b36116..ef76166f6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index 545eb01def..bce739bbf2 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -204,7 +204,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { 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 gasMultiplier = 1.4; + private readonly defaultGasMultiplier = 1.4; /** * Creates an instance by connecting to the given CometBFT RPC endpoint. @@ -617,7 +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); - const multiplier = typeof fee === "number" ? fee : this.gasMultiplier; + const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; @@ -653,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 : this.gasMultiplier; + const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index 840d3148f9..bb9e9715c2 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -112,7 +112,7 @@ export class SigningStargateClient extends StargateClient { 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 gasMultiplier = 1.4; + private readonly defaultGasMultiplier = 1.4; /** * Creates an instance by connecting to the given CometBFT RPC endpoint. @@ -311,7 +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); - const multiplier = typeof fee === "number" ? fee : this.gasMultiplier; + const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee; @@ -338,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 : this.gasMultiplier; + const multiplier = typeof fee === "number" ? fee : this.defaultGasMultiplier; usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice); } else { usedFee = fee;