Skip to content
Closed
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
2 changes: 1 addition & 1 deletion base/script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract DeployScript is DevOps {
admin: cfg.initialOwner,
data: abi.encodeCall(
BridgeValidator.initialize,
(cfg.baseValidators, cfg.baseSignatureThreshold, cfg.partnerValidatorThreshold)
(cfg.baseValidators, cfg.baseSignatureThreshold, cfg.partnerValidatorThreshold, cfg.initialOwner)
)
});
}
Expand Down
75 changes: 68 additions & 7 deletions base/src/BridgeValidator.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {Ownable} from "solady/auth/Ownable.sol";
import {ECDSA} from "solady/utils/ECDSA.sol";
import {Initializable} from "solady/utils/Initializable.sol";

Expand All @@ -15,7 +16,7 @@ import {Bridge} from "./Bridge.sol";
///
/// @notice A validator contract to be used during the Stage 0 phase of Base Bridge. This will likely later be replaced
/// by `CrossL2Inbox` from the OP Stack.
contract BridgeValidator is Initializable {
contract BridgeValidator is Initializable, Ownable {
using ECDSA for bytes32;

/// @notice Container for data used to derive a unique `messageHash` for registration.
Expand Down Expand Up @@ -146,17 +147,77 @@ contract BridgeValidator is Initializable {
///
/// @dev Callable only once due to `initializer` modifier.
///
/// @param baseValidators The initial list of Base validators.
/// @param baseThreshold The minimum number of Base validator signatures required.
/// @param baseValidators The initial list of Base validators.
/// @param baseThreshold The minimum number of Base validator signatures required.
/// @param partnerThreshold The minimum number of partner validator signatures required.
function initialize(address[] calldata baseValidators, uint128 baseThreshold, uint256 partnerThreshold)
external
initializer
{
/// @param owner The owner of the bridge validator contract. Has permission to add / remove validators
/// and update threshold values
function initialize(
address[] calldata baseValidators,
uint128 baseThreshold,
uint256 partnerThreshold,
address owner
) external initializer {
VerificationLib.initialize(baseValidators, baseThreshold);

require(partnerThreshold <= MAX_PARTNER_VALIDATOR_THRESHOLD, ThresholdTooHigh());
require(owner != address(0), ZeroAddress());
partnerValidatorThreshold = partnerThreshold;

_initializeOwner(owner);
}

/// @notice Reinitializes Base validator.
///
/// @param partnerThreshold The minimum number of partner validator signatures required.
/// @param newOwner The owner of the bridge validator contract. Has permission to add / remove validators
/// and update threshold values
function reinitialize(uint256 partnerThreshold, address newOwner) external reinitializer(2) {
require(partnerThreshold <= MAX_PARTNER_VALIDATOR_THRESHOLD, ThresholdTooHigh());
require(newOwner != address(0), ZeroAddress());

partnerValidatorThreshold = partnerThreshold;

_initializeOwner(newOwner);
}

/// @notice Updates the Base signature threshold.
///
/// @dev Only callable by the BridgeValidator owner.
///
/// @param newThreshold The new threshold value.
function setThreshold(uint256 newThreshold) external onlyOwner {
VerificationLib.setThreshold(newThreshold);
}

/// @notice Updates the partner signature threshold.
///
/// @dev Only callable by the BridgeValidator owner.
///
/// @param newThreshold The new partner validator threshold value.
function setPartnerThreshold(uint256 newThreshold) external onlyOwner {
require(newThreshold <= MAX_PARTNER_VALIDATOR_THRESHOLD, ThresholdTooHigh());
uint256 oldThreshold = partnerValidatorThreshold;
partnerValidatorThreshold = newThreshold;
emit PartnerThresholdUpdated(oldThreshold, newThreshold);
}

/// @notice Adds a Base validator.
///
/// @dev Only callable by the BridgeValidator owner.
///
/// @param validator The validator address to add.
function addValidator(address validator) external onlyOwner {
VerificationLib.addValidator(validator);
}

/// @notice Removes a Base validator.
///
/// @dev Only callable by the BridgeValidator owner.
///
/// @param validator The validator address to remove.
function removeValidator(address validator) external onlyOwner {
VerificationLib.removeValidator(validator);
}

/// @notice Pre-validates a batch of Solana → Base messages.
Expand Down
Loading
Loading