Skip to main content

Reference

This document provides an overview of the core data structures used in Kwil's consensus algorithm.

Block

A Kwil block consists of a header, transactions and the signature.

FieldTypeDescription
HeaderBlockHeaderBlock header
TxnsTransactionList of transactions included in the block
Signature[]byteSignature of the block by the block proposer (leader)

Block Header

A BlockHeader contains metadata about the block, including its position in the blockchain, the previous block's hash, and other relevant information.

FieldTypeDescription
Versionuint16Version of the block
Heightint64Height of the block in the blockchain
NumTxnsuint32Number of transactions included in the block
PrevHashHashHash of the previous block
PrevAppHashHashApplication state hash from the execution of the previous block
Timestamptime.TimeTimestamp when the block was created
MerkleRootHashMerkle tree reference to hash of all transactions included in the block
ValidatorSetHashHashHash of the current validator set used in the current consensus round
NetworkParamsHashHashHash of the network parameters for the block
NewLeadercrypto.PublicKeyPublic key of the new leader if changed using non-transaction based approaches

CommitInfo

The CommitInfo contains details about the block's commit, including signed validators votes for the block. Before applying the block, nodes verify the CommitInfo to ensure the block and application state are valid and that a majority of validators agree with the leader on the block.

FieldTypeDescription
AppHashHashApplication state hash from the execution of the block
Votes[]*VoteInfoList of signed votes from validators
ParamUpdatesParamUpdatesUpdates to the network parameters, if any
ValidatorUpdates[]*ValidatorUpdates to the validator set, if any

VoteInfo

The VoteInfo represents the leader's interpretation of the AckRes vote received from the validator.

FieldTypeDescription
AckStatusAckStatusStatus of the acknowledgment (Agree, Reject, Forked)
AppHash*HashApplication state hash, provided only if AckStatus is AckStatusDiverged
SignatureSignatureSignature of the vote

AckStatus

The AckStatus represents the different statuses of the acknowledgment.

ValueDescription
AckRejectValidator did not accept the proposed block
AckAgreeValidator accepted the proposed block and computed the same AppHash
AckForkedValidator accepted the proposed block but diverged after processing it

Signature

The Signature structure contains the public key and the signature data of the validator.

FieldTypeDescription
PubKeyTypecrypto.KeyTypeType of the public key
PubKey[]bytePublic key of the validator
Data[]byteSignature data

Validator

The Validator structure represents a validator in the network.

FieldTypeDescription
Identifier[]bytePublic key of the validator
PubKeyTypecrypto.KeyTypeType of the public key
Powerint64Voting power of the validator