IConsensusRegistry

Git Source

Author: Matter Labs

Note: security-contact: security@matterlabs.dev

Functions

add

function add(
  address _nodeOwner,
  uint32 _validatorWeight,
  BLS12_381PublicKey calldata _validatorPubKey,
  BLS12_381Signature calldata _validatorPoP,
  uint32 _attesterWeight,
  Secp256k1PublicKey calldata _attesterPubKey
) external;

deactivate

function deactivate(address _nodeOwner) external;

activate

function activate(address _nodeOwner) external;

remove

function remove(address _nodeOwner) external;

changeValidatorWeight

function changeValidatorWeight(address _nodeOwner, uint32 _weight) external;

changeAttesterWeight

function changeAttesterWeight(address _nodeOwner, uint32 _weight) external;

changeValidatorKey

function changeValidatorKey(
  address _nodeOwner,
  BLS12_381PublicKey calldata _pubKey,
  BLS12_381Signature calldata _pop
) external;

changeAttesterKey

function changeAttesterKey(
  address _nodeOwner,
  Secp256k1PublicKey calldata _pubKey
) external;

commitAttesterCommittee

function commitAttesterCommittee() external;

commitValidatorCommittee

function commitValidatorCommittee() external;

getAttesterCommittee

function getAttesterCommittee()
  external
  view
  returns (CommitteeAttester[] memory);

getValidatorCommittee

function getValidatorCommittee()
  external
  view
  returns (CommitteeValidator[] memory);

Events

NodeAdded

event NodeAdded(
  address indexed nodeOwner,
  uint32 validatorWeight,
  BLS12_381PublicKey validatorPubKey,
  BLS12_381Signature validatorPoP,
  uint32 attesterWeight,
  Secp256k1PublicKey attesterPubKey
);

NodeDeactivated

event NodeDeactivated(address indexed nodeOwner);

NodeActivated

event NodeActivated(address indexed nodeOwner);

NodeRemoved

event NodeRemoved(address indexed nodeOwner);

NodeDeleted

event NodeDeleted(address indexed nodeOwner);

NodeValidatorWeightChanged

event NodeValidatorWeightChanged(address indexed nodeOwner, uint32 newWeight);

NodeAttesterWeightChanged

event NodeAttesterWeightChanged(address indexed nodeOwner, uint32 newWeight);

NodeValidatorKeyChanged

event NodeValidatorKeyChanged(
  address indexed nodeOwner,
  BLS12_381PublicKey newPubKey,
  BLS12_381Signature newPoP
);

NodeAttesterKeyChanged

event NodeAttesterKeyChanged(
  address indexed nodeOwner, Secp256k1PublicKey newPubKey
);

ValidatorsCommitted

event ValidatorsCommitted(uint32 commit);

AttestersCommitted

event AttestersCommitted(uint32 commit);

Errors

UnauthorizedOnlyOwnerOrNodeOwner

error UnauthorizedOnlyOwnerOrNodeOwner();

NodeOwnerExists

error NodeOwnerExists();

NodeOwnerDoesNotExist

error NodeOwnerDoesNotExist();

NodeOwnerNotFound

error NodeOwnerNotFound();

ValidatorPubKeyExists

error ValidatorPubKeyExists();

AttesterPubKeyExists

error AttesterPubKeyExists();

InvalidInputNodeOwnerAddress

error InvalidInputNodeOwnerAddress();

InvalidInputBLS12_381PublicKey

error InvalidInputBLS12_381PublicKey();

InvalidInputBLS12_381Signature

error InvalidInputBLS12_381Signature();

InvalidInputSecp256k1PublicKey

error InvalidInputSecp256k1PublicKey();

Structs

Node

Represents a consensus node.

struct Node {
  uint32 attesterLastUpdateCommit;
  uint32 validatorLastUpdateCommit;
  uint32 nodeOwnerIdx;
  AttesterAttr attesterLatest;
  AttesterAttr attesterSnapshot;
  ValidatorAttr validatorLatest;
  ValidatorAttr validatorSnapshot;
}

Properties

NameTypeDescription
attesterLastUpdateCommituint32The latest attestersCommit where the node's attester attributes were updated.
validatorLastUpdateCommituint32The latest validatorsCommit where the node's validator attributes were updated.
nodeOwnerIdxuint32Index of the node owner within the array of node owners.
attesterLatestAttesterAttrAttester attributes to read if node.attesterLastUpdateCommit < attestersCommit.
attesterSnapshotAttesterAttrAttester attributes to read if node.attesterLastUpdateCommit == attestersCommit.
validatorLatestValidatorAttrValidator attributes to read if node.validatorLastUpdateCommit < validatorsCommit.
validatorSnapshotValidatorAttrValidator attributes to read if node.validatorLastUpdateCommit == validatorsCommit.

AttesterAttr

Represents the attester attributes of a consensus node.

struct AttesterAttr {
  bool active;
  bool removed;
  uint32 weight;
  Secp256k1PublicKey pubKey;
}

Properties

NameTypeDescription
activeboolA flag stating if the attester is active.
removedboolA flag stating if the attester has been removed (and is pending a deletion).
weightuint32Attester's voting weight.
pubKeySecp256k1PublicKeyAttester's Secp256k1 public key.

CommitteeAttester

Represents an attester within a committee.

struct CommitteeAttester {
  uint32 weight;
  Secp256k1PublicKey pubKey;
}

Properties

NameTypeDescription
weightuint32Attester's voting weight.
pubKeySecp256k1PublicKeyAttester's Secp256k1 public key.

ValidatorAttr

Represents the validator attributes of a consensus node.

struct ValidatorAttr {
  bool active;
  bool removed;
  uint32 weight;
  BLS12_381PublicKey pubKey;
  BLS12_381Signature proofOfPossession;
}

Properties

NameTypeDescription
activeboolA flag stating if the validator is active.
removedboolA flag stating if the validator has been removed (and is pending a deletion).
weightuint32Validator's voting weight.
pubKeyBLS12_381PublicKeyValidator's BLS12-381 public key.
proofOfPossessionBLS12_381SignatureValidator's Proof-of-possession (a signature over the public key).

CommitteeValidator

Represents a validator within a committee.

struct CommitteeValidator {
  uint32 weight;
  BLS12_381PublicKey pubKey;
  BLS12_381Signature proofOfPossession;
}

Properties

NameTypeDescription
weightuint32Validator's voting weight.
pubKeyBLS12_381PublicKeyValidator's BLS12-381 public key.
proofOfPossessionBLS12_381SignatureValidator's Proof-of-possession (a signature over the public key).

BLS12_381PublicKey

Represents BLS12_381 public key.

struct BLS12_381PublicKey {
  bytes32 a;
  bytes32 b;
  bytes32 c;
}

Properties

NameTypeDescription
abytes32First component of the BLS12-381 public key.
bbytes32Second component of the BLS12-381 public key.
cbytes32Third component of the BLS12-381 public key.

BLS12_381Signature

Represents BLS12_381 signature.

struct BLS12_381Signature {
  bytes32 a;
  bytes16 b;
}

Properties

NameTypeDescription
abytes32First component of the BLS12-381 signature.
bbytes16Second component of the BLS12-381 signature.

Secp256k1PublicKey

Represents Secp256k1 public key.

struct Secp256k1PublicKey {
  bytes1 tag;
  bytes32 x;
}

Properties

NameTypeDescription
tagbytes1Y-coordinate's even/odd indicator of the Secp256k1 public key.
xbytes32X-coordinate component of the Secp256k1 public key.