songtianyi / phat-stateful-rollup

Phat Contract Stateful Rollup implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

phat-offchain-rollup

Phat Contract Offchain Rollup implementation

Highlighted TODOs

  • E2E test script
  • Simple scheduler
  • Lock: the correct implementation; may require a rewrite
  • Optimization: Batch read from rollup anchor

Phat Contract side

Misc

  • Refactor experimantal code as contracts
    • Switch to OpenBrush's ink-env with the advanced unit test kits

Contract

  • SimpleScheduler
    • Design
    • Query poll()
      • call all the ready targets
      • should check health (trigger exactly one health worker)
    • Tx register(config, address, calldata) owner-only (direct call, stateless)
    • Tx delete(id) owner-only
    • log the triggered events
  • RollupTransactor
    • Account management: generate secret key & reveal public key
    • Tx config(rpc, rollup_handler, anchor) by owner
    • Query poll()
      • get Result<RollupResult, Vec<u8>> response
      • submit tx to RollupResult.target_id
        • use the latest nonce
        • fire and forget
    • enum RollupTarget
      • EVM(chain, address)
      • Pallet(chain)
    • Raw tx submit
    • Gas efficiency submit - for gas efficiency, save the recent submitted tx to local storage (with timeout) to avoid redundant submission in a short period
  • TestOracle
    • Minimum implementation
    • Real-time fetch price
    • Refactor to strip SDK logic

SDK

  • Locks
    • Experimental lock tree (tx_read, tx_write)
    • Correct implementation
  • struct RollupTx
    • Condition
    • Updates
    • Actions
  • struct RollupResult
    • RollupTx
    • RollupTarget
    • (opt) signature of RollupTx
  • RollupReadClient
    • Read from EVM
    • Wrap as QueuedAnchorClient
    • Consider block_hash when reading data
    • Cross validation
  • (low) Cross-platform Rollup
    • Basic codec abstraction (platform::Platform)
    • State reading abstraction
    • RollupTx serialization

Development Notes

  • abi.decode() doesn't have any error handling currently. When it failed, the transaction will get revereted silently, which is hard to debug. So it's always a good habit to verify the raw input to decode() beforehand.

About

Phat Contract Stateful Rollup implementation

License:Apache License 2.0


Languages

Language:Rust 60.9%Language:TypeScript 20.3%Language:Solidity 18.5%Language:Shell 0.3%