Skip to content

refactor: rename witness→validator across protocol, chain, API, and w…#102

Open
On1x wants to merge 27 commits into
masterfrom
witness-rename
Open

refactor: rename witness→validator across protocol, chain, API, and w…#102
On1x wants to merge 27 commits into
masterfrom
witness-rename

Conversation

@On1x
Copy link
Copy Markdown
Member

@On1x On1x commented May 17, 2026

…allet layers

Rename the core "witness" concept to "validator" throughout the C++ node without breaking binary block_log compatibility (binary format is positional, not name-based).

Operations (protocol layer):

  • witness_update_operation → validator_update_operation
  • account_witness_vote_operation → account_validator_vote_operation
  • account_witness_proxy_operation → account_validator_proxy_operation
  • shutdown_witness_operation → shutdown_validator_operation
  • witness_reward_operation → validator_reward_operation

JSON backward compatibility: resolve_operation_name() alias table in operation_util_impl.cpp maps old operation names to new ones, so existing JSON transactions and block explorers continue to work.

Chain objects and DB methods:

  • witness_object → validator_object
  • witness_schedule_object → validator_schedule_object
  • witness_index / validator_index, get_validator_schedule_object(),
    adjust_validator_vote(), clear_validator_votes(), etc.

Chain properties fields:

  • inflation_witness_percent → inflation_validator_percent
  • witness_miss_penalty_percent → validator_miss_penalty_percent
  • witness_miss_penalty_duration → validator_miss_penalty_duration
  • witness_declaration_fee → validator_declaration_fee
    (updated in chain_operations.hpp, global_property_object.hpp,
    chain_api_properties.hpp, database.cpp, chain_properties_evaluators.cpp)

API and wallet:

  • witness_api_object → validator_api_object
  • remote_witness_api methods renamed to get_validators / get_validator_*
  • wallet.cpp command implementations and wallet.hpp declarations updated

Snapshot backward compatibility:

  • patch_chain_props_variant() helper translates old JSON field names before fc::from_variant, so pre-rename snapshots import correctly
  • import_witness_schedule() handles current_shuffled_witnesses → current_shuffled_validators and num_scheduled_witnesses → num_scheduled_validators key aliases

Note: block_header::witness and signed_block_header::witness_signature are NOT renamed in this commit (Task 8a, separate PR). Physical file renames (witness_objects.hpp → validator_objects.hpp, plugins/witness_api/ → plugins/validator_api/) are also deferred to a follow-up commit.

On1x added 27 commits May 17, 2026 13:18
…allet layers

Rename the core "witness" concept to "validator" throughout the C++ node
without breaking binary block_log compatibility (binary format is
positional, not name-based).

Operations (protocol layer):
- witness_update_operation          → validator_update_operation
- account_witness_vote_operation    → account_validator_vote_operation
- account_witness_proxy_operation   → account_validator_proxy_operation
- shutdown_witness_operation        → shutdown_validator_operation
- witness_reward_operation          → validator_reward_operation

JSON backward compatibility: resolve_operation_name() alias table in
operation_util_impl.cpp maps old operation names to new ones, so existing
JSON transactions and block explorers continue to work.

Chain objects and DB methods:
- witness_object                    → validator_object
- witness_schedule_object           → validator_schedule_object
- witness_index / validator_index, get_validator_schedule_object(),
  adjust_validator_vote(), clear_validator_votes(), etc.

Chain properties fields:
- inflation_witness_percent         → inflation_validator_percent
- witness_miss_penalty_percent      → validator_miss_penalty_percent
- witness_miss_penalty_duration     → validator_miss_penalty_duration
- witness_declaration_fee           → validator_declaration_fee
  (updated in chain_operations.hpp, global_property_object.hpp,
   chain_api_properties.hpp, database.cpp, chain_properties_evaluators.cpp)

API and wallet:
- witness_api_object                → validator_api_object
- remote_witness_api methods renamed to get_validators / get_validator_*
- wallet.cpp command implementations and wallet.hpp declarations updated

Snapshot backward compatibility:
- patch_chain_props_variant() helper translates old JSON field names before
  fc::from_variant, so pre-rename snapshots import correctly
- import_witness_schedule() handles current_shuffled_witnesses →
  current_shuffled_validators and num_scheduled_witnesses →
  num_scheduled_validators key aliases

Note: block_header::witness and signed_block_header::witness_signature are
NOT renamed in this commit (Task 8a, separate PR). Physical file renames
(witness_objects.hpp → validator_objects.hpp, plugins/witness_api/ →
plugins/validator_api/) are also deferred to a follow-up commit.
…ject

fc::mutable_variant_object does not have a contains() method — only
fc::variant_object (read-only) does. Replace all .contains() calls with
.find() != .end() in patch_chain_props_variant() and
import_witness_schedule().
Rename all remaining witness-named files, directories, namespaces,
plugin names and chain objects to validator equivalents.

File renames (git mv):
- libraries/chain/include/graphene/chain/witness_objects.hpp
    → validator_objects.hpp
- libraries/api/include/graphene/api/witness_api_object.{hpp,cpp}
    → validator_api_object.{hpp,cpp}
- plugins/witness/ → plugins/validator/
    witness.{hpp,cpp} → validator.{hpp,cpp}
- plugins/witness_api/ → plugins/validator_api/
- plugins/witness_guard/ → plugins/validator_guard/
    witness_guard.{hpp,cpp} → validator_guard.{hpp,cpp}

C++ namespace/class renames:
- namespace witness_plugin → validator_plugin
- class witness_plugin → validator_plugin
- namespace witness_api → validator_api
- namespace witness_guard → validator_guard
- class witness_guard_plugin → validator_guard_plugin
- plugin_name: "witness" → "validator", "witness_api" → "validator_api",
  "witness_guard" → "validator_guard"
- struct remote_witness_api → remote_validator_api (wallet)

Chain object renames:
- block_post_validation_object → validator_confirmation_object
- block_post_validation_index → validator_confirmation_index
- get_block_post_validations() → get_validator_confirmations()
  Snapshot JSON key "block_post_validation" kept for backward compat.

CMake targets:
- graphene_witness → graphene_validator
- graphene_witness_api → graphene_validator_api
- graphene_witness_guard → graphene_validator_guard

Config files (all config*.ini):
- plugin = witness → plugin = validator
- plugin = witness_api → plugin = validator_api
- plugin = witness_guard → plugin = validator_guard
  --witness kept as deprecated backward-compat alias for --validator.

All include paths, FC_REFLECT macros, CMakeLists.txt updated accordingly.
Rename remaining API-visible witness fields and protocol constants.

account_object / account_api_object:
- witnesses_voted_for → validators_voted_for
- witnesses_vote_weight → validators_vote_weight
- witness_votes → validator_votes
- witness_vote_weight() / witness_vote_fair_weight() /
  witness_vote_fair_weight_prehf5() → validator_*

validator_confirmation_object (chain_objects.hpp):
- current_shuffled_witnesses → current_shuffled_validators
- current_shuffled_witnesses_validations → current_shuffled_validators_validations

config.hpp / config_testnet.hpp constants:
- CHAIN_MAX_WITNESSES → CHAIN_MAX_VALIDATORS
- CHAIN_BLOCK_WITNESS_REPEAT → CHAIN_BLOCK_VALIDATOR_REPEAT
- CHAIN_EMERGENCY_WITNESS_ACCOUNT / _PUBLIC_KEY → CHAIN_EMERGENCY_VALIDATOR_*
- CHAIN_HARDFORK_REQUIRED_WITNESSES → CHAIN_HARDFORK_REQUIRED_VALIDATORS
- CHAIN_MAX_ACCOUNT_WITNESS_VOTES[_PRE_HF4] → CHAIN_MAX_ACCOUNT_VALIDATOR_VOTES[_PRE_HF4]
- CHAIN_MAX_WITNESS_URL_LENGTH → CHAIN_MAX_VALIDATOR_URL_LENGTH
- CHAIN_MAX_WITNESS_MISSED_BLOCKS → CHAIN_MAX_VALIDATOR_MISSED_BLOCKS
- CONSENSUS_WITNESS_MISS_PENALTY_{PERCENT,DURATION} → CONSENSUS_VALIDATOR_MISS_PENALTY_*
- CONSENSUS_WITNESS_DECLARATION_FEE → CONSENSUS_VALIDATOR_DECLARATION_FEE
- CHAIN_CONSENSUS_INFLATION_WITNESS_PERCENT → CHAIN_CONSENSUS_INFLATION_VALIDATOR_PERCENT

get_config.cpp: API response keys updated to new constant names.

Snapshot backward compat:
- import_accounts: reads "witnesses_voted_for" from old snapshots
- import_block_post_validations: reads "current_shuffled_witnesses[_validations]"
  from old snapshots; validator_schedule_object compat was already in place

Also fixes validator_guard.cpp ctor/dtor that still used witness_guard_plugin name.
- Removed throwing exception for invalid forks in fork_db
- Restored original head without triggering P2P error handling
- Return false to signal block rejection without sync restarts
- Allow natural network fork resolution to occur smoothly
…ss (p77)

When a peer consistently sends block ranges where every block goes to
fork_db and none are applied, the node enters an infinite fetch loop:
any_fork_db_only triggers request_blocks_from_peer(), which detects a
large gap and re-requests from LIB, the peer replies with the same fork
blocks, repeat forever.

Add fork_only_batch_count to dlt_peer_state. After FORK_ONLY_BATCH_LIMIT
(5) consecutive range replies with zero applied blocks, soft-ban the peer.
The counter resets whenever any block is applied. Legitimate fork switches
resolve within a few batches once the fork point is found and applied.
- Change log messages to specify blocks are "validated by" validators
- Update multiple log instances for consistency and clarity
- Include context for gap fill blocks in logs as well
- Replace all occurrences of "witness" with "validator" in block log specification
- Update block processing and plugin option parsing to reference validator nodes
- Modify examples and references in chain properties and governance docs accordingly
- Change CLI wallet command and operation sections for validator terminology
- Adjust consensus emergency parameters content to use validator naming and context
- Update data types document to refer to validator voting and rewards instead of witness
- Ensure consistent use of validator terminology across all related documentation files
- Change all instances of "witness" to "validator" to reflect updated terminology
- Update command examples and descriptions accordingly
- Modify headings and code snippets for commands like get_active_validators, list_validators, get_validator, update_validator, and vote_for_validator
- Ensure consistency across validator operation instructions in CLI wallet docs
Network-latency forks at the same block height (two scheduled validators
producing competing blocks for the same slot due to differing views of
missed slots) previously caused minority-side nodes to:

  - reject the disputed block outright via FC_ASSERT in
    validate_block_header,
  - remove it from fork_db in the _push_block catch,
  - flag descendants of the disputed branch as DEAD_FORK and soft-ban
    the peer carrying the majority chain,
  - fail any later fork-switch attempt because the same assertion
    fires again during branch re-application.

Effect: the minority node stays stranded on a losing fork, severs
useful peers, and cannot recover even when the majority chain becomes
demonstrably heavier.

This change introduces a typed exception (wrong_scheduled_validator_exception)
for the schedule mismatch and treats it as a soft fork-resolution
condition rather than a fatal validation failure:

  - validate_block_header throws the typed exception instead of an
    untyped FC_ASSERT in the non-emergency branch.
  - _push_block's direct-apply catch keeps the block in fork_db (does
    not call _fork_db.remove) and returns false so the P2P layer reports
    FORK_DB_ONLY instead of REJECTED, preventing soft-bans of peers
    relaying the alternative branch.
  - _push_block's fork-switch loop retries the offending block once
    with skip_witness_schedule_check when compare_fork_branches has
    already chosen its branch as heavier, allowing the heavier chain
    to win and the minority node to switch back to majority consensus.

Emergency-mode relaxation, signature verification, parent linkage,
timestamp validation, and the generic exception recovery paths are
unchanged. The behavior mirrors the existing emergency-consensus
bypass: trust the chain that vote-weighted comparison preferred,
because its producers' blocks already represent collective consensus.
…ation

When sync_stagnation_check() transitions to FORWARD, check_forward_behind()
runs on the same periodic tick and immediately transitions back to SYNC
because the peer is still ahead — creating an infinite oscillation loop
that prevents the node from ever syncing.

Add a 15-second grace period after entering FORWARD mode during which
check_forward_behind() skips its peer-head comparison. This gives
broadcast blocks time to arrive and gap fill a chance to work before
re-evaluating whether we've fallen behind.
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.

1 participant