feat: add active provider index#497
Open
Luisfc68 wants to merge 3 commits into
Open
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a v2.1.0 “active provider” enumeration to FlyoverDiscovery to avoid getProviders() scanning historical provider IDs (mitigating O(n) collateral checks), and wires CollateralManagement to notify discovery on full collateral withdrawal so withdrawn providers are removed from the active enumeration.
Changes:
- Introduces an
_activeProviderIdsset inFlyoverDiscovery, updatesapproveRegistration()/getProviders(), and addsremoveProvider()for withdrawal-driven removal. - Adds v2.1.0 reinitializers (
initializeV2_1_0) to bothFlyoverDiscoveryandCollateralManagement, plus deployment-script wiring. - Expands unit/integration/fuzz/invariant coverage for active listing, withdrawals, and “inflated lastProviderId” scenarios.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/pegout/PegOutTestBase.sol | Updates test setup to call v2.1.0 initializers. |
| test/pegin/PegInTestBase.sol | Updates test setup to call v2.1.0 initializers. |
| test/invariant/SystemInvariant.t.sol | Initializes v2.1.0 in invariant system setup. |
| test/invariant/handlers/DiscoveryHandler.sol | Extends invariant handler to cover pending-withdraw, resign, and withdraw flows. |
| test/invariant/DiscoveryInvariant.t.sol | Adds/updates invariants for operational listing, uniqueness, and withdrawn filtering. |
| test/integration/FlyoverDiscovery.t.sol | Initializes v2.1.0 in integration setup. |
| test/integration/CollateralManagement.t.sol | Initializes v2.1.0 in integration setup. |
| test/helpers/FlyoverTestBase.sol | Initializes v2.1.0 in shared test base setup. |
| test/fuzz/discovery/DiscoveryFuzzTestBase.sol | Initializes v2.1.0 for discovery fuzz tests. |
| test/fuzz/discovery/DiscoveryActiveListing.fuzz.t.sol | New fuzz suite validating active-index listing behavior under many scenarios. |
| test/discovery/ListingFilter.t.sol | Adds focused tests for pending registrations, withdrawals, and inflated providerId scanning avoidance. |
| test/discovery/DiscoveryTestBase.sol | Adds “no v2.1.0 init” deployment path and upgrade helpers for migration tests. |
| test/discovery/ActiveListing.t.sol | New unit tests for active-index behavior, initialization, and upgrade/migration scenarios. |
| test/differential/DifferentialParity.diff.t.sol | Adjusts BTC address helper to vary by network (mainnet/testnet) in differential tests. |
| test/differential/base/DifferentialBase.sol | Adds env override for reference address and deploy options tweaks for differential harness. |
| test/deployment/DeployFlyoverDiscovery.t.sol | Extends deployment test to run v2.1.0 initialization during flow. |
| test/deployment/DeployFlyover.t.sol | Runs v2.1.0 initialization in full deployment tests. |
| test/Benchmark.t.sol | Initializes v2.1.0 for benchmark setup. |
| src/test-contracts/CollateralManagementMock.sol | Adds setFlyoverDiscovery surface and event to match new interface usage in tests. |
| src/interfaces/IFlyoverDiscovery.sol | Adds removeProvider(address) to discovery interface. |
| src/interfaces/ICollateralManagement.sol | Adds setFlyoverDiscovery(address) to collateral management interface. |
| src/FlyoverDiscovery.sol | Implements active provider index, migration initializer, and removeProvider(). |
| src/CollateralManagement.sol | Adds discovery pointer + initializer + setter; notifies discovery on full collateral withdrawal. |
| script/deployment/DeployFlyoverDiscovery.s.sol | Initializes discovery + collateral management v2.1.0 during discovery deployment. |
| script/deployment/DeployFlyover.s.sol | Initializes discovery + collateral management v2.1.0 during full deployment. |
| script/deployment/DeployCollateralManagement.s.sol | Optionally initializes CM v2.1.0 with discovery proxy from env. |
| addresses.json | Adds LiquidityBridgeContract addresses for networks. |
Comment on lines
+84
to
+88
| lp = _liquidityProviders[i]; | ||
| if (_collateralManagement.isRegistered(lp.providerType, lp.providerAddress)) { | ||
| _addActiveProvider(i); | ||
| _registrationStates[lp.providerAddress] = RegistrationState.Approved; | ||
| } |
Comment on lines
+148
to
+150
| if (address(flyoverDiscovery).code.length == 0) revert Flyover.NoContract(flyoverDiscovery); | ||
| _flyoverDiscovery = IFlyoverDiscovery(flyoverDiscovery); | ||
| } |
Comment on lines
+391
to
+395
| function _notifyCollateralWithdrawal(address providerAddress) private { | ||
| if (address(_flyoverDiscovery) != address(0)) { | ||
| _flyoverDiscovery.removeProvider(providerAddress); | ||
| } | ||
| } |
Comment on lines
+59
to
+61
| function setFlyoverDiscovery(address addr) external { | ||
| emit FlyoverDiscoverySet(address(0), addr); | ||
| } |
Comment on lines
+81
to
+93
| function initializeV2_1_0() external reinitializer(2) onlyRole(DEFAULT_ADMIN_ROLE) { | ||
| Flyover.LiquidityProvider storage lp; | ||
| bool providerExists; | ||
| for (uint i = 1; i < lastProviderId + 1; ++i) { | ||
| lp = _liquidityProviders[i]; | ||
| providerExists = lp.providerAddress != address(0); | ||
| if (providerExists) { | ||
| _registrationStates[lp.providerAddress] = RegistrationState.Approved; | ||
| } | ||
| if (providerExists && _collateralManagement.isRegistered(lp.providerType, lp.providerAddress)) { | ||
| _addActiveProvider(i); | ||
| } | ||
| } |
Comment on lines
+120
to
+127
| uint256 approved = handler.ghost_approvedCount(); | ||
| uint256 withdrawn = handler.ghost_withdrawnCount(); | ||
|
|
||
| assertLe( | ||
| discovery.getProviders().length, | ||
| approved - withdrawn, | ||
| "INVARIANT VIOLATED: Listing larger than active approved providers" | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add active provider index
Why
So multiple registration don't cause discovery to make O(n) calls to collateral management during
getProvidersTask
https://rsklabs.atlassian.net/browse/FLY-2298