{"id":28301979,"url":"https://github.com/timdaub/interop-pingpong","last_synced_at":"2025-10-12T18:34:37.022Z","repository":{"id":294497058,"uuid":"987159566","full_name":"TimDaub/interop-pingpong","owner":"TimDaub","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-20T17:05:48.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-13T05:42:59.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimDaub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-20T16:59:01.000Z","updated_at":"2025-05-20T17:05:54.000Z","dependencies_parsed_at":"2025-05-20T18:37:09.295Z","dependency_job_id":null,"html_url":"https://github.com/TimDaub/interop-pingpong","commit_stats":null,"previous_names":["timdaub/interop-pingpong"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TimDaub/interop-pingpong","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimDaub%2Finterop-pingpong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimDaub%2Finterop-pingpong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimDaub%2Finterop-pingpong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimDaub%2Finterop-pingpong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimDaub","download_url":"https://codeload.github.com/TimDaub/interop-pingpong/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimDaub%2Finterop-pingpong/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279012514,"owners_count":26085134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-23T20:13:16.154Z","updated_at":"2025-10-12T18:34:37.017Z","avatar_url":"https://github.com/TimDaub.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CrossChain PingPong\n\nA demonstration of Optimism's L2-to-L2 cross-chain messaging using two OP chains in a SuperSim environment. This project implements a simple \"ping pong\" game where a virtual ball is sent back and forth between two OP chains.\n\nThis project is based on the [SuperSim Cross-chain Contract Calls tutorial](https://supersim.pages.dev/guides/interop/cross-chain-contract-calls-pingpong), but has been isolated and simplified to focus purely on the cross-chain messaging functionality.\n\n## Overview\n\nThis project demonstrates:\n- L2-to-L2 direct messaging between Optimism chains\n- Using [SuperSim](https://supersim.pages.dev/) to run a local OP Stack devnet\n- Deterministic deployments using CREATE2\n- Cross-chain communication via the L2ToL2CrossDomainMessenger\n\n## Prerequisites\n\n- [Foundry](https://book.getfoundry.sh/getting-started/installation)\n- [SuperSim](https://supersim.pages.dev/)\n\n## Setup Instructions\n\n1. Start SuperSim with auto-relay enabled:\n\n```bash\nsupersim --interop.autorelay\n```\n\nThis will launch two OP chains with the following configuration:\n- OPChainA: Chain ID 901, port 9545\n- OPChainB: Chain ID 902, port 9546\n- Available accounts, with the first account (used for deployment) having private key `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80`\n\n2. Deploy the contracts to both chains:\n\n```bash\n./deploy.sh\n```\n\nThe deploy script will:\n- Create identical contracts on both chain 901 and chain 902 at the same address (using CREATE2)\n- Initialize chain 901 with the ball (as specified in the constructor)\n\nSuccessful deployment will look like:\n\n```\nDeploying to OPChainA (Chain ID 901)...\n[⠊] Compiling...\nNo files changed, compilation skipped\nScript ran successfully.\n\n== Logs ==\n  Deployed at:  0xEFd7B7eCD385EdB10311Deeb760b433E215d101A\n\n## Setting up 1 EVM.\n\n==========================\n\nChain 901\n\n... (deployment details)\n\nONCHAIN EXECUTION COMPLETE \u0026 SUCCESSFUL.\n\nDeploying to OPChainB (Chain ID 902)...\n[⠊] Compiling...\nNo files changed, compilation skipped\nScript ran successfully.\n\n== Logs ==\n  Deployed at:  0xEFd7B7eCD385EdB10311Deeb760b433E215d101A\n\n## Setting up 1 EVM.\n\n==========================\n\nChain 902\n\n... (deployment details)\n\nONCHAIN EXECUTION COMPLETE \u0026 SUCCESSFUL.\n```\n\n**Note:** Deployment can only happen once per SuperSim session as the CREATE2 addresses will already exist on subsequent attempts. If you need to redeploy, restart SuperSim.\n\n## Using the PingPong Game\n\n### Check Ball Location\n\nTo check where the ball is currently located:\n\n```bash\n./check.sh\n```\n\nInitial state should show the ball on OPChainA (901):\n\n```\nChecking ball on OPChainA (901):\n1\n901\n0x4e59b44847b379578588920cA78FbF26c0B4956C  # Address may vary\n\nChecking ball on OPChainB (902):\n0\n0\n0x0000000000000000000000000000000000000000\n```\n\n### Hit Ball to Chain B\n\nTo hit the ball from Chain A to Chain B:\n\n```bash\n./hit.sh\n```\n\nYou should see transaction details and in the SuperSim logs, you'll see messages like:\n\n```\nINFO [timestamp] L2ToL2CrossChainMessenger#SentMessage    sourceChainID=901 destinationChainID=902 ...\nINFO [timestamp] L2ToL2CrossChainMessenger#RelayedMessage sourceChainID=901 destinationChainID=902 ...\n```\n\n### Check Ball Again\n\nAfter hitting the ball to Chain B, check its location:\n\n```bash\n./check.sh\n```\n\nYou should now see:\n\n```\nChecking ball on OPChainA (901):\n0\n0\n0x0000000000000000000000000000000000000000\n\nChecking ball on OPChainB (902):\n2\n901\n0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266  # Address of player who hit the ball\n```\n\n### Hit Ball Back to Chain A\n\nTo hit the ball from Chain B back to Chain A:\n\n```bash\n./hitback.sh\n```\n\nAfter hitting the ball back, check its location again:\n\n```bash\n./check.sh\n```\n\nYou should see:\n\n```\nChecking ball on OPChainA (901):\n3\n902\n0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266  # Address of player who hit the ball\n\nChecking ball on OPChainB (902):\n0\n0\n0x0000000000000000000000000000000000000000\n```\n\n## How It Works\n\n1. **Contract Deployment:**\n   - The same contract is deployed to two different OP chains at the same address using CREATE2\n   - The deployment script specifies chain 901 as the \"server chain\" that starts with the ball\n\n2. **Cross-Chain Messaging:**\n   - When a user calls `hitBallTo()`, the contract:\n     - Increments the rally count\n     - Records the sender's address and chain ID\n     - Clears the ball from the current chain\n     - Sends a cross-chain message to the destination chain using the L2ToL2CrossDomainMessenger\n\n3. **Message Relay:**\n   - SuperSim's auto-relay functionality automatically relays the message to the destination chain\n   - The destination contract receives the ball via the `receiveBall()` function\n   - The ball is now on the destination chain and can be hit back\n\n4. **Ball State:**\n   - The ball's state includes:\n     - `rallyCount`: How many times the ball has been hit\n     - `lastHitterChainId`: The chain ID where the ball was last hit\n     - `lastHitterAddress`: The address of the last player to hit the ball\n\n## Technical Details\n\n### Contract Address\n\nBoth contracts are deployed to the same address on different chains through CREATE2, using the same salt value:\n\n```solidity\nCrossChainPingPong game = new CrossChainPingPong{salt: \"pingpong\"}(901);\n```\n\n### Message Authentication\n\nThe contract includes safeguards to ensure messages come from valid sources:\n\n```solidity\nmodifier onlyCrossDomainCallback() {\n    if (msg.sender != address(messenger)) revert CallerNotL2ToL2CrossDomainMessenger();\n    if (messenger.crossDomainMessageSender() != address(this)) revert InvalidCrossDomainSender();\n    _;\n}\n```\n\n## Troubleshooting\n\n- **Deployment Fails**: If you see revert errors during deployment, it's likely because the contracts have already been deployed. Restart SuperSim to reset the chains.\n- **Ball Not Moving**: Ensure SuperSim's auto-relay is enabled with the `--interop.autorelay` flag.\n- **Script Permissions**: If scripts don't run, ensure they have executable permissions: `chmod +x *.sh`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimdaub%2Finterop-pingpong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimdaub%2Finterop-pingpong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimdaub%2Finterop-pingpong/lists"}