From a686dfabbf827386c44f9c693e4bce491604fbf3 Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Wed, 31 Jan 2024 06:40:17 +0100 Subject: [PATCH 1/2] Permit non-consecutive increases in validator set Changes the validator set successions to still be sequential, but non-consecutive. For bridge security against collusion by validators, it's important that these validators are still bonded, but the timing of the signature itself is secondary. As such, even if some validators have rotated out, this change permits keeping the bridge alive so long as 2/3rds of the `currentValidatorSet` are still bonded and sign the commitment. Co-authored-by: bhargavbh <2bhargav5@gmail.com> Co-authored-by: Alistair Stewart --- contracts/src/BeefyClient.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/src/BeefyClient.sol b/contracts/src/BeefyClient.sol index eeb27bfc42..072578af79 100644 --- a/contracts/src/BeefyClient.sol +++ b/contracts/src/BeefyClient.sol @@ -345,7 +345,7 @@ contract BeefyClient { bool is_next_session = false; ValidatorSetState storage vset; - if (commitment.validatorSetID == nextValidatorSet.id) { + if (commitment.validatorSetID > currentValidatorSet.id) { is_next_session = true; vset = nextValidatorSet; } else if (commitment.validatorSetID == currentValidatorSet.id) { @@ -359,7 +359,7 @@ contract BeefyClient { bytes32 newMMRRoot = ensureProvidesMMRRoot(commitment); if (is_next_session) { - if (leaf.nextAuthoritySetID != nextValidatorSet.id + 1) { + if (leaf.nextAuthoritySetID <= nextValidatorSet.id) { revert InvalidMMRLeaf(); } bool leafIsValid = From a223f97a2c21f14a83aa9786644f9e81f94c1fce Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Wed, 31 Jan 2024 17:01:32 +0100 Subject: [PATCH 2/2] adjust submitInitial too Co-authored-by: bhargavbh <2bhargav5@gmail.com> --- contracts/src/BeefyClient.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/BeefyClient.sol b/contracts/src/BeefyClient.sol index 072578af79..1ed214d7f9 100644 --- a/contracts/src/BeefyClient.sol +++ b/contracts/src/BeefyClient.sol @@ -253,7 +253,7 @@ contract BeefyClient { signatureUsageCount = currentValidatorSet.usageCounters.get(proof.index); currentValidatorSet.usageCounters.set(proof.index, signatureUsageCount.saturatingAdd(1)); vset = currentValidatorSet; - } else if (commitment.validatorSetID == nextValidatorSet.id) { + } else if (commitment.validatorSetID >= nextValidatorSet.id) { signatureUsageCount = nextValidatorSet.usageCounters.get(proof.index); nextValidatorSet.usageCounters.set(proof.index, signatureUsageCount.saturatingAdd(1)); vset = nextValidatorSet;