-
Notifications
You must be signed in to change notification settings - Fork 260
How do use cast
to relay messages
#1589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
❌ Deploy Preview for docs-optimism failed. Why did it fail? →Built without sensitive environment variables
|
📝 Walkthrough""" WalkthroughThis change introduces a new manual relay transaction tutorial for blockchain interoperability using the Foundry Sequence Diagram(s)sequenceDiagram
participant User
participant ChainA
participant ChainB
participant SupersimRPC
User->>ChainA: Deploy GreetingSender contract
User->>ChainB: Deploy Greeter contract
User->>ChainA: Call setGreeting() on GreetingSender
ChainA-->>User: Emit SentMessage event
User->>User: Extract event log and construct payload
User->>SupersimRPC: Request access list for relay tx
SupersimRPC-->>User: Return access list
User->>ChainB: Call relayMessage() on CrossDomainMessenger with payload and access list
ChainB-->>User: Greeter greeting updated
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (5)
💤 Files with no reviewable changes (3)
✅ Files skipped from review due to trivial changes (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (5)
public/tutorials/setup-for-manual-relay.sh (2)
86-90
: Add error handling for directory changes
Similar to the initialcd
, wrapcd lib
andcd ..
with|| exit 1
or set strict mode so failed directory changes abort:- cd lib + cd lib || exit 1 ... - cd .. + cd .. || exit 1🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 86-86: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
91-93
: Use a more robust download command
Replacewget
with a fail-safecurl
invocation (or ensurewget -q
errors are caught):- wget https://raw.githubusercontent.com/.../IL2ToL2CrossDomainMessenger.sol + curl -fsSL https://raw.githubusercontent.com/.../IL2ToL2CrossDomainMessenger.sol -o IL2ToL2CrossDomainMessenger.solpages/interop/tutorials/message-passing/relay-with-cast.mdx (3)
24-28
: Remove unused import
Callout
is imported but never used. Please remove the unused import to keep the code clean:- import { Callout } from 'nextra/components'
59-59
: Use sentence case for H3 headings
Change “### What You'll Build” to:### What you'll build
to comply with sentence-case rules for headers.
101-102
: Avoid exposing private key in docs snippet
Displaying the hardcoded private key in the tutorial may confuse readers or leak test credentials. Replace it with a placeholder or instruct the user to set their own:- PRIVATE_KEY=0xac0974bec39a... + PRIVATE_KEY=<YOUR_SUPERSIM_PRIVATE_KEY>🧰 Tools
🪛 Gitleaks (8.21.2)
101-101: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
pages/interop/tutorials/message-passing/_meta.json
(1 hunks)pages/interop/tutorials/message-passing/relay-with-cast.mdx
(1 hunks)public/tutorials/setup-for-manual-relay.sh
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.mdx`: "ALWAYS review Markdown content THOROUGHLY with the following criteria: - First, check the frontmatter section at the top of the file: 1. For regular pages, ensure AL...
**/*.mdx
: "ALWAYS review Markdown content THOROUGHLY with the following criteria:
- First, check the frontmatter section at the top of the file:
- For regular pages, ensure ALL these fields are present and not empty:
--- title: [non-empty] lang: [non-empty] description: [non-empty] topic: [non-empty] personas: [non-empty array] categories: [non-empty array] content_type: [valid type] ---
- For landing pages (index.mdx or files with ), only these fields are required:
--- title: [non-empty] lang: [non-empty] description: [non-empty] topic: [non-empty] ---
- If any required fields are missing or empty, comment:
'This file appears to be missing required metadata. Please check keywords.config.yaml for valid options and add the required fields manually. You can validate your changes by running:pnpm validate-metadata ```'
- Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
- Avoid gender-specific language and use the imperative form.
- Monitor capitalization for emphasis. Avoid using all caps, italics, or bold for emphasis.
- Ensure proper nouns are capitalized in sentences.
- Apply the Oxford comma.
- Use proper title case for buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
- Use correct spelling and grammar at all times (IMPORTANT).
- For H1, H2, and H3 headers:
- Use sentence case, capitalizing only the first word.
- Preserve the capitalization of proper nouns, technical terms, and acronyms as defined in the 'nouns.txt' file located in the root directory of the project.
- Do not automatically lowercase words that appear in the 'nouns.txt' file, regardless of their position in the header.
- Flag any headers that seem to inconsistently apply these rules for manual review.
- When reviewing capitalization, always refer to the 'nouns.txt' file for the correct capitalization of proper nouns and technical terms specific to the project.
"
pages/interop/tutorials/message-passing/relay-with-cast.mdx
🪛 Biome (1.9.4)
pages/interop/tutorials/message-passing/_meta.json
[error] 2-3: Expected a property but instead found '}'.
Expected a property here.
(parse)
🪛 Gitleaks (8.21.2)
pages/interop/tutorials/message-passing/relay-with-cast.mdx
101-101: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
public/tutorials/setup-for-manual-relay.sh
7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 Shellcheck (0.10.0)
public/tutorials/setup-for-manual-relay.sh
[warning] 5-5: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
[warning] 86-86: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
[warning] 97-97: Use semicolon or linefeed before 'done' (or quote to make it literal).
(SC1010)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - docs-optimism
- GitHub Check: Header rules - docs-optimism
- GitHub Check: Pages changed - docs-optimism
🔇 Additional comments (2)
public/tutorials/setup-for-manual-relay.sh (2)
13-53
: ContractGreeter
implementation looks solid
The SPDX license, pragma, imports, and event logic for cross-domain messaging are all correctly defined and follow best practices.
55-83
: ContractGreetingSender
implementation looks good
Constructor arguments and thesetGreeting
relay logic usingabi.encodeCall
are appropriately implemented.
#! /bin/sh | ||
|
||
rm -rf manual-relay | ||
mkdir manual-relay | ||
cd manual-relay | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ensure safe script execution and error handling
Add strict mode and handle cd
failures to prevent the script from continuing on error. For example, right after the shebang add:
+ set -euo pipefail
and change:
- cd manual-relay
+ cd manual-relay || exit 1
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 5-5: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
(SC2164)
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
USER_ADDRESS=`cast wallet address --private-key $PRIVATE_KEY` | ||
URL_CHAIN_A=http://localhost:9545 | ||
URL_CHAIN_B=http://localhost:9546 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid hardcoding private keys in source
Embedding a private key in the script can leak sensitive credentials. Instead, load the key from an environment variable or CLI argument and validate it before use:
- PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
+ : "${PRIVATE_KEY:?Environment variable PRIVATE_KEY must be set}"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | |
USER_ADDRESS=`cast wallet address --private-key $PRIVATE_KEY` | |
URL_CHAIN_A=http://localhost:9545 | |
URL_CHAIN_B=http://localhost:9546 | |
# public/tutorials/setup-for-manual-relay.sh | |
# Ensure PRIVATE_KEY is provided via env var, don’t hard-code it | |
: "${PRIVATE_KEY:?Environment variable PRIVATE_KEY must be set}" | |
USER_ADDRESS=`cast wallet address --private-key $PRIVATE_KEY` | |
URL_CHAIN_A=http://localhost:9545 | |
URL_CHAIN_B=http://localhost:9546 |
🧰 Tools
🪛 Gitleaks (8.21.2)
7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
"relay-with-cast": "Manual relay transaction", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix invalid JSON (remove trailing comma)
The trailing comma after the single property makes this file unparsable. Remove it:
- "relay-with-cast": "Manual relay transaction",
+ "relay-with-cast": "Manual relay transaction"
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"relay-with-cast": "Manual relay transaction", | |
} | |
"relay-with-cast": "Manual relay transaction" | |
} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 2-3: Expected a property but instead found '}'.
Expected a property here.
(parse)
import { InteropCallout } from '@/components/WipCallout' | ||
import { AutorelayCallout } from '@/components/AutorelayCallout' | ||
|
||
# Manual relay transactions tutorial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align H1 with frontmatter title
The H1 reads “Manual relay transactions tutorial” but the frontmatter title is singular (“Manual relay transaction tutorial”). Please make them consistent.
Description
A separate tutorial because this is a rare edge case.
Tests
N/A
Additional context
Remove https://docs.optimism.io/interop/tutorials/relay-messages-cast and https://docs.optimism.io/interop/tutorials/relay-messages-viem because they are redundant.
After #1581 is merged, it would be a good idea to move https://docs.optimism.io/interop/tutorials/message-passing#implement-manual-message-relaying to the same place as the
cast
tutorial - they are very similar.Metadata
N/A