From 3e85984334f362335adfce116410d31e623bdf61 Mon Sep 17 00:00:00 2001 From: Yorke Rhodes Date: Thu, 7 Nov 2024 15:28:13 -0500 Subject: [PATCH] Adjust whitelist matching --- typescript/sdk/src/core/HyperlaneCore.ts | 11 +++++++---- typescript/sdk/src/core/HyperlaneRelayer.ts | 16 +++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/typescript/sdk/src/core/HyperlaneCore.ts b/typescript/sdk/src/core/HyperlaneCore.ts index b5d6198ee6..a3f82e36d1 100644 --- a/typescript/sdk/src/core/HyperlaneCore.ts +++ b/typescript/sdk/src/core/HyperlaneCore.ts @@ -204,13 +204,16 @@ export class HyperlaneCore extends HyperlaneApp { mailbox.on( mailbox.filters.Dispatch(), (_sender, _destination, _recipient, message, event) => { - const parsed = HyperlaneCore.parseDispatchedMessage(message); - const destChain = this.getDestination(parsed); + const dispatched = HyperlaneCore.parseDispatchedMessage(message); + + // add human readable chain names + dispatched.parsed.originChain = this.getOrigin(dispatched); + dispatched.parsed.destinationChain = this.getDestination(dispatched); this.logger.info( - `Observed message ${parsed.id} on ${originChain} to ${destChain}`, + `Observed message ${dispatched.id} on ${originChain} to ${dispatched.parsed.destinationChain}`, ); - return handler(parsed, event); + return handler(dispatched, event); }, ); }); diff --git a/typescript/sdk/src/core/HyperlaneRelayer.ts b/typescript/sdk/src/core/HyperlaneRelayer.ts index ecf9fb05dc..0a1a451ebf 100644 --- a/typescript/sdk/src/core/HyperlaneRelayer.ts +++ b/typescript/sdk/src/core/HyperlaneRelayer.ts @@ -121,10 +121,6 @@ export class HyperlaneRelayer { whitelist, (_chain, addresses) => new Set(addresses), ); - for (const [chain, addresses] of Object.entries(this.whitelist)) { - const chainId = this.multiProvider.getChainId(chain); - this.whitelist[chainId] = addresses; - } } this.backlog = []; @@ -218,6 +214,12 @@ export class HyperlaneRelayer { message = HyperlaneCore.getDispatchedMessages(dispatchTx)[messageIndex], ): Promise { if (this.whitelist) { + // add human readable names for use in whitelist checks + message.parsed = { + originChain: this.core.getOrigin(message), + destinationChain: this.core.getDestination(message), + ...message.parsed, + }; assert( messageMatchesWhitelist(this.whitelist, message.parsed), `Message ${message.id} does not match whitelist`, @@ -319,11 +321,7 @@ export class HyperlaneRelayer { } protected whitelistChains() { - return this.whitelist - ? Object.keys(this.whitelist).filter( - (chain) => chain in this.core.contractsMap, - ) - : undefined; + return this.whitelist ? Object.keys(this.whitelist) : undefined; } start(): void {