celestiaorg / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Other
19 stars 33 forks source link

Transition fraud proof prototype from block fraud proofs to fraud proof with ISRs #265

Closed Manav-Aggarwal closed 2 years ago

Manav-Aggarwal commented 2 years ago

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 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 forwards parts by Optimint should be just simulated in the test.

Manav-Aggarwal commented 2 years ago

Closed by: https://github.com/celestiaorg/cosmos-sdk-rollmint/pull/1