Skip to content

Commit 5b2dd58

Browse files
authored
chore: consistently load the state variables at the beginning of functions (#211)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview Closes #203 ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [ ] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [ ] Linked issues closed with keywords
1 parent 22b310c commit 5b2dd58

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/QuantumGravityBridge.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ contract QuantumGravityBridge is IDAOracle, Initializable, UUPSUpgradeable, Owna
252252

253253
uint256 currentNonce = state_eventNonce;
254254
uint256 currentPowerThreshold = state_powerThreshold;
255+
bytes32 lastValidatorSetCheckpoint = state_lastValidatorSetCheckpoint;
255256

256257
// Check that the new nonce is one more than the current one.
257258
if (_newNonce != currentNonce + 1) {
@@ -267,7 +268,7 @@ contract QuantumGravityBridge is IDAOracle, Initializable, UUPSUpgradeable, Owna
267268
bytes32 currentValidatorSetHash = computeValidatorSetHash(_currentValidatorSet);
268269
if (
269270
domainSeparateValidatorSetHash(_oldNonce, currentPowerThreshold, currentValidatorSetHash)
270-
!= state_lastValidatorSetCheckpoint
271+
!= lastValidatorSetCheckpoint
271272
) {
272273
revert SuppliedValidatorSetInvalid();
273274
}
@@ -316,6 +317,7 @@ contract QuantumGravityBridge is IDAOracle, Initializable, UUPSUpgradeable, Owna
316317

317318
uint256 currentNonce = state_eventNonce;
318319
uint256 currentPowerThreshold = state_powerThreshold;
320+
bytes32 lastValidatorSetCheckpoint = state_lastValidatorSetCheckpoint;
319321

320322
// Check that the new nonce is one more than the current one.
321323
if (_newNonce != currentNonce + 1) {
@@ -331,7 +333,7 @@ contract QuantumGravityBridge is IDAOracle, Initializable, UUPSUpgradeable, Owna
331333
bytes32 currentValidatorSetHash = computeValidatorSetHash(_currentValidatorSet);
332334
if (
333335
domainSeparateValidatorSetHash(_validatorSetNonce, currentPowerThreshold, currentValidatorSetHash)
334-
!= state_lastValidatorSetCheckpoint
336+
!= lastValidatorSetCheckpoint
335337
) {
336338
revert SuppliedValidatorSetInvalid();
337339
}

0 commit comments

Comments
 (0)