Skip to content

Refactor/fly 2245#449

Open
Hakob23 wants to merge 10 commits intov2.6.0from
refactor/FLY-2245
Open

Refactor/fly 2245#449
Hakob23 wants to merge 10 commits intov2.6.0from
refactor/FLY-2245

Conversation

@Hakob23
Copy link
Copy Markdown
Collaborator

@Hakob23 Hakob23 commented Apr 2, 2026

What

Implement a two-step LP registration flow.
Added request lifecycle functions approveRegistration, rejectRegistration, and withdrawRegisterRequest, plus getRegistrationState getter function, tests and fixture updates.

Why

This change prevents immediate activation on register and guarantees collateral is returned when a request is rejected or withdrawn.

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change
  • Refactor (no intended behavior change)
  • Security hardening
  • Tests only
  • Build/CI/Tooling
  • Documentation

Affected Areas

  • PegIn flow (registerPegIn, callForUser, quote validation)
  • PegOut flow (depositPegout, refundPegOut, refundUserPegOut)
  • Liquidity Provider lifecycle (register/update/status/resign/collateral/withdraw)
  • Pause/operational controls
  • Quote hashing/signature logic
  • Bitcoin tx / PMT / merkle validation
  • Deployment or upgrade scripts / Makefile targets
  • CI workflows (ci, fuzz, slither, codeql)
  • Docs

Risk & Security Review

  • Access control and authorization paths reviewed
  • Reentrancy and external call paths reviewed
  • Storage layout / upgrade safety reviewed (if upgradeable code changed)
  • Time/block/confirmation assumptions reviewed
  • BTC tx output/index assumptions reviewed (if pegout validation touched)
  • No secrets or sensitive values added

Additional notes on test coverage, edge cases, and any tests intentionally skipped:

  • Ran targeted and full Forge suites while implementing this change:
    • forge test --match-path 'test/discovery/*.t.sol'
    • forge test --match-path 'test/integration/*.t.sol'
    • forge test --match-path test/Pause.t.sol
    • forge test --match-path test/Benchmark.t.sol
    • forge test (full suite)
  • Added/updated tests for:
    • pending registration not listed/operational until approved
    • owner approve path
    • owner reject path with collateral refund
    • LP withdraw request path with collateral refund
    • unauthorized approval rejection
    • re-registration behavior and fixture compatibility

Deployment & Ops Impact

  • No deployment impact
  • Requires deployment
  • Requires upgrade
  • Env/config changes required (.env, network RPCs, verification, etc.)
  • Runbook/update instructions added to PR description

Related Issues

Key local outputs:

  • Full forge test suite passed after updating registration-dependent tests and fixtures.

@Hakob23 Hakob23 requested a review from Luisfc68 April 2, 2026 00:42
@Hakob23 Hakob23 self-assigned this Apr 2, 2026
@Hakob23 Hakob23 requested a review from a team as a code owner April 2, 2026 00:42
Comment thread src/FlyoverDiscovery.sol
Comment on lines +253 to +256
function _refundCollateral(address payable providerAddress, uint256 amount) private {
(bool success,) = providerAddress.call{value: amount}("");
if (!success) revert Flyover.PaymentFailed(providerAddress, amount, hex"");
}

Check warning

Code scanning / Slither

Low-level calls Warning

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 5a46eb0.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Comment thread src/FlyoverDiscovery.sol

mapping(uint => Flyover.LiquidityProvider) private _liquidityProviders;
mapping(address => uint) private _providerIdByAddress;
mapping(address => PendingRegistration) private _pendingRegistrations;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be deployed in already existing contracts (since the 2.5.0 is already deployed) so we need to respect the storage layout from now on. This mappings should be moved to below the already existing variables

Comment thread src/FlyoverDiscovery.sol
if (_registrationStates[msg.sender] != RegistrationState.Pending) {
revert RegistrationNotPending(msg.sender);
}
uint256 providerId = _providerIdByAddress[msg.sender];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is the rationale to give the provider id when the registration request is created? isn't it more intuitive (and simple) to give it only if the registration is approved?

Comment thread src/FlyoverDiscovery.sol

/// @inheritdoc IFlyoverDiscovery
function rejectRegistration(address providerAddress) external whenNotPaused {
if (msg.sender != defaultAdmin()) revert NotAuthorized(msg.sender);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the admin check and pending state check repeats in all the registration management functions, maybe we should add a modifier, do you see any downsides?

Comment thread src/FlyoverDiscovery.sol
function _getProvider(address providerAddress) private view returns (Flyover.LiquidityProvider memory) {
uint providerId = _providerIdByAddress[providerAddress];
if (providerId == 0) revert Flyover.ProviderNotRegistered(providerAddress);
if (providerId == 0 || _registrationStates[providerAddress] != RegistrationState.Approved) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, I think this change wouldn't be necessary if we granted the id only after the approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants