magicblock
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMagicBlock Ephemeral Rollups Skill
MagicBlock Ephemeral Rollups 开发技能
What this Skill is for
本技能适用场景
Use this Skill when the user asks for:
- MagicBlock Ephemeral Rollups integration
- Delegating/undelegating Solana accounts to ephemeral rollups
- High-performance, low-latency transaction flows
- Crank scheduling (recurring automated transactions)
- VRF (Verifiable Random Function) for provable randomness
- Dual-connection architecture (base layer + ephemeral rollup)
- Gaming and real-time app development on Solana
当用户有以下需求时,可使用本技能:
- MagicBlock Ephemeral Rollups 集成
- 将Solana账户委托给临时Rollup/从临时Rollup撤销委托
- 高性能、低延迟的交易流程
- Crank调度(周期性自动化交易)
- 用于可验证随机数的VRF(Verifiable Random Function)
- 双连接架构(底层网络+临时Rollup)
- Solana上的游戏与实时应用开发
Key Concepts
核心概念
Ephemeral Rollups enable high-performance, low-latency transactions by temporarily delegating Solana account ownership to an ephemeral rollup. Ideal for gaming, real-time apps, and fast transaction throughput.
Delegation transfers account ownership from your program to the delegation program, allowing the ephemeral rollup to process transactions at ~10-50ms latency vs ~400ms on base layer.
Architecture:
┌─────────────────┐ delegate ┌─────────────────────┐
│ Base Layer │ ───────────────► │ Ephemeral Rollup │
│ (Solana) │ │ (MagicBlock) │
│ │ ◄─────────────── │ │
└─────────────────┘ undelegate └─────────────────────┘
~400ms ~10-50ms临时Rollup(Ephemeral Rollups) 通过将Solana账户所有权临时委托给临时Rollup,实现高性能、低延迟的交易。非常适合游戏、实时应用和高吞吐量交易场景。
委托(Delegation) 将账户所有权从你的程序转移到委托程序,使临时Rollup能够以约10-50ms的延迟处理交易,而底层网络的延迟约为400ms。
架构:
┌─────────────────┐ 委托 ┌─────────────────────┐
│ 底层网络 │ ───────────────► │ 临时Rollup │
│ (Solana) │ │ (MagicBlock) │
│ │ ◄─────────────── │ │
└─────────────────┘ 撤销委托 └─────────────────────┘
~400ms ~10-50msDefault stack decisions (opinionated)
预设技术栈选型(推荐方案)
-
Programs: Anchor with ephemeral-rollups-sdk
- Use with Anchor features
ephemeral-rollups-sdk - Apply macro before
#[ephemeral]#[program] - Use and
#[delegate]macros for delegation contexts#[commit]
- Use
-
Dual Connections
- Base layer connection for initialization and delegation
- Ephemeral rollup connection for operations on delegated accounts
-
Transaction Routing
- Delegate transactions → Base Layer
- Operations on delegated accounts → Ephemeral Rollup
- Undelegate/commit transactions → Ephemeral Rollup
-
程序:基于ephemeral-rollups-sdk的Anchor
- 结合Anchor功能使用
ephemeral-rollups-sdk - 在宏之前添加
#[program]宏#[ephemeral] - 在委托上下文中使用和
#[delegate]宏#[commit]
- 结合Anchor功能使用
-
双连接机制
- 底层网络连接:用于初始化和委托操作
- 临时Rollup连接:用于已委托账户的操作
-
交易路由规则
- 委托交易 → 底层网络
- 已委托账户的操作 → 临时Rollup
- 撤销委托/提交状态交易 → 临时Rollup
Operating procedure (how to execute tasks)
操作流程(任务执行步骤)
1. Classify the operation type
1. 分类操作类型
- Account initialization (base layer)
- Delegation (base layer)
- Operations on delegated accounts (ephemeral rollup)
- Commit state (ephemeral rollup)
- Undelegation (ephemeral rollup)
- 账户初始化(底层网络)
- 委托操作(底层网络)
- 已委托账户的操作(临时Rollup)
- 状态提交(临时Rollup)
- 撤销委托(临时Rollup)
2. Pick the right connection
2. 选择正确的连接
- Base layer: (or mainnet)
https://api.devnet.solana.com - Ephemeral rollup:
https://devnet.magicblock.app/
- 底层网络:(或主网)
https://api.devnet.solana.com - 临时Rollup:
https://devnet.magicblock.app/
3. Implement with MagicBlock-specific correctness
3. 按照MagicBlock规范实现
Always be explicit about:
- Which connection to use for each transaction
- Delegation status checks before operations
- PDA seeds matching between delegate call and account definition
- Using for ER transactions
skipPreflight: true - Waiting for state propagation after delegate/undelegate
需明确以下要点:
- 每笔交易对应的连接类型
- 操作前检查委托状态
- 委托调用与账户定义的PDA种子一致
- 对ER交易设置
skipPreflight: true - 委托/撤销委托后等待状态同步
4. Add appropriate features
4. 添加合适的功能
- Cranks for recurring automated transactions
- VRF for verifiable randomness in games/lotteries
- 用于周期性自动化交易的Crank机制
- 用于游戏/抽奖场景可验证随机数的VRF
5. Deliverables expectations
5. 交付物要求
When you implement changes, provide:
- Exact files changed + diffs
- Commands to install/build/test
- Risk notes for anything touching delegation/signing/state commits
当你完成实现变更后,需提供:
- 具体修改的文件及差异内容
- 安装/构建/测试的命令
- 涉及委托/签名/状态提交操作的风险说明
Progressive disclosure (read when needed)
进阶参考资料(按需查阅)
- Core delegation patterns: delegation.md
- TypeScript frontend setup: typescript-setup.md
- Cranks (scheduled tasks): cranks.md
- VRF (randomness): vrf.md
- Reference links & versions: resources.md
- 核心委托模式:delegation.md
- TypeScript前端配置:typescript-setup.md
- Crank(定时任务):cranks.md
- VRF(随机数):vrf.md
- 参考链接与版本信息:resources.md