pub fn verify(
    rollup_type_hash: H256,
    config: &RollupConfig,
    revert_args: RollupRevertReader,
    prev_global_state: &GlobalState,
    post_global_state: &GlobalState,
) -> Result<(), Error> {
    check_status(prev_global_state, Status::Halting)?;
    // check rollup lock cells,
    // we do not handle the reverting of lock cells in here,
    // instead we handle them in the submitting layer2 block action
    check_rollup_lock_cells_except_stake(&rollup_type_hash, config)?;
    // do not accept stake cells in the output
    if !collect_stake_cells(&rollup_type_hash, config, Source::Output)?.is_empty() {
        return Err(Error::InvalidStakeCell);
    }
    // load reverted blocks
    let reverted_blocks_vec = revert_args.reverted_blocks();
    let reverted_blocks: Vec<_> = reverted_blocks_vec.iter().collect();
    // check challenge cells
    let challenge_cell = find_challenge_cell(&rollup_type_hash, config, Source::Input)?
        .ok_or(Error::InvalidChallengeCell)?;
    // the first reverted block is challenged target block
    let challenged_block = reverted_blocks.get(0).ok_or(Error::InvalidRevertedBlocks)?;
    check_challenge_cell(
        &rollup_type_hash,
        config,
        &challenge_cell,
        &challenged_block.hash().into(),
    )?;
    check_rewards(&rollup_type_hash, config, &reverted_blocks, &challenge_cell)?;
    let reverted_global_state = check_reverted_blocks(
        config,
        &reverted_blocks,
        &revert_args,
        prev_global_state,
        post_global_state,
    )?;
    if post_global_state != &reverted_global_state {
        return Err(Error::InvalidPostGlobalState);
    }
    Ok(())
}
/// Verify revert
/// 1. check revert merkle roots
/// 2. check reverted block root
/// 3. check other lock cells
Verify revert
1. check revert merkle roots
2. check reverted block root
3. check other lock cells
Verify revert 1 . check revert merkle roots 2 . check reverted block root 3 . check other lock cells
pub fn verify(
    rollup_type_hash: H256,
    config: &RollupConfig,
    revert_args: RollupRevertReader,
    prev_global_state: &GlobalState,
    post_global_state: &GlobalState,
) -> Result<(), Error> {
    check_status(prev_global_state, Status::Halting)?;
    // check rollup lock cells,
    // we do not handle the reverting of lock cells in here,
    // instead we handle them in the submitting layer2 block action
    check_rollup_lock_cells_except_stake(&rollup_type_hash, config)?;
    // do not accept stake cells in the output
    if !collect_stake_cells(&rollup_type_hash, config, Source::Output)?.is_empty() {
        return Err(Error::InvalidStakeCell);
    }
    // load reverted blocks
    let reverted_blocks_vec = revert_args.reverted_blocks();
    let reverted_blocks: Vec<_> = reverted_blocks_vec.iter().collect();
    // check challenge cells
    let challenge_cell = find_challenge_cell(&rollup_type_hash, config, Source::Input)?
        .ok_or(Error::InvalidChallengeCell)?;
    // the first reverted block is challenged target block
    let challenged_block = reverted_blocks.get(0).ok_or(Error::InvalidRevertedBlocks)?;
    check_challenge_cell(
        &rollup_type_hash,
        config,
        &challenge_cell,
        &challenged_block.hash().into(),
    )?;
    check_rewards(&rollup_type_hash, config, &reverted_blocks, &challenge_cell)?;
    let reverted_global_state = check_reverted_blocks(
        config,
        &reverted_blocks,
        &revert_args,
        prev_global_state,
        post_global_state,
    )?;
    if post_global_state != &reverted_global_state {
        return Err(Error::InvalidPostGlobalState);
    }
    Ok(())
}
pub fn verify ( rollup_type_hash : H256 , config : & RollupConfig , revert_args : RollupRevertReader , prev_global_state : & GlobalState , post_global_state : & GlobalState , ) -> Result < ( ) , Error > { check_status ( prev_global_state , Status :: Halting ) ? ; // check rollup lock cells, // we do not handle the reverting of lock cells in here, // instead we handle them in the submitting layer2 block action check_rollup_lock_cells_except_stake ( & rollup_type_hash , config ) ? ; // do not accept stake cells in the output if ! collect_stake_cells ( & rollup_type_hash , config , Source :: Output ) ? . is_empty ( ) { return Err ( Error :: InvalidStakeCell ) ; } // load reverted blocks let reverted_blocks_vec = revert_args . reverted_blocks ( ) ; let reverted_blocks : Vec < _ > = reverted_blocks_vec . iter ( ) . collect ( ) ; // check challenge cells let challenge_cell = find_challenge_cell ( & rollup_type_hash , config , Source :: Input ) ? . ok_or ( Error :: InvalidChallengeCell ) ? ; // the first reverted block is challenged target block let challenged_block = reverted_blocks . get ( 0 ) . ok_or ( Error :: InvalidRevertedBlocks ) ? ; check_challenge_cell ( & rollup_type_hash , config , & challenge_cell , & challenged_block . hash ( ) . into ( ) , ) ? ; check_rewards ( & rollup_type_hash , config , & reverted_blocks , & challenge_cell ) ? ; let reverted_global_state = check_reverted_blocks ( config , & reverted_blocks , & revert_args , prev_global_state , post_global_state , ) ? ; if post_global_state != & reverted_global_state { return Err ( Error :: InvalidPostGlobalState ) ; } Ok ( ( ) ) }
Verify revert
1. check revert merkle roots
2. check reverted block root
3. check other lock cells
Verify revert 1 . check revert merkle roots 2 . check reverted block root 3 . check other lock cells
rollup_type_hash
H256
config
&RollupConfig
revert_args
RollupRevertReader
prev_global_state
&GlobalState
post_global_state
&GlobalState
rollup_type_hash
H256
config
&RollupConfig
revert_args
RollupRevertReader
prev_global_state
&GlobalState
post_global_state
&GlobalState