Skip to content

Commit f0cdb07

Browse files
feat(IProfile, ICandidateManager, ICoinbaseExecution, IRoninValidatorSet): add related function to support zk-evm integration (#139)
Co-authored-by: TuDo1403 <[email protected]>
1 parent 5900eda commit f0cdb07

File tree

4 files changed

+113
-17
lines changed

4 files changed

+113
-17
lines changed

src/interfaces/IProfile.sol

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ interface IProfile {
3737
bytes32 vrfKeyHash;
3838
/// @dev Timestamp of last change of VRF key hash. Only used in the logic of Beacon. Not used for checking for cooldown of updating the profile.
3939
uint256 vrfKeyHashLastChange;
40+
/////////////////// ZkEVM Related Variables //////////////////////
41+
/// @dev The rollup id of the candidate.
42+
uint32 rollupId;
43+
/// @dev The trusted aggregator to verify the zk proof.
44+
address aggregator;
45+
/// @dev The trusted sequencer to sequence batch of L2 transactions.
46+
address sequencer;
4047
}
4148

4249
/// @dev Event emitted when a profile with `id` is added.
@@ -53,6 +60,12 @@ interface IProfile {
5360
event VRFKeyHashChanged(address indexed id, bytes32 vrfKeyHash);
5461
/// @dev Event emitted when the pubkey is verified successfully.
5562
event PubkeyVerified(bytes pubkey, bytes proofOfPossession);
63+
/// @dev Event emitted when the validator create new rollup contract.
64+
event RollupCreated(address indexed id, uint32 indexed rollupId);
65+
/// @dev Event emitted when the validator change the trusted aggregator.
66+
event AggregatorChanged(address indexed id, address indexed aggregator);
67+
/// @dev Event emitted when the validator change the trusted sequencer.
68+
event SequencerChanged(address indexed id, address indexed sequencer);
5669

5770
/// @dev Error of already existed profile.
5871
error ErrExistentProfile();
@@ -74,7 +87,11 @@ interface IProfile {
7487
error ErrInvalidProofOfPossession(bytes pubkey, bytes proofOfPossession);
7588
error ErrLookUpIdFailed(TConsensus consensus);
7689
error ErrLookUpIdFromVRFKeyFailed(bytes32 vrfKeyHash);
90+
error ErrLookUpIdFromRollupIdFailed(uint32 rollupId);
7791
error ErrValidatorOnRenunciation(address cid);
92+
error ErrExistentRollup(address cid, uint32 createdRollupId);
93+
error ErrZeroRollupId(address cid);
94+
error ErrRollupIdAlreadyRegistered(uint32 rollupId);
7895

7996
function initialize(
8097
address validatorContract
@@ -86,6 +103,43 @@ interface IProfile {
86103
uint256 cooldown
87104
) external;
88105

106+
function initializeV4(
107+
address rollupManager
108+
) external;
109+
110+
/// @dev Getter to query `id` from `rollupId`.
111+
function getRollupId2Id(
112+
uint32 rollupId
113+
) external view returns (address id);
114+
115+
/// @dev Getter to query `rollupId` from `id` address.
116+
function getId2RollupId(
117+
address id
118+
) external view returns (uint32);
119+
120+
/// @dev Getter to query `aggregator` from `id` address.
121+
function getId2Aggregator(
122+
address id
123+
) external view returns (address);
124+
125+
/// @dev Getter to query `sequencer` from `id` address.
126+
function getId2Sequencer(
127+
address id
128+
) external view returns (address);
129+
130+
/*
131+
* @dev Cross-contract function to add new rollup contract of a candidate.
132+
*
133+
* Requirements:
134+
* - Only `rollupManager` can call this method.
135+
* - On renounce, the candidate cannot create a new rollup contract.
136+
* - `id` must be a valid candidate.
137+
* - `rollupId` must be unique.
138+
* - `rollupId` must be greater than 0.
139+
* - Candidate must not have any rollup id before.
140+
*/
141+
function execCreateRollup(address id, uint32 rollupId) external;
142+
89143
/// @dev Getter to query full `profile` from `id` address.
90144
function getId2Profile(
91145
address id
@@ -186,6 +240,11 @@ interface IProfile {
186240
bytes32 vrfKeyHash
187241
) external view returns (bool found, address id);
188242

243+
/// @dev Getter to backward query from `rollupId` to `id` address.
244+
function tryGetRollupId2Id(
245+
uint32 rollupId
246+
) external view returns (bool found, address id);
247+
189248
/// @dev Getter to backward batch query from `consensus` address to `id` address.
190249
function getManyConsensus2Id(
191250
TConsensus[] memory consensus
@@ -206,6 +265,26 @@ interface IProfile {
206265
bytes calldata proofOfPossession
207266
) external;
208267

268+
/**
269+
* @dev Updated the `sequencer` address of candidate id `id` immediately without waiting time.
270+
* Requirements:
271+
* - Only admin can call this method.
272+
* - The profile must be existed.
273+
* - The new sequencer address must not be duplicated or zero.
274+
* - Must have created rollup contract before.
275+
*/
276+
function changeSequencerAddr(address id, address newSequencer) external;
277+
278+
/**
279+
* @dev Updated the `aggregator` address of candidate id `id` immediately without waiting time.
280+
* Requirements:
281+
* - Only admin can call this method.
282+
* - The profile must be existed.
283+
* - The new aggregator address must not be duplicated or zero.
284+
* - Must have created rollup contract before.
285+
*/
286+
function changeAggregatorAddr(address id, address newAggregator) external;
287+
209288
/**
210289
* @dev Updated the treasury address of candidate id `id` immediately without waiting time.
211290
*

src/interfaces/validator/ICandidateManager.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ interface ICandidateManager {
7171
error ErrInvalidCommissionRate();
7272
/// @dev Error of invalid min effective days onwards.
7373
error ErrInvalidMinEffectiveDaysOnwards();
74+
/// @dev Error of validator who is rollup owner cannot renounce.
75+
error ErrRollupOwnerCannotRenounce();
7476

7577
/**
7678
* @dev Returns the maximum number of validator candidate.

src/interfaces/validator/ICoinbaseExecution.sol

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,42 @@ interface ICoinbaseExecution is ISlashingExecution {
1717
event EmptyValidatorSet(uint256 indexed period, uint256 indexed epoch, address[] fallbackCids);
1818
/// @dev Emitted when the validator set is updated
1919
event ValidatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] cids);
20-
/// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.
20+
/// @dev Emitted when the block producer operator set is updated, to mirror the in-jail and maintaining status of the validator.
2121
event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] cids);
22-
/// @dev Emitted when the bridge operator set is updated.
23-
event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators);
2422

2523
/// @dev Emitted when the reward of the block producer is deprecated.
2624
event BlockRewardDeprecated(address indexed cid, uint256 rewardAmount, BlockRewardDeprecatedType deprecatedType);
2725
/// @dev Emitted when the block reward is submitted.
2826
event BlockRewardSubmitted(address indexed cid, uint256 submittedAmount, uint256 bonusAmount);
27+
/// @dev Emitted when the L2 tx fee is submitted.
28+
event L2BlockRewardSubmitted(address indexed cid, uint256 submittedAmount);
2929

30+
/// @dev Emitted when the mining reward of corresponding l2 is distributed.
31+
event L2MiningRewardDistributed(address indexed cid, address indexed recipient, uint256 amount);
32+
/// @dev Emitted when the contract fails when distributing the mining reward of corresponding l2.
33+
event L2MiningRewardDistributionFailed(
34+
address indexed cid, address indexed recipient, uint256 amount, uint256 contractBalance
35+
);
3036
/// @dev Emitted when the block producer reward is distributed.
3137
event MiningRewardDistributed(address indexed cid, address indexed recipient, uint256 amount);
3238
/// @dev Emitted when the contract fails when distributing the block producer reward.
3339
event MiningRewardDistributionFailed(
3440
address indexed cid, address indexed recipient, uint256 amount, uint256 contractBalance
3541
);
3642

37-
/// @dev Emitted when the bridge operator reward is distributed.
38-
event BridgeOperatorRewardDistributed(
39-
address indexed cid, address indexed bridgeOperator, address indexed recipientAddr, uint256 amount
40-
);
41-
/// @dev Emitted when the contract fails when distributing the bridge operator reward.
42-
event BridgeOperatorRewardDistributionFailed(
43-
address indexed cid,
44-
address indexed bridgeOperator,
45-
address indexed recipient,
46-
uint256 amount,
47-
uint256 contractBalance
48-
);
49-
5043
/// @dev Emitted when the fast finality reward is distributed to validator.
5144
event FastFinalityRewardDistributed(address indexed cid, address indexed recipient, uint256 amount);
5245
/// @dev Emitted when the contract fails when distributing the fast finality reward to validator.
5346
event FastFinalityRewardDistributionFailed(
5447
address indexed cid, address indexed recipient, uint256 amount, uint256 contractBalance
5548
);
5649

50+
/// @dev Emitted when the L2 tx fee is distributed to the delegator.
51+
event L2MiningRewardDelegatorsDistributed(address[] cids, uint256[] delegatingAmounts);
52+
/// @dev Emitted when the contract fails when distributing the L2 tx fee to the delegator.
53+
event L2MiningRewardDelegatorsDistributionFailed(
54+
address[] cids, uint256[] delegatingAmounts, uint256 contractBalance
55+
);
5756
/// @dev Emitted when the amount of block mining reward is distributed to staking contract for delegators.
5857
event MiningRewardDelegatorsDistributed(address[] cids, uint256[] delegatingAmounts);
5958
/// @dev Emitted when the contracts fails when distributing the amount of RON to the staking contract for delegators.
@@ -85,6 +84,20 @@ interface ICoinbaseExecution is ISlashingExecution {
8584
*/
8685
function submitBlockReward() external payable;
8786

87+
/**
88+
* @dev Receives L2 tx fee from `ZkEVMFeePlazaL1` contract.
89+
*
90+
* - L2 fee will be distributed to both `validator` and their corresponding `delegator`.
91+
* - L2 fee is shared among the validators and delegators based on `commissionRate`.
92+
*
93+
* Requirements:
94+
* - The method caller is `ZkEVMFeePlazaL1` contract.
95+
* @param cid The candidate id (owner) of the rollup contract.
96+
*/
97+
function onL2BlockRewardSubmitted(
98+
address cid
99+
) external payable;
100+
88101
/**
89102
* @dev Wraps up the current epoch.
90103
*
@@ -96,7 +109,6 @@ interface ICoinbaseExecution is ISlashingExecution {
96109
* Emits the event `MiningRewardDistributed` when some validator has reward distributed.
97110
* Emits the event `StakingRewardDistributed` when some staking pool has reward distributed.
98111
* Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up.
99-
* Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending.
100112
* Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated.
101113
* Emits the event `WrappedUpEpoch`.
102114
*

src/interfaces/validator/IRoninValidatorSet.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ interface IRoninValidatorSet is
4646
function initializeV4(
4747
address profileContract
4848
) external;
49+
function initializeV5(
50+
address zkFeePlazaContract
51+
) external;
4952
}

0 commit comments

Comments
 (0)