refactor(common/constants): move ignoreSignerCheckBlockArray and denylist to shared global file#2339
refactor(common/constants): move ignoreSignerCheckBlockArray and denylist to shared global file#2339gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors common network constants by deduplicating the ignoreSignerCheckBlockArray and denylist data across networks and centralizing the related helper functions.
Changes:
- Removed per-network
ignoreSignerCheckBlockArrayanddenylistentries fromconstants.{mainnet,testnet,devnet,local}.go. - Introduced
common/constants.shared.gowith shared global maps andIsIgnoreSignerCheckBlock/IsInDenylisthelpers. - Simplified
common/constants.all.goby removing struct fields andCopyConstantsmap-copy logic tied to those collections.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| common/constants.shared.go | Adds shared global denylist + ignore-signer-check maps and lookup helpers. |
| common/constants.all.go | Removes per-network fields/copying logic for denylist/ignore-signer-check data. |
| common/constants.mainnet.go | Removes embedded denylist/ignore-signer-check data from mainnet constants. |
| common/constants.testnet.go | Removes embedded denylist/ignore-signer-check data from testnet constants. |
| common/constants.devnet.go | Removes embedded denylist/ignore-signer-check data from devnet constants. |
| common/constants.local.go | Removes empty local overrides for denylist/ignore-signer-check data. |
Comments suppressed due to low confidence (1)
common/constants.all.go:173
- CopyConstants no longer updates the denylist / ignore-signer-check collections when switching networks, so any runtime chainID switch will keep using the shared globals regardless of selected network. If different networks are meant to have different values (notably local previously had empty sets), please reintroduce per-network selection in CopyConstants (either by reassigning the active maps or by storing them on the constant struct again).
// CopyConstants only handles testnet, devnet, local network.
// It skips mainnet since the default value is from mainnet.
func CopyConstants(chainID uint64) {
log.Info("[CopyConstants]", "chainID", chainID)
var c *constant
switch chainID {
case MainnetConstant.chainID:
log.Info("[CopyConstants] mainnet chainID matched, no need to copy constants")
return
case TestnetConstant.chainID:
log.Info("[CopyConstants] testnet chainID matched, copying testnet constants")
c = &TestnetConstant
IsTestnet = true
case DevnetConstant.chainID:
log.Info("[CopyConstants] devnet chainID matched, copying devnet constants")
c = &DevnetConstant
default: // local custom chain, it can have any chainID
log.Info("[CopyConstants] local chainID matched, copying local constants")
c = &localConstant
}
c.print()
MaxMasternodesV2 = c.maxMasternodesV2
DenylistHFNumber = c.denylistHFNumber
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5ae154f to
01df48e
Compare
…list to shared global file - Consolidate ignoreSignerCheckBlockArray and denylist into constants.shared.go for all networks - Remove per-network duplication and related code - Update related functions to use shared global variables
01df48e to
1c599f4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Proposed changes
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that