Skip to content

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Jan 6, 2026

Proposed changes

configIndex is the keys of AllConfigs, we should skip compare a.configIndex and b.configIndex after upgrade.

image

Types of changes

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

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

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
  • 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

Copilot AI review requested due to automatic review settings January 6, 2026 10:15
@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

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.

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


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.

Copy link

Copilot AI left a comment

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 addresses a V2 configuration comparison issue in the XDPoS consensus params package. The changes improve nil handling logic, enhance logging by switching from Info to Warn level for mismatches, and restructure comparison functions to provide more granular field-by-field validation with detailed logging.

Key changes include:

  • Improved nil pointer handling in comparison functions (XDPoSConfigEqual, V2Equal, V2ConfigEqual)
  • Enhanced logging from Info to Warn level for better visibility of configuration mismatches
  • Refactored V2Equal to simplify AllConfigs comparison by only checking overlapping keys
  • Expanded V2ConfigEqual to compare fields individually with detailed logging
Comments suppressed due to low confidence (1)

params/config.go:583

  • The V2ConfigEqual function is missing comparisons for several important fields of V2Config: MinePeriod, TimeoutSyncThreshold, TimeoutPeriod, and ExpTimeoutConfig (which includes Base and MaxExponent). These fields are part of the V2Config struct and should be compared to ensure configuration equality. Without these comparisons, two V2Config instances with different values for these fields would incorrectly be considered equal.
		return true
	}
	if a.MaxMasternodes != b.MaxMasternodes {
		log.Warn("[V2ConfigEqual] MaxMasternodes mismatch", "a.MaxMasternodes", a.MaxMasternodes, "b.MaxMasternodes", b.MaxMasternodes)
		return false
	}
	if a.SwitchRound != b.SwitchRound {
		log.Warn("[V2ConfigEqual] SwitchRound mismatch", "a.SwitchRound", a.SwitchRound, "b.SwitchRound", b.SwitchRound)
		return false
	}
	if a.CertThreshold != b.CertThreshold {
		log.Warn("[V2ConfigEqual] CertThreshold mismatch", "a.CertThreshold", a.CertThreshold, "b.CertThreshold", b.CertThreshold)
		return false
	}
	return true
}

func (c *XDPoSConfig) String() string {
	return "XDPoS"
}

func (c *XDPoSConfig) Description(indent int) string {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 549 to +557
}
}
return true
}

func V2ConfigEqual(a, b *V2Config) bool {
if a == nil || b == nil {
log.Info("[V2ConfigEqual] Nil check", "a", a, "b", b, "equal", a == b)
return a == b
if a != b {
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The V2Equal function now only checks configs that exist in both AllConfigs maps (keys that overlap). This means if config A has keys [1, 2, 3] and config B has keys [1, 2, 4], the function would not detect that they are different - it would only compare keys 1 and 2. The comparison should verify that both maps have the same set of keys before comparing individual configs. Additionally, the comparison of configIndex was removed from line 543 (originally checked with slices.Equal), but configIndex is a derived field from AllConfigs that's used for config lookups. If the maps have different keys, the configIndex values would differ, which could cause runtime issues.

Copilot uses AI. Check for mistakes.
@AnilChinchawale AnilChinchawale merged commit 29f2e6c into XinFinOrg:v2.6.x-beta Jan 6, 2026
14 checks passed
@gzliudan gzliudan deleted the fix-v2-compare branch January 6, 2026 14:02
@gzliudan gzliudan mentioned this pull request Jan 7, 2026
19 tasks
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.

4 participants