Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: gateway short channel id assignments #4275

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

okjodom
Copy link
Contributor

@okjodom okjodom commented Feb 8, 2024

  • adds coverage for short channel id assignments when federations are connected to gateway
  • shows each scid assignment info for each connected federation
  • shows all scid assignments in gateway info. This includes scids assigned to federations that have since been removed
  • sets const INITIAL_SCID = 0 because we always increment the scid value before assignment.

@okjodom okjodom requested a review from a team as a code owner February 8, 2024 20:20
@okjodom okjodom changed the title test gateway short channel id assignments test and improve gateway short channel id assignments Feb 8, 2024
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (52f0c96) 58.06% compared to head (28870c8) 58.12%.
Report is 114 commits behind head on master.

❗ Current head 28870c8 differs from pull request most recent head cb54b7c. Consider uploading reports for the commit cb54b7c to get more accurate results

Files Patch % Lines
gateway/ln-gateway/src/lib.rs 85.36% 6 Missing ⚠️
gateway/cli/src/main.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4275      +/-   ##
==========================================
+ Coverage   58.06%   58.12%   +0.06%     
==========================================
  Files         197      197              
  Lines       43755    43740      -15     
==========================================
+ Hits        25405    25425      +20     
+ Misses      18350    18315      -35     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1167,6 +1167,82 @@ async fn test_gateway_shows_info_about_all_connected_federations() -> anyhow::Re
.await
}

#[tokio::test(flavor = "multi_thread")]
async fn test_gateway_can_leave_connected_federations() -> anyhow::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add a devimint test that reboots the gateway in between to verify that the short channel ids are correct after the restart (or maybe the existing devimint test can be modified to cover this)?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC the bug we observed only happened after restarting the gateway. That accurate @douglaz?

I would try to leave the federation with the lowest SCID, then restart gateway, then join a new previously un-joined federation.

Tricky thing is that we may need at least 2 federations for this devimint test?

We can't really tests a gatewayd restart in this test because it uses memdb?

Copy link
Contributor

Choose a reason for hiding this comment

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

The duplicated id was certainly after restarting. But we also had issues (same? others?) before restarting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding these tests highlighted several bugs / slight logical with scid assignments. If we backported this to 0.2.1 and updated a live gateway, future scid assignments when connecting / disconnecting feds would be predictable as defined by the new test spec.

Tricky thing is that we may need at least 2 federations for this devimint test?

Yes. We have a gateway reboot test, but we can't improve it's coverage to scid assignments because devimint is limited. Relevant to #3985

We can't really tests a gatewayd restart in this test because it uses memdb?

Well this also is a limitation for testing persisted states

m1sterc001guy
m1sterc001guy previously approved these changes Feb 10, 2024
Copy link
Contributor

@m1sterc001guy m1sterc001guy left a comment

Choose a reason for hiding this comment

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

LGTM

@okjodom okjodom marked this pull request as draft February 19, 2024 07:18
@okjodom okjodom force-pushed the test-scids branch 5 times, most recently from d27b2af to 2c44e17 Compare February 19, 2024 17:18
@okjodom okjodom changed the title test and improve gateway short channel id assignments test: gateway short channel id assignments Feb 19, 2024
@okjodom okjodom marked this pull request as ready for review February 19, 2024 17:45
@elsirion
Copy link
Contributor

Needs rebase

- renames `channel_id_generator` to `max_used_scid`
- fixes channel id tracking in load clients. here we only need to track the max used channel id assigned
  to a loaded client.

this change ensures we only increment the channel id when connecting to new federations.
- when a federation is removed from the gateway scid_to_federation map.
this frees up scid slots for potential reuse by other connected feds
@justinmoon justinmoon added this pull request to the merge queue Feb 21, 2024
Merged via the queue into fedimint:master with commit a9e807e Feb 21, 2024
20 checks passed
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.

None yet

5 participants