AbstractConsensus

Git Source

Inherits: IConsensus, ERC165

Abstract implementation of IConsensus

State Variables

_epochLength

The epoch length

uint256 private immutable _epochLength;

_validOutputsMerkleRoots

Indexes accepted claims by application contract address.

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

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);

supportsInterface

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

_acceptClaim

Accept a claim.

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