Skip to content

Comments

evn: add support for node id removal#3073

Merged
zzzckck merged 2 commits intodevelopfrom
add-remove-nodeid
May 8, 2025
Merged

evn: add support for node id removal#3073
zzzckck merged 2 commits intodevelopfrom
add-remove-nodeid

Conversation

@MatusKysel
Copy link
Contributor

Add support for node ID removal in EVN

Description

This PR adds support for removing node IDs from the StakeHub contract, complementing the existing node ID registration functionality. The changes include both the contract interaction layer and the configuration management.

Changes

  1. Added RemoveNodeIDs function to Parlia consensus engine

    • Creates and signs transactions to remove node IDs from StakeHub
    • Handles gas estimation and transaction creation
    • Includes proper error handling and logging
  2. Refactored node ID management in Ethereum backend

    • Split registerNodeID into handleRemovals and handleAdditions
    • Added support for wildcard removal (removing all node IDs)
    • Improved efficiency with map-based lookups
    • Added deduplication logic to prevent redundant operations
  3. Updated configuration

    • Renamed ValidatorNodeIDsToAdd to EVNNodeIDsToAdd for consistency
    • Added new EVNNodeIDsToRemove configuration option
    • Updated TOML configuration handling

Technical Details

  • Uses proper 32-byte zero value comparison for wildcard removal
  • Implements efficient filtering to skip node IDs that are in both add and remove lists
  • Maintains proper nonce handling for transaction sequencing
  • Includes comprehensive logging for debugging and monitoring

#3071

Copy link
Contributor

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 adds support for removing node IDs in the EVN module by extending configuration options and updating node ID management logic in the Ethereum backend and StakeHub contract interaction.

  • Updates configuration marshalling/unmarshalling to use EVNNodeIDsToAdd and EVNNodeIDsToRemove.
  • Refactors node ID registration into separate handling of removals and additions with improved deduplication logic.
  • Introduces a new RemoveNodeIDs function in the Parlia engine to create signed transactions for node ID removal.

Reviewed Changes

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

File Description
eth/ethconfig/gen_config.go Renames the configuration field and adds support for node ID removal.
eth/ethconfig/config.go Updates config structure with new EVN node ID add/remove options.
eth/backend.go Refactors the node ID registration to incorporate removals and additions with deduplication logic.
consensus/parlia/stakehub.go Implements the RemoveNodeIDs function for creating node ID removal transactions.
Comments suppressed due to low confidence (1)

eth/backend.go:560

  • [nitpick] The function 'registerNodeID' now handles both additions and removals; consider renaming it (e.g., to 'updateNodeIDs') to better reflect its dual responsibility.
func (s *Ethereum) registerNodeID(parlia *parlia.Parlia) error {

zzzckck
zzzckck previously approved these changes May 7, 2025
isRegistered = true
break
// Handle wildcard removal
if len(s.config.EVNNodeIDsToRemove) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does removal need to check the registeredSet? It may avoid a repeat removal operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean get once this account can remove and check against that ?

Copy link
Contributor

Choose a reason for hiding this comment

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

After the nodeIDs have been removed, they may be removed again when the BSC is restarted next time. If here check the registeredSet from on-chain, it may avoid this repeat removal operation.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a bug, if you agree, you could optimize it next time.

@zzzckck zzzckck merged commit d2a2c40 into develop May 8, 2025
7 checks passed
@zzzckck zzzckck deleted the add-remove-nodeid branch May 14, 2025 06:22
galaio pushed a commit to galaio/bsc that referenced this pull request May 29, 2025
galaio pushed a commit to galaio/bsc that referenced this pull request May 29, 2025
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