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

feat(protocol): allow minGuardians be any value between 0 and numGuardians #16384

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 3 additions & 8 deletions packages/protocol/contracts/L1/provers/Guardians.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import "../../common/EssentialContract.sol";
/// @notice A contract that manages a set of guardians and their approvals.
/// @custom:security-contact security@taiko.xyz
abstract contract Guardians is EssentialContract {
/// @notice The minimum number of guardians
uint256 public constant MIN_NUM_GUARDIANS = 5;

/// @notice Contains the index of the guardian in `guardians` plus one (zero means not a
/// guardian)
/// @dev Slot 1
Expand Down Expand Up @@ -58,15 +55,13 @@ abstract contract Guardians is EssentialContract {
onlyOwner
nonReentrant
{
// We need at least MIN_NUM_GUARDIANS and at most 255 guardians (so the approval bits fit in
// a uint256)
if (_newGuardians.length < MIN_NUM_GUARDIANS || _newGuardians.length > type(uint8).max) {
// We need at most 255 guardians (so the approval bits fit in a uint256)
if (_newGuardians.length == 0 || _newGuardians.length > type(uint8).max) {
revert INVALID_GUARDIAN_SET();
}
// Minimum number of guardians to approve is at least equal or greater than half the
// guardians (rounded up) and less or equal than the total number of guardians
if (_minGuardians < (_newGuardians.length + 1) >> 1 || _minGuardians > _newGuardians.length)
{
if (_minGuardians == 0 || _minGuardians > _newGuardians.length) {
revert INVALID_MIN_GUARDIANS();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/test/L1/Guardians.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract DummyGuardians is Guardians {
}
}

contract TestSignalService is TaikoTest {
contract TestGuardianProver is TaikoTest {
DummyGuardians target;

function getSigners(uint256 numGuardians) internal returns (address[] memory signers) {
Expand Down
Loading