> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# getAgGenesisCert

> getAgGenesisCert 返回 Alpenglow 创世证书；如果集群仍在运行 TowerBFT，则返回 null。可使用此方法检查 Alpenglow 共识是否已启用。

<Note>
  需要 Agave v4.3 或更高版本。更早的版本无法识别此方法，并会
  返回 `Method not found` (-32601)。
</Note>

## 检测迁移状态

使用此方法检查集群是否运行 [Alpenglow](https://www.helius.dev/blog/alpenglow) 共识。响应有以下三种形式：

* **证书对象。** 集群已完成迁移。`result.block.slot` 是 Alpenglow 下生成的第一个槽位。
* **`null`。** 节点运行 Agave v4.3 或更高版本，但集群尚未迁移。
* **错误 `-32601`。** 节点版本早于 v4.3。集群的共识状态未知。

应将 `-32601` 视为“未知”，而不是“尚未迁移”。无法回答此问题的节点无法说明集群的状态。

集群迁移后，证书不会改变。首次收到成功响应后应缓存证书，而不是持续轮询。

## 读取证书

`block` 标识已认证的区块。`slot` 是其槽位编号。`blockId` 是一个 32 字节数组，而不是 RPC API 其他位置使用的 base-58 字符串。

`signature` 包含所有签署该证书的验证者的聚合 BLS 签名。`bitmap` 记录这些验证者，并按质押排名建立索引。读取该位图时，需要使用集群当时采用的同一份按质押量排序的验证者列表。

`blockId` 始终为 32 字节，`signature` 始终为 192 字节，示例中二者均以完整长度显示。`bitmap` 没有固定大小：它为每个验证者分配一位，因此会随验证者集合的增大而增长，示例中展示的是一个较短的位图。

Solana CLI 通过 `solana alpenglow-genesis-info` 返回相同的数据。


## OpenAPI

````yaml zh/openapi/rpc-http/getAgGenesisCert.yaml POST /
openapi: 3.1.0
info:
  title: Solana RPC API
  version: 1.0.0
  description: >-
    共识迁移 API，用于检索 Alpenglow 创世证书，即基于 Alpenglow 共识生成的第一个区块的证书，以检测集群是否已从 TowerBFT
    迁移。
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://mainnet.helius-rpc.com
    description: 主网 RPC 端点
  - url: https://devnet.helius-rpc.com
    description: 开发网 RPC 端点
security: []
paths:
  /:
    post:
      tags:
        - RPC
      summary: getAgGenesisCert
      description: >
        检索 Alpenglow 创世证书，即集群基于 Alpenglow 共识生成的第一个区块的证书；如果集群仍在运行 TowerBFT，则返回
        `null`。

        这是运行时检测 Alpenglow 共识是否已启用的受支持方式，无需根据验证者版本或槽位编号进行推断。该证书包含

        经认证的区块（其槽位和 32 字节区块 ID）、签署该证书的验证者的聚合 BLS 签名，

        以及用于标识哪些验证者完成签署并按质押排名排序的位图。

        需要 Agave v4.3 或更高版本；早期版本无法识别此方法，并会返回

        `Method not found` (-32601)，而不是 `null`。
      operationId: getAgGenesisCert
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  description: JSON-RPC 协议版本。
                  enum:
                    - '2.0'
                  example: '2.0'
                  default: '2.0'
                id:
                  type: string
                  description: 请求的唯一标识符。
                  example: '1'
                  default: '1'
                method:
                  type: string
                  description: 要调用的 RPC 方法名称。
                  enum:
                    - getAgGenesisCert
                  example: getAgGenesisCert
                  default: getAgGenesisCert
      responses:
        '200':
          description: 已成功检索 Alpenglow 创世证书；如果集群尚未迁移，则返回 `null`。
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: JSON-RPC 协议版本。
                    enum:
                      - '2.0'
                    example: '2.0'
                  id:
                    type: string
                    description: 与请求匹配的标识符。
                    example: '1'
                  result:
                    type: object
                    nullable: true
                    description: Alpenglow 创世证书；当集群仍在运行 TowerBFT 时为 `null`。
                    properties:
                      block:
                        type: object
                        description: 经认证的第一个 Alpenglow 区块。
                        properties:
                          slot:
                            type: integer
                            format: uint64
                            description: 基于 Alpenglow 共识生成的第一个区块的槽位。
                            example: 412300800
                          blockId:
                            type: array
                            description: 区块标识符，以字节数组表示。始终为 32 字节。
                            minItems: 32
                            maxItems: 32
                            items:
                              type: integer
                              minimum: 0
                              maximum: 255
                      signature:
                        type: object
                        description: 经认证区块的验证者聚合签名。
                        properties:
                          signature:
                            type: array
                            description: 签署该证书的所有验证者的聚合 BLS 签名，以字节数组表示。始终为 192 字节。
                            minItems: 192
                            maxItems: 192
                            items:
                              type: integer
                              minimum: 0
                              maximum: 255
                          bitmap:
                            type: array
                            description: >-
                              用于标记哪些验证者完成签署的位图，按质押排名位置编制索引。长度可变，每个验证者对应一位，因此会随验证者集合增大。
                            items:
                              type: integer
                              minimum: 0
                              maximum: 255
        '400':
          description: 错误请求 - 请求参数无效或请求格式错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: 参数无效
        '401':
          description: 未授权 - API 密钥无效或缺失。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32001
                  message: 未授权
                id: '1'
        '429':
          description: 请求过多 - 已超出速率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32005
                  message: 请求过多
                id: '1'
        '500':
          description: 服务器内部错误 - 服务器发生错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32603
                  message: 内部错误
                id: '1'
        '503':
          description: 服务不可用 - 服务暂时不可用。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32002
                  message: 服务不可用
                id: '1'
        '504':
          description: 网关超时 - 请求超时。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32003
                  message: 网关超时
                id: '1'
      security:
        - ApiKeyQuery: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        jsonrpc:
          type: string
          description: JSON-RPC 协议版本。
          enum:
            - '2.0'
          example: '2.0'
        error:
          type: object
          properties:
            code:
              type: integer
              description: 错误代码。
              example: -32602
            message:
              type: string
              description: 错误消息。
            data:
              type: object
              description: 有关错误的其他数据。
        id:
          type: string
          description: 与请求匹配的标识符。
          example: '1'
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: >-
        你的 Helius API
        密钥。你可以在[控制面板](https://dashboard.helius.dev/api-keys)中免费获取一个。

````