文件 1 的 12:AccessControl.sol
pragma solidity 0.8.9;
import "@openzeppelin/contracts-v4.4/access/IAccessControl.sol";
import "@openzeppelin/contracts-v4.4/utils/Context.sol";
import "@openzeppelin/contracts-v4.4/utils/Strings.sol";
import "@openzeppelin/contracts-v4.4/utils/introspection/ERC165.sol";
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
bytes32 private constant ROLES_POSITION = keccak256("openzeppelin.AccessControl._roles");
function _storageRoles() private pure returns (mapping(bytes32 => RoleData) storage _roles) {
bytes32 position = ROLES_POSITION;
assembly { _roles.slot := position }
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _storageRoles()[role].members[account];
}
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _storageRoles()[role].adminRole;
}
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_storageRoles()[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_storageRoles()[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_storageRoles()[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
文件 2 的 12:AccessControlEnumerable.sol
pragma solidity 0.8.9;
import "@openzeppelin/contracts-v4.4/access/IAccessControlEnumerable.sol";
import "@openzeppelin/contracts-v4.4/utils/structs/EnumerableSet.sol";
import "./AccessControl.sol";
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
bytes32 private constant ROLE_MEMBERS_POSITION = keccak256("openzeppelin.AccessControlEnumerable._roleMembers");
function _storageRoleMembers() private pure returns (
mapping(bytes32 => EnumerableSet.AddressSet) storage _roleMembers
) {
bytes32 position = ROLE_MEMBERS_POSITION;
assembly { _roleMembers.slot := position }
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
return _storageRoleMembers()[role].at(index);
}
function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
return _storageRoleMembers()[role].length();
}
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_storageRoleMembers()[role].add(account);
}
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_storageRoleMembers()[role].remove(account);
}
}
文件 3 的 12:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 4 的 12:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 5 的 12:EnumerableSet.sol
pragma solidity ^0.8.0;
library EnumerableSet {
struct Set {
bytes32[] _values;
mapping(bytes32 => uint256) _indexes;
}
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
function _remove(Set storage set, bytes32 value) private returns (bool) {
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
set._values[toDeleteIndex] = lastvalue;
set._indexes[lastvalue] = valueIndex;
}
set._values.pop();
delete set._indexes[value];
return true;
} else {
return false;
}
}
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
struct Bytes32Set {
Set _inner;
}
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
struct AddressSet {
Set _inner;
}
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
struct UintSet {
Set _inner;
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
文件 6 的 12:HashConsensus.sol
pragma solidity 0.8.9;
import { SafeCast } from "@openzeppelin/contracts-v4.4/utils/math/SafeCast.sol";
import { Math } from "../lib/Math.sol";
import { AccessControlEnumerable } from "../utils/access/AccessControlEnumerable.sol";
interface IReportAsyncProcessor {
function submitConsensusReport(bytes32 report, uint256 refSlot, uint256 deadline) external;
function discardConsensusReport(uint256 refSlot) external;
function getLastProcessingRefSlot() external view returns (uint256);
function getConsensusVersion() external view returns (uint256);
}
contract HashConsensus is AccessControlEnumerable {
using SafeCast for uint256;
error InvalidChainConfig();
error NumericOverflow();
error AdminCannotBeZero();
error ReportProcessorCannotBeZero();
error DuplicateMember();
error AddressCannotBeZero();
error InitialEpochIsYetToArrive();
error InitialEpochAlreadyArrived();
error InitialEpochRefSlotCannotBeEarlierThanProcessingSlot();
error EpochsPerFrameCannotBeZero();
error NonMember();
error UnexpectedConsensusVersion(uint256 expected, uint256 received);
error QuorumTooSmall(uint256 minQuorum, uint256 receivedQuorum);
error InvalidSlot();
error DuplicateReport();
error EmptyReport();
error StaleReport();
error NonFastLaneMemberCannotReportWithinFastLaneInterval();
error NewProcessorCannotBeTheSame();
error ConsensusReportAlreadyProcessing();
error FastLanePeriodCannotBeLongerThanFrame();
event FrameConfigSet(uint256 newInitialEpoch, uint256 newEpochsPerFrame);
event FastLaneConfigSet(uint256 fastLaneLengthSlots);
event MemberAdded(address indexed addr, uint256 newTotalMembers, uint256 newQuorum);
event MemberRemoved(address indexed addr, uint256 newTotalMembers, uint256 newQuorum);
event QuorumSet(uint256 newQuorum, uint256 totalMembers, uint256 prevQuorum);
event ReportReceived(uint256 indexed refSlot, address indexed member, bytes32 report);
event ConsensusReached(uint256 indexed refSlot, bytes32 report, uint256 support);
event ConsensusLost(uint256 indexed refSlot);
event ReportProcessorSet(address indexed processor, address indexed prevProcessor);
struct FrameConfig {
uint64 initialEpoch;
uint64 epochsPerFrame;
uint64 fastLaneLengthSlots;
}
struct ConsensusFrame {
uint256 index;
uint256 refSlot;
uint256 reportProcessingDeadlineSlot;
}
struct ReportingState {
uint64 lastReportRefSlot;
uint64 lastConsensusRefSlot;
uint64 lastConsensusVariantIndex;
}
struct MemberState {
uint64 lastReportRefSlot;
uint64 lastReportVariantIndex;
}
struct ReportVariant {
bytes32 hash;
uint64 support;
}
bytes32 public constant MANAGE_MEMBERS_AND_QUORUM_ROLE =
keccak256("MANAGE_MEMBERS_AND_QUORUM_ROLE");
bytes32 public constant DISABLE_CONSENSUS_ROLE = keccak256("DISABLE_CONSENSUS_ROLE");
bytes32 public constant MANAGE_FRAME_CONFIG_ROLE = keccak256("MANAGE_FRAME_CONFIG_ROLE");
bytes32 public constant MANAGE_FAST_LANE_CONFIG_ROLE = keccak256("MANAGE_FAST_LANE_CONFIG_ROLE");
bytes32 public constant MANAGE_REPORT_PROCESSOR_ROLE = keccak256("MANAGE_REPORT_PROCESSOR_ROLE");
uint64 internal immutable SLOTS_PER_EPOCH;
uint64 internal immutable SECONDS_PER_SLOT;
uint64 internal immutable GENESIS_TIME;
uint256 internal constant UNREACHABLE_QUORUM = type(uint256).max;
bytes32 internal constant ZERO_HASH = bytes32(0);
uint256 internal constant DEADLINE_SLOT_OFFSET = 0;
FrameConfig internal _frameConfig;
MemberState[] internal _memberStates;
address[] internal _memberAddresses;
mapping(address => uint256) internal _memberIndices1b;
ReportingState internal _reportingState;
uint256 internal _quorum;
mapping(uint256 => ReportVariant) internal _reportVariants;
uint256 internal _reportVariantsLength;
address internal _reportProcessor;
constructor(
uint256 slotsPerEpoch,
uint256 secondsPerSlot,
uint256 genesisTime,
uint256 epochsPerFrame,
uint256 fastLaneLengthSlots,
address admin,
address reportProcessor
) {
if (slotsPerEpoch == 0) revert InvalidChainConfig();
if (secondsPerSlot == 0) revert InvalidChainConfig();
SLOTS_PER_EPOCH = slotsPerEpoch.toUint64();
SECONDS_PER_SLOT = secondsPerSlot.toUint64();
GENESIS_TIME = genesisTime.toUint64();
if (admin == address(0)) revert AdminCannotBeZero();
if (reportProcessor == address(0)) revert ReportProcessorCannotBeZero();
_setupRole(DEFAULT_ADMIN_ROLE, admin);
uint256 farFutureEpoch = _computeEpochAtTimestamp(type(uint64).max);
_setFrameConfig(farFutureEpoch, epochsPerFrame, fastLaneLengthSlots, FrameConfig(0, 0, 0));
_reportProcessor = reportProcessor;
}
function getChainConfig() external view returns (
uint256 slotsPerEpoch,
uint256 secondsPerSlot,
uint256 genesisTime
) {
return (SLOTS_PER_EPOCH, SECONDS_PER_SLOT, GENESIS_TIME);
}
function getFrameConfig() external view returns (
uint256 initialEpoch,
uint256 epochsPerFrame,
uint256 fastLaneLengthSlots
) {
FrameConfig memory config = _frameConfig;
return (config.initialEpoch, config.epochsPerFrame, config.fastLaneLengthSlots);
}
function getCurrentFrame() external view returns (
uint256 refSlot,
uint256 reportProcessingDeadlineSlot
) {
ConsensusFrame memory frame = _getCurrentFrame();
return (frame.refSlot, frame.reportProcessingDeadlineSlot);
}
function getInitialRefSlot() external view returns (uint256) {
return _getInitialFrame().refSlot;
}
function updateInitialEpoch(uint256 initialEpoch) external onlyRole(DEFAULT_ADMIN_ROLE) {
FrameConfig memory prevConfig = _frameConfig;
if (_computeEpochAtTimestamp(_getTime()) >= prevConfig.initialEpoch) {
revert InitialEpochAlreadyArrived();
}
_setFrameConfig(
initialEpoch,
prevConfig.epochsPerFrame,
prevConfig.fastLaneLengthSlots,
prevConfig
);
if (_getInitialFrame().refSlot < _getLastProcessingRefSlot()) {
revert InitialEpochRefSlotCannotBeEarlierThanProcessingSlot();
}
}
function setFrameConfig(uint256 epochsPerFrame, uint256 fastLaneLengthSlots)
external onlyRole(MANAGE_FRAME_CONFIG_ROLE)
{
uint256 timestamp = _getTime();
uint256 currentFrameStartEpoch = _computeFrameStartEpoch(timestamp, _frameConfig);
_setFrameConfig(currentFrameStartEpoch, epochsPerFrame, fastLaneLengthSlots, _frameConfig);
}
function getIsMember(address addr) external view returns (bool) {
return _isMember(addr);
}
function getIsFastLaneMember(address addr) external view returns (bool) {
uint256 index1b = _memberIndices1b[addr];
unchecked {
return index1b > 0 && _isFastLaneMember(index1b - 1, _getCurrentFrame().index);
}
}
function getMembers() external view returns (
address[] memory addresses,
uint256[] memory lastReportedRefSlots
) {
return _getMembers(false);
}
function getFastLaneMembers() external view returns (
address[] memory addresses,
uint256[] memory lastReportedRefSlots
) {
return _getMembers(true);
}
function setFastLaneLengthSlots(uint256 fastLaneLengthSlots)
external onlyRole(MANAGE_FAST_LANE_CONFIG_ROLE)
{
_setFastLaneLengthSlots(fastLaneLengthSlots);
}
function addMember(address addr, uint256 quorum)
external
onlyRole(MANAGE_MEMBERS_AND_QUORUM_ROLE)
{
_addMember(addr, quorum);
}
function removeMember(address addr, uint256 quorum)
external
onlyRole(MANAGE_MEMBERS_AND_QUORUM_ROLE)
{
_removeMember(addr, quorum);
}
function getQuorum() external view returns (uint256) {
return _quorum;
}
function setQuorum(uint256 quorum) external {
_setQuorumAndCheckConsensus(quorum, _memberStates.length);
}
function disableConsensus() external {
_setQuorumAndCheckConsensus(UNREACHABLE_QUORUM, _memberStates.length);
}
function getReportProcessor() external view returns (address) {
return _reportProcessor;
}
function setReportProcessor(address newProcessor)
external
onlyRole(MANAGE_REPORT_PROCESSOR_ROLE)
{
_setReportProcessor(newProcessor);
}
function getConsensusState() external view returns (
uint256 refSlot,
bytes32 consensusReport,
bool isReportProcessing
) {
refSlot = _getCurrentFrame().refSlot;
(consensusReport,,) = _getConsensusReport(refSlot, _quorum);
isReportProcessing = _getLastProcessingRefSlot() == refSlot;
}
function getReportVariants() external view returns (
bytes32[] memory variants,
uint256[] memory support
) {
if (_reportingState.lastReportRefSlot != _getCurrentFrame().refSlot) {
return (variants, support);
}
uint256 variantsLength = _reportVariantsLength;
variants = new bytes32[](variantsLength);
support = new uint256[](variantsLength);
for (uint256 i = 0; i < variantsLength; ++i) {
ReportVariant memory variant = _reportVariants[i];
variants[i] = variant.hash;
support[i] = variant.support;
}
}
struct MemberConsensusState {
uint256 currentFrameRefSlot;
bytes32 currentFrameConsensusReport;
bool isMember;
bool isFastLane;
bool canReport;
uint256 lastMemberReportRefSlot;
bytes32 currentFrameMemberReport;
}
function getConsensusStateForMember(address addr)
external view returns (MemberConsensusState memory result)
{
ConsensusFrame memory frame = _getCurrentFrame();
result.currentFrameRefSlot = frame.refSlot;
(result.currentFrameConsensusReport,,) = _getConsensusReport(frame.refSlot, _quorum);
uint256 index = _memberIndices1b[addr];
result.isMember = index != 0;
if (index != 0) {
unchecked { --index; }
MemberState memory memberState = _memberStates[index];
result.lastMemberReportRefSlot = memberState.lastReportRefSlot;
result.currentFrameMemberReport =
result.lastMemberReportRefSlot == frame.refSlot
? _reportVariants[memberState.lastReportVariantIndex].hash
: ZERO_HASH;
uint256 slot = _computeSlotAtTimestamp(_getTime());
result.canReport = slot <= frame.reportProcessingDeadlineSlot &&
frame.refSlot > _getLastProcessingRefSlot();
result.isFastLane = _isFastLaneMember(index, frame.index);
if (!result.isFastLane && result.canReport) {
result.canReport = slot > frame.refSlot + _frameConfig.fastLaneLengthSlots;
}
}
}
function submitReport(uint256 slot, bytes32 report, uint256 consensusVersion) external {
_submitReport(slot, report, consensusVersion);
}
function _setFrameConfig(
uint256 initialEpoch,
uint256 epochsPerFrame,
uint256 fastLaneLengthSlots,
FrameConfig memory prevConfig
) internal {
if (epochsPerFrame == 0) revert EpochsPerFrameCannotBeZero();
if (fastLaneLengthSlots > epochsPerFrame * SLOTS_PER_EPOCH) {
revert FastLanePeriodCannotBeLongerThanFrame();
}
_frameConfig = FrameConfig(
initialEpoch.toUint64(),
epochsPerFrame.toUint64(),
fastLaneLengthSlots.toUint64()
);
if (initialEpoch != prevConfig.initialEpoch || epochsPerFrame != prevConfig.epochsPerFrame) {
emit FrameConfigSet(initialEpoch, epochsPerFrame);
}
if (fastLaneLengthSlots != prevConfig.fastLaneLengthSlots) {
emit FastLaneConfigSet(fastLaneLengthSlots);
}
}
function _getCurrentFrame() internal view returns (ConsensusFrame memory) {
return _getFrameAtTimestamp(_getTime(), _frameConfig);
}
function _getInitialFrame() internal view returns (ConsensusFrame memory) {
return _getFrameAtIndex(0, _frameConfig);
}
function _getFrameAtTimestamp(uint256 timestamp, FrameConfig memory config)
internal view returns (ConsensusFrame memory)
{
return _getFrameAtIndex(_computeFrameIndex(timestamp, config), config);
}
function _getFrameAtIndex(uint256 frameIndex, FrameConfig memory config)
internal view returns (ConsensusFrame memory)
{
uint256 frameStartEpoch = _computeStartEpochOfFrameWithIndex(frameIndex, config);
uint256 frameStartSlot = _computeStartSlotAtEpoch(frameStartEpoch);
uint256 nextFrameStartSlot = frameStartSlot + config.epochsPerFrame * SLOTS_PER_EPOCH;
return ConsensusFrame({
index: frameIndex,
refSlot: uint64(frameStartSlot - 1),
reportProcessingDeadlineSlot: uint64(nextFrameStartSlot - 1 - DEADLINE_SLOT_OFFSET)
});
}
function _computeFrameStartEpoch(uint256 timestamp, FrameConfig memory config)
internal view returns (uint256)
{
return _computeStartEpochOfFrameWithIndex(_computeFrameIndex(timestamp, config), config);
}
function _computeStartEpochOfFrameWithIndex(uint256 frameIndex, FrameConfig memory config)
internal pure returns (uint256)
{
return config.initialEpoch + frameIndex * config.epochsPerFrame;
}
function _computeFrameIndex(uint256 timestamp, FrameConfig memory config)
internal view returns (uint256)
{
uint256 epoch = _computeEpochAtTimestamp(timestamp);
if (epoch < config.initialEpoch) {
revert InitialEpochIsYetToArrive();
}
return (epoch - config.initialEpoch) / config.epochsPerFrame;
}
function _computeTimestampAtSlot(uint256 slot) internal view returns (uint256) {
return GENESIS_TIME + slot * SECONDS_PER_SLOT;
}
function _computeSlotAtTimestamp(uint256 timestamp) internal view returns (uint256) {
return (timestamp - GENESIS_TIME) / SECONDS_PER_SLOT;
}
function _computeEpochAtSlot(uint256 slot) internal view returns (uint256) {
return slot / SLOTS_PER_EPOCH;
}
function _computeEpochAtTimestamp(uint256 timestamp) internal view returns (uint256) {
return _computeEpochAtSlot(_computeSlotAtTimestamp(timestamp));
}
function _computeStartSlotAtEpoch(uint256 epoch) internal view returns (uint256) {
return epoch * SLOTS_PER_EPOCH;
}
function _getTime() internal virtual view returns (uint256) {
return block.timestamp;
}
function _isMember(address addr) internal view returns (bool) {
return _memberIndices1b[addr] != 0;
}
function _getMemberIndex(address addr) internal view returns (uint256) {
uint256 index1b = _memberIndices1b[addr];
if (index1b == 0) {
revert NonMember();
}
unchecked {
return uint256(index1b - 1);
}
}
function _addMember(address addr, uint256 quorum) internal {
if (_isMember(addr)) revert DuplicateMember();
if (addr == address(0)) revert AddressCannotBeZero();
_memberStates.push(MemberState(0, 0));
_memberAddresses.push(addr);
uint256 newTotalMembers = _memberStates.length;
_memberIndices1b[addr] = newTotalMembers;
emit MemberAdded(addr, newTotalMembers, quorum);
_setQuorumAndCheckConsensus(quorum, newTotalMembers);
}
function _removeMember(address addr, uint256 quorum) internal {
uint256 index = _getMemberIndex(addr);
uint256 newTotalMembers = _memberStates.length - 1;
assert(index <= newTotalMembers);
MemberState memory memberState = _memberStates[index];
if (index != newTotalMembers) {
address addrToMove = _memberAddresses[newTotalMembers];
_memberAddresses[index] = addrToMove;
_memberStates[index] = _memberStates[newTotalMembers];
_memberIndices1b[addrToMove] = index + 1;
}
_memberStates.pop();
_memberAddresses.pop();
_memberIndices1b[addr] = 0;
emit MemberRemoved(addr, newTotalMembers, quorum);
if (memberState.lastReportRefSlot > 0) {
ConsensusFrame memory frame = _getCurrentFrame();
if (memberState.lastReportRefSlot == frame.refSlot &&
_getLastProcessingRefSlot() < frame.refSlot
) {
--_reportVariants[memberState.lastReportVariantIndex].support;
}
}
_setQuorumAndCheckConsensus(quorum, newTotalMembers);
}
function _setFastLaneLengthSlots(uint256 fastLaneLengthSlots) internal {
FrameConfig memory frameConfig = _frameConfig;
if (fastLaneLengthSlots > frameConfig.epochsPerFrame * SLOTS_PER_EPOCH) {
revert FastLanePeriodCannotBeLongerThanFrame();
}
if (fastLaneLengthSlots != frameConfig.fastLaneLengthSlots) {
_frameConfig.fastLaneLengthSlots = fastLaneLengthSlots.toUint64();
emit FastLaneConfigSet(fastLaneLengthSlots);
}
}
function _getFastLaneSubset(uint256 frameIndex, uint256 totalMembers)
internal view returns (uint256 startIndex, uint256 pastEndIndex)
{
uint256 quorum = _quorum;
if (quorum >= totalMembers) {
startIndex = 0;
pastEndIndex = totalMembers;
} else {
startIndex = frameIndex % totalMembers;
pastEndIndex = startIndex + quorum;
}
}
function _isFastLaneMember(uint256 index, uint256 frameIndex) internal view returns (bool) {
uint256 totalMembers = _memberStates.length;
(uint256 flLeft, uint256 flPastRight) = _getFastLaneSubset(frameIndex, totalMembers);
unchecked {
return (
flPastRight != 0 &&
Math.pointInClosedIntervalModN(index, flLeft, flPastRight - 1, totalMembers)
);
}
}
function _getMembers(bool fastLane) internal view returns (
address[] memory addresses,
uint256[] memory lastReportedRefSlots
) {
uint256 totalMembers = _memberStates.length;
uint256 left;
uint256 right;
if (fastLane) {
(left, right) = _getFastLaneSubset(_getCurrentFrame().index, totalMembers);
} else {
right = totalMembers;
}
addresses = new address[](right - left);
lastReportedRefSlots = new uint256[](addresses.length);
for (uint256 i = left; i < right; ++i) {
uint256 iModTotal = i % totalMembers;
MemberState memory memberState = _memberStates[iModTotal];
uint256 k = i - left;
addresses[k] = _memberAddresses[iModTotal];
lastReportedRefSlots[k] = memberState.lastReportRefSlot;
}
}
function _submitReport(uint256 slot, bytes32 report, uint256 consensusVersion) internal {
if (slot == 0) revert InvalidSlot();
if (slot > type(uint64).max) revert NumericOverflow();
if (report == ZERO_HASH) revert EmptyReport();
uint256 memberIndex = _getMemberIndex(_msgSender());
MemberState memory memberState = _memberStates[memberIndex];
uint256 expectedConsensusVersion = _getConsensusVersion();
if (consensusVersion != expectedConsensusVersion) {
revert UnexpectedConsensusVersion(expectedConsensusVersion, consensusVersion);
}
uint256 timestamp = _getTime();
uint256 currentSlot = _computeSlotAtTimestamp(timestamp);
FrameConfig memory config = _frameConfig;
ConsensusFrame memory frame = _getFrameAtTimestamp(timestamp, config);
if (slot != frame.refSlot) revert InvalidSlot();
if (currentSlot > frame.reportProcessingDeadlineSlot) revert StaleReport();
if (currentSlot <= frame.refSlot + config.fastLaneLengthSlots &&
!_isFastLaneMember(memberIndex, frame.index)
) {
revert NonFastLaneMemberCannotReportWithinFastLaneInterval();
}
if (slot <= _getLastProcessingRefSlot()) {
if (slot == memberState.lastReportRefSlot) {
revert ConsensusReportAlreadyProcessing();
} else {
return;
}
}
uint256 variantsLength;
if (_reportingState.lastReportRefSlot != slot) {
_reportingState.lastReportRefSlot = uint64(slot);
variantsLength = 0;
} else {
variantsLength = _reportVariantsLength;
}
uint64 varIndex = 0;
bool prevConsensusLost = false;
while (varIndex < variantsLength && _reportVariants[varIndex].hash != report) {
++varIndex;
}
if (slot == memberState.lastReportRefSlot) {
uint64 prevVarIndex = memberState.lastReportVariantIndex;
assert(prevVarIndex < variantsLength);
if (varIndex == prevVarIndex) {
revert DuplicateReport();
} else {
uint256 support = --_reportVariants[prevVarIndex].support;
if (support == _quorum - 1) {
prevConsensusLost = true;
}
}
}
uint256 support;
if (varIndex < variantsLength) {
support = ++_reportVariants[varIndex].support;
} else {
support = 1;
_reportVariants[varIndex] = ReportVariant({hash: report, support: 1});
_reportVariantsLength = ++variantsLength;
}
_memberStates[memberIndex] = MemberState({
lastReportRefSlot: uint64(slot),
lastReportVariantIndex: varIndex
});
emit ReportReceived(slot, _msgSender(), report);
if (support >= _quorum) {
_consensusReached(frame, report, varIndex, support);
} else if (prevConsensusLost) {
_consensusNotReached(frame);
}
}
function _consensusReached(
ConsensusFrame memory frame,
bytes32 report,
uint256 variantIndex,
uint256 support
) internal {
if (_reportingState.lastConsensusRefSlot != frame.refSlot ||
_reportingState.lastConsensusVariantIndex != variantIndex
) {
_reportingState.lastConsensusRefSlot = uint64(frame.refSlot);
_reportingState.lastConsensusVariantIndex = uint64(variantIndex);
emit ConsensusReached(frame.refSlot, report, support);
_submitReportForProcessing(frame, report);
}
}
function _consensusNotReached(ConsensusFrame memory frame) internal {
if (_reportingState.lastConsensusRefSlot == frame.refSlot) {
_reportingState.lastConsensusRefSlot = 0;
emit ConsensusLost(frame.refSlot);
_cancelReportProcessing(frame);
}
}
function _setQuorumAndCheckConsensus(uint256 quorum, uint256 totalMembers) internal {
if (quorum <= totalMembers / 2) {
revert QuorumTooSmall(totalMembers / 2 + 1, quorum);
}
uint256 prevQuorum = _quorum;
if (quorum != prevQuorum) {
_checkRole(
quorum == UNREACHABLE_QUORUM ? DISABLE_CONSENSUS_ROLE : MANAGE_MEMBERS_AND_QUORUM_ROLE,
_msgSender()
);
_quorum = quorum;
emit QuorumSet(quorum, totalMembers, prevQuorum);
}
if (_computeEpochAtTimestamp(_getTime()) >= _frameConfig.initialEpoch) {
_checkConsensus(quorum);
}
}
function _checkConsensus(uint256 quorum) internal {
uint256 timestamp = _getTime();
ConsensusFrame memory frame = _getFrameAtTimestamp(timestamp, _frameConfig);
if (_computeSlotAtTimestamp(timestamp) > frame.reportProcessingDeadlineSlot) {
return;
}
if (_getLastProcessingRefSlot() >= frame.refSlot) {
return;
}
(bytes32 consensusReport, int256 consensusVariantIndex, uint256 support) =
_getConsensusReport(frame.refSlot, quorum);
if (consensusVariantIndex >= 0) {
_consensusReached(frame, consensusReport, uint256(consensusVariantIndex), support);
} else {
_consensusNotReached(frame);
}
}
function _getConsensusReport(uint256 currentRefSlot, uint256 quorum)
internal view returns (bytes32 report, int256 variantIndex, uint256 support)
{
if (_reportingState.lastReportRefSlot != currentRefSlot) {
return (ZERO_HASH, -1, 0);
}
uint256 variantsLength = _reportVariantsLength;
variantIndex = -1;
report = ZERO_HASH;
support = 0;
for (uint256 i = 0; i < variantsLength; ++i) {
uint256 iSupport = _reportVariants[i].support;
if (iSupport >= quorum) {
variantIndex = int256(i);
report = _reportVariants[i].hash;
support = iSupport;
break;
}
}
return (report, variantIndex, support);
}
function _setReportProcessor(address newProcessor) internal {
address prevProcessor = _reportProcessor;
if (newProcessor == address(0)) revert ReportProcessorCannotBeZero();
if (newProcessor == prevProcessor) revert NewProcessorCannotBeTheSame();
_reportProcessor = newProcessor;
emit ReportProcessorSet(newProcessor, prevProcessor);
ConsensusFrame memory frame = _getCurrentFrame();
uint256 lastConsensusRefSlot = _reportingState.lastConsensusRefSlot;
uint256 processingRefSlotPrev = IReportAsyncProcessor(prevProcessor).getLastProcessingRefSlot();
uint256 processingRefSlotNext = IReportAsyncProcessor(newProcessor).getLastProcessingRefSlot();
if (
processingRefSlotPrev < frame.refSlot &&
processingRefSlotNext < frame.refSlot &&
lastConsensusRefSlot == frame.refSlot
) {
bytes32 report = _reportVariants[_reportingState.lastConsensusVariantIndex].hash;
_submitReportForProcessing(frame, report);
}
}
function _getLastProcessingRefSlot() internal view returns (uint256) {
return IReportAsyncProcessor(_reportProcessor).getLastProcessingRefSlot();
}
function _submitReportForProcessing(ConsensusFrame memory frame, bytes32 report) internal {
IReportAsyncProcessor(_reportProcessor).submitConsensusReport(
report,
frame.refSlot,
_computeTimestampAtSlot(frame.reportProcessingDeadlineSlot)
);
}
function _cancelReportProcessing(ConsensusFrame memory frame) internal {
IReportAsyncProcessor(_reportProcessor).discardConsensusReport(frame.refSlot);
}
function _getConsensusVersion() internal view returns (uint256) {
return IReportAsyncProcessor(_reportProcessor).getConsensusVersion();
}
}
文件 7 的 12:IAccessControl.sol
pragma solidity ^0.8.0;
interface IAccessControl {
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
文件 8 的 12:IAccessControlEnumerable.sol
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
interface IAccessControlEnumerable is IAccessControl {
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
文件 9 的 12:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 10 的 12:Math.sol
pragma solidity 0.8.9;
library Math {
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function pointInHalfOpenIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n)
internal pure returns (bool)
{
return (x + n - a) % n < (b - a) % n;
}
function pointInClosedIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n)
internal pure returns (bool)
{
return (x + n - a) % n <= (b - a) % n;
}
}
文件 11 的 12:SafeCast.sol
pragma solidity ^0.8.0;
library SafeCast {
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
function toInt128(int256 value) internal pure returns (int128) {
require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
return int128(value);
}
function toInt64(int256 value) internal pure returns (int64) {
require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
return int64(value);
}
function toInt32(int256 value) internal pure returns (int32) {
require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
return int32(value);
}
function toInt16(int256 value) internal pure returns (int16) {
require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
return int16(value);
}
function toInt8(int256 value) internal pure returns (int8) {
require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
return int8(value);
}
function toInt256(uint256 value) internal pure returns (int256) {
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
文件 12 的 12:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
{
"compilationTarget": {
"contracts/0.8.9/oracle/HashConsensus.sol": "HashConsensus"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"slotsPerEpoch","type":"uint256"},{"internalType":"uint256","name":"secondsPerSlot","type":"uint256"},{"internalType":"uint256","name":"genesisTime","type":"uint256"},{"internalType":"uint256","name":"epochsPerFrame","type":"uint256"},{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"reportProcessor","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressCannotBeZero","type":"error"},{"inputs":[],"name":"AdminCannotBeZero","type":"error"},{"inputs":[],"name":"ConsensusReportAlreadyProcessing","type":"error"},{"inputs":[],"name":"DuplicateMember","type":"error"},{"inputs":[],"name":"DuplicateReport","type":"error"},{"inputs":[],"name":"EmptyReport","type":"error"},{"inputs":[],"name":"EpochsPerFrameCannotBeZero","type":"error"},{"inputs":[],"name":"FastLanePeriodCannotBeLongerThanFrame","type":"error"},{"inputs":[],"name":"InitialEpochAlreadyArrived","type":"error"},{"inputs":[],"name":"InitialEpochIsYetToArrive","type":"error"},{"inputs":[],"name":"InitialEpochRefSlotCannotBeEarlierThanProcessingSlot","type":"error"},{"inputs":[],"name":"InvalidChainConfig","type":"error"},{"inputs":[],"name":"InvalidSlot","type":"error"},{"inputs":[],"name":"NewProcessorCannotBeTheSame","type":"error"},{"inputs":[],"name":"NonFastLaneMemberCannotReportWithinFastLaneInterval","type":"error"},{"inputs":[],"name":"NonMember","type":"error"},{"inputs":[],"name":"NumericOverflow","type":"error"},{"inputs":[{"internalType":"uint256","name":"minQuorum","type":"uint256"},{"internalType":"uint256","name":"receivedQuorum","type":"uint256"}],"name":"QuorumTooSmall","type":"error"},{"inputs":[],"name":"ReportProcessorCannotBeZero","type":"error"},{"inputs":[],"name":"StaleReport","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"UnexpectedConsensusVersion","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refSlot","type":"uint256"}],"name":"ConsensusLost","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refSlot","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"report","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"support","type":"uint256"}],"name":"ConsensusReached","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"name":"FastLaneConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newInitialEpoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newEpochsPerFrame","type":"uint256"}],"name":"FrameConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTotalMembers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"MemberAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"newTotalMembers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"}],"name":"MemberRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newQuorum","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalMembers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"prevQuorum","type":"uint256"}],"name":"QuorumSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"processor","type":"address"},{"indexed":true,"internalType":"address","name":"prevProcessor","type":"address"}],"name":"ReportProcessorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"refSlot","type":"uint256"},{"indexed":true,"internalType":"address","name":"member","type":"address"},{"indexed":false,"internalType":"bytes32","name":"report","type":"bytes32"}],"name":"ReportReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DISABLE_CONSENSUS_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_FAST_LANE_CONFIG_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_FRAME_CONFIG_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_MEMBERS_AND_QUORUM_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_REPORT_PROCESSOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"quorum","type":"uint256"}],"name":"addMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableConsensus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getChainConfig","outputs":[{"internalType":"uint256","name":"slotsPerEpoch","type":"uint256"},{"internalType":"uint256","name":"secondsPerSlot","type":"uint256"},{"internalType":"uint256","name":"genesisTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConsensusState","outputs":[{"internalType":"uint256","name":"refSlot","type":"uint256"},{"internalType":"bytes32","name":"consensusReport","type":"bytes32"},{"internalType":"bool","name":"isReportProcessing","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getConsensusStateForMember","outputs":[{"components":[{"internalType":"uint256","name":"currentFrameRefSlot","type":"uint256"},{"internalType":"bytes32","name":"currentFrameConsensusReport","type":"bytes32"},{"internalType":"bool","name":"isMember","type":"bool"},{"internalType":"bool","name":"isFastLane","type":"bool"},{"internalType":"bool","name":"canReport","type":"bool"},{"internalType":"uint256","name":"lastMemberReportRefSlot","type":"uint256"},{"internalType":"bytes32","name":"currentFrameMemberReport","type":"bytes32"}],"internalType":"struct HashConsensus.MemberConsensusState","name":"result","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentFrame","outputs":[{"internalType":"uint256","name":"refSlot","type":"uint256"},{"internalType":"uint256","name":"reportProcessingDeadlineSlot","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFastLaneMembers","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"lastReportedRefSlots","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFrameConfig","outputs":[{"internalType":"uint256","name":"initialEpoch","type":"uint256"},{"internalType":"uint256","name":"epochsPerFrame","type":"uint256"},{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInitialRefSlot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getIsFastLaneMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getIsMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMembers","outputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"lastReportedRefSlots","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getQuorum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReportProcessor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReportVariants","outputs":[{"internalType":"bytes32[]","name":"variants","type":"bytes32[]"},{"internalType":"uint256[]","name":"support","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"quorum","type":"uint256"}],"name":"removeMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"name":"setFastLaneLengthSlots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"epochsPerFrame","type":"uint256"},{"internalType":"uint256","name":"fastLaneLengthSlots","type":"uint256"}],"name":"setFrameConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"quorum","type":"uint256"}],"name":"setQuorum","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newProcessor","type":"address"}],"name":"setReportProcessor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"slot","type":"uint256"},{"internalType":"bytes32","name":"report","type":"bytes32"},{"internalType":"uint256","name":"consensusVersion","type":"uint256"}],"name":"submitReport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"initialEpoch","type":"uint256"}],"name":"updateInitialEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"}]