feat: Add pzEth Config Generator (#4624)
### Description Adds pzEth Config Generator files to deploy to ethereum and zircuit - new lockbox and xerc20 addresses - supplied via this message: https://t.me/c/2192542084/925 - Reusing ezEth validators config for both chains - Reusing Safe addresses. - confirmed via this message: https://t.me/c/2192542084/948 ### Drive-by changes Rename to differentiate between ezEth and pzEth ### Related issues #4623 ### Backward compatibility Yes ### Testing Manualpull/3899/merge
parent
6b57467267
commit
dc9adf3b55
@ -0,0 +1,104 @@ |
||||
import { |
||||
ChainMap, |
||||
IsmType, |
||||
TokenRouterConfig, |
||||
TokenType, |
||||
buildAggregationIsmConfigs, |
||||
} from '@hyperlane-xyz/sdk'; |
||||
import { symmetricDifference } from '@hyperlane-xyz/utils'; |
||||
|
||||
import { getRegistry as getMainnet3Registry } from '../../chains.js'; |
||||
|
||||
import { ezEthSafes, ezEthValidators } from './getRenzoEZETHWarpConfig.js'; |
||||
|
||||
const lockbox = '0xbC5511354C4A9a50DE928F56DB01DD327c4e56d5'; |
||||
const xERC20 = '0x9cb41CD74D01ae4b4f640EC40f7A60cA1bCF83E7'; |
||||
const lockboxChain = 'ethereum'; |
||||
// over the default 100k to account for xerc20 gas + ISM overhead over the default ISM https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/49f41d9759fd515bfd89e6e22e799c41b27b4119/typescript/sdk/src/router/GasRouterDeployer.ts#L14
|
||||
const warpRouteOverheadGas = 200_000; |
||||
|
||||
const chainsToDeploy = ['ethereum', 'zircuit']; |
||||
|
||||
const pzEthValidators = { |
||||
ethereum: ezEthValidators.ethereum, |
||||
zircuit: ezEthValidators.zircuit, |
||||
}; |
||||
|
||||
const pzEthSafes: Record<string, string> = { |
||||
ethereum: ezEthSafes.ethereum, |
||||
zircuit: ezEthSafes.zircuit, |
||||
}; |
||||
|
||||
export const getRenzoPZETHWarpConfig = async (): Promise< |
||||
ChainMap<TokenRouterConfig> |
||||
> => { |
||||
const registry = await getMainnet3Registry(); |
||||
|
||||
const validatorDiff = symmetricDifference( |
||||
new Set(chainsToDeploy), |
||||
new Set(Object.keys(pzEthValidators)), |
||||
); |
||||
const safeDiff = symmetricDifference( |
||||
new Set(chainsToDeploy), |
||||
new Set(Object.keys(pzEthSafes)), |
||||
); |
||||
if (validatorDiff.size > 0) { |
||||
throw new Error( |
||||
`chainsToDeploy !== validatorConfig, diff is ${Array.from( |
||||
validatorDiff, |
||||
).join(', ')}`,
|
||||
); |
||||
} |
||||
if (safeDiff.size > 0) { |
||||
throw new Error( |
||||
`chainsToDeploy !== safeDiff, diff is ${Array.from(safeDiff).join(', ')}`, |
||||
); |
||||
} |
||||
|
||||
const tokenConfig = Object.fromEntries<TokenRouterConfig>( |
||||
await Promise.all( |
||||
chainsToDeploy.map( |
||||
async (chain): Promise<[string, TokenRouterConfig]> => { |
||||
const ret: [string, TokenRouterConfig] = [ |
||||
chain, |
||||
{ |
||||
isNft: false, |
||||
type: |
||||
chain === lockboxChain |
||||
? TokenType.XERC20Lockbox |
||||
: TokenType.XERC20, |
||||
token: chain === lockboxChain ? lockbox : xERC20, |
||||
owner: pzEthSafes[chain], |
||||
gas: warpRouteOverheadGas, |
||||
mailbox: (await registry.getChainAddresses(chain))!.mailbox, |
||||
interchainSecurityModule: { |
||||
type: IsmType.AGGREGATION, |
||||
threshold: 2, |
||||
modules: [ |
||||
{ |
||||
type: IsmType.ROUTING, |
||||
owner: pzEthSafes[chain], |
||||
domains: buildAggregationIsmConfigs( |
||||
chain, |
||||
chainsToDeploy, |
||||
pzEthValidators, |
||||
), |
||||
}, |
||||
{ |
||||
type: IsmType.FALLBACK_ROUTING, |
||||
domains: {}, |
||||
owner: pzEthSafes[chain], |
||||
}, |
||||
], |
||||
}, |
||||
}, |
||||
]; |
||||
|
||||
return ret; |
||||
}, |
||||
), |
||||
), |
||||
); |
||||
|
||||
return tokenConfig; |
||||
}; |
@ -0,0 +1,23 @@ |
||||
import { writeFileSync } from 'fs'; |
||||
import { stringify as yamlStringify } from 'yaml'; |
||||
|
||||
import { WarpRouteDeployConfigSchema } from '@hyperlane-xyz/sdk'; |
||||
|
||||
import { getRenzoPZETHWarpConfig } from '../config/environments/mainnet3/warp/configGetters/getRenzoPZETHWarpConfig.js'; |
||||
|
||||
async function main() { |
||||
const tokenConfig = await getRenzoPZETHWarpConfig(); |
||||
const parsed = WarpRouteDeployConfigSchema.safeParse(tokenConfig); |
||||
|
||||
if (!parsed.success) { |
||||
console.dir(parsed.error.format(), { depth: null }); |
||||
return; |
||||
} |
||||
|
||||
writeFileSync( |
||||
'renzo-pzeth-warp-route-config.yaml', |
||||
yamlStringify(parsed.data, null, 2), |
||||
); |
||||
} |
||||
|
||||
main().catch(console.error).then(console.log); |
Loading…
Reference in new issue