Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Naming Suggestions #853

Open
wants to merge 1 commit into
base: consensus-fix-review
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions l2-contracts/contracts/ConsensusRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
return;
}

_ensureAttesterSnapshot(node);
_snapshotAttesterIfOutdated(node);
node.attesterLatest.active = false;
_ensureValidatorSnapshot(node);
_snapshotValidatorIfOutdated(node);
node.validatorLatest.active = false;

emit NodeDeactivated(_nodeOwner);
Expand All @@ -149,9 +149,9 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
return;
}

_ensureAttesterSnapshot(node);
_snapshotAttesterIfOutdated(node);
node.attesterLatest.active = true;
_ensureValidatorSnapshot(node);
_snapshotValidatorIfOutdated(node);
node.validatorLatest.active = true;

emit NodeActivated(_nodeOwner);
Expand All @@ -168,9 +168,9 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
return;
}

_ensureAttesterSnapshot(node);
_snapshotAttesterIfOutdated(node);
node.attesterLatest.removed = true;
_ensureValidatorSnapshot(node);
_snapshotValidatorIfOutdated(node);
node.validatorLatest.removed = true;

emit NodeRemoved(_nodeOwner);
Expand All @@ -188,7 +188,7 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
return;
}

_ensureValidatorSnapshot(node);
_snapshotValidatorIfOutdated(node);
node.validatorLatest.weight = _weight;

emit NodeValidatorWeightChanged(_nodeOwner, _weight);
Expand All @@ -206,7 +206,7 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
return;
}

_ensureAttesterSnapshot(node);
_snapshotAttesterIfOutdated(node);
node.attesterLatest.weight = _weight;

emit NodeAttesterWeightChanged(_nodeOwner, _weight);
Expand Down Expand Up @@ -236,7 +236,7 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
bytes32 newHash = _hashValidatorPubKey(_pubKey);
_verifyValidatorPubKeyDoesNotExist(newHash);
validatorPubKeyHashes[newHash] = true;
_ensureValidatorSnapshot(node);
_snapshotValidatorIfOutdated(node);
node.validatorLatest.pubKey = _pubKey;
node.validatorLatest.proofOfPossession = _pop;

Expand Down Expand Up @@ -265,7 +265,7 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
_verifyAttesterPubKeyDoesNotExist(newHash);
attesterPubKeyHashes[newHash] = true;

_ensureAttesterSnapshot(node);
_snapshotAttesterIfOutdated(node);
node.attesterLatest.pubKey = _pubKey;

emit NodeAttesterKeyChanged(_nodeOwner, _pubKey);
Expand Down Expand Up @@ -386,21 +386,21 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
emit NodeDeleted(_nodeOwner);
}

function _ensureAttesterSnapshot(Node storage _node) private {
function _snapshotAttesterIfOutdated(Node storage _node) private {
if (_node.attesterLastUpdateCommit < attestersCommit) {
_node.attesterSnapshot = _node.attesterLatest;
_node.attesterLastUpdateCommit = attestersCommit;
}
}

function _ensureValidatorSnapshot(Node storage _node) private {
function _snapshotValidatorIfOutdated(Node storage _node) private {
if (_node.validatorLastUpdateCommit < validatorsCommit) {
_node.validatorSnapshot = _node.validatorLatest;
_node.validatorLastUpdateCommit = validatorsCommit;
}
}

function _isNodeOwnerExists(address _nodeOwner) private view returns (bool) {
function _doesNodeOwnerExist(address _nodeOwner) private view returns (bool) {
BLS12_381PublicKey storage pubKey = nodes[_nodeOwner].validatorLatest.pubKey;
if (pubKey.a == bytes32(0) && pubKey.b == bytes32(0) && pubKey.c == bytes32(0)) {
return false;
Expand All @@ -409,13 +409,13 @@ contract ConsensusRegistry is IConsensusRegistry, Initializable, Ownable2StepUpg
}

function _verifyNodeOwnerExists(address _nodeOwner) private view {
if (!_isNodeOwnerExists(_nodeOwner)) {
if (!_doesNodeOwnerExist(_nodeOwner)) {
revert NodeOwnerDoesNotExist();
}
}

function _verifyNodeOwnerDoesNotExist(address _nodeOwner) private view {
if (_isNodeOwnerExists(_nodeOwner)) {
if (_doesNodeOwnerExist(_nodeOwner)) {
revert NodeOwnerExists();
}
}
Expand Down
Loading