Aggregated Seal

This document describes the generation process of the AggregatedSeal field in the block header's extraData field.

MAP Block Header Structure

The MAP block header contains the following fields:

// Header represents a block header in the Ethereum blockchain.
type Header struct {
	ParentHash  common.Hash    `json:"parentHash"       gencodec:"required"`
	Coinbase    common.Address `json:"miner"            gencodec:"required"`
	Root        common.Hash    `json:"stateRoot"        gencodec:"required"`
	TxHash      common.Hash    `json:"transactionsRoot" gencodec:"required"`
	ReceiptHash common.Hash    `json:"receiptsRoot"     gencodec:"required"`
	Bloom       Bloom          `json:"logsBloom"        gencodec:"required"`
	Number      *big.Int       `json:"number"           gencodec:"required"`
	GasLimit    uint64         `json:"gasLimit"         gencodec:"required"`
	GasUsed     uint64         `json:"gasUsed"          gencodec:"required"`
	Time        uint64         `json:"timestamp"        gencodec:"required"`
	Extra       []byte         `json:"extraData"        gencodec:"required"`
	MixDigest   common.Hash    `json:"mixHash"`
	Nonce       BlockNonce     `json:"nonce"`

	// BaseFee was added by EIP-1559 and is ignored in legacy headers.
	BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
}

The extraData field in the block header is the result of RLP encoding. The structure before encoding is as follows:

To obtain the structured information of extraData, you only need to RLP decode the bytes after the first 32 bytes of extraData. The specific decoding process can be found in the ExtractIstanbulExtra function:

Calculating Block Header Hash

Calculating the hash of a block header requires all fields in the block header. However, special attention must be paid to extraData, as its length affects the hash calculation method.

When extraData length is less than 32 bytes

The block header hash is simply the keccak256 hash of the RLP-encoded block header.

When extraData length is 32 bytes or more

Before calculating the hash, we first need to decode extraData and then set the AggregatedSeal field to empty. This specific operation can be found in the IstanbulFilteredHeader function below. After that, we perform a keccak256 hash on the RLP-encoded block header to obtain the block header hash.

Validator Broadcasting Commit Message

Validator nodes broadcast commit messages that carry CommittedSeal. The Signature field in AggregatedSeal is the result of aggregating all the CommittedSeal signatures from the collected commit messages.

Generating Committed Seal

  • sub.Digest: The hash of the block

  • sub.View.Round: The round number

Convert hash, round, MsgCommit into bytes and concatenate to get a simple seal. MsgCommit is a constant with value 2.

By concatenating the block header's hash, round, and a fixed MsgCommit, we get a simple seal. However, this is not enough because anyone can generate this seal. We also need to BLS sign the seal with the validator's private key to get the final committedSeal.

Creating Aggregated Seal

Put all the CommittedSeals from collected messages into a two-dimensional array. The first dimension stores the index of messages in the message list, and the second dimension stores the actual CommittedSeal. Then perform BLS aggregate signature on this two-dimensional array.

Appending Signature to Block Header's extraData Field

Last updated