Skip to content

Commit ac0249a

Browse files
authored
fix(infra): use agent-only overrides only for generating config (#7254)
1 parent 5a4e22d commit ac0249a

File tree

2 files changed

+67
-31
lines changed

2 files changed

+67
-31
lines changed

typescript/infra/config/environments/mainnet3/chains.ts

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ export const ethereumChainNames = supportedChainNames.filter(
1212
isEthereumProtocolChain,
1313
);
1414

15+
// Agent specific chain metadata overrides
16+
// Such as minGasPrice, minFeePerGas, minPriorityFeePerGas
17+
export const agentSpecificChainMetadataOverrides: ChainMap<
18+
Partial<ChainMetadata>
19+
> = {
20+
incentiv: {
21+
transactionOverrides: {
22+
minGasPrice: 1 * 10 ** 9, // 1 gwei
23+
minFeePerGas: 1 * 10 ** 9, // 1 gwei
24+
minPriorityFeePerGas: 1 * 10 ** 9, // 1 gwei
25+
},
26+
},
27+
ronin: {
28+
transactionOverrides: {
29+
minGasPrice: 20 * 10 ** 9, // 20 gwei
30+
minFeePerGas: 20 * 10 ** 9, // 20 gwei
31+
minPriorityFeePerGas: 20 * 10 ** 9, // 20 gwei
32+
},
33+
},
34+
ink: {
35+
transactionOverrides: {
36+
minGasPrice: 1, // 1 wei
37+
minFeePerGas: 1, // 1 wei
38+
minPriorityFeePerGas: 1, // 1 wei
39+
},
40+
},
41+
};
42+
1543
export const chainMetadataOverrides: ChainMap<Partial<ChainMetadata>> = {
1644
bsc: {
1745
transactionOverrides: {
@@ -50,27 +78,6 @@ export const chainMetadataOverrides: ChainMap<Partial<ChainMetadata>> = {
5078
gasPrice: 1 * 10 ** 6, // 0.001 gwei
5179
},
5280
},
53-
incentiv: {
54-
transactionOverrides: {
55-
minGasPrice: 1 * 10 ** 9, // 1 gwei
56-
minFeePerGas: 1 * 10 ** 9, // 1 gwei
57-
minPriorityFeePerGas: 1 * 10 ** 9, // 1 gwei
58-
},
59-
},
60-
ronin: {
61-
transactionOverrides: {
62-
minGasPrice: 20 * 10 ** 9, // 20 gwei
63-
minFeePerGas: 20 * 10 ** 9, // 20 gwei
64-
minPriorityFeePerGas: 20 * 10 ** 9, // 20 gwei
65-
},
66-
},
67-
ink: {
68-
transactionOverrides: {
69-
minGasPrice: 1, // 1 wei
70-
minFeePerGas: 1, // 1 wei
71-
minPriorityFeePerGas: 1, // 1 wei
72-
},
73-
},
7481
// Deploy-only overrides, set when deploying contracts
7582
// chilizmainnet: {
7683
// transactionOverrides: {

typescript/infra/scripts/agents/update-agent-config.ts

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ChainAddresses } from '@hyperlane-xyz/registry';
55
import {
66
AgentConfig,
77
ChainMap,
8+
ChainMetadata,
89
ChainTechnicalStack,
910
CoreFactories,
1011
HyperlaneContracts,
@@ -25,6 +26,7 @@ import {
2526
} from '@hyperlane-xyz/utils';
2627

2728
import { Contexts } from '../../config/contexts.js';
29+
import { agentSpecificChainMetadataOverrides } from '../../config/environments/mainnet3/chains.js';
2830
import mainnet3GasPrices from '../../config/environments/mainnet3/gasPrices.json' with { type: 'json' };
2931
import testnet4GasPrices from '../../config/environments/testnet4/gasPrices.json' with { type: 'json' };
3032
import {
@@ -69,20 +71,29 @@ export async function writeAgentConfig(
6971
// Get gas prices for Cosmos chains.
7072
// Instead of iterating through `addresses`, which only includes EVM chains,
7173
// iterate through the environment chain names.
74+
75+
const envConfig = getEnvironmentConfig(environment);
7276
const envAgentConfig = getAgentConfig(Contexts.Hyperlane, environment);
7377
const environmentChains = envAgentConfig.environmentChainNames;
78+
const registry =
79+
environment !== 'test' ? await envConfig.getRegistry() : undefined;
80+
81+
// Build additional config for:
82+
// - cosmos/cosmos native chains that require special gas price handling
83+
// - any chains that have agent-specific overrides
7484
const additionalConfig = Object.fromEntries(
7585
await Promise.all(
76-
environmentChains
77-
.filter(
78-
(chain) =>
79-
chainIsProtocol(chain, ProtocolType.Cosmos) ||
80-
chainIsProtocol(chain, ProtocolType.CosmosNative),
81-
)
82-
.map(async (chain) => {
86+
environmentChains.map(async (chain) => {
87+
let config: Partial<ChainMetadata> = {};
88+
89+
// Get Cosmos gas price if applicable
90+
if (
91+
chainIsProtocol(chain, ProtocolType.Cosmos) ||
92+
chainIsProtocol(chain, ProtocolType.CosmosNative)
93+
) {
8394
try {
8495
const gasPrice = await getCosmosChainGasPrice(chain, multiProvider);
85-
return [chain, { gasPrice }];
96+
config.gasPrice = gasPrice;
8697
} catch (error) {
8798
rootLogger.error(`Error getting gas price for ${chain}:`, error);
8899
const { denom } = await multiProvider.getNativeToken(chain);
@@ -93,9 +104,27 @@ export async function writeAgentConfig(
93104
.amount
94105
: testnet4GasPrices[chain as keyof typeof testnet4GasPrices]
95106
.amount;
96-
return [chain, { gasPrice: { denom, amount } }];
107+
config.gasPrice = { denom, amount };
97108
}
98-
}),
109+
}
110+
111+
// Merge agent-specific overrides with general overrides
112+
// TODO: support testnet4 overrides (if we ever need to)
113+
const agentSpecificOverrides =
114+
agentSpecificChainMetadataOverrides[chain];
115+
if (agentSpecificOverrides && registry) {
116+
const chainMetadata = await registry.getChainMetadata(chain);
117+
assert(chainMetadata, `Chain metadata not found for chain ${chain}`);
118+
// Only care about blocks and transactionOverrides from the agent-specific overrides
119+
const { blocks, transactionOverrides } = objMerge(
120+
chainMetadata,
121+
agentSpecificOverrides,
122+
);
123+
config = objMerge(config, { blocks, transactionOverrides });
124+
}
125+
126+
return [chain, config];
127+
}),
99128
),
100129
);
101130

0 commit comments

Comments
 (0)