pub async fn insert_block_certificate(
        &mut self,
        cert: &BlockCertificate,
    ) -> Result<(), InsertCertificateError> {
        use InsertCertificateError as E;

        // Extract block number and payload hash based on certificate variant
        let block_number = cert.number();
        let payload_hash = cert.payload_hash();

        let want_payload = self
            .block_payload(block_number)
            .await?
            .ok_or(E::MissingPayload)?;

        if payload_hash != want_payload.encode().hash() {
            return Err(E::PayloadMismatch(want_payload));
        }

        sqlx::query!(
            r#"
            INSERT INTO
            miniblocks_consensus (number, versioned_certificate)
            VALUES
            ($1, $2)
            "#,
            i64::try_from(block_number.0).context("overflow")?,
            zksync_protobuf::serde::Serialize
                .proto_fmt(cert, serde_json::value::Serializer)
                .unwrap(),
        )
        .instrument("insert_block_certificate")
        .report_latency()
        .execute(self.storage)
        .await?;

        Ok(())
    }
Inserts a certificate for the L2 block `cert.header().number`.
Fails if certificate doesn't match the stored block.
core/lib/dal/src/consensus_dal/mod.rs