Skip to content

Commit

Permalink
Feature/merc 908/integrate billing and rewards (#10103)
Browse files Browse the repository at this point in the history
* Initial implementation of Reward contract

* Update mentions of "NOP" to "Payee" + Optimizations

* Update function names + event

* make proxy upgradable as not needed when onFeePaid

* update rewards contract to claim model

* Initial implementation of Reward contract

* initial implementation

* Added LINK + native support + optimisations

* Update Native address to wrapped contract

* Initial e2e impl

* Add functionality to pay all nops within a pool

* Amendments and tests

* Additional tests

* Added ByteUtil tests and removed unused impl

* Update verifier test locations

* Updates and fixes to tests

* Reward Manager tests + prettier

* Removed ability to add and remove from reward set

* Changed Assets -> uint256 to save gas

* Added FeeManager tests

* Prevent premiums exceeding 100%

* Added support for Unwrapped Native

* Added events and tests

* Fixed rounding error issues

* reward/fee managers are now modifiable

* Calldata optimisations

* Mitigate parasitic usage risk

* Added native billing + cleanup

* Added expiry + clean up + tests

* Final review of RM

* Reorganize contract code and minor FeeManager updates (tests failing)

* Fix padding issues & broken tests

* Remove SafeERC20 as its not req

* fixes + additional tests to FeeManager

* Fixes + remaining tests

* Added linkAvailableForPayment

* Added gas tests

* prettier

* Improve (somewhat) gas estimations

* Bulk approve transfers from feeManager -> rewardManager

* Small optimisation

* Updates to comments and terminology

* Terminology updates

* Snapshot

* Rebase upstream repo

* Update llo go wrappers

* update gas snapshots

* move dependencies to vendor

* small fixes

* update pnpm lockfile

* update file name to fix test failures

* update wrappers

* update gas snapshots

* Update llo wrappers

* Fixed integration tests

* Fixed issue around claiming when recipients not set

* Add report versioning to FeeManager

* Update version to begining of bytes

* Update naming to align with convention

* gas snapshot

* clean up vendor

* Add event when paying into pool

* Bug fixes

* Move contracts to dev until audit

* Fixes + optimisations

---------

Co-authored-by: Austin Born <[email protected]>
  • Loading branch information
Fletch153 and austinborn authored Aug 11, 2023
1 parent b79f88a commit c620d67
Show file tree
Hide file tree
Showing 66 changed files with 13,242 additions and 452 deletions.
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ core/services/ocr2/plugins/functions @bolekk @justinkaseman @KuphJr @pinebit
/contracts/**/*Upkeep* @smartcontractkit/keepers
/contracts/**/*Functions* @bolekk @justinkaseman @KuphJr @pinebit
/contracts/src/v0.8/functions @bolekk @justinkaseman @KuphJr @pinebit
/contracts/src/v0.8/llo-feeds @austinborn @Fletch153

# Tests
/integration-tests/ @smartcontractkit/test-tooling-team
/integration-tests/**/*keeper* @smartcontractkit/keepers
/integration-tests/**/*automation* @smartcontractkit/keepers


# CI/CD
/.github/** @chainchad @javuto @jkongie @jmank88 @samsondav
/.github/workflows/integration-tests.yml @smartcontractkit/test-tooling-team
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ go-solidity-wrappers-functions: pnpmdep abigen ## Recompiles solidity contracts
.PHONY: go-solidity-wrappers-llo
go-solidity-wrappers-llo: pnpmdep abigen ## Recompiles solidity contracts and their go wrappers.
./contracts/scripts/native_solc_compile_all_llo
go generate ./core/gethwrappers/go_generate_llo.go
go generate ./core/gethwrappers/llo-feeds/go_generate.go

.PHONY: generate
generate: abigen codecgen mockery ## Execute all go:generate commands.
Expand Down
115 changes: 6 additions & 109 deletions contracts/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,111 +1,8 @@
AutomationForwarder_forward:testBasicSuccess() (gas: 87621)
AutomationForwarder_forward:testNotAuthorizedReverts() (gas: 20812)
AutomationForwarder_forward:testWrongFunctionSelectorSuccess() (gas: 17949)
AutomationForwarder_updateRegistry:testBasicSuccess() (gas: 14577)
AutomationForwarder_updateRegistry:testNotFromRegistryNotAuthorizedReverts() (gas: 13893)
EIP_712_1014_4337:testEIP712EIP4337AndCreateSmartContractAccount() (gas: 910680)
EIP_712_1014_4337:testEIP712EIP4337AndCreateSmartContractAccountWithPaymaster() (gas: 2299908)
EIP_712_1014_4337:testEIP712EIP4337AndCreateSmartContractAccountWithPaymasterForVRFRequest() (gas: 2893568)
EIP_712_1014_4337:testEIP712EIP4337WithExistingSmartContractAccount() (gas: 875294)
FunctionsOracle_sendRequest:testEmptyRequestDataReverts() (gas: 13430)
FunctionsOracle_setDONPublicKey:testEmptyPublicKeyReverts() (gas: 10974)
FunctionsOracle_setDONPublicKey:testOnlyOwnerReverts() (gas: 11255)
FunctionsOracle_setDONPublicKey:testSetDONPublicKeySuccess() (gas: 126453)
FunctionsOracle_setDONPublicKey:testSetDONPublicKey_gas() (gas: 97558)
FunctionsOracle_setRegistry:testEmptyPublicKeyReverts() (gas: 10635)
FunctionsOracle_setRegistry:testOnlyOwnerReverts() (gas: 10927)
FunctionsOracle_setRegistry:testSetRegistrySuccess() (gas: 35791)
FunctionsOracle_setRegistry:testSetRegistry_gas() (gas: 31987)
FunctionsOracle_typeAndVersion:testTypeAndVersionSuccess() (gas: 6905)
FunctionsRouter_createSubscription:testCreateSubscriptionSuccess() (gas: 4946892)
HeartbeatRequester_getAggregatorRequestHeartbeat:testBasicSuccess() (gas: 75412)
HeartbeatRequester_getAggregatorRequestHeartbeat:testHeartbeatNotPermittedReverts() (gas: 21730)
HeartbeatRequester_permitHeartbeat:testBasicDeployerSuccess() (gas: 48280)
HeartbeatRequester_permitHeartbeat:testBasicSuccess() (gas: 45856)
HeartbeatRequester_permitHeartbeat:testOnlyCallableByOwnerReverts() (gas: 13796)
HeartbeatRequester_removeHeartbeat:testBasicSuccess() (gas: 30192)
HeartbeatRequester_removeHeartbeat:testOnlyCallableByOwnerReverts() (gas: 11629)
HeartbeatRequester_removeHeartbeat:testRemoveNoPermitsSuccess() (gas: 15660)
VRFCoordinatorV2Plus_Migration:testDeregister() (gas: 98037)
VRFCoordinatorV2Plus_Migration:testMigrateRevertsWhenInvalidCaller() (gas: 27076)
VRFCoordinatorV2Plus_Migration:testMigrateRevertsWhenInvalidCoordinator() (gas: 17633)
VRFCoordinatorV2Plus_Migration:testMigrateRevertsWhenPendingFulfillment() (gas: 239503)
VRFCoordinatorV2Plus_Migration:testMigration() (gas: 447420)
VRFV2Plus:testCreateSubscription() (gas: 92680)
VRFV2Plus:testRegisterProvingKey() (gas: 100709)
VRFV2Plus:testRequestAndFulfillRandomWordsLINK() (gas: 669592)
VRFV2Plus:testRequestAndFulfillRandomWordsNative() (gas: 620387)
VRFV2Plus:testSetConfig() (gas: 72716)
VRFV2PlusWrapperTest:testRequestAndFulfillRandomWordsLINKWrapper() (gas: 374856)
VRFV2PlusWrapperTest:testRequestAndFulfillRandomWordsNativeWrapper() (gas: 275074)
VerificationdeactivateConfigWhenThereAreMultipleDigestsTest:test_correctlyRemovesAMiddleDigest() (gas: 24243)
VerificationdeactivateConfigWhenThereAreMultipleDigestsTest:test_correctlyRemovesTheFirstDigest() (gas: 24210)
VerificationdeactivateConfigWhenThereAreMultipleDigestsTest:test_correctlyUnsetsDigestsInSequence() (gas: 44307)
VerificationdeactivateConfigWhenThereAreMultipleDigestsTest:test_revertsIfCalledByNonOwner() (gas: 11322)
VerificationdeactivateConfigWhenThereAreMultipleDigestsTest:test_revertsIfRemovingAnEmptyDigest() (gas: 10951)
VerificationdeactivateConfigWhenThereAreMultipleDigestsTest:test_revertsIfRemovingAnNonExistentDigest() (gas: 13425)
VerifierActivateConfigTest:test_revertsIfDigestIsEmpty() (gas: 10939)
VerifierActivateConfigTest:test_revertsIfDigestNotSet() (gas: 13371)
VerifierActivateConfigTest:test_revertsIfNotOwner() (gas: 13410)
VerifierActivateConfigWithDeactivatedConfigTest:test_allowsVerification() (gas: 93382)
VerifierActivateFeedTest:test_revertsIfNoFeedExistsActivate() (gas: 13179)
VerifierActivateFeedTest:test_revertsIfNoFeedExistsDeactivate() (gas: 13179)
VerifierActivateFeedTest:test_revertsIfNotOwnerActivateFeed() (gas: 13360)
VerifierActivateFeedTest:test_revertsIfNotOwnerDeactivateFeed() (gas: 13437)
VerifierConstructorTest:test_revertsIfInitializedWithEmptyVerifierProxy() (gas: 59748)
VerifierConstructorTest:test_setsTheCorrectProperties() (gas: 1613888)
VerifierDeactivateFeedWithVerifyTest:test_currentReportAllowsVerification() (gas: 188235)
VerifierDeactivateFeedWithVerifyTest:test_currentReportFailsVerification() (gas: 108080)
VerifierDeactivateFeedWithVerifyTest:test_previousReportAllowsVerification() (gas: 95709)
VerifierDeactivateFeedWithVerifyTest:test_previousReportFailsVerification() (gas: 64662)
VerifierProxyAccessControlledVerificationTest:test_proxiesToTheVerifierIfHasAccess() (gas: 193000)
VerifierProxyAccessControlledVerificationTest:test_revertsIfNoAccess() (gas: 104244)
VerifierProxyConstructorTest:test_correctlySetsTheCorrectAccessControllerInterface() (gas: 868185)
VerifierProxyConstructorTest:test_correctlySetsTheOwner() (gas: 848303)
VerifierProxyConstructorTest:test_correctlySetsVersion() (gas: 6961)
VerifierProxyInitializeVerifierTest:test_revertsIfDigestAlreadySet() (gas: 49842)
VerifierProxyInitializeVerifierTest:test_revertsIfNotCorrectVerifier() (gas: 13103)
VerifierProxyInitializeVerifierTest:test_revertsIfNotOwner() (gas: 13375)
VerifierProxyInitializeVerifierTest:test_revertsIfVerifierAlreadyInitialized() (gas: 41915)
VerifierProxyInitializeVerifierTest:test_revertsIfZeroAddress() (gas: 10904)
VerifierProxyInitializeVerifierTest:test_updatesVerifierIfVerifier() (gas: 49086)
VerifierProxySetAccessControllerTest:test_emitsTheCorrectEvent() (gas: 35362)
VerifierProxySetAccessControllerTest:test_revertsIfCalledByNonOwner() (gas: 11345)
VerifierProxySetAccessControllerTest:test_successfullySetsNewAccessController() (gas: 32027)
VerifierProxySetAccessControllerTest:test_successfullySetsNewAccessControllerIsEmpty() (gas: 12126)
VerifierProxyUnsetVerifierTest:test_revertsIfDigestDoesNotExist() (gas: 13174)
VerifierProxyUnsetVerifierTest:test_revertsIfNotAdmin() (gas: 11249)
VerifierProxyUnsetVerifierWithPreviouslySetVerifierTest:test_correctlyUnsetsVerifier() (gas: 12686)
VerifierProxyUnsetVerifierWithPreviouslySetVerifierTest:test_emitsAnEventAfterUnsettingVerifier() (gas: 17965)
VerifierProxyVerifyTest:test_proxiesToTheCorrectVerifier() (gas: 190392)
VerifierProxyVerifyTest:test_revertsIfNoVerifierConfigured() (gas: 106909)
VerifierSetConfigTest:test_correctlyUpdatesTheConfig() (gas: 1056693)
VerifierSetConfigTest:test_revertsIfCalledByNonOwner() (gas: 178549)
VerifierSetConfigTest:test_revertsIfDuplicateSigners() (gas: 250802)
VerifierSetConfigTest:test_revertsIfFaultToleranceIsZero() (gas: 175843)
VerifierSetConfigTest:test_revertsIfNotEnoughSigners() (gas: 15106)
VerifierSetConfigTest:test_revertsIfSetWithTooManySigners() (gas: 21461)
VerifierSetConfigTest:test_revertsIfSignerContainsZeroAddress() (gas: 227232)
VerifierSetConfigWhenThereAreMultipleDigestsTest:test_correctlySetsConfigWhenDigestsAreRemoved() (gas: 537498)
VerifierSetConfigWhenThereAreMultipleDigestsTest:test_correctlyUpdatesDigestsOnMultipleVerifiersInTheProxy() (gas: 961835)
VerifierSetConfigWhenThereAreMultipleDigestsTest:test_correctlyUpdatesTheDigestInTheProxy() (gas: 518984)
VerifierSupportsInterfaceTest:test_falseIfIsNotCorrectInterface() (gas: 5590)
VerifierSupportsInterfaceTest:test_trueIfIsCorrectInterface() (gas: 5611)
VerifierVerifyMultipleConfigDigestTest:test_canVerifyNewerReportsWithNewerConfigs() (gas: 127391)
VerifierVerifyMultipleConfigDigestTest:test_canVerifyOlderReportsWithOlderConfigs() (gas: 183273)
VerifierVerifyMultipleConfigDigestTest:test_revertsIfAReportIsVerifiedWithAnExistingButIncorrectDigest() (gas: 82823)
VerifierVerifyMultipleConfigDigestTest:test_revertsIfVerifyingWithAnUnsetDigest() (gas: 122803)
VerifierVerifySingleConfigDigestTest:test_emitsAnEventIfReportVerified() (gas: 183146)
VerifierVerifySingleConfigDigestTest:test_returnsThePriceAndBlockNumIfReportVerified() (gas: 183283)
VerifierVerifySingleConfigDigestTest:test_revertsIfConfigDigestNotSet() (gas: 110853)
VerifierVerifySingleConfigDigestTest:test_revertsIfDuplicateSignersHaveSigned() (gas: 177012)
VerifierVerifySingleConfigDigestTest:test_revertsIfMismatchedSignatureLength() (gas: 47600)
VerifierVerifySingleConfigDigestTest:test_revertsIfReportHasUnconfiguredFeedID() (gas: 98652)
VerifierVerifySingleConfigDigestTest:test_revertsIfVerifiedByNonProxy() (gas: 99453)
VerifierVerifySingleConfigDigestTest:test_revertsIfVerifiedWithIncorrectAddresses() (gas: 178753)
VerifierVerifySingleConfigDigestTest:test_revertsIfWrongNumberOfSigners() (gas: 104735)
VerifierVerifySingleConfigDigestTest:test_setsTheCorrectEpoch() (gas: 190459)
Verifier_accessControlledVerify:testVerifyWithAccessControl_gas() (gas: 194809)
Verifier_setConfig:testSetConfigSuccess_gas() (gas: 921474)
Verifier_verify:testVerifyProxySuccess_gas() (gas: 185263)
Verifier_verify:testVerifySuccess_gas() (gas: 180648)
Verifier_accessControlledVerify:testVerifyWithAccessControl_gas() (gas: 207063)
Verifier_setConfig:testSetConfigSuccess_gas() (gas: 922517)
Verifier_verify:testVerifyProxySuccess_gas() (gas: 197508)
Verifier_verify:testVerifySuccess_gas() (gas: 182991)
Verifier_verifyWithFee:testVerifyProxyWithLinkFeeSuccess_gas() (gas: 245475)
Verifier_verifyWithFee:testVerifyProxyWithNativeFeeSuccess_gas() (gas: 262092)
Loading

0 comments on commit c620d67

Please sign in to comment.