Repository navigation
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
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 changed and why
PeerManager.urlPointsAtUsdecides whether an advertised peer URL is this node's own address. It compared the two hostnames as exact strings. The URL parser keeps a trailing dot (http://us.example.:53550has hostnameus.example.), and a trailing dot is the absolute form of the same DNS name. So another identity advertising our own address with a trailing dot was not refused byaddPeer/canAddPeer, and the same happened the other way round whenEXPOSED_URLitself is written with the dot.This PR strips trailing dots from both hostnames before comparing. It reuses the linear
stripTrailingDotsthatisLoopbackHostalready uses insrc/config/nodeUrl.ts(now exported and re-exported fromsrc/config). The port check, the loopback branch and the exemption for our own identity are unchanged.Scope: this is only the self-address piece of an older peer-admission proposal. It does not change how peer identities are stored or compared, and it does not touch the "URL already bound to another identity" check (see follow-ups).
Two commits, test first:
8418608baddssrc/libs/peer/selfUrlAlias.test.ts. ThroughcanAddPeerandaddPeerit checks that another identity is refused at our address with a trailing dot, and at our plain address when we advertise the dotted form. Four controls: our exact address is refused; another host with a trailing dot, our host on another port, and our own identity at our own address are accepted.a147dad0makes the comparison ignore trailing dots, and adds the test toscripts/test-consensus.shso CI runs it. It also adds twoeslint-disable-next-linecomments to the test file; no assertion differs between the two commits.The one-line change in
scripts/test-consensus.shmay conflict with other open PRs that add a test to the same list.How it was checked
Run on macOS with Bun 1.4.4 (the version the repo pins), after
bun install --frozen-lockfile.8418608b(test only)a147dad0(head)bun test ./src/libs/peer/selfUrlAlias.test.tsAt the head, compared with
stabilisationat21095de5on the same machine:bun run type-check: exit 0.bun run test:release: exit 0.bun test testing/forks/rehearsal/: exit 0.bun run test:consensus: 186 files, 1 failed (scripts/node-doctor.test.ts, 16 failing tests). The base has 185 files and the same file failing with the same 16 tests. The new file runs in it: 6 pass.bash scripts/launcher-wipe-guard.test.sh: exit 4 at the head and at the base.eslint .: output identical to the base; the only entries in the changed files are three existingno-consolewarnings insrc/config/nodeUrl.ts.tsc --noEmit: 413 errors at the head and at the base, none in the changed files.The base failures were not investigated; they may be specific to this machine.
Builder and verifier
a147dad03020b302f69b0e33befe5c9763fb93a2: verdict approve, no critical or high findings. The review read the code; it did not run it.Follow-ups (from the review, not in this PR)
findPeersByUrlcompares raw origins, so identity B athttp://alice.example.:53550is not seen as colliding with identity A athttp://alice.example:53550. The reviewer judges the harm bounded, because a hello to that address is answered by A's key and fails the identity check. Suggested fix: onecanonicalOrigin(url)innodeUrl.ts, used by bothfindPeersByUrlandurlPointsAtUs, with a test.manageHelloPeer.tsandidentityLiveness.tscompare our origin with a reported origin as raw strings, so a dotted and an undotted spelling of our own address count as a twin.src/configwith a fixed export list that lacksstripTrailingDots(GossipManager.lifecycle.test.ts,helloGenesisGate.test.ts). Both pass at this head in the run above (8 and 7 pass).EXPOSED_URL=http://.:53550is accepted byvalidateExposedUrl, and its hostname now strips to an empty string. Only a nonsensical configuration is affected.prodloopback branch with a dotted name.🤖 Generated with Claude Code