pub async fn try_update_global_config(&mut self, want: &GlobalConfig) -> anyhow::Result<()> {
        let mut txn = self.storage.start_transaction().await?;
        let got = txn.consensus_dal().global_config().await?;
        if let Some(got) = &got {
            // Exit if the global config didn't change.
            if got == want {
                return Ok(());
            }
            verify_config_transition(got, want)?;

            // If genesis didn't change, just update the config.
            if got.genesis == want.genesis {
                let s = zksync_protobuf::serde::Serialize;
                let global_config = s.proto_fmt(want, serde_json::value::Serializer).unwrap();
                sqlx::query!(
                    r#"
                    UPDATE consensus_replica_state
                    SET
                        global_config = $1
                    "#,
                    global_config,
                )
                .instrument("try_update_global_config#UPDATE consensus_replica_state")
                .execute(&mut txn)
                .await?;
                txn.commit().await?;
                return Ok(());
            }
        }

        // Reset the consensus state.
        let s = zksync_protobuf::serde::Serialize;
        let global_config = s.proto_fmt(want, serde_json::value::Serializer).unwrap();
        let state = s
            .proto_fmt(
                &validator::ReplicaState::default(),
                serde_json::value::Serializer,
            )
            .unwrap();
        sqlx::query!(
            r#"
            DELETE FROM miniblocks_consensus
            "#
        )
        .instrument("try_update_genesis#DELETE FROM miniblock_consensus")
        .execute(&mut txn)
        .await?;
        sqlx::query!(
            r#"
            DELETE FROM consensus_replica_state
            "#
        )
        .instrument("try_update_genesis#DELETE FROM consensus_replica_state")
        .execute(&mut txn)
        .await?;
        sqlx::query!(
            r#"
            INSERT INTO
            consensus_replica_state (fake_key, global_config, state)
            VALUES
            (TRUE, $1, $2)
            "#,
            global_config,
            state,
        )
        .instrument("try_update_global_config#INSERT INTO consensus_replica_state")
        .execute(&mut txn)
        .await?;
        txn.commit().await?;
        Ok(())
    }
Attempts to update the global config.
Fails if the new genesis is invalid.
Fails if the new genesis has different `chain_id`.
Fails if the storage contains a newer genesis (higher fork number).
Noop if the new global config is the same as the current one.
Resets the stored consensus state otherwise and purges all certificates.
core/lib/dal/src/consensus_dal/mod.rs