Repository: unionlabs/union
File: light-clients/ethereum-light-client/src/client.rs (Rust)

Code before:
                },
            )?;

            ensure(
                consensus_state.data.slot == header.consensus_update.attested_header.beacon.slot,
                Error::SlotCannotBeModified,
            )?;

            // NOTE(aeryz): we don't check the timestamp here since it is calculated based on the
            // thn slot and we already check the slot.

            // NOTE(aeryz): we don't check the next sync committee because it's not being signed with
            // a header. so it should be an error during the state update not a misbehaviour.
        }

        Ok(false)
    }

    fn check_for_misbehaviour_on_misbehaviour(
        _deps: Deps<Self::CustomQuery>,
        misbehaviour: Self::Misbehaviour,
    ) -> Result<bool, Self::Error> {
        if misbehaviour.update_1.attested_header.beacon.slot
            == misbehaviour.update_2.attested_header.beacon.slot
        {
            // TODO(aeryz): this is gonna be the finalized header when we implement justified
            // This ensures that there are no conflicting justified/finalized headers at the same height
            if misbehaviour.update_1.attested_header != misbehaviour.update_2.attested_header {
                return Ok(true);
            }
        }

        Ok(false)
    }

    fn verify_upgrade_and_update_state(
        _deps: DepsMut<Self::CustomQuery>,
        _upgrade_client_state: Self::ClientState,
        _upgrade_consensus_state: Self::ConsensusState,
        _proof_upgrade_client: Vec<u8>,
        _proof_upgrade_consensus_state: Vec<u8>,
    ) -> Result<(), Self::Error> {
        Err(Error::Unimplemented)
    }

    fn migrate_client_store(mut deps: DepsMut<Self::CustomQuery>) -> Result<(), Self::Error> {
        let subject_client_state: WasmClientState = read_subject_client_state(deps.as_ref())?;
        let substitute_client_state: WasmClientState = read_substitute_client_state(deps.as_ref())?;

        ensure(
            substitute_client_state.data.frozen_height == ZERO_HEIGHT,

Review comment (suggestion):
```suggestion
            // TODO(aeryz): this will be the finalized header when we implement justified
```

Code after:
                consensus_state.data.storage_root
                    == header.account_update.account_proof.storage_root,
                Error::StorageRootMismatch {
                    expected: consensus_state.data.storage_root,
                    found: header.account_update.account_proof.storage_root,
                },
            )?;

            ensure(
                consensus_state.data.slot == header.consensus_update.attested_header.beacon.slot,
                Error::SlotCannotBeModified,
            )?;

            // NOTE(aeryz): we don't check the timestamp here since it is calculated based on the
            // thn slot and we already check the slot.

            // NOTE(aeryz): we don't check the next sync committee because it's not being signed with
            // a header. so it should be an error during the state update not a misbehaviour.
        }

        Ok(false)
    }

    fn check_for_misbehaviour_on_misbehaviour(
        _deps: Deps<Self::CustomQuery>,
        misbehaviour: Self::Misbehaviour,
    ) -> Result<bool, Self::Error> {
        if misbehaviour.update_1.attested_header.beacon.slot
            == misbehaviour.update_2.attested_header.beacon.slot
        {
            // TODO(aeryz): this will be the finalized header when we implement justified
            // This ensures that there are no conflicting justified/finalized headers at the same height
            if misbehaviour.update_1.attested_header != misbehaviour.update_2.attested_header {
                return Ok(true);
            }
        }

        Ok(false)
    }

    fn verify_upgrade_and_update_state(
        _deps: DepsMut<Self::CustomQuery>,
        _upgrade_client_state: Self::ClientState,
        _upgrade_consensus_state: Self::ConsensusState,
        _proof_upgrade_client: Vec<u8>,
        _proof_upgrade_consensus_state: Vec<u8>,
    ) -> Result<(), Self::Error> {
        Err(Error::Unimplemented)
    }

    fn migrate_client_store(mut deps: DepsMut<Self::CustomQuery>) -> Result<(), Self::Error> {