Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
Closed
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
5 changes: 5 additions & 0 deletions .changeset/three-roses-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@confio/relayer': minor
---

Added the ability to specify custom gas limits for each chain
22 changes: 22 additions & 0 deletions spec/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ chains:
- prefix: wasm
# this determines the gas payments we make (and defines the fee token)
- gas_price: 0.1umayo
# this defines the gas limits we are going to use
- gas_limits:
# max amount of gas to be used when performing client init transactions
- init_client: 150000
# # max amount of gas to be used when performing client update transactions
- update_client: 600000
# max amount of gas to be used when performing connection init transactions
- init_connection: 150000
# max amount of gas to be used when performing connection handshakes transactions
- connection_handshake: 300000
# max amount of gas to be used when performing channel init transactions
- init_channel: 150000
# max amount of gas to be used when performing channel handshakes transactions
- channel_handshake: 300000
# max amount of gas to be used when receiving packets
- receive_packet: 300000
# max amount of gas to be used when receiving acknowledgments
- ack_packet: 300000
# max amount of gas to be used when receiving timeout packets
- timeout_packet: 300000
# max amount of gas to be used when performing transfer transactions
- transfer: 180000
# the path we use to derive the private key from the mnemonic
- hd_path: 44'/108'/0'/1'
# if you include an optional faucet, it will load the relayer with tokens in `ibc-setup init`
Expand Down
14 changes: 14 additions & 0 deletions src/binary/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import { GasPrice } from '@cosmjs/stargate';

export type GasLimits = {
init_client?: number;
update_client?: number;
init_connection?: number;
connection_handshake?: number;
init_channel?: number;
channel_handshake?: number;
receive_packet?: number;
ack_packet?: number;
timeout_packet?: number;
transfer?: number;
};

export type Chain = {
chain_id: string;
prefix: string;
gas_price: string;
gas_limits?: GasLimits;
faucet?: string;
hd_path?: string;
ics20_port?: string;
Expand Down
18 changes: 18 additions & 0 deletions src/binary/utils/load-and-validate-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ export function loadAndValidateRegistry(filepath: string): Registry {
chain_id: { type: 'string' },
prefix: { type: 'string' },
gas_price: { type: 'string' },
gas_limits: {
type: 'object',
required: [],
additionalProperties: false,
properties: {
init_client: { type: 'number', nullable: true },
update_client: { type: 'number', nullable: true },
init_connection: { type: 'number', nullable: true },
connection_handshake: { type: 'number', nullable: true },
init_channel: { type: 'number', nullable: true },
channel_handshake: { type: 'number', nullable: true },
receive_packet: { type: 'number', nullable: true },
ack_packet: { type: 'number', nullable: true },
timeout_packet: { type: 'number', nullable: true },
transfer: { type: 'number', nullable: true },
},
nullable: true,
},
faucet: { type: 'string', nullable: true },
hd_path: { type: 'string', nullable: true },
ics20_port: { type: 'string', nullable: true },
Expand Down
12 changes: 12 additions & 0 deletions src/binary/utils/signing-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ export async function signingClient(
const options: IbcClientOptions = {
prefix: chain.prefix,
gasPrice: GasPrice.fromString(chain.gas_price),
gasLimits: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Can you add a test that this works?

Like setting these very low in a test config, and asserting that running a command leads to an error. This would ensure they are actually used.

initClient: chain.gas_limits?.init_client,
updateClient: chain.gas_limits?.update_client,
initConnection: chain.gas_limits?.init_connection,
connectionHandshake: chain.gas_limits?.connection_handshake,
initChannel: chain.gas_limits?.init_channel,
channelHandshake: chain.gas_limits?.channel_handshake,
receivePacket: chain.gas_limits?.receive_packet,
ackPacket: chain.gas_limits?.ack_packet,
timeoutPacket: chain.gas_limits?.ack_packet,
transfer: chain.gas_limits?.transfer,
},
logger,
...extras,
};
Expand Down