Skip to content

Commit fcc755d

Browse files
ypatil12eigenmikem
andcommitted
feat: operator table updater (#1436)
**Motivation:** We need an operator table updater contract that will update all operator tables. **Modifications:** Create an `OperatoTableUpdater` contract. This contract serves two purposes: 1. Updates the `globalTableRoot` with a valid certificate from the `globalRootConfirmerSet` 2. Updates operator tables for ECDSA and BN254 Update all interfaces to be `>=0.5.0`. Security Assumptions: 1. The `globalTableRoot` cannot overwrite _past_ timestamps. In addition, it cannot be set for future timestamps 2. `updateOperatorTable` can only be called for referenceTimestamps after the opSet's stored `latestReferenceTimestamp` **Result:** Almost complete multi chain setup --------- Co-authored-by: Michael <michael.muehl@eigenlabs.org>
1 parent 4d6426e commit fcc755d

16 files changed

+974
-45
lines changed

src/contracts/interfaces/IBN254CertificateVerifier.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {BN254} from "../libraries/BN254.sol";
55
import {OperatorSet} from "../libraries/OperatorSetLib.sol";

src/contracts/interfaces/IBN254TableCalculator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {BN254} from "../libraries/BN254.sol";
55
import {OperatorSet} from "../libraries/OperatorSetLib.sol";

src/contracts/interfaces/IBaseCertificateVerifier.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import "./ICrossChainRegistry.sol";
55
import {OperatorSet} from "../libraries/OperatorSetLib.sol";

src/contracts/interfaces/ICrossChainRegistry.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
55
import "./IOperatorTableCalculator.sol";

src/contracts/interfaces/IECDSACertificateVerifier.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
55
import "./IBaseCertificateVerifier.sol";

src/contracts/interfaces/IECDSATableCalculator.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
55

@@ -13,7 +13,7 @@ interface IECDSATableCalculatorTypes {
1313
*/
1414
struct ECDSAOperatorInfo {
1515
address pubkey;
16-
uint96[] weights;
16+
uint256[] weights;
1717
}
1818
}
1919

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity >=0.5.0;
3+
4+
interface IKeyRegistrarTypes {
5+
/// @dev Enum defining supported curve types
6+
enum CurveType {
7+
NONE,
8+
ECDSA,
9+
BN254
10+
}
11+
12+
/// @dev Structure to store key information
13+
struct KeyInfo {
14+
bool isRegistered;
15+
bytes keyData; // Flexible storage for different curve types
16+
}
17+
}

src/contracts/interfaces/IOperatorTableCalculator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
55

src/contracts/interfaces/IOperatorTableUpdater.sol

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
// SPDX-License-Identifier: BUSL-1.1
2-
pragma solidity ^0.8.27;
2+
pragma solidity >=0.5.0;
33

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
55

66
import "./IECDSATableCalculator.sol";
77
import "./IBN254TableCalculator.sol";
88
import "./IECDSACertificateVerifier.sol";
99
import "./IBN254CertificateVerifier.sol";
10+
import "./IKeyRegistrar.sol";
1011
import "./ICrossChainRegistry.sol";
1112

1213
interface IOperatorTableUpdaterErrors {
14+
/// @notice Thrown when the global table root is in the future
15+
error GlobalTableRootInFuture();
16+
/// @notice Thrown when the global table root is stale
17+
error GlobalTableRootStale();
18+
/// @notice Thrown when the table root does not match what is in the certificate
19+
error TableRootNotInCertificate();
1320
/// @notice Thrown when the GlobalTableRoot update fails
14-
error GlobalTableRootUpdateFailed();
21+
error CertificateInvalid();
22+
/// @notice Thrown when the table has been updated for the timestamp
23+
error TableUpdateForPastTimestamp();
24+
/// @notice Thrown when the global table root does not match what is in storage
25+
error InvalidGlobalTableRoot();
26+
/// @notice Thrown when the operator set proof is invalid
27+
error InvalidOperatorSetProof();
28+
/// @notice Thrown when the confirmation threshold is invalid
29+
error InvalidConfirmationThreshold();
30+
/// @notice Thrown when the curve type is invalid
31+
error InvalidCurveType();
1532
}
1633

1734
interface IOperatorTableUpdaterEvents {
@@ -20,14 +37,27 @@ interface IOperatorTableUpdaterEvents {
2037
* @param referenceTimestamp the timestamp of the global table root
2138
* @param globalTableRoot the root of the global table
2239
*/
23-
event NewglobalTableRoot(uint32 referenceTimestamp, bytes32 globalTableRoot);
40+
event NewGlobalTableRoot(uint32 indexed referenceTimestamp, bytes32 indexed globalTableRoot);
41+
42+
/**
43+
* @notice Emitted when the global root confirmer set is updated
44+
* @param operatorSet The operatorSet which certifies against global roots
45+
*/
46+
event GlobalRootConfirmerSetUpdated(OperatorSet operatorSet);
47+
48+
/**
49+
* @notice Emitted when the global root confirmation threshold is updated
50+
* @param bps The threshold, in bps, for a global root to be signed off on and updated
51+
*/
52+
event GlobalRootConfirmationThresholdUpdated(uint16 bps);
2453
}
2554

2655
interface IOperatorTableUpdater is
2756
IOperatorTableUpdaterErrors,
2857
IOperatorTableUpdaterEvents,
2958
IECDSACertificateVerifierTypes,
3059
IBN254CertificateVerifierTypes,
60+
IKeyRegistrarTypes,
3161
ICrossChainRegistryTypes
3262
{
3363
/**
@@ -63,45 +93,20 @@ interface IOperatorTableUpdater is
6393
) external;
6494

6595
/**
66-
* @notice update a BN254 operator table in the CertificateVerifier
67-
* @param referenceTimestamp the reference block number of the globalTableRoot
68-
* @param globalTableRoot the new globalTableRoot
69-
* @param operatorSetIndex the index of the given operatorSet being updated
70-
* @param proof the proof of the leaf at index against the globalTableRoot
71-
* @param operatorSet the operatorSet being proven
72-
* @param operatorSetInfo the operatorSetInfo of the operator table
73-
* @param config the configuration of the operatorSet
74-
* @dev globalTableRoot must be confirmed majority certified by globalTableRootSet
75-
*/
76-
function updateBN254OperatorTable(
77-
uint32 referenceTimestamp,
78-
bytes32 globalTableRoot,
79-
uint32 operatorSetIndex,
80-
bytes calldata proof,
81-
OperatorSet calldata operatorSet,
82-
BN254OperatorSetInfo calldata operatorSetInfo,
83-
OperatorSetConfig calldata config
84-
) external;
85-
86-
/**
87-
* @notice updates an ECDSA operator table in the CertificateVerifier
96+
* @notice Updates an operator table
8897
* @param referenceTimestamp the reference block number of the globalTableRoot
8998
* @param globalTableRoot the new globalTableRoot
9099
* @param operatorSetIndex the index of the given operatorSet being updated
91100
* @param proof the proof of the leaf at index against the globalTableRoot
92-
* @param operatorSet the operatorSet being proven
93-
* @param operatorInfos the operatorInfos of the operator table
94-
* @param config the configuration of the operatorSet
95-
* @dev globalTableRoot must be confirmed majority certified by globalTableRootSet
101+
* @param tableInfo the tableInfo of the operator table
102+
* @dev Depending on the decoded KeyType, the tableInfo will be decoded to a
96103
*/
97-
function updateECDSAOperatorTable(
104+
function updateOperatorTable(
98105
uint32 referenceTimestamp,
99106
bytes32 globalTableRoot,
100107
uint32 operatorSetIndex,
101108
bytes calldata proof,
102-
OperatorSet calldata operatorSet,
103-
ECDSAOperatorInfo[] calldata operatorInfos,
104-
OperatorSetConfig calldata config
109+
bytes calldata tableInfo
105110
) external;
106111

107112
/**
@@ -115,7 +120,22 @@ interface IOperatorTableUpdater is
115120
* @param referenceTimestamp the timestamp of the table root
116121
* @return tableRoot the table root at the given timestamp
117122
*/
118-
function getTableRootByTimestamp(
123+
function getGlobalTableRootByTimestamp(
119124
uint32 referenceTimestamp
120125
) external view returns (bytes32 tableRoot);
126+
127+
/**
128+
* @notice Get the operatorSet which certifies against global roots
129+
* @return The operatorSet which certifies against global roots
130+
*/
131+
function getGlobalRootConfirmerSet() external view returns (OperatorSet memory);
132+
133+
/**
134+
* @notice Get the certificate verifier for a given key type
135+
* @param curveType The curve type
136+
* @return The certificate verifier for the given key type
137+
*/
138+
function getCertificateVerifier(
139+
CurveType curveType
140+
) external view returns (address);
121141
}

src/contracts/multichain/BN254CertificateVerifierStorage.sol

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

44
import {OperatorSet} from "../libraries/OperatorSetLib.sol";
5-
import {IBN254TableCalculator, IBN254TableCalculatorTypes} from "../interfaces/IBN254TableCalculator.sol";
6-
import {IBN254CertificateVerifier, IBN254CertificateVerifierTypes} from "../interfaces/IBN254CertificateVerifier.sol";
7-
import {IBaseCertificateVerifier} from "../interfaces/IBaseCertificateVerifier.sol";
5+
import "../interfaces/IBN254TableCalculator.sol";
6+
import "../interfaces/IBN254CertificateVerifier.sol";
7+
import "../interfaces/IBaseCertificateVerifier.sol";
88

99
abstract contract BN254CertificateVerifierStorage is IBN254CertificateVerifier {
1010
// Constants

0 commit comments

Comments
 (0)