Skip to content

Commit 3f245f8

Browse files
committed
chore: update BN254CertificateVerifier (#1447)
**Motivation:** Minor updates for `BN254CertificateVerifier` **Modifications:** - Update interface - Use types for `OperatorTableUpdater` - Remove ownable **Result:** Minor Updates
1 parent 3fe7089 commit 3f245f8

File tree

5 files changed

+19
-41
lines changed

5 files changed

+19
-41
lines changed

foundry.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
[profile.coverage.fuzz]
124124
optimizer = false
125125
runs = 1
126+
gas_limit = "18446744073709551615" # u64::MAX
126127

127128
[profile.medium.fuzz]
128129
optimizer = false

src/contracts/multichain/BN254CertificateVerifier.sol

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
pragma solidity ^0.8.27;
33

44
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
5-
import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
65

76
import {BN254} from "../libraries/BN254.sol";
87
import {Merkle} from "../libraries/Merkle.sol";
98
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
109

11-
import "../interfaces/IBN254TableCalculator.sol";
12-
import "../interfaces/IBN254CertificateVerifier.sol";
13-
import "../interfaces/IBaseCertificateVerifier.sol";
1410
import "./BN254CertificateVerifierStorage.sol";
1511

1612
/**
@@ -19,7 +15,7 @@ import "./BN254CertificateVerifierStorage.sol";
1915
* @dev This contract uses BN254 curves for signature verification and
2016
* caches operator information for efficient verification
2117
*/
22-
contract BN254CertificateVerifier is Initializable, OwnableUpgradeable, BN254CertificateVerifierStorage {
18+
contract BN254CertificateVerifier is Initializable, BN254CertificateVerifierStorage {
2319
using Merkle for bytes;
2420
using BN254 for BN254.G1Point;
2521

@@ -37,32 +33,21 @@ contract BN254CertificateVerifier is Initializable, OwnableUpgradeable, BN254Cer
3733
* @notice Restricts access to the operator table updater
3834
*/
3935
modifier onlyTableUpdater() {
40-
require(msg.sender == _operatorTableUpdater, OnlyTableUpdater());
36+
require(msg.sender == address(operatorTableUpdater), OnlyTableUpdater());
4137
_;
4238
}
4339

4440
/**
4541
* @notice Constructor for the certificate verifier
4642
* @dev Disables initializers to prevent implementation initialization
47-
* @param __operatorTableUpdater Address authorized to update operator tables
43+
* @param _operatorTableUpdater Address authorized to update operator tables
4844
*/
4945
constructor(
50-
address __operatorTableUpdater
51-
) BN254CertificateVerifierStorage(__operatorTableUpdater) {
46+
IOperatorTableUpdater _operatorTableUpdater
47+
) BN254CertificateVerifierStorage(_operatorTableUpdater) {
5248
_disableInitializers();
5349
}
5450

55-
/**
56-
* @notice Initialize the contract
57-
* @param __owner The initial owner of the contract
58-
*/
59-
function initialize(
60-
address __owner
61-
) external initializer {
62-
__Ownable_init();
63-
_transferOwnership(__owner);
64-
}
65-
6651
///@inheritdoc IBaseCertificateVerifier
6752
function getOperatorSetOwner(
6853
OperatorSet memory operatorSet
@@ -374,12 +359,4 @@ contract BN254CertificateVerifier is Initializable, OwnableUpgradeable, BN254Cer
374359
bytes32 operatorSetKey = operatorSet.key();
375360
return _operatorSetInfos[operatorSetKey][referenceTimestamp];
376361
}
377-
378-
/**
379-
* @notice Get the current operator table updater address
380-
* @return The operator table updater address
381-
*/
382-
function getOperatorTableUpdater() external view returns (address) {
383-
return _operatorTableUpdater;
384-
}
385362
}

src/contracts/multichain/BN254CertificateVerifierStorage.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pragma solidity ^0.8.27;
33

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
5+
import "../interfaces/IOperatorTableUpdater.sol";
56
import "../interfaces/IBN254TableCalculator.sol";
67
import "../interfaces/IBN254CertificateVerifier.sol";
78
import "../interfaces/IBaseCertificateVerifier.sol";
@@ -15,12 +16,12 @@ abstract contract BN254CertificateVerifierStorage is IBN254CertificateVerifier {
1516
/// @dev Basis point unit denominator for division
1617
uint256 internal constant BPS_DENOMINATOR = 10_000;
1718

18-
// Immutables - None in this case, but could be added if needed
19-
20-
// Mutatables
19+
// Immutables
2120

2221
/// @dev The address that can update operator tables
23-
address immutable _operatorTableUpdater;
22+
IOperatorTableUpdater public immutable operatorTableUpdater;
23+
24+
// Mutatables
2425

2526
/// @dev Mapping from operatorSet key to owner address
2627
mapping(bytes32 => address) internal _operatorSetOwners;
@@ -32,19 +33,18 @@ abstract contract BN254CertificateVerifierStorage is IBN254CertificateVerifier {
3233
mapping(bytes32 => uint32) internal _latestReferenceTimestamps;
3334

3435
/// @dev Mapping from operatorSet key to reference timestamp to operator set info
35-
mapping(bytes32 => mapping(uint32 => IBN254TableCalculatorTypes.BN254OperatorSetInfo)) internal _operatorSetInfos;
36+
mapping(bytes32 => mapping(uint32 => BN254OperatorSetInfo)) internal _operatorSetInfos;
3637

3738
/// @dev Mapping from operatorSet key to reference timestamp to operator index to operator info
3839
/// This is used to cache operator info that has been proven against a tree root
39-
mapping(bytes32 => mapping(uint32 => mapping(uint256 => IBN254TableCalculatorTypes.BN254OperatorInfo))) internal
40-
_operatorInfos;
40+
mapping(bytes32 => mapping(uint32 => mapping(uint256 => BN254OperatorInfo))) internal _operatorInfos;
4141

4242
// Construction
4343

4444
constructor(
45-
address __operatorTableUpdater
45+
IOperatorTableUpdater _operatorTableUpdater
4646
) {
47-
_operatorTableUpdater = __operatorTableUpdater;
47+
operatorTableUpdater = _operatorTableUpdater;
4848
}
4949

5050
/**

src/test/integration/tests/ALM_Multi.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ contract Integration_ALM_Multi is IntegrationCheckUtils {
6969

7070
/// Reduce fuzz runs because this test is thiccc:
7171
///
72-
/// forge-config: default.fuzz.runs = 5
72+
/// forge-config: default.fuzz.runs = 3
7373
/// forge-config: forktest.fuzz.runs = 3
7474
function test_Multi(uint24 _r) public rand(_r) {
7575
// Do 20 iterations

src/test/unit/BN254CertificateVerifierUnit.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "src/contracts/libraries/BN254.sol";
88
import "src/contracts/libraries/Merkle.sol";
99
import "src/contracts/libraries/OperatorSetLib.sol";
1010
import "src/contracts/multichain/BN254CertificateVerifier.sol";
11+
import "src/contracts/interfaces/IOperatorTableUpdater.sol";
1112
import "src/contracts/interfaces/IBN254CertificateVerifier.sol";
1213
import "src/contracts/interfaces/IBN254TableCalculator.sol";
1314
import "src/contracts/interfaces/ICrossChainRegistry.sol";
@@ -48,11 +49,10 @@ contract BN254CertificateVerifierTest is Test {
4849
testOperatorSet.id = 1;
4950

5051
// Deploy implementation
51-
BN254CertificateVerifier implementation = new BN254CertificateVerifier(tableUpdater);
52+
BN254CertificateVerifier implementation = new BN254CertificateVerifier(IOperatorTableUpdater(tableUpdater));
5253

5354
// Deploy proxy and initialize
54-
ERC1967Proxy proxy =
55-
new ERC1967Proxy(address(implementation), abi.encodeWithSelector(BN254CertificateVerifier.initialize.selector, owner));
55+
ERC1967Proxy proxy = new ERC1967Proxy(address(implementation), "");
5656

5757
verifier = BN254CertificateVerifier(address(proxy));
5858

0 commit comments

Comments
 (0)