diff --git a/src/interfaces/IProfile.sol b/src/interfaces/IProfile.sol index fef04f1f..22fe9342 100644 --- a/src/interfaces/IProfile.sol +++ b/src/interfaces/IProfile.sol @@ -37,6 +37,13 @@ interface IProfile { bytes32 vrfKeyHash; /// @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. uint256 vrfKeyHashLastChange; + /////////////////// ZkEVM Related Variables ////////////////////// + /// @dev The rollup id of the candidate. + uint32 rollupId; + /// @dev The trusted aggregator to verify the zk proof. + address aggregator; + /// @dev The trusted sequencer to sequence batch of L2 transactions. + address sequencer; } /// @dev Event emitted when a profile with `id` is added. @@ -53,6 +60,12 @@ interface IProfile { event VRFKeyHashChanged(address indexed id, bytes32 vrfKeyHash); /// @dev Event emitted when the pubkey is verified successfully. event PubkeyVerified(bytes pubkey, bytes proofOfPossession); + /// @dev Event emitted when the validator create new rollup contract. + event RollupCreated(address indexed id, uint32 indexed rollupId); + /// @dev Event emitted when the validator change the trusted aggregator. + event AggregatorChanged(address indexed id, address indexed aggregator); + /// @dev Event emitted when the validator change the trusted sequencer. + event SequencerChanged(address indexed id, address indexed sequencer); /// @dev Error of already existed profile. error ErrExistentProfile(); @@ -74,7 +87,11 @@ interface IProfile { error ErrInvalidProofOfPossession(bytes pubkey, bytes proofOfPossession); error ErrLookUpIdFailed(TConsensus consensus); error ErrLookUpIdFromVRFKeyFailed(bytes32 vrfKeyHash); + error ErrLookUpIdFromRollupIdFailed(uint32 rollupId); error ErrValidatorOnRenunciation(address cid); + error ErrExistentRollup(address cid, uint32 createdRollupId); + error ErrZeroRollupId(address cid); + error ErrRollupIdAlreadyRegistered(uint32 rollupId); function initialize( address validatorContract @@ -86,6 +103,43 @@ interface IProfile { uint256 cooldown ) external; + function initializeV4( + address rollupManager + ) external; + + /// @dev Getter to query `id` from `rollupId`. + function getRollupId2Id( + uint32 rollupId + ) external view returns (address id); + + /// @dev Getter to query `rollupId` from `id` address. + function getId2RollupId( + address id + ) external view returns (uint32); + + /// @dev Getter to query `aggregator` from `id` address. + function getId2Aggregator( + address id + ) external view returns (address); + + /// @dev Getter to query `sequencer` from `id` address. + function getId2Sequencer( + address id + ) external view returns (address); + + /* + * @dev Cross-contract function to add new rollup contract of a candidate. + * + * Requirements: + * - Only `rollupManager` can call this method. + * - On renounce, the candidate cannot create a new rollup contract. + * - `id` must be a valid candidate. + * - `rollupId` must be unique. + * - `rollupId` must be greater than 0. + * - Candidate must not have any rollup id before. + */ + function execCreateRollup(address id, uint32 rollupId) external; + /// @dev Getter to query full `profile` from `id` address. function getId2Profile( address id @@ -186,6 +240,11 @@ interface IProfile { bytes32 vrfKeyHash ) external view returns (bool found, address id); + /// @dev Getter to backward query from `rollupId` to `id` address. + function tryGetRollupId2Id( + uint32 rollupId + ) external view returns (bool found, address id); + /// @dev Getter to backward batch query from `consensus` address to `id` address. function getManyConsensus2Id( TConsensus[] memory consensus @@ -206,6 +265,26 @@ interface IProfile { bytes calldata proofOfPossession ) external; + /** + * @dev Updated the `sequencer` address of candidate id `id` immediately without waiting time. + * Requirements: + * - Only admin can call this method. + * - The profile must be existed. + * - The new sequencer address must not be duplicated or zero. + * - Must have created rollup contract before. + */ + function changeSequencerAddr(address id, address newSequencer) external; + + /** + * @dev Updated the `aggregator` address of candidate id `id` immediately without waiting time. + * Requirements: + * - Only admin can call this method. + * - The profile must be existed. + * - The new aggregator address must not be duplicated or zero. + * - Must have created rollup contract before. + */ + function changeAggregatorAddr(address id, address newAggregator) external; + /** * @dev Updated the treasury address of candidate id `id` immediately without waiting time. * diff --git a/src/interfaces/validator/ICandidateManager.sol b/src/interfaces/validator/ICandidateManager.sol index f73883d8..1d62cb47 100644 --- a/src/interfaces/validator/ICandidateManager.sol +++ b/src/interfaces/validator/ICandidateManager.sol @@ -71,6 +71,8 @@ interface ICandidateManager { error ErrInvalidCommissionRate(); /// @dev Error of invalid min effective days onwards. error ErrInvalidMinEffectiveDaysOnwards(); + /// @dev Error of validator who is rollup owner cannot renounce. + error ErrRollupOwnerCannotRenounce(); /** * @dev Returns the maximum number of validator candidate. diff --git a/src/interfaces/validator/ICoinbaseExecution.sol b/src/interfaces/validator/ICoinbaseExecution.sol index 43158659..4b830e80 100644 --- a/src/interfaces/validator/ICoinbaseExecution.sol +++ b/src/interfaces/validator/ICoinbaseExecution.sol @@ -17,16 +17,22 @@ interface ICoinbaseExecution is ISlashingExecution { event EmptyValidatorSet(uint256 indexed period, uint256 indexed epoch, address[] fallbackCids); /// @dev Emitted when the validator set is updated event ValidatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] cids); - /// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator. + /// @dev Emitted when the block producer operator set is updated, to mirror the in-jail and maintaining status of the validator. event BlockProducerSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] cids); - /// @dev Emitted when the bridge operator set is updated. - event BridgeOperatorSetUpdated(uint256 indexed period, uint256 indexed epoch, address[] bridgeOperators); /// @dev Emitted when the reward of the block producer is deprecated. event BlockRewardDeprecated(address indexed cid, uint256 rewardAmount, BlockRewardDeprecatedType deprecatedType); /// @dev Emitted when the block reward is submitted. event BlockRewardSubmitted(address indexed cid, uint256 submittedAmount, uint256 bonusAmount); + /// @dev Emitted when the L2 tx fee is submitted. + event L2BlockRewardSubmitted(address indexed cid, uint256 submittedAmount); + /// @dev Emitted when the mining reward of corresponding l2 is distributed. + event L2MiningRewardDistributed(address indexed cid, address indexed recipient, uint256 amount); + /// @dev Emitted when the contract fails when distributing the mining reward of corresponding l2. + event L2MiningRewardDistributionFailed( + address indexed cid, address indexed recipient, uint256 amount, uint256 contractBalance + ); /// @dev Emitted when the block producer reward is distributed. event MiningRewardDistributed(address indexed cid, address indexed recipient, uint256 amount); /// @dev Emitted when the contract fails when distributing the block producer reward. @@ -34,19 +40,6 @@ interface ICoinbaseExecution is ISlashingExecution { address indexed cid, address indexed recipient, uint256 amount, uint256 contractBalance ); - /// @dev Emitted when the bridge operator reward is distributed. - event BridgeOperatorRewardDistributed( - address indexed cid, address indexed bridgeOperator, address indexed recipientAddr, uint256 amount - ); - /// @dev Emitted when the contract fails when distributing the bridge operator reward. - event BridgeOperatorRewardDistributionFailed( - address indexed cid, - address indexed bridgeOperator, - address indexed recipient, - uint256 amount, - uint256 contractBalance - ); - /// @dev Emitted when the fast finality reward is distributed to validator. event FastFinalityRewardDistributed(address indexed cid, address indexed recipient, uint256 amount); /// @dev Emitted when the contract fails when distributing the fast finality reward to validator. @@ -54,6 +47,12 @@ interface ICoinbaseExecution is ISlashingExecution { address indexed cid, address indexed recipient, uint256 amount, uint256 contractBalance ); + /// @dev Emitted when the L2 tx fee is distributed to the delegator. + event L2MiningRewardDelegatorsDistributed(address[] cids, uint256[] delegatingAmounts); + /// @dev Emitted when the contract fails when distributing the L2 tx fee to the delegator. + event L2MiningRewardDelegatorsDistributionFailed( + address[] cids, uint256[] delegatingAmounts, uint256 contractBalance + ); /// @dev Emitted when the amount of block mining reward is distributed to staking contract for delegators. event MiningRewardDelegatorsDistributed(address[] cids, uint256[] delegatingAmounts); /// @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 { */ function submitBlockReward() external payable; + /** + * @dev Receives L2 tx fee from `ZkEVMFeePlazaL1` contract. + * + * - L2 fee will be distributed to both `validator` and their corresponding `delegator`. + * - L2 fee is shared among the validators and delegators based on `commissionRate`. + * + * Requirements: + * - The method caller is `ZkEVMFeePlazaL1` contract. + * @param cid The candidate id (owner) of the rollup contract. + */ + function onL2BlockRewardSubmitted( + address cid + ) external payable; + /** * @dev Wraps up the current epoch. * @@ -96,7 +109,6 @@ interface ICoinbaseExecution is ISlashingExecution { * Emits the event `MiningRewardDistributed` when some validator has reward distributed. * Emits the event `StakingRewardDistributed` when some staking pool has reward distributed. * Emits the event `BlockProducerSetUpdated` when the epoch is wrapped up. - * Emits the event `BridgeOperatorSetUpdated` when the epoch is wrapped up at period ending. * Emits the event `ValidatorSetUpdated` when the epoch is wrapped up at period ending, and the validator set gets updated. * Emits the event `WrappedUpEpoch`. * diff --git a/src/interfaces/validator/IRoninValidatorSet.sol b/src/interfaces/validator/IRoninValidatorSet.sol index 7985af4d..726771a6 100644 --- a/src/interfaces/validator/IRoninValidatorSet.sol +++ b/src/interfaces/validator/IRoninValidatorSet.sol @@ -46,4 +46,7 @@ interface IRoninValidatorSet is function initializeV4( address profileContract ) external; + function initializeV5( + address zkFeePlazaContract + ) external; }