-
Notifications
You must be signed in to change notification settings - Fork 1
/
EigenDAVerifier.sol
145 lines (122 loc) · 4.87 KB
/
EigenDAVerifier.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {EigenDARollupUtils} from "eigenda/libraries/EigenDARollupUtils.sol";
import {IEigenDAServiceManager} from "eigenda/interfaces/IEigenDAServiceManager.sol";
import "../interfaces/IDataAvailabilityProtocol.sol";
import "../interfaces/IPolygonZkEVMVEtrogErrors.sol";
/*
* Contract responsible for on-chain data availability verification of L2 batch data submitted to the EigenDA
* layer using the blob verification proofs. The contract serves as an adaptor pattern for the existing DA
* interface on the PolygonValidium data availability protocol to interact with the EigenDAServiceManager.
*/
contract EigenDAVerifier is
IDataAvailabilityProtocol,
IPolygonZkEVMVEtrogErrors
{
/**
* @notice Struct which will store the blob verification data
* @param blobHeader stores the header of the blob containing the relevant attributes of the blob
* @param blobVerificationProof stores the relevant data needed to prove inclusion of the blob on EigenDA layer
*/
struct BlobData {
IEigenDAServiceManager.BlobHeader blobHeader;
EigenDARollupUtils.BlobVerificationProof blobVerificationProof;
}
// Name of the data availability protocol
string internal constant _PROTOCOL_NAME = "EigenDA";
// Address of the EigenDA service manager
IEigenDAServiceManager dataAvailabilityProtocol;
// Address that will be able to adjust contract parameters
address public admin;
// This account will be able to accept the admin role
address public pendingAdmin;
/**
* @dev Emitted when the admin updates the data availability protocol address
*/
event SetDataAvailabilityProtocol(IEigenDAServiceManager newTrustedSequencer);
/**
* @dev Emitted when the admin starts the two-step transfer role setting a new pending admin
*/
event TransferAdminRole(address newPendingAdmin);
/**
* @dev Emitted when the pending admin accepts the admin role
*/
event AcceptAdminRole(address newAdmin);
/**
* @param _eigenDAServiceManager EigenDA service manager address
*/
constructor(
address _admin,
IEigenDAServiceManager _eigenDAServiceManager
) {
admin = _admin;
dataAvailabilityProtocol = _eigenDAServiceManager;
}
modifier onlyAdmin() {
if (admin != msg.sender) {
revert OnlyAdmin();
}
_;
}
/**
* @notice Return the protocol name
*/
function getProcotolName() external pure returns (string memory) {
return _PROTOCOL_NAME;
}
/////////////////////////////////////////////
// Data availability message decode functions
/////////////////////////////////////////////
/**
* @notice Decodes the data availaiblity message to the EigenDA blob data
* @param data The encoded data availability message bytes
*/
function decodeBlobData(bytes calldata data) public pure returns (BlobData memory blobData) {
return abi.decode(data, (BlobData));
}
//////////////////
// Admin functions
//////////////////
/**
* @notice Allow the admin to set a new data availability protocol
* @param newDataAvailabilityProtocol Address of the new trusted sequencer
*/
function setDataAvailabilityProtocol(
IEigenDAServiceManager newDataAvailabilityProtocol
) external onlyAdmin {
dataAvailabilityProtocol = newDataAvailabilityProtocol;
emit SetDataAvailabilityProtocol(newDataAvailabilityProtocol);
}
/**
* @notice Starts the admin role transfer
* This is a two step process, the pending admin must accepted to finalize the process
* @param newPendingAdmin Address of the new pending admin
*/
function transferAdminRole(address newPendingAdmin) external onlyAdmin {
pendingAdmin = newPendingAdmin;
emit TransferAdminRole(newPendingAdmin);
}
/**
* @notice Allow the current pending admin to accept the admin role
*/
function acceptAdminRole() external {
if (pendingAdmin != msg.sender) {
revert OnlyPendingAdmin();
}
admin = pendingAdmin;
emit AcceptAdminRole(pendingAdmin);
}
/////////////////////////////////
// Data availability verification
/////////////////////////////////
/**
* @notice Verifies that the given blob verification proof has been signed by EigenDA operators and verified
* on-chain to be to be available
* @param data Byte array containing the abi-encoded EigenDA blob verification proof to be used for on-chain
* verification with the EigenDAServiceManager
*/
function verifyMessage(bytes32, bytes calldata data) external view {
BlobData memory blob = decodeBlobData(data);
EigenDARollupUtils.verifyBlob(blob.blobHeader, dataAvailabilityProtocol, blob.blobVerificationProof);
}
}