Skip to content

This assignment project requires the implementation of a full node supporting verification and storage mechanisms for both the Data Availability (DA) and sequencer layers' blocks.

License

Notifications You must be signed in to change notification settings

AlirezaRoshanzamir/blockchain-rollup-full-node

Repository files navigation

Blockchain Rollup Full Node (Storage and Verification)

This repository involves implementing a Rust program (mock full node) for a sovereign rollup project with Bitcoin as the Data Availability (DA) layer. The rollup's objective is to maintain a record of a 256-leaf Merkle tree, with the sequencer publishing 5 L2 blocks before writing state changes to the DA layer.

Full nodes must handle three states: Trusted state (blocks from the sequencer), not finalized state (Merkle leaf changes from a 5 L2 block batch) on DA, and finalized state (a 5 L2 block batch in a finalized DA block) on DA. The program reads input from files representing sequencer and DA layer data, considering potential reorganizations and ensuring efficient leaf querying and memory optimization throughout the process. The implementation needs to track blocks, batches, and the Merkle tree after every state change, addressing potential malicious behavior from the sequencer and handling reorganizations that may invalidate batches. The challenge emphasizes efficiency in querying leaves and memory usage optimization. The provided Python generator script can be used to create additional test cases.

For more information on rollups, please visit here.

Build

git clone https://github.com/AlirezaRoshanzamir/blockchain-rollup-full-node
cd blockchain-rollup-full-node
cargo build

Run

cargo run -- -d from_da.txt -s from_sequencer.txt

Options

These options exist to pass to the executable as input parameters:

  • To specify DA file path: -d, --da-file <DA_FILE>
  • To specify SEQ file path: -s, --sequencer-file <SEQ_FILE>
  • To enable state persist: -p, --persist
  • To load state from db: -l, --load-state
  • -h, --help Print help
  • -V, --version Print version

Use mongo

If you want to use mongodb as the key-value database, you need to run it before running the app. Use run_mongo.sh to run a dockerized version.

cargo run -- -d from_da.txt -s from_sequencer.txt --load-state --persist

Output

  • Sequencer lies are printed in red.
  • Reorgs are printed in yellow.
  • A summary is printed at the end.
  • If a reorg is not possible, an error message is printed

Nex steps

  • Create a backend endpoint (maybe a REST API) for the node to make runs and tests and queries simpler.

About

This assignment project requires the implementation of a full node supporting verification and storage mechanisms for both the Data Availability (DA) and sequencer layers' blocks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published