Skip to content

Feat/testnet4 deployment support#3932

Open
lionakhnazarov wants to merge 74 commits intothreshold-network:mainfrom
lionakhnazarov:feat/testnet4-deployment-support
Open

Feat/testnet4 deployment support#3932
lionakhnazarov wants to merge 74 commits intothreshold-network:mainfrom
lionakhnazarov:feat/testnet4-deployment-support

Conversation

@lionakhnazarov
Copy link
Copy Markdown
Collaborator

@lionakhnazarov lionakhnazarov commented Apr 8, 2026

feat: Bitcoin testnet4 defaults + Sepolia Hardhat/deploy tooling

Summary

This PR wires the Go client to Bitcoin testnet4 when using the Sepolia Ethereum mapping, adds an embedded Electrum URL list for testnet4, and updates ECDSA / random-beacon Hardhat config and deploy scripts so Sepolia deployments and redeploys work reliably with local artifacts and deployer accounts.
It fixes several failures that were blocking branch validation, including Yarn/Corepack mismatches in Docker and docs workflows, Git/Yarn checkout issues in GitHub Actions, stale random-beacon deploy exports used by ECDSA tests, and flaky/incompatible Go integration tests caused by provider rate limits, Electrum timeouts, and local block watcher race conditions.

Client (Go)

  • Adds bitcoin.Testnet4 and extends Network.String() so embedded Electrum resolution can use _electrum_urls/testnet4.
  • Maps SepoliaBitcoin testnet4 in config/network (replacing the legacy testnet mapping).
  • Adds config/_electrum_urls/testnet4 with a default Electrum server URL and extends config/electrum_test.go accordingly.

Solidity / Hardhat

  • ECDSA hardhat.config.ts: makes contract verification optional (@nomicfoundation/hardhat-verify), adjusts Sepolia named accounts to use index 0 (works with ACCOUNTS_PRIVATE_KEYS), trims external deployment paths for Sepolia to avoid RPC issues with stale transactionHash in npm artifacts, and relaxes typing where needed.
  • Deploy scripts (02_deploy_dkg_validator, 03_deploy_wallet_registry): supports forced compile via THRESHOLD_FORCE_DKG_COMPILE, and sets skipIfAlreadyDeployed: false for DKG validator where bytecode must be refreshed after Solidity changes.
  • Random beacon: updates export.json, hardhat.config.ts, 05_approve_random_beacon_in_token_staking.ts, and yarn.lock (large lockfile refresh).

Other

  • CI: trivial newline-only edits at EOF in contracts-ecdsa.yml and contracts-random-beacon.yml.
  • config/peers_test.go: adds an extra expected bootstrap peer for the testnet test case (consider splitting out if this PR should stay scoped only to testnet4/Sepolia tooling).
  • Fixed GitHub Actions Yarn setup by isolating Git config for Yarn-based git dependency fetches.
  • Updated Solidity Docker builds for ecdsa and random-beacon to include .yarnrc.yml and use Corepack with yarn@4.8.1.
  • Replaced upstream docs workflow usage with a local reusable workflow that installs dependencies with Corepack/Yarn 4.
  • Added a bundled random-beacon export deploy path for ECDSA so CI does not depend on gitignored sibling exports or stale npm exports.
  • Fixed the exported 05_approve_random_beacon_in_token_staking.js flow to skip networks where TokenStaking does not expose approveApplication.
  • Updated WalletRegistryGovernance test fixture setup to load the full deployment fixture so T and other external deployments are available.
  • Improved Ethereum integration tests by avoiding fragile latest-block decoding and skipping transient provider rate-limit failures.
  • Improved Electrum integration tests by skipping transient transport timeout failures from public backends.
  • Fixed local_v1 block counter watcher shutdown behavior and increased watcher buffering to reduce flaky coordination-layer test failures.

How to test

  • go test ./config/... ./pkg/bitcoin/...
  • From solidity/ecdsa / solidity/random-beacon: yarn install and deploy or dry-run against Sepolia as you normally do for this stack.

Notes / follow-ups

  • Review whether the Electrum URL and deployer/account choices in config are appropriate for a public merge (or replace with placeholders and document env overrides).
  • Consider moving peers_test.go and pure lockfile/export churn to separate commits or PRs if reviewers want a minimal diff.
  • Regenerate OpenZeppelin / deployment JSON locally and commit if your workflow expects those artifacts in-repo.

lionakhnazarov and others added 30 commits December 12, 2025 14:16
- Introduced Testnet4 configuration in  with a new Electrum server URL.
- Updated  to include Testnet4 for Bitcoin networks.
- Added Testnet4 constant in  for better network identification.
- Adjusted test cases in  for improved readability.
- Updated Hardhat configuration files to streamline deployment processes and handle potential errors during verification.
…ort.json file

- Removed a defunct Thesis Electrum URL from the expected peers in .
- Deleted the  file as it is no longer needed, streamlining the project structure.
…ackage.json and yarn.lock for ECDSA and random-beacon
…nterface for improved compatibility and clarity
…tency, enhancing readability and maintainability
…con export for deployment scripts, enhancing CI compatibility
…y directories for HOME and XDG_CONFIG_HOME, improving isolation during Git operations
…arnrc.yml for better configuration management
…ad of block counter, improving compatibility with modern transaction types
…e timing-sensitive block drops during tests and local coordination
Copy link
Copy Markdown
Member

@lrsaturnino lrsaturnino left a comment

Choose a reason for hiding this comment

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

Hey Lev, nice work on the testnet4 side — the core bits (enum variant, embedded URL, Sepolia remap) look clean and focused. Left a small set of inline comments on the infrastructure pieces that came along; these are the ones I'd flag as worth addressing before merge rather than general suggestions.

One thing worth surfacing at the top is the WalletRegistry.withdrawRewards change. I poked at the live mainnet state and the proxy at 0x46d52E41C2F300BC82217Ce22b920c34995204eb currently returns a non-zero allowlist() (0x5E1b4E41ea2eeA6aC7656431CCDC7B204a88386f), and that contract does implement rolesOf. So once this implementation is redeployed and the proxy repointed, the switch to _currentAuthorizationSource() does change beneficiary resolution on mainnet for any staker where owner ≠ beneficiary delegation is in play — it's not quite the no-op it might look like. Worth calling out explicitly in the PR description, and I'd really like to see that contract change land as its own PR with a test exercising the allowlist-set path.

Comment thread config/_electrum_urls/testnet4 Outdated
address operator = stakingProviderToOperator(stakingProvider);
if (operator == address(0)) revert UnknownOperator();
(, address beneficiary, ) = staking.rolesOf(stakingProvider);
(, address beneficiary, ) = _currentAuthorizationSource().rolesOf(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This reroutes the reward beneficiary through _currentAuthorizationSource() rather than staking directly, which means the allowlist when allowlist != address(0) and staking otherwise. On mainnet today allowlist() is non-zero — I checked the live proxy and it returns 0x5E1b4E41ea2eeA6aC7656431CCDC7B204a88386f, and that contract exposes rolesOf(address)(address,address,address). So once this implementation is redeployed and the proxy is repointed, beneficiary resolution under withdrawRewards actually does change on mainnet for any staker where owner ≠ beneficiary delegation is in play. Would feel much better if this change landed as its own PR with isolated audit visibility rather than inside the testnet4 work, ideally with a Solidity test that exercises withdrawRewards() under an allowlist != address(0) state.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

addressed in #3945

Comment thread solidity/ecdsa/deploy/02_deploy_dkg_validator.ts Outdated
Comment thread solidity/ecdsa/hardhat.config.ts Outdated
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