BEP-221: CometBFT Light Block Validation #221
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BEP-221: CometBFT Light Block Validation.
1. Summary
This BEP introduces a new precompiled contract to validate the CometBFT light blocks.
2. Motivation
There are some cross-chain requirements between BSC and CometBFT-compatible blockchains, like the
BNB Greenfield
which is an important part of the BNB ecosystem, thus we need a gas-friendly solution to validate the light blocks from theCometBFT-compatible blockchains.
3. Specification
3.1 Consensus State
To validate the light blocks from the CometBFT-compatible blockchains, there should be a light client of the blockchain
on the BSC side, it could be implemented as a smart contract, and this light client should record the necessary
current state which we call it Consensus State to validate the future light blocks. The consensus state is defined as:
The consensus state should be encoded as a part of the precompiled contract's input, and after applying the light block,
the updated consensus state should be encoded as a part of the precompiled contract's output. The encoding format should be:
The
validator pubkey
andvoting power
are necessary for recovering the validator in the current validator set. Therelayer address
andrelayer bls pubkey
are extended to support some cross-chain infrastructure base on BLS,we can just pad zero bytes if we don't use
relayer address
orrelayer bls pubkey
.3.2 Light Block
A light block of CometBFT-compatible blockchain contains a SignedHeader and a ValidatorSet, which can be imported into
the CometBFT Light Client and update the light client's consensus state accordingly. The light block is defined as:
The light block itself has a Marshal method to convert it into a byte array, and it should be a part of the precompiled
contract's input. Within the precompiled contract, use the Unmarshal method to recover it.
3.3 Validate Light Block
The input of the precompiled contract should include the current consensus state and the future light block. The encoding
format should be:
Here are the steps to validate the light block within the precompiled contract:
The output of the precompiled contract should be encoded as follows:
4. License
The content is licensed under CC0.