Skip to content

chore(p2p/discv5): add deprecation warning and remove unused code #20367#2382

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:p2p-discv5-staticcheck
Open

chore(p2p/discv5): add deprecation warning and remove unused code #20367#2382
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:p2p-discv5-staticcheck

Conversation

@gzliudan

Copy link
Copy Markdown
Collaborator

Proposed changes

  • p2p/discv5: add deprecation warning and remove unused code

  • p2p/discv5: remove unused variables

Ref: ethereum#20367

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb6170be-809e-451e-a587-88ceced75334

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR deprecates the p2p/discv5 package (prototype Discovery v5 implementation) and trims unused/legacy code and tests within that package.

Changes:

  • Mark p2p/discv5 as deprecated and add a brief README pointing to the upstream Discovery v5 spec.
  • Remove unused helpers/fields and leftover commented/debug code in discv5 implementation files.
  • Delete unused/disconnected files/tests (e.g., ntp.go, udp_test.go) and test-only helpers no longer referenced.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
p2p/discv5/udp.go Removes unused NAT field/import and unused helper methods.
p2p/discv5/udp_test.go Deletes unused/obsolete UDP tests and related test scaffolding.
p2p/discv5/ticket.go Removes unused constants/helpers and cleans up commented debug code.
p2p/discv5/table.go Adds package-level deprecation notice (doc comment).
p2p/discv5/table_test.go Removes unused test transport/helper code.
p2p/discv5/README Adds short warning that discv5 is a prototype and links to spec.
p2p/discv5/ntp.go Removes NTP drift detection code from discv5.
p2p/discv5/node.go Removes unused node address/pubkey helpers.
p2p/discv5/net.go Removes unused findnodeQuery field and simplifies shutdown TODO block.
p2p/discv5/net_test.go Removes unused testnet mining helper and an unused import.
Comments suppressed due to low confidence (1)

p2p/discv5/ticket.go:456

  • There is a stray commented closing brace (//}) left inside searchLookupDone, which makes the control flow harder to read and looks like an unfinished edit. It should be removed.
func (s *ticketStore) searchLookupDone(lookup lookupInfo, nodes []*Node, query func(n *Node, topic Topic) []byte) {
	now := mclock.Now()
	for i, n := range nodes {
		if i == 0 || (binary.BigEndian.Uint64(n.sha[:8])^binary.BigEndian.Uint64(lookup.target[:8])) < s.radius[lookup.topic].minRadius {
			if lookup.radiusLookup {
				if lastReq, ok := s.nodeLastReq[n]; !ok || time.Duration(now-lastReq.time) > radiusTC {
					s.nodeLastReq[n] = reqInfo{pingHash: nil, lookup: lookup, time: now}
				}
			}
			if s.canQueryTopic(n, lookup.topic) {
				hash := query(n, lookup.topic)
				if hash != nil {
					s.addTopicQuery(common.BytesToHash(hash), n, lookup)
				}
			}
			//}
		}
	}

Comment thread p2p/discv5/table.go Outdated
…ereum#20367

* p2p/discv5: add deprecation warning and remove unused code

* p2p/discv5: remove unused variables
@gzliudan gzliudan force-pushed the p2p-discv5-staticcheck branch from ae48d56 to 0c0266b Compare June 17, 2026 04:14
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.

5 participants