From 715bd205ddb67add3dc5ad80e8574f07813202be Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Mon, 24 Feb 2025 11:41:33 -0600 Subject: [PATCH 1/3] Updates related to the fact we'll have an autorelayer on mainnet --- components/AutorelayCallout.tsx | 27 +++++++++++++++++++ pages/stack/interop/message-passing.mdx | 7 +++-- pages/stack/interop/superchain-weth.mdx | 8 +++--- .../interop/tutorials/message-passing.mdx | 3 +++ 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 components/AutorelayCallout.tsx diff --git a/components/AutorelayCallout.tsx b/components/AutorelayCallout.tsx new file mode 100644 index 000000000..4320a19f7 --- /dev/null +++ b/components/AutorelayCallout.tsx @@ -0,0 +1,27 @@ +/** + * The AutorelayCallout function renders a callout component with a message about autorelays + * + * @param {Props} props - Expected to be empty, ignored. + * @returns {ReactElement} The AutorelayCallout component, a callout that explains about autorelays. + */ +import type { ReactElement } from 'react'; +import { useState } from 'react'; + +interface Props { + context?: string; +} +export function AutorelayCallout({ context }: Props): ReactElement { + return ( +
+
+
+ Normally we expect Superchain blockchains to run an autorelayer and relay your messages automatically. + However, for performance reasons or reliability, you might decide to subnmit the executing message manually. + This section shows how to do that. +
+
+
+ ); +} \ No newline at end of file diff --git a/pages/stack/interop/message-passing.mdx b/pages/stack/interop/message-passing.mdx index e4e247dfc..f6eab30bb 100644 --- a/pages/stack/interop/message-passing.mdx +++ b/pages/stack/interop/message-passing.mdx @@ -69,7 +69,7 @@ sequenceDiagram ```mermaid sequenceDiagram - participant app as Application + participant app as Autorelayer box rgba(0,0,0,0.1) Source Chain participant log as Event Log end @@ -88,7 +88,7 @@ sequenceDiagram 1. Before the executing message is processed, the log event of the initiating message has to get to `op-supervisor` on the destination chain. -2. The application (or a contract calling on the application's behalf) calls [`L2ToL2CrossDomainMessenger.SendMessage.relayMessage`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol#L156-L216). +2. The autorelayer, the application, or a contract calling on the application's behalf calls [`L2ToL2CrossDomainMessenger.SendMessage.relayMessage`](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/L2ToL2CrossDomainMessenger.sol#L156-L216). This call includes the message that was sent (`_sendMessage`), as well as the [fields required to find that message (`_id`)](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/interfaces/L2/ICrossL2Inbox.sol#L4-L10). 3. The `L2ToL2CrossDomainMessenger` uses `CrossL2Inbox` to verify the message was sent from the source. @@ -107,10 +107,9 @@ sequenceDiagram ## Next steps * Build a [revolutionary app](/app-developers/get-started) that uses multiple blockchains within the Superchain +* Actually [pass messages between blockchains](/stack/interop/tutorials/message-passing). * Deploy a [SuperchainERC20](/stack/interop/tutorials/deploy-superchain-erc20) to the Superchain * Practice how to use [Superchain interop message passing](/stack/interop/message-passing) * Read how [messages get from one blockchain to another (`CrossL2Inbox`)](explainer#how-messages-get-from-one-chain-to-the-other). * Try [Supersim](tools/supersim) for testing cross-chain messages locally. * Learn about [manually relaying messages](/stack/interop/tutorials/relay-messages-viem) - -{/* After the tutorial for L2ToL2CrossDomainMessenger is written, need to add a link here */} diff --git a/pages/stack/interop/superchain-weth.mdx b/pages/stack/interop/superchain-weth.mdx index fabd575e0..eb12e5f85 100644 --- a/pages/stack/interop/superchain-weth.mdx +++ b/pages/stack/interop/superchain-weth.mdx @@ -82,13 +82,13 @@ sequenceDiagram 4. An off-chain entity submits a transaction to execute the message. Any address can submit this transaction, but it must have ETH on the destination chain. - Typically, a relayer submits the transaction, since the user does not yet have ETH on the destination chain. + Typically this would be thge chain's autorelayer. 5. `L2ToL2CrossDomainMessenger` on the destination chain calls `SuperchainWETH` with the following details: -* Source of the ETH -* Destination address -* Amount of ETH + * Source of the ETH + * Destination address + * Amount of ETH `SuperchainWETH` performs several sanity checks: diff --git a/pages/stack/interop/tutorials/message-passing.mdx b/pages/stack/interop/tutorials/message-passing.mdx index 49b0690e0..5738571e8 100644 --- a/pages/stack/interop/tutorials/message-passing.mdx +++ b/pages/stack/interop/tutorials/message-passing.mdx @@ -7,6 +7,7 @@ description: Learn to implement cross-chain communication in the Superchain by b import { Callout } from 'nextra/components' import { Steps } from 'nextra/components' import { InteropCallout } from '@/components/WipCallout' +import { AutorelayCallout } from '@/components/AutorelayCallout' @@ -362,6 +363,8 @@ In this section we change `Greeter.sol` to emit a separate event in it receives ## Implement manual message relaying + + So far we relied on `--interop.autorelay` to send the executing messages to chain B. But we only have it because we're using a development system. In production we will not have this, we need to create our own executing messages. From 57d23296312b58038a67c7b891885ef669d40f16 Mon Sep 17 00:00:00 2001 From: soyboy <85043086+sbvegan@users.noreply.github.com> Date: Mon, 24 Feb 2025 10:02:45 -0800 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- components/AutorelayCallout.tsx | 2 +- pages/stack/interop/superchain-weth.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/AutorelayCallout.tsx b/components/AutorelayCallout.tsx index 4320a19f7..1770b0ed8 100644 --- a/components/AutorelayCallout.tsx +++ b/components/AutorelayCallout.tsx @@ -18,7 +18,7 @@ export function AutorelayCallout({ context }: Props): ReactElement {
Normally we expect Superchain blockchains to run an autorelayer and relay your messages automatically. - However, for performance reasons or reliability, you might decide to subnmit the executing message manually. + However, for performance reasons or reliability, you might decide to submit the executing message manually. This section shows how to do that.
diff --git a/pages/stack/interop/superchain-weth.mdx b/pages/stack/interop/superchain-weth.mdx index eb12e5f85..7dc21e86a 100644 --- a/pages/stack/interop/superchain-weth.mdx +++ b/pages/stack/interop/superchain-weth.mdx @@ -82,7 +82,7 @@ sequenceDiagram 4. An off-chain entity submits a transaction to execute the message. Any address can submit this transaction, but it must have ETH on the destination chain. - Typically this would be thge chain's autorelayer. + Typically, this would be the chain's autorelayer. 5. `L2ToL2CrossDomainMessenger` on the destination chain calls `SuperchainWETH` with the following details: From 930f2c27cc7ee265a9d1be02187ffc2678c0826a Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Mon, 24 Feb 2025 16:26:49 -0600 Subject: [PATCH 3/3] Some fixes related to autorelay --- components/AutorelayCallout.tsx | 4 ++-- pages/stack/interop/tutorials/message-passing.mdx | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/components/AutorelayCallout.tsx b/components/AutorelayCallout.tsx index 1770b0ed8..47c289c91 100644 --- a/components/AutorelayCallout.tsx +++ b/components/AutorelayCallout.tsx @@ -19,9 +19,9 @@ export function AutorelayCallout({ context }: Props): ReactElement {
Normally we expect Superchain blockchains to run an autorelayer and relay your messages automatically. However, for performance reasons or reliability, you might decide to submit the executing message manually. - This section shows how to do that. + See below to learn how to do that.
); -} \ No newline at end of file +} diff --git a/pages/stack/interop/tutorials/message-passing.mdx b/pages/stack/interop/tutorials/message-passing.mdx index 5738571e8..555f5e9e4 100644 --- a/pages/stack/interop/tutorials/message-passing.mdx +++ b/pages/stack/interop/tutorials/message-passing.mdx @@ -365,10 +365,6 @@ In this section we change `Greeter.sol` to emit a separate event in it receives -So far we relied on `--interop.autorelay` to send the executing messages to chain B. -But we only have it because we're using a development system. -In production we will not have this, we need to create our own executing messages. - ### Set up