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: Transition fraud proof prototype from block fraud proofs to fraud proof with ISRs #264

Conversation

Manav-Aggarwal
Copy link
Member

@Manav-Aggarwal Manav-Aggarwal commented Aug 19, 2022

Description

#245 covers the block fraud-proof prototype, we'd like to make it compatible with ISRs. It'd modify the cycle of a fraudproof to look like this:

Optimint Full Node (Producer of ISR fraudproof)

  1. An optimint full node while trying to execute blocks, finds a fraudulent tx in some block. It passes a message to cosmos-sdk telling it to go into fraudproof generation mode.
  2. In the fraudproof generation mode, a cosmos-sdk app reverts its state to a previous state before the fraudulent block is applied and enables tracing.
  3. Now, optimint can tell cosmos-sdk to fast forward to right before the fraudulent transaction was executed. Now, simply execute the fraudulent transaction while logging all the states touched by the transaction. Then, it will revert to a previous state again, fast forward it to right before the fraudulent transaction was executed, and then snapshot the state while using the contents of the log to filter down to the minimal set of states needed. This minimal snapshot will be packaged as a fraudproof and passed back to optimint.
  4. The verifying optimint full node will alert the P2P network by gossiping that fraudproof around.

Optimint Full/Light Node (Verifier of ISR fraudproof)

  1. An optimint full/node receives the fraudproof from the P2P Network. It retrieves the fraudulent block header from the DA layer using the block height and hash indicated in the fraudproof.
  2. It verifies the fraudproof by doing a cross-reference of a header app hash from the blockchain against the contents of a fraudproof
  3. Now, it spins up a fresh cosmos-sdk and tells it to initialize with the fraudproof which is essentially a minimal snapshot sufficient to execute the fraudulent block.
  4. Optimint tells cosmos-sdk to execute the fraudulent transaction and finally checks if the local app's state (app hash) matches the app hash of the next block published on-chain.
  5. If it doesn't match, then fraud has been verified, so the whole network halts. Otherwise, no fraud was detected, so the system continues as it is.

Specifically, we cover this part of the cycle by modifying the existing TestGenerateAndLoadFraudProof:

  1. Now, optimint can tell cosmos-sdk to fast forward to right before the fraudulent transaction was executed. Now, simply execute the fraudulent transaction while logging all the states touched by the transaction. Then, it will revert to a previous state again, fast forward it to right before the fraudulent transaction was executed, and then snapshot the state while using the contents of the log to filter down to the minimal set of states needed. This minimal snapshot will be packaged as a fraudproof and passed back to Optimint.

The fast-forward parts by Optimint should be just simulated in the test.

Also covers:

  • Add appHash to fraudProof data structure
  • use tmcrypto.ProofOp instead of smt.SparseMerkleProof in fraudproof to make exports easier
  • refactor code to remove pre-execution and use of a deep smt while generating fraudproof

Closes: #265


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • [ x followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@Manav-Aggarwal Manav-Aggarwal self-assigned this Aug 19, 2022
@Manav-Aggarwal Manav-Aggarwal added the C: Cevmos Changes related to the cevmos branches label Aug 19, 2022
@Manav-Aggarwal Manav-Aggarwal changed the title FraudProof with ISRs Transition fraud proof prototype from block fraud proofs to fraud proof with ISRs Aug 20, 2022
@Manav-Aggarwal Manav-Aggarwal changed the title Transition fraud proof prototype from block fraud proofs to fraud proof with ISRs feat: Transition fraud proof prototype from block fraud proofs to fraud proof with ISRs Aug 20, 2022
@Manav-Aggarwal Manav-Aggarwal marked this pull request as ready for review August 20, 2022 05:39
@Manav-Aggarwal
Copy link
Member Author

everything is moved to cosmos-sdk-rollmint repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Cevmos Changes related to the cevmos branches C:Store Type: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transition fraud proof prototype from block fraud proofs to fraud proof with ISRs
1 participant