From efc2410ed6fc9b3ad8118820679b40c91f01fc5a Mon Sep 17 00:00:00 2001 From: Nam Chu Hoai Date: Thu, 4 Jan 2024 20:12:18 +0100 Subject: [PATCH] Fix IGP bytecode checking (#3128) ### Description Can't really explain it, but we had some misnamed bytecode constants that I had to fix up. Also checked the bytecodes in the IGP checker --- typescript/sdk/src/consts/bytecode.ts | 8 +++--- .../sdk/src/core/HyperlaneCoreChecker.ts | 2 +- typescript/sdk/src/gas/HyperlaneIgpChecker.ts | 28 +++++++------------ 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/typescript/sdk/src/consts/bytecode.ts b/typescript/sdk/src/consts/bytecode.ts index 86a046d0d..c9d5f3e95 100644 --- a/typescript/sdk/src/consts/bytecode.ts +++ b/typescript/sdk/src/consts/bytecode.ts @@ -1,11 +1,11 @@ export enum BytecodeHash { V3_MAILBOX_BYTECODE_HASH = '0x6e853444a6e38bb1d7ac7608b92a70cee83153c891c70ed882b2432134bb23a0', // without optimizer OPT_V3_MAILBOX_BYTECODE_HASH = '0x7cc944e10fa5597f10265bdac4a808e705711451ee7f117ebf9a97193b796136', // with optimizer - TRANSPARENT_PROXY_BYTECODE_HASH = '0x320bda003dfa31828115be5c01b9f3e7eecaf2532afdb89d2b53559f2e7ab86d', - PROXY_ADMIN_BYTECODE_HASH = '0x13855ae57da3aadecb9259cecece16e1f434b8850fe95531f422e4e262f3f200', // without optimizer - OPT_PROXY_ADMIN_BYTECODE_HASH = '0x30aa3b1506a94c0fe2749af099851623685d9a24a65e2e8b3746c272499979d1', // with optimizer + TRANSPARENT_PROXY_BYTECODE_HASH = '0x320bda003dfa31828115be5c01b9f3e7eecaf2532afdb89d2b53559f2e7ab86d', // without optimizer + OPT_TRANSPARENT_PROXY_BYTECODE_HASH = '0x30aa3b1506a94c0fe2749af099851623685d9a24a65e2e8b3746c272499979d1', // with optimizer + PROXY_ADMIN_BYTECODE_HASH = '0x13855ae57da3aadecb9259cecece16e1f434b8850fe95531f422e4e262f3f200', V2_PROXY_ADMIN_BYTECODE_HASH = '0x7c378e9d49408861ca754fe684b9f7d1ea525bddf095ee0463902df701453ba0', // reused from v2 - INTERCHAIN_GAS_PAYMASTER_BYTECODE_HASH = '0xe995bcd732f4861606036357edb2a4d4c3e9b8d7e599fe548790ac1cf26888f8', + INTERCHAIN_GAS_PAYMASTER_BYTECODE_HASH = '0x69325ab0957fcca37e2eac622af6186380f4cddb279183a97c37511459d40f18', OWNER_INITIALIZABLE_INTERCHAIN_GAS_PAYMASTER_BYTECODE_HASH = '0xd2c5b00ac2d058117491d581d63c3c4fcf6aeb2667c6cc0c7caed359c9eebea1', OVERHEAD_IGP_BYTECODE_HASH = '0x3cfed1f24f1e9b28a76d5a8c61696a04f7bc474404b823a2fcc210ea52346252', } diff --git a/typescript/sdk/src/core/HyperlaneCoreChecker.ts b/typescript/sdk/src/core/HyperlaneCoreChecker.ts index 580f732eb..8dc0545a7 100644 --- a/typescript/sdk/src/core/HyperlaneCoreChecker.ts +++ b/typescript/sdk/src/core/HyperlaneCoreChecker.ts @@ -156,7 +156,7 @@ export class HyperlaneCoreChecker extends HyperlaneAppChecker< contracts.mailbox.address, [ BytecodeHash.TRANSPARENT_PROXY_BYTECODE_HASH, - BytecodeHash.OPT_PROXY_ADMIN_BYTECODE_HASH, + BytecodeHash.OPT_TRANSPARENT_PROXY_BYTECODE_HASH, ], ); await this.checkBytecode( diff --git a/typescript/sdk/src/gas/HyperlaneIgpChecker.ts b/typescript/sdk/src/gas/HyperlaneIgpChecker.ts index 2c9467f04..a3a15e172 100644 --- a/typescript/sdk/src/gas/HyperlaneIgpChecker.ts +++ b/typescript/sdk/src/gas/HyperlaneIgpChecker.ts @@ -40,12 +40,6 @@ export class HyperlaneIgpChecker extends HyperlaneAppChecker< async checkBytecodes(chain: ChainName): Promise { const contracts = this.app.getContracts(chain); - await this.checkBytecode( - chain, - 'InterchainGasPaymaster proxy', - contracts.interchainGasPaymaster.address, - [BytecodeHash.TRANSPARENT_PROXY_BYTECODE_HASH], - ); const implementation = await proxyImplementation( this.multiProvider.getProvider(chain), contracts.interchainGasPaymaster.address, @@ -55,24 +49,22 @@ export class HyperlaneIgpChecker extends HyperlaneAppChecker< 'InterchainGasPaymaster implementation', implementation, [BytecodeHash.INTERCHAIN_GAS_PAYMASTER_BYTECODE_HASH], + (bytecode) => + bytecode // We persist the block number in the bytecode now too, so we have to strip it + .replaceAll( + /(00000000000000000000000000000000000000000000000000000000[a-f0-9]{0,22})81565/g, + (match, _offset) => (match.length % 2 === 0 ? '' : '0'), + ), ); await this.checkBytecode( chain, 'InterchainGasPaymaster proxy', contracts.interchainGasPaymaster.address, - [BytecodeHash.TRANSPARENT_PROXY_BYTECODE_HASH], - (bytecode) => - bytecode - // We persist the block number in the bytecode now too, so we have to strip it - .replaceAll( - /(00000000000000000000000000000000000000000000000000000000[a-f0-9]{0,22})81565/g, - (match, _offset) => (match.length % 2 === 0 ? '' : '0'), - ) - .replaceAll( - /(0000000000000000000000000000000000000000000000000000[a-f0-9]{0,22})6118123373/g, - (match, _offset) => (match.length % 2 === 0 ? '' : '0'), - ), + [ + BytecodeHash.TRANSPARENT_PROXY_BYTECODE_HASH, + BytecodeHash.OPT_TRANSPARENT_PROXY_BYTECODE_HASH, + ], ); }