Skip to content

Commit

Permalink
Add logs to relay logic
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes committed May 2, 2024
1 parent d5f140e commit ca1dd22
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions typescript/sdk/src/core/HyperlaneCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,21 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {

const metadata = await pollAsync(
async () => {
this.logger.debug({ message }, `Simulating recipient message handling`);
await recipient.callStatic.handle(
message.parsed.origin,
message.parsed.sender,
message.parsed.body,
);
this.logger.debug(
{ message, recipientIsm },
`Building recipient ISM ${recipientIsm} metadata`,
);
const metadata = await this.buildMetadata(message);
this.logger.debug(
{ message, metadata },
`Simulating recipient ISM ${recipientIsm} verification`,
);
const verified = await ism.callStatic.verify(metadata, message.message);
assert(verified, 'ISM verification failed');
return metadata;
Expand All @@ -155,6 +164,11 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {
12, // 12 attempts (1 minute total)
);

this.logger.info(
{ message, metadata },
`Relaying message ${message.id} to ${destinationChain}`,
);

return this.multiProvider.handleTx(
destinationChain,
mailbox.process(metadata, message.message),
Expand All @@ -166,8 +180,15 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {
const mailbox = this.getContracts(chain).mailbox;
mailbox.on<DispatchEvent>(
mailbox.filters.Dispatch(...filter),
async (_sender, _destination, _recipient, message) =>
this.relayMessage(HyperlaneCore.parseDispatchedMessage(message)),
async (_sender, _destination, _recipient, message) => {
this.logger.info(
{ chain, message },
`Observed message from ${chain}, attempting to relay`,
);
await this.relayMessage(
HyperlaneCore.parseDispatchedMessage(message),
);
},
);
}
}
Expand Down

0 comments on commit ca1dd22

Please sign in to comment.