Skip to content

Commit

Permalink
feat: Rewards v2 (#837)
Browse files Browse the repository at this point in the history
* feat: avs performance rewards pauser index

* feat: IRewardsCoordinator

* feat: isAVSPerformanceRewardsSubmissionHash

* feat: OperatorReward struct

* feat: _validatePerformanceRewardsSubmission

* feat: processClaims

* feat: operatorAVSCommissionBips

* feat: setOperatorAVSCommission

* feat: delegation aware rewards submission

* feat: rewards description

* feat: setOperatorAVSCommission

* refactor: operator commission struct

* feat: setOperatorPICommission

* refactor: spaces

* fix: storage gap

* feat: timestamp checkpoints

* feat: handling overlapping commission delays

* feat: operator commission getters

* feat: pausers

* fix: git submodule

* chore: resolved TODOs

* chore: remove safecast

* refactor: operator commission

* docs: updated natspec

* refactor: commission to split in RewardsCoordinator

* refactor: commission to split in deploy scripts

* refactor: commission to split in tests

* refactor: operator-directed rewards

* test: initial tests

* test: refactor setup

* test: caller is not avs

* test: no operator rewards

* test: remove unused commented code

* test: duplicate strategies

* test: invalid strategy

* test: exceeding max duration

* test: invalid interval seconds

* test: invalid interval start timestamp

* test: rewards submission too stale

* test: not retroactive

* test: refactor

* test: duplicate operators

* test: operator rewards

* test: single submission

* test: multiple submissions

* test: initial operator avs split tests

* test: operator avs split negative cases

* test: set operator PI split tests

* test: re-entrancy

* fix: remove PI minimum

* test: process claims

* fix: comments

* refactor: common validation

* test: fix failing fuzz tests

* docs: storage report

* chore: new bindings

* fix: use slow mode on local build

* chore: remove from scratch config

---------

Co-authored-by: Yash Patil <[email protected]>
  • Loading branch information
0xrajath and ypatil12 authored Nov 14, 2024
1 parent dd9bc54 commit ac57bc1
Show file tree
Hide file tree
Showing 16 changed files with 4,451 additions and 773 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
export RPC_URL="http://127.0.0.1:8545"
echo "Extracted PRIVATE_KEY: $PRIVATE_KEY"
echo "---Deploying Contracts"
RUST_LOG=forge,foundry=trace forge script script/deploy/local/Deploy_From_Scratch.s.sol \
RUST_LOG=forge,foundry=trace forge script script/deploy/local/Deploy_From_Scratch.s.sol --slow \
--rpc-url $RPC_URL \
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
--broadcast \
Expand Down
1 change: 1 addition & 0 deletions docs/storage-report/BackingEigen.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
| transferRestrictionsDisabledAfter | uint256 | 304 | 0 | 32 | src/contracts/token/BackingEigen.sol:BackingEigen |
| allowedFrom | mapping(address => bool) | 305 | 0 | 32 | src/contracts/token/BackingEigen.sol:BackingEigen |
| allowedTo | mapping(address => bool) | 306 | 0 | 32 | src/contracts/token/BackingEigen.sol:BackingEigen |
| isMinter | mapping(address => bool) | 307 | 0 | 32 | src/contracts/token/BackingEigen.sol:BackingEigen |
55 changes: 29 additions & 26 deletions docs/storage-report/RewardsCoordinator.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
| Name | Type | Slot | Offset | Bytes | Contract |
|--------------------------------------|---------------------------------------------------------|------|--------|-------|--------------------------------------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _initializing | bool | 0 | 1 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _owner | address | 51 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _status | uint256 | 151 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[49] | 152 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _DOMAIN_SEPARATOR | bytes32 | 201 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 202 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| rewardsUpdater | address | 203 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| activationDelay | uint32 | 203 | 20 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| currRewardsCalculationEndTimestamp | uint32 | 203 | 24 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| globalOperatorCommissionBips | uint16 | 203 | 28 | 2 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| claimerFor | mapping(address => address) | 204 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 205 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| submissionNonce | mapping(address => uint256) | 206 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 207 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 208 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isRewardsForAllSubmitter | mapping(address => bool) | 209 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 210 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[39] | 211 | 0 | 1248 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| Name | Type | Slot | Offset | Bytes | Contract |
|--------------------------------------------|----------------------------------------------------------------------------------|------|--------|-------|--------------------------------------------------------------|
| _initialized | uint8 | 0 | 0 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _initializing | bool | 0 | 1 | 1 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[50] | 1 | 0 | 1600 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _owner | address | 51 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[49] | 52 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| pauserRegistry | contract IPauserRegistry | 101 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _paused | uint256 | 102 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[48] | 103 | 0 | 1536 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _status | uint256 | 151 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[49] | 152 | 0 | 1568 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _DOMAIN_SEPARATOR | bytes32 | 201 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 202 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| rewardsUpdater | address | 203 | 0 | 20 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| activationDelay | uint32 | 203 | 20 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| currRewardsCalculationEndTimestamp | uint32 | 203 | 24 | 4 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| defaultOperatorSplitBips | uint16 | 203 | 28 | 2 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| claimerFor | mapping(address => address) | 204 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 205 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| submissionNonce | mapping(address => uint256) | 206 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 207 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 208 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isRewardsForAllSubmitter | mapping(address => bool) | 209 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 210 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| isOperatorDirectedAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 211 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| operatorAVSSplitBips | mapping(address => mapping(address => struct IRewardsCoordinator.OperatorSplit)) | 212 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| operatorPISplitBips | mapping(address => struct IRewardsCoordinator.OperatorSplit) | 213 | 0 | 32 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
| __gap | uint256[37] | 214 | 0 | 1184 | src/contracts/core/RewardsCoordinator.sol:RewardsCoordinator |
35 changes: 19 additions & 16 deletions docs/storage-report/RewardsCoordinatorStorage.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
| Name | Type | Slot | Offset | Bytes | Contract |
|--------------------------------------|---------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------|
| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 1 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| rewardsUpdater | address | 2 | 0 | 20 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| activationDelay | uint32 | 2 | 20 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| currRewardsCalculationEndTimestamp | uint32 | 2 | 24 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| globalOperatorCommissionBips | uint16 | 2 | 28 | 2 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| claimerFor | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 4 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| submissionNonce | mapping(address => uint256) | 5 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 6 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 7 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isRewardsForAllSubmitter | mapping(address => bool) | 8 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 9 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| __gap | uint256[39] | 10 | 0 | 1248 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| Name | Type | Slot | Offset | Bytes | Contract |
|--------------------------------------------|----------------------------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------|
| _DOMAIN_SEPARATOR | bytes32 | 0 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| _distributionRoots | struct IRewardsCoordinator.DistributionRoot[] | 1 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| rewardsUpdater | address | 2 | 0 | 20 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| activationDelay | uint32 | 2 | 20 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| currRewardsCalculationEndTimestamp | uint32 | 2 | 24 | 4 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| defaultOperatorSplitBips | uint16 | 2 | 28 | 2 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| claimerFor | mapping(address => address) | 3 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| cumulativeClaimed | mapping(address => mapping(contract IERC20 => uint256)) | 4 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| submissionNonce | mapping(address => uint256) | 5 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 6 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isRewardsSubmissionForAllHash | mapping(address => mapping(bytes32 => bool)) | 7 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isRewardsForAllSubmitter | mapping(address => bool) | 8 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isRewardsSubmissionForAllEarnersHash | mapping(address => mapping(bytes32 => bool)) | 9 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| isOperatorDirectedAVSRewardsSubmissionHash | mapping(address => mapping(bytes32 => bool)) | 10 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| operatorAVSSplitBips | mapping(address => mapping(address => struct IRewardsCoordinator.OperatorSplit)) | 11 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| operatorPISplitBips | mapping(address => struct IRewardsCoordinator.OperatorSplit) | 12 | 0 | 32 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
| __gap | uint256[37] | 13 | 0 | 1184 | src/contracts/core/RewardsCoordinatorStorage.sol:RewardsCoordinatorStorage |
Loading

0 comments on commit ac57bc1

Please sign in to comment.