---
eip: 7998
label: EIP-7998
title: Turn `randao_reveal` into a VRF
status: Draft
type: Standards Track
category: Core
created: 2025-08-03
official: https://eips.ethereum.org/EIPS/eip-7998
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7998.md
canonical: https://eips.huatuo.xyz/zh/eip-7998/
lang: zh
tldr: 让区块提议者的 `randao_reveal` 签署上一个 epoch 的 RANDAO mix 和 slot，而不再只签 epoch 编号，使其成为任何人都无法预先计算的、按 slot 生成的 BLS VRF。
tags: [consensus, randomness, randao, vrf, bls]
---

# EIP-7998: Turn `randao_reveal` into a VRF

> Transforms Ethereum’s `randao_reveal` into a per-slot BLS-based VRF by signing the previous epoch’s mix and current slot.

**TL;DR:** 让区块提议者的 `randao_reveal` 签署上一个 epoch 的 RANDAO mix 和 slot，而不再只签 epoch 编号，使其成为任何人都无法预先计算的、按 slot 生成的 BLS VRF。

## 它解决什么问题？

每个信标区块都包含一个 `randao_reveal`：提议者对当前 **epoch 编号**的 BLS 签名。它会被哈希进 RANDAO mix，协议将其用作链上随机数（合约通过 `PREVRANDAO` 读取）。

由于被签名的消息只是 epoch 编号，验证者可以提前算出自己所有未来的 reveal。这使得 reveal 无法作为每个提议者各自新鲜的随机值，也妨碍了那些需要每个提议者提供私密、不可预测值的设计，例如 Single Secret Leader Election（秘密提议者选举）；作者认为它能减少 MEV，并消除已知的 RANDAO 偏置攻击。

## 它如何运作

分叉之后，提议者签署的是一个新的 SSZ 容器，而不是 epoch：

```python
class RandaoRevealSeed(Container):
    previous_mix: Bytes32  # final RANDAO mix of the previous epoch
    slot: Slot             # current slot
```

- `previous_mix` 要等到上一个 epoch 结束后才知道，所以未来 epoch 的 reveal 无法提前计算，验证者自己也不行。
- `slot` 让每个 reveal 都唯一，即使同一个验证者在一个 epoch 中多次提议区块也是如此。

`process_randao` 中的验证仍然是针对提议者公钥的一次 `bls.Verify`，使用相同的 `DOMAIN_RANDAO`。reveal 仍然像以前一样混入 RANDAO mix。对某条消息的 BLS 签名是确定性且可验证的，因此无需单独的证明就可以充当 VRF（在计算性 Diffie-Hellman 假设下是安全的）。

作者选择*上一个* epoch 的 mix 而不是最新的 mix，因为如果以后把 reveal 用于 SSLE，使用最新的 mix 会造成分叉歧义。

## 示例代码

修改后的 `process_randao`（consensus-spec Python）：

```python
def process_randao(state: BeaconState, body: BeaconBlockBody) -> None:
    epoch = get_current_epoch(state)
    proposer = state.validators[get_beacon_proposer_index(state)]
    if epoch < FORK_EPOCH:
        signing_root = compute_signing_root(epoch, get_domain(state, DOMAIN_RANDAO))
    else:
        seed = RandaoRevealSeed(
            previous_mix=get_randao_mix(state, get_previous_epoch(state)),
            slot=state.slot,
        )
        signing_root = compute_signing_root(seed, get_domain(state, DOMAIN_RANDAO))
    assert bls.Verify(proposer.pubkey, signing_root, body.randao_reveal)

    mix = xor(get_randao_mix(state, epoch), hash(body.randao_reveal))
    state.randao_mixes[epoch % EPOCHS_PER_HISTORICAL_VECTOR] = mix
```

## 需要注意

- **状态：Draft。** 这是共识层的硬分叉变更；分叉之后签署旧消息的区块无效。
- 验证者客户端和远程签名器必须更新，改为签署 `RandaoRevealSeed` 而不是 epoch 编号。
- 在当前 epoch 内，reveal 对提议者自己仍然是可预测的；只有在秘密领导者选举或 [EIP-7956](/eip-7956/) 以它为基础时，slot 字段才有意义。
- reveal 没有可被"磨"（grind）的输入，但这个提案本身并不能消除 RANDAO 现有的"最后揭示者"偏置；那需要它所启用的后续设计。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7998
