availproject / avail

772 stars 529 forks source link

feat: native light client state verification #630

Open xavierdmello opened 1 month ago

xavierdmello commented 1 month ago

Inside the Vector pallet, instead of verifying a proof of light client logic, we natively implement the logic at a node level. This mirrors SP1 Telepathy's approach. The Rust-based logic built on top of Helios allows for seamless integration with Avail's pallet.

Additionally, this approach dramatically simplifies the operator. Instead of fetching specialized inputs and generating proofs, we simply retrieve inputs for Helios and relay that to the chain.

Modifications

We've optimized storage by directly using the canonical Ethereum consensus state's sync committee hash, eliminating the need for Poseidon hashes.

The updated verification logic is inside the fulfill_call function of pallets/vector/src/lib.rs.

Operator

The new operator is based on SP1 Telepathy's operator. The logic remains the same, with placeholders for reading and writing to Avail using avail-subxt instead of a smart contract on Ethereum.

For reference, I've created a fork of the SP1 Telepathy operator with added comments highlighting the lines that need to be changed: https://github.com/xavierdmello/avail-telepathy-operator

Testing

We've adapted a few tests into tests_new.rs, which replaces the current tests.rs. You can try the new ones by running cargo test test_fulfill inside of ./pallets/vector/. We generated test inputs using SP1 Telepathy (instructions here), which outputs bytes that should be placed inside ./pallets/vector/examples