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:remove agentStartBlock and use mailbox.deployedBlock() instead #3005

Merged
merged 3 commits into from
Nov 30, 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
7 changes: 7 additions & 0 deletions .changeset/tall-shirts-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hyperlane-xyz/infra': patch
'@hyperlane-xyz/cli': patch
'@hyperlane-xyz/sdk': patch
---

Removing agentStartBlocks and using mailbox.deployedBlock() instead
29 changes: 8 additions & 21 deletions typescript/cli/src/deploy/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
DeployedIsm,
GasOracleContractType,
HookType,
HyperlaneAddresses,
HyperlaneAddressesMap,
HyperlaneContractsMap,
HyperlaneCore,
HyperlaneCoreDeployer,
HyperlaneDeploymentArtifacts,
HyperlaneIsmFactory,
Expand All @@ -21,7 +21,6 @@ import {
MultiProvider,
MultisigConfig,
RoutingIsmConfig,
agentStartBlocks,
buildAgentConfig,
buildAggregationIsmConfigs,
defaultMultisigConfigs,
Expand Down Expand Up @@ -472,33 +471,21 @@ async function writeAgentConfig(
chains: ChainName[],
multiProvider: MultiProvider,
) {
// TODO: share with rust/config/*
const startBlocks: ChainMap<number> = { ...agentStartBlocks };

const startBlocks: ChainMap<number> = {};
for (const chain of chains) {
if (startBlocks[chain]) continue;
startBlocks[chain] = await multiProvider
.getProvider(chain)
.getBlockNumber();
const core = HyperlaneCore.fromAddressesMap(artifacts, multiProvider);
const mailbox = core.getContracts(chain).mailbox;
startBlocks[chain] = (await mailbox.deployedBlock()).toNumber();
}

const mergedAddressesMap: HyperlaneAddressesMap<any> = objMerge(
const mergedAddressesMap = objMerge(
sdkContractAddressesMap,
artifacts,
);
const filteredAddressesMap = objFilter(
mergedAddressesMap,
(chain, v): v is HyperlaneAddresses<any> =>
chains.includes(chain) &&
!!v.mailbox &&
!!v.interchainGasPaymaster &&
!!v.validatorAnnounce,
) as ChainMap<HyperlaneDeploymentArtifacts>;

const agentConfig = buildAgentConfig(
Object.keys(filteredAddressesMap),
Object.keys(mergedAddressesMap),
multiProvider,
filteredAddressesMap,
mergedAddressesMap,
startBlocks,
);
writeJson(filePath, agentConfig);
Expand Down
20 changes: 13 additions & 7 deletions typescript/infra/src/deployment/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ChainMap,
ChainName,
HyperlaneAddresses,
HyperlaneCore,
HyperlaneDeployer,
HyperlaneDeploymentArtifacts,
MultiProvider,
Expand Down Expand Up @@ -126,14 +127,19 @@ export async function writeAgentConfig(
} catch (e) {
console.error('Failed to load cached addresses');
}
// Write agent config indexing from the deployed or latest block numbers.
// For non-net-new deployments, these changes will need to be
// reverted manually.
aroralanuk marked this conversation as resolved.
Show resolved Hide resolved
const startBlocks = await promiseObjAll(
objMap(addresses, (chain, _) =>
multiProvider.getProvider(chain).getBlockNumber(),
),

const core = HyperlaneCore.fromAddressesMap(addresses, multiProvider);
// Write agent config indexing from the deployed Mailbox which stores the block number at deployment
const startBlocksBigNumber = await promiseObjAll(
objMap(addresses, (chain, _) => {
const mailbox = core.getContracts(chain).mailbox;
return mailbox.deployedBlock();
}),
);
const startBlocks = objMap(startBlocksBigNumber, (_, blockNumber) =>
blockNumber.toNumber(),
);

const agentConfig = buildAgentConfig(
multiProvider.getKnownChainNames(),
multiProvider,
Expand Down
26 changes: 0 additions & 26 deletions typescript/sdk/src/consts/agentStartBlocks.ts

This file was deleted.

1 change: 0 additions & 1 deletion typescript/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export {
BaseSealevelAdapter,
MultiProtocolApp,
} from './app/MultiProtocolApp';
export { agentStartBlocks } from './consts/agentStartBlocks';
export {
chainIdToMetadata,
chainMetadata,
Expand Down
Loading