Skip to content

Ungated fixes extracted from harmony-one/harmony#5122 - #5125

Closed
Frozen wants to merge 2 commits into
harmony-one:mainfrom
Frozen:critical-fixes
Closed

Ungated fixes extracted from harmony-one/harmony#5122#5125
Frozen wants to merge 2 commits into
harmony-one:mainfrom
Frozen:critical-fixes

Conversation

@Frozen

@Frozen Frozen commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR extracts the mixed-binary-compatible, fork-free fixes from #5122.

These changes do not depend on StrictStateValidationEpoch, do not change its activation epochs, and do not include any fork-gated behavior from #5122. They are intended to remain consensus-compatible while v1.2 and v1.3 validators operate together.

Included fixes

Severity Area Fix
Critical Consensus / view change Reject VIEWCHANGE senders that are not committee participants.
Critical Cross-shard receipts Reject nil merkle proofs and CXShardHashes lists shorter than ShardIDs; preserve legacy acceptance of trailing hashes.
High Cross-shard receipts Bound pending receipt header epochs to current + 1 and cap requeues.
High Block storage Copy CommitSig and CommitBitmap into the correct fields.
High Rewards Bounds-check AddReward against the delegation snapshot.
Medium Staking / validator Apply MaxBLSPerValidator before BLS proof verification.
Low Block processing Check that the parent block exists before reading its root.
Low Cross-shard receipts Handle a nil CXReceiptsProof receiver.
Low Staking / validator Prevent slot-key slice aliasing on validator creation.
Low Node messages Guard empty block-message payloads.
Low Rewards Remove the unreachable unsigned lower-bound comparison.
Low Blockchain config Return a copy from GetVMConfig.

Explicitly excluded

All rows marked Gated: Yes in #5122 remain excluded, including the gated EVM, delegation, reward, vote-power, receipt-import, and validator-state behavior changes. This PR contains no StrictStateValidationEpoch configuration change.

Two initially ungated changes are also excluded because they alter mixed-binary state-transition behavior and require coordinated activation:

  • zero-total-effective-stake vote-power handling;
  • zero-external-stake slashing handling.

Strict equality for ShardIDs and CXShardHashes is likewise deferred to a coordinated activation. This PR rejects only a shorter hash list, matching the legacy accepted-input boundary while replacing its out-of-range panic with an error.

Provenance and scope

Testing

Focused local verification on the current head:

go test -mod=readonly -count=1 ./consensus ./core ./consensus/votepower ./staking/slash

Additional compatibility checks:

  • the direct onViewChangeSanityCheck membership test fails when the committee check is removed;
  • the trailing-hash proof test passes against both the base implementation and this PR;
  • shorter hash lists and nil merkle proofs return errors without panicking.

Frozen added 2 commits August 18, 2026 22:17
Fork-free subset of harmony-one#5122: every fix here changes no
epoch-gated behaviour, so nodes running it stay in consensus with the
current network.

Critical:
- consensus: reject VIEWCHANGE senders not in the committee; a non-member
  signature left the M3 aggregate unverifiable against its bitmap
- slash: skip external debt apportionment when total external stake is
  zero (divide by zero on fully undelegated delegators)
- votepower: guard zero TotalEffectiveStake in Compute (divide by zero)
- core: reject CXReceiptsProof with mismatched ShardIDs/CXShardHashes
  lengths or a nil merkle proof

High:
- consensus: bound pending receipt header epoch to current+1 and cap
  requeues of proofs whose shard state never arrives
- types: CXReceiptsProof.Copy wrote CommitSig into CommitBitmap
- state: bounds-check AddReward against the delegation snapshot

Medium:
- staking: apply MaxBLSPerValidator before BLS proof verification

Low:
- core: nil parent check in MayBalanceMigration; nil receiver in
  ContainsEmptyField; GetVMConfig returns a copy; empty payload guard in
  HandleNodeMessage; unreachable uint64 comparison removed; slot key
  slice aliasing fixed
@GheisMohammadi
GheisMohammadi marked this pull request as draft August 19, 2026 13:31
@Frozen Frozen closed this Aug 19, 2026
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.

2 participants