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

Update gas multiplier to 1.4 and CosmWasm upload to 1.1 #1469

Merged
merged 2 commits into from
Aug 21, 2023
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ and this project adheres to
- @cosmjs/tendermint-rpc: Add missing `earliest_*` fields to `SyncInfo` record
returned from the `/status` RPC endpoint ([#1448]).

### Changed

- @cosmjs/stargate, @cosmjs/cosmwasm-stargate: Change default multiplier for gas
simulation from 1.3 to 1.4 to avoid out of case cases starting with Cosmos SDK
0.47.
- @cosmjs/cosmwasm-stargate: Reduce default gas multiplier for
`SigningCosmWasmClient.upload` to 1.1. ([#1360])

[#1360]: https://github.com/cosmos/cosmjs/issues/1360

## [0.31.0] - 2023-06-22

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/examples/simulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet
},
};
const memo = "With simulate";
const result = await client.signAndBroadcast(account.address, [sendMsg], 1.4, memo);
const result = await client.signAndBroadcast(account.address, [sendMsg], 1.55, memo);
assertIsDeliverTxSuccess(result);
console.log("Successfully broadcasted:", result);
}
Expand Down
10 changes: 8 additions & 2 deletions packages/cosmwasm-stargate/src/signingcosmwasmclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ export class SigningCosmWasmClient extends CosmWasmClient {
}),
};

const result = await this.signAndBroadcast(senderAddress, [storeCodeMsg], fee, memo);
// When uploading a contract, the simulation is only 1-2% away from the actual gas usage.
// So we have a smaller default gas multiplier than signAndBroadcast.
const usedFee = fee == "auto" ? 1.1 : fee;

const result = await this.signAndBroadcast(senderAddress, [storeCodeMsg], usedFee, memo);
if (isDeliverTxFailure(result)) {
throw new Error(createDeliverTxResponseErrorMessage(result));
}
Expand Down Expand Up @@ -604,7 +608,9 @@ 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;
// 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;
usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
} else {
usedFee = fee;
Expand Down
4 changes: 3 additions & 1 deletion packages/stargate/src/signingstargateclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ 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;
// 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;
usedFee = calculateFee(Math.round(gasEstimation * multiplier), this.gasPrice);
} else {
usedFee = fee;
Expand Down