Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AbstractConsensus

Git Source

Inherits: IConsensus, ERC165

Abstract implementation of IConsensus

State Variables

_EPOCH_LENGTH

The epoch length

uint256 internal immutable _EPOCH_LENGTH

_validOutputsMerkleRoots

Indexes accepted claims by application contract address.

mapping(address => mapping(bytes32 => bool)) private _validOutputsMerkleRoots

_numOfAcceptedClaims

Number of claims accepted by the consensus.

Must be monotonically non-decreasing in time

uint256 _numOfAcceptedClaims

Functions

constructor

Reverts if the epoch length is zero.

constructor(uint256 epochLength) ;

Parameters

NameTypeDescription
epochLengthuint256The epoch length

isOutputsMerkleRootValid

Check whether an outputs Merkle root is valid.

function isOutputsMerkleRootValid(address appContract, bytes32 outputsMerkleRoot)
    public
    view
    override
    returns (bool);

Parameters

NameTypeDescription
appContractaddressThe application contract address
outputsMerkleRootbytes32The outputs Merkle root

getEpochLength

Get the epoch length, in number of base layer blocks.

The epoch number of a block is defined as the integer division of the block number by the epoch length.

function getEpochLength() public view override returns (uint256);

getNumberOfAcceptedClaims

Get the number of claims accepted by the consensus.

function getNumberOfAcceptedClaims() external view override returns (uint256);

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(IERC165, ERC165)
    returns (bool);

_validateLastProcessedBlockNumber

Validate a last processed block number.

function _validateLastProcessedBlockNumber(uint256 lastProcessedBlockNumber)
    internal
    view;

Parameters

NameTypeDescription
lastProcessedBlockNumberuint256The number of the last processed block

_acceptClaim

Accept a claim.

Marks the outputsMerkleRoot as valid.

Emits a ClaimAccepted event.

function _acceptClaim(
    address appContract,
    uint256 lastProcessedBlockNumber,
    bytes32 outputsMerkleRoot
) internal;

Parameters

NameTypeDescription
appContractaddressThe application contract address
lastProcessedBlockNumberuint256The number of the last processed block
outputsMerkleRootbytes32The output Merkle root hash