Skip to content

refactor: extract _broadcast, fix cross-chain dispatch bugs#121

Merged
hudsonhrh merged 2 commits intomainfrom
hudsonhrh/cross-chain-uniqueness
Mar 14, 2026
Merged

refactor: extract _broadcast, fix cross-chain dispatch bugs#121
hudsonhrh merged 2 commits intomainfrom
hudsonhrh/cross-chain-uniqueness

Conversation

@hudsonhrh
Copy link
Member

Summary

  • Extracts duplicated 15-line satellite dispatch loop from 3 cross-chain functions into single _broadcast internal, eliminating ~40 lines of copy-paste code
  • Fixes silent-success bug: NoActiveSatellites now always reverts when activeSatelliteCount == 0 (previously only reverted when ETH was sent, allowing governance to silently upgrade only the home chain)
  • Adds activeSatelliteCount storage cache and SatelliteNotActive guard on double-remove to prevent counter corruption
  • Simplifies event signatures (removes per-satellite domain/messageId params, emits once per operation)
  • Adds testnet E2E infrastructure: deploy-testnet.sh, InfraUpgradeE2E, InfraConfigE2E, TriggerAdminCall scripts for cross-chain testing on Sepolia/Base Sepolia

Test plan

  • 63 PoaManagerHub unit tests pass (8 new/updated for NoActiveSatellites + SatelliteNotActive)
  • 15 CrossChainUpgradeIntegration tests pass
  • PoaManagerSatellite tests pass
  • forge build --skip test compiles cleanly
  • Testnet E2E (4 tests) passed on prior run; re-run after merge to confirm

🤖 Generated with Claude Code

Consolidates duplicated 15-line satellite dispatch pattern from 3 cross-chain functions (upgradeBeaconCrossChain, addContractTypeCrossChain, adminCallCrossChain) into single internal _broadcast function. Reduces ~40 lines of code duplication and eliminates a class of copy-paste bugs.

Changes:
- Simplify event signatures: remove per-satellite domain/messageId params, emit once per operation
- Add activeSatelliteCount storage cache to eliminate double satellite iteration
- Extract _broadcast(payload, preBalance) internal function
- Remove _feePerActiveSatellite() helper (no longer needed)
- Fix bug: NoActiveSatellites always reverts when count==0, not only when msg.value>0
- Add 4 new tests for NoActiveSatellites revert behavior
- Update 4 existing tests that expected success with 0 satellites

Cross-chain message types now correctly defined: MSG_UPGRADE_BEACON (0x01), MSG_ADD_CONTRACT_TYPE (0x02), MSG_ADMIN_CALL (0x03).

Also includes testnet E2E infrastructure: new deploy-testnet.sh, InfraUpgradeE2E, TriggerAdminCall, VerifyAdminCall scripts for testing cross-chain infrastructure upgrades on Sepolia/Base testnets.

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
@github-actions
Copy link
Contributor

Coverage Report

Metric Coverage
Lines 100.00% (0/0)
Statements 100.00% (0/0)
Branches 100.00% (0/0)
Functions 100.00% (0/0)
Coverage by file
File Lines Statements Branches Functions

Include GovernanceFactory, AccessFactory, ModulesFactory, HatsTreeSetup,
and PasskeyFactory in deploy-testnet.sh output so all indexed contract
addresses are visible after deployment.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@hudsonhrh hudsonhrh merged commit 443a7b0 into main Mar 14, 2026
5 checks passed
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