Skip to content

Conversation

@pinges
Copy link
Contributor

@pinges pinges commented Oct 13, 2025

This PR adds an app test for discovery. The test allows the number of nodes to be created an the number of expected connections to be changed. The checked in version creates 10 nodes and expects every node to have 9 connections.
The test checks that each node has the expected connections and also checks that the EL nodes start syncing.


Note

Adds a 10-node discovery integration test and refactors peer scoring tests for stability; also logs ENR updates in discovery service.

  • Integration Tests (app):
    • Discovery: New MaruDiscoveryTest spins up N Besu/Maru nodes, uses node 0 as bootnode, verifies peer discovery via ENR and EL block sync (defaults: 10 nodes, expect 9 peers each).
    • Peer Scoring: MaruPeerScoringTest refactored for robustness:
      • Simplifies setup/teardown; replaces manual ports with p2pPort=0u/discoveryPort=0u; removes coroutine tx loop and unused mocks.
      • Uses await-based checks, clearer assertions, and ensures clients start/sync before assertions.
      • Adjusts timeouts/cooldowns; logs validator ENR.
  • P2P:
    • MaruDiscoveryService: add info log on local node record updates including enr.

Written by Cursor Bugbot for commit 3b16325. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.48%. Comparing base (a597f9a) to head (3b16325).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #423      +/-   ##
============================================
+ Coverage     83.26%   83.48%   +0.21%     
- Complexity     1111     1126      +15     
============================================
  Files           226      228       +2     
  Lines          8003     8072      +69     
  Branches        624      628       +4     
============================================
+ Hits           6664     6739      +75     
+ Misses         1000      996       -4     
+ Partials        339      337       -2     
Flag Coverage Δ
kotlin 83.48% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@jonesho jonesho left a comment

Choose a reason for hiding this comment

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

LGTM

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Filter94
Filter94 previously approved these changes Oct 28, 2025
assertThat(
followerEthApiClient.getBlockByNumberWithoutTransactionsData(BlockParameter.Tag.LATEST).get().number,
).isGreaterThanOrEqualTo(0UL)
}
Copy link

Choose a reason for hiding this comment

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

Bug: Unsynced Peers Break Network Connection Tests

The removal of awaitTillMaruHasPeers(1u) calls for both validator and follower nodes means the tests proceed without ensuring the Maru nodes have established P2P connections. The peer scoring tests explicitly check peer counts and disconnection behavior, which requires nodes to be connected first. Without this synchronization, tests may check peer counts before connections are established, causing flaky failures or incorrect test behavior.

Fix in Cursor Fix in Web


// Create and start the bootnode (validator)
val bootnodeStack = networkStacks[0]
val bootnodeUdpPort = findFreePort()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I will oppose every new usage of findPorts by default, because this pattern feels wrong. In real world, ports are either set to 0 and assigned by the OS or a specific port number reserved for a certain instance ahead of time. And findPorts is trying to do the work that is supposed to be done by the OS.

What happened to your very strong opposition stated here ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nothing. Thanks for keeping my integrity in check!

fluentcrafter
fluentcrafter previously approved these changes Nov 12, 2025
.putDiscoverySequenceNumber(newRecord.seq.toBigInteger().toULong())
.commit()
) {
log.info("Node record updated. $newRecord")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please favour logfmt and string template

Suggested change
log.info("Node record updated. $newRecord")
log.info("updated enr={}", newRecord)

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not ENR, but yes, we should stick with logfmt. Let me change that

@Filter94 Filter94 merged commit 0de5672 into main Nov 13, 2025
16 of 17 checks passed
@Filter94 Filter94 deleted the appDiscoveryTest branch November 13, 2025 10:33
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.

6 participants