Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contracts): new challenger #223

Merged
merged 51 commits into from
Oct 14, 2024

Conversation

merklefruit
Copy link
Collaborator

@merklefruit merklefruit commented Sep 11, 2024

Overview

This iteration of the BoltChallenger implements the new Commitment Challenge game.
The challenge resolution flow consists of the following steps:

  1. identify the challengeID you want to solve, based on the event emitted upon new challenge creation
  2. provide a blockHash from a trusted source. For recent blocks, this can be the EVM directly. For historical blocks, this can come from a number of sources like blockhash accumulators, zk-coprocessors, or other proving systems.
  3. provide a proof consisting of:
    • RLP-encoded block header (hashing to the provided blockHash)
    • Account merkle trie proof
    • Transaction merkle trie proof

Tasks

  • decode block header, given a trusted block hash
  • prove existence of an account and decode its contents from RLP, given a proof and a trusted state root
  • prove inclusion of a transaction and decode its contents from RLP, given a proof and a trusted tx root
  • add unit tests for opening challenges
  • build an end2end test with the challenge resolution proof flow
  • build out the functionality to open a new challenge
  • build out the first challenge resolution logic
  • add more unit tests for fault resolution logic
  • add extensive documentation

RLP transaction decoder

  •  implement decoding for EIP-2718 transaction envelopes of type 0, 1, 2, 3
  • test decoding & preimages with ethers-js test vectors

Extra (out of scope):

  • write a Rust library and CLI tool to generate all the required proofs for resolving a challenge
  • write a challenger agent binary that monitors the chain for newly opened challenges

Meta

@merklefruit merklefruit added C: smart-contracts Component: smart contracts T: feature Type: Feature labels Sep 11, 2024
@merklefruit merklefruit self-assigned this Sep 12, 2024
@merklefruit merklefruit added this to the v0.3: Holesky 1 milestone Sep 12, 2024
@merklefruit merklefruit linked an issue Sep 12, 2024 that may be closed by this pull request
@merklefruit merklefruit removed this from the v0.3: Holesky 1 milestone Sep 13, 2024
@merklefruit merklefruit force-pushed the nico/feat/commitment-registry branch from dd182a5 to 8f6bf3e Compare September 18, 2024 18:43
@merklefruit merklefruit force-pushed the nico/feat/new-challenger branch from 3b7f6ed to 2a96103 Compare September 18, 2024 18:44
@merklefruit merklefruit marked this pull request as ready for review September 20, 2024 12:05
Copy link
Contributor

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stunning work. Just left some comments on the dispute logic since I've trouble understanding to what data the account proofs points to: before transactions or after transactions?

bolt-contracts/README.md Outdated Show resolved Hide resolved

AccountData memory account = _decodeAccountRLP(accountRLP);

if (account.nonce > decodedTx.nonce) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this check:

  • Suppose my account before sending the preconf has nonce $n$. As such, the nonce of the tx is $n$ as well. After it has been included my account will have nonce $n+1$. Since the proof.accountMerkleProof is performed against the blockHeader.stateRoot after all its transaction I'm worried we might always enter this if condition is always satisfied
  • What if I send multiple preconfirmations for the same slot? According to the reasoning of the previous point, can we encounter some edge cases?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points! A simple fix is using the previous blocks' state root to do these checks right?

bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/interfaces/IBoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/lib/TransactionDecoder.sol Show resolved Hide resolved
bolt-contracts/src/lib/TransactionDecoder.sol Show resolved Hide resolved
Copy link

Copy link

Challenger

@merklefruit merklefruit force-pushed the nico/feat/new-challenger branch from e0db9f3 to 82b4744 Compare October 1, 2024 08:50
@mempirate mempirate merged commit 960dfaa into nico/feat/commitment-registry Oct 14, 2024
5 checks passed
@mempirate mempirate deleted the nico/feat/new-challenger branch October 14, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: smart-contracts Component: smart contracts T: feature Type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Challenger implementation V1
3 participants