Skip to content

Commit 72a20c2

Browse files
authored
Use old validator set nonce instead of latest nonce. (#121)
* Use old validator set nonce instead of latest nonce. * Update go wrapper.
1 parent 210a1fb commit 72a20c2

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

src/QuantumGravityBridge.sol

+5-2
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,15 @@ contract QuantumGravityBridge is IDAOracle {
243243
///
244244
/// The validator set hash that is signed over is domain separated as per
245245
/// `domainSeparateValidatorSetHash`.
246-
/// @param _newValidatorSetHash The hash of the new validator set.
247246
/// @param _newNonce The new event nonce.
247+
/// @param _oldNonce The nonce of the latest update to the validator set.
248+
/// @param _newPowerThreshold At least this much power must have signed.
249+
/// @param _newValidatorSetHash The hash of the new validator set.
248250
/// @param _currentValidatorSet The current validator set.
249251
/// @param _sigs Signatures.
250252
function updateValidatorSet(
251253
uint256 _newNonce,
254+
uint256 _oldNonce,
252255
uint256 _newPowerThreshold,
253256
bytes32 _newValidatorSetHash,
254257
Validator[] calldata _currentValidatorSet,
@@ -272,7 +275,7 @@ contract QuantumGravityBridge is IDAOracle {
272275
// Check that the supplied current validator set matches the saved checkpoint.
273276
bytes32 currentValidatorSetHash = computeValidatorSetHash(_currentValidatorSet);
274277
if (
275-
domainSeparateValidatorSetHash(BRIDGE_ID, currentNonce, currentPowerThreshold, currentValidatorSetHash) !=
278+
domainSeparateValidatorSetHash(BRIDGE_ID, _oldNonce, currentPowerThreshold, currentValidatorSetHash) !=
276279
state_lastValidatorSetCheckpoint
277280
) {
278281
revert SuppliedValidatorSetInvalid();

src/test/QuantumGravityBridge.t.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ contract RelayerTest is DSTest {
4747
}
4848

4949
function testUpdateValidatorSet() public {
50+
uint256 initialVelsetNonce = 0;
51+
5052
// Save the old test validator set before we add to it.
5153
Validator[] memory oldVS = new Validator[](1);
5254
oldVS[0] = Validator(cheats.addr(testPriv1), votingPower);
@@ -64,7 +66,7 @@ contract RelayerTest is DSTest {
6466
(uint8 v, bytes32 r, bytes32 s) = cheats.sign(testPriv1, digest_eip191);
6567
sigs[0] = Signature(v, r, s);
6668

67-
bridge.updateValidatorSet(newNonce, newPowerThreshold, newVSHash, oldVS, sigs);
69+
bridge.updateValidatorSet(newNonce, initialVelsetNonce, newPowerThreshold, newVSHash, oldVS, sigs);
6870

6971
assertEq(bridge.state_eventNonce(), newNonce);
7072
assertEq(bridge.state_powerThreshold(), newPowerThreshold);

0 commit comments

Comments
 (0)