Skip to content

Commit ee0ce16

Browse files
committed
chore: add interface
1 parent 159ea1d commit ee0ce16

File tree

4 files changed

+255
-18
lines changed

4 files changed

+255
-18
lines changed

src/contracts/interfaces/ICertificateVerifier.sol

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ pragma solidity ^0.8.27;
33

44
import "src/contracts/libraries/OperatorSetLib.sol";
55
import "src/contracts/libraries/BN254.sol";
6-
6+
import "src/contracts/interfaces/ICrossChainRegistry.sol";
77
import "src/contracts/interfaces/IECDSATableCalculator.sol";
88
import "src/contracts/interfaces/IBN254TableCalculator.sol";
99

10-
interface ICertificateVerifierTypes is IBN254TableCalculatorTypes, IECDSATableCalculatorTypes {
10+
interface ICertificateVerifierTypes is
11+
IBN254TableCalculatorTypes,
12+
IECDSATableCalculatorTypes,
13+
ICrossChainRegistryTypes
14+
{
1115
// TODO: use the `KeyType` from `KeyRegistrar`
1216
/**
1317
* @notice The type of key used by the operatorSet. An OperatorSet can
@@ -18,16 +22,6 @@ interface ICertificateVerifierTypes is IBN254TableCalculatorTypes, IECDSATableCa
1822
BN254
1923
}
2024

21-
/**
22-
* @notice A per-operatorSet configuration struct that is transported from the CrossChainRegistry on L1.
23-
* @param owner the permissioned owner of the OperatorSet on L2 that can call the CertificateVerifier specific setters
24-
* @param maxStalenessPeriod the maximum staleness period of the operatorSet
25-
*/
26-
struct OpSetConfig {
27-
address owner;
28-
uint32 maxStalenessPeriod;
29-
}
30-
3125
/**
3226
* @notice A ECDSA Certificate
3327
* @param referenceTimestamp the timestamp at which the certificate was created
@@ -97,15 +91,15 @@ interface ICertificateVerifier is ICertificateVerifierEvents, ICertificateVerifi
9791
* @param operatorSet the operatorSet to update the operator table for
9892
* @param referenceTimestamp the timestamp at which the operatorInfos were sourced
9993
* @param operatorInfos the operatorInfos to update the operator table with
100-
* @param opSetConfig the configuration of the operatorSet
94+
* @param OperatorSetConfig the configuration of the operatorSet
10195
* @dev only callable by the operatorTableUpdater for the given operatorSet
10296
* @dev We pass in an `operatorSet` for future-proofing a global `TableManager` contract
10397
*/
10498
function updateECDSAOperatorTable(
10599
OperatorSet calldata operatorSet,
106100
uint32 referenceTimestamp,
107101
ECDSAOperatorInfo[] calldata operatorInfos,
108-
OpSetConfig calldata opSetConfig
102+
OperatorSetConfig calldata OperatorSetConfig
109103
) external;
110104

111105
/**
@@ -152,15 +146,15 @@ interface ICertificateVerifier is ICertificateVerifierEvents, ICertificateVerifi
152146
* @param referenceTimestamp the timestamp at which the operatorSetInfo and
153147
* operatorInfoTreeRoot were sourced
154148
* @param operatorSetInfo the aggregate information about the operatorSet
155-
* @param opSetConfig the configuration of the operatorSet
149+
* @param OperatorSetConfig the configuration of the operatorSet
156150
* @dev only callable by the operatorTableUpdater for the given operatorSet
157151
* @dev We pass in an `operatorSet` for future-proofing a global `TableManager` contract
158152
*/
159153
function updateBN254OperatorTable(
160154
OperatorSet calldata operatorSet,
161155
uint32 referenceTimestamp,
162156
BN254OperatorSetInfo memory operatorSetInfo,
163-
OpSetConfig calldata opSetConfig
157+
OperatorSetConfig calldata OperatorSetConfig
164158
) external;
165159

166160
/**
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import "src/contracts/libraries/OperatorSetLib.sol";
5+
6+
interface IOperatorTableCalculator {
7+
// TODO: implement, stub for now
8+
}
9+
10+
interface ICrossChainRegistryErrors {
11+
/// @notice Thrown when the chainId is invalid
12+
error InvalidChainId();
13+
}
14+
15+
interface ICrossChainRegistryTypes {
16+
/**
17+
* @notice A per-operatorSet configuration struct that is transported from the CrossChainRegistry on L1.
18+
* @param owner the permissioned owner of the OperatorSet on L2 that can call the CertificateVerifier specific setters
19+
* @param maxStalenessPeriod the maximum staleness period of the operatorSet
20+
*/
21+
struct OperatorSetConfig {
22+
address owner;
23+
uint32 maxStalenessPeriod;
24+
}
25+
}
26+
27+
interface ICrossChainRegistryEvents {
28+
/// @notice Emitted when a generation reservation is made
29+
event GenerationReservationMade(OperatorSet operatorSet, IOperatorTableCalculator operatorTableCalculator);
30+
31+
/// @notice Emitted when a generation reservation is removed
32+
event GenerationReservationRemoved(OperatorSet operatorSet, IOperatorTableCalculator operatorTableCalculator);
33+
34+
/// @notice Emitted when a transport destination is added
35+
event TransportDestinationAdded(OperatorSet operatorSet, uint32 chainID);
36+
37+
/// @notice Emitted when a transport destination is removed
38+
event TransportDestinationRemoved(OperatorSet operatorSet, uint32 chainID);
39+
40+
/// @notice Emitted when a chainID is added to the whitelist
41+
event ChainIDAddedToWhitelist(uint32 chainID);
42+
43+
/// @notice Emitted when a chainID is removed from the whitelist
44+
event ChainIDRemovedFromWhitelist(uint32 chainID);
45+
}
46+
47+
interface ICrossChainRegistry is ICrossChainRegistryErrors, ICrossChainRegistryTypes, ICrossChainRegistryEvents {
48+
/**
49+
* @notice Initiates a generation reservation
50+
* @param operatorSet the operatorSet to make a reservation for
51+
* @param operatorTableCalculator the address of the operatorTableCalculator
52+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
53+
*/
54+
function requestGenerationReservation(OperatorSet calldata operatorSet, address operatorTableCalculator) external;
55+
56+
/**
57+
* @notice Removes a generation reservation for a given operatorSet
58+
* @param operatorSet the operatorSet to remove
59+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
60+
*/
61+
function removeGenerationReservation(
62+
OperatorSet calldata operatorSet
63+
) external;
64+
65+
/**
66+
* @notice Adds a destination chain to transport to
67+
* @param chainID to add transport to
68+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
69+
*/
70+
function addTransportDestination(OperatorSet calldata operatorSet, uint32 chainID) external;
71+
72+
/**
73+
* @notice Removes a destination chain to transport to
74+
* @param chainID to remove transport to
75+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
76+
*/
77+
function removeTransportDestination(OperatorSet calldata operatorSet, uint32 chainID) external;
78+
79+
/**
80+
* @notice Sets the operatorTableCalculator for the operatorSet
81+
* @param operatorSet the operatorSet whose operatorTableCalculator is desired to be set
82+
* @param calculator the contract to call to calculate the operator table
83+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
84+
* @dev operatorSet must have an active reservation
85+
*/
86+
function setOperatorTableCalculator(
87+
OperatorSet calldata operatorSet,
88+
IOperatorTableCalculator calculator
89+
) external;
90+
91+
/**
92+
* @notice Adds a chainID to the whitelist of chainIDs that can be transported to
93+
* @param chainID the chainID to add to the whitelist
94+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
95+
*/
96+
function addChainIDToWhitelist(
97+
uint32 chainID
98+
) external;
99+
100+
/**
101+
* @notice Removes a chainID from the whitelist of chainIDs that can be transported to
102+
* @param chainID the chainID to remove from the whitelist
103+
* @dev msg.sender must be UAM permissioned for operatorSet.avs
104+
*/
105+
function removeChainIDFromWhitelist(
106+
uint32 chainID
107+
) external;
108+
109+
/**
110+
* @notice Gets the operatorTableCalculator for a given operatorSet
111+
* @param operatorSet the operatorSet to get the operatorTableCalculator for
112+
* @return The operatorTableCalculator for the given operatorSet
113+
*/
114+
function getOperatorTableCalculator(
115+
OperatorSet calldata operatorSet
116+
) external returns (IOperatorTableCalculator);
117+
118+
/**
119+
* @notice Gets the active generation reservations
120+
* @return An array of operatorSets with active generationReservations
121+
* @return An array of the corresponding operatorTableCalculators
122+
*/
123+
function getActiveGenerationReservations()
124+
external
125+
returns (OperatorSet[] memory, IOperatorTableCalculator[] memory);
126+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.27;
3+
4+
import "src/contracts/libraries/OperatorSetLib.sol";
5+
6+
import "src/contracts/interfaces/IECDSATableCalculator.sol";
7+
import "src/contracts/interfaces/IBN254TableCalculator.sol";
8+
import "src/contracts/interfaces/ICertificateVerifier.sol";
9+
10+
interface IOperatorTableUpdaterErrors {
11+
/// @notice Thrown when the GlobalTableRoot update fails
12+
error GlobalTableRootUpdateFailed();
13+
}
14+
15+
interface IOperatorTableUpdaterEvents {
16+
/**
17+
* @notice Emitted when a new global table root is set
18+
* @param referenceTimestamp the timestamp of the global table root
19+
* @param globalTableRoot the root of the global table
20+
*/
21+
event NewglobalTableRoot(uint32 referenceTimestamp, bytes32 globalTableRoot);
22+
}
23+
24+
interface IOperatorTableUpdater is
25+
IOperatorTableUpdaterErrors,
26+
IOperatorTableUpdaterEvents,
27+
ICertificateVerifierTypes
28+
{
29+
/**
30+
* @notice Confirms Global operator table root
31+
* @param globalTableRootCert certificate of the root
32+
* @param globalTableRoot merkle root of all operatorSet tables
33+
* @param referenceTimestamp timestamp of the root
34+
* @dev Any entity can submit with a valid certificate signed off by the `globalRootConfirmerSet`
35+
* @dev The `msgHash` in the `globalOperatorTableRootCert` is the hash of the `globalOperatorTableRoot`
36+
*/
37+
function confirmGlobalTableRoot(
38+
BN254Certificate calldata globalTableRootCert,
39+
bytes32 globalTableRoot,
40+
uint32 referenceTimestamp
41+
) external;
42+
43+
/**
44+
* @notice Set the operatorSet which certifies against global roots
45+
* @param operatorSet the operatorSet which certifies against global roots
46+
* @dev The `operatorSet` is used to verify the certificate of the global table root
47+
* @dev Only callable by the owner of the contract
48+
*/
49+
function setGlobalRootConfirmerSet(
50+
OperatorSet calldata operatorSet
51+
) external;
52+
53+
/**
54+
* @notice The threshold, in bps, for a global root to be signed off on and updated
55+
* @dev Only callable by the owner of the contract
56+
*/
57+
function setGlobalRootConfirmationThreshold(
58+
uint16 bps
59+
) external;
60+
61+
/**
62+
* @notice update a BN254 operator table in the CertificateVerifier
63+
* @param referenceTimestamp the reference block number of the globalTableRoot
64+
* @param globalTableRoot the new globalTableRoot
65+
* @param operatorSetIndex the index of the given operatorSet being updated
66+
* @param proof the proof of the leaf at index against the globalTableRoot
67+
* @param operatorSet the operatorSet being proven
68+
* @param operatorSetInfo the operatorSetInfo of the operator table
69+
* @param config the configuration of the operatorSet
70+
* @dev globalTableRoot must be confirmed majority certified by globalTableRootSet
71+
*/
72+
function updateBN254OperatorTable(
73+
uint32 referenceTimestamp,
74+
bytes32 globalTableRoot,
75+
uint32 operatorSetIndex,
76+
bytes calldata proof,
77+
OperatorSet calldata operatorSet,
78+
BN254OperatorSetInfo calldata operatorSetInfo,
79+
OperatorSetConfig calldata config
80+
) external;
81+
82+
/**
83+
* @notice updates an ECDSA operator table in the CertificateVerifier
84+
* @param referenceTimestamp the reference block number of the globalTableRoot
85+
* @param globalTableRoot the new globalTableRoot
86+
* @param operatorSetIndex the index of the given operatorSet being updated
87+
* @param proof the proof of the leaf at index against the globalTableRoot
88+
* @param operatorSet the operatorSet being proven
89+
* @param operatorInfos the operatorInfos of the operator table
90+
* @param config the configuration of the operatorSet
91+
* @dev globalTableRoot must be confirmed majority certified by globalTableRootSet
92+
*/
93+
function updateECDSAOperatorTable(
94+
uint32 referenceTimestamp,
95+
bytes32 globalTableRoot,
96+
uint32 operatorSetIndex,
97+
bytes calldata proof,
98+
OperatorSet calldata operatorSet,
99+
ECDSAOperatorInfo[] calldata operatorInfos,
100+
OperatorSetConfig calldata config
101+
) external;
102+
103+
/**
104+
* @notice Get the current global table root
105+
* @return globalTableRoot the current global table root
106+
*/
107+
function getCurrentGlobalTableRoot() external view returns (bytes32 globalTableRoot);
108+
109+
/**
110+
* @notice Get the table root by timestamp
111+
* @param referenceTimestamp the timestamp of the table root
112+
* @return tableRoot the table root at the given timestamp
113+
*/
114+
function getTableRootByTimestamp(
115+
uint32 referenceTimestamp
116+
) external view returns (bytes32 tableRoot);
117+
}

src/contracts/libraries/Bn254.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ library BN254 {
6262
}
6363

6464
// generator of group G2
65-
/// @dev Generator point in F_q2 is of the form: (x0 + ix1, y0 + iy1).
65+
/// @dev Generator point in F_q2 is of the form: (x0 + ix1, y0 + it1).
6666
uint256 internal constant G2x1 =
6767
11_559_732_032_986_387_107_991_004_021_392_285_783_925_812_861_821_192_530_917_403_151_452_391_805_634;
6868
uint256 internal constant G2x0 =
@@ -82,7 +82,7 @@ library BN254 {
8282
}
8383

8484
// negation of the generator of group G2
85-
/// @dev Generator point in F_q2 is of the form: (x0 + ix1, y0 + iy1).
85+
/// @dev Generator point in F_q2 is of the form: (x0 + ix1, y0 + it1).
8686
uint256 internal constant nG2x1 =
8787
11_559_732_032_986_387_107_991_004_021_392_285_783_925_812_861_821_192_530_917_403_151_452_391_805_634;
8888
uint256 internal constant nG2x0 =

0 commit comments

Comments
 (0)