Skip to content

build(solidity): remove external sortition dependencies - #4330

Merged
piotr-roslaniec merged 9 commits into
devfrom
codex/remove-sortition-dependency
Sep 14, 2026
Merged

piotr-roslaniec merged 9 commits into
devfrom
codex/remove-sortition-dependency

Conversation

@mswilkison

@mswilkison mswilkison commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Remove @keep-network/sortition-pools from both Solidity packages and lockfiles while preserving the legacy implementations still needed by the source tree, fixtures, and deployment replay.

Freeze the nine runtime sortition sources plus their three Thesis interfaces under contracts/legacy/, with licenses, original package metadata, source revisions, and hashes. The runtime sources in the previously resolved 2.0.0 and 2.0.0-pre.16 packages are identical; only local import paths change.

ECDSA's published Random Beacon dependency also reintroduced sortition transitively. Replace it with the seven required support sources, initialization tasks, and eleven frozen deployment artifacts from its existing 2.1.0-dev.18 dependency. Preserve the already-corrected deployment scripts. Package the compatibility files explicitly and remove CI steps that could reinstall sortition, including the old test-fork override. Keep the existing dependency exclusions in lint/Slither for the relocated frozen files.

Testnet SortitionPool deploys now run unmodified production 2.0.0 logic instead of the removed test-fork override, which had been tweaked to bypass the chaosnet beta-operator gate (Chaosnet.sol's isChaosnetActive/isBetaOperator check, enforced in SortitionPool.sol's operator-insertion path) for easier operator onboarding. The addBetaOperator task is the existing onboarding path for that gate on both testnet and mainnet: it already called sortitionPool.chaosnetOwner() + addBetaOperators([operator]) before this PR and is already wired into the standard initialize task flow, just imported from the vendored copy instead of the npm package now. It is not new to this PR, but testnets that previously bypassed the gate via the fork must now go through it like mainnet does.

Validation:

  • Beacon: 955 tests pass; ECDSA: 673 tests pass, 44 inherited skips.
  • Clean local deployment replay and package export pass for both packages; lint passes.
  • Project contract ABIs, storage layouts, and executable runtime bytecode match the baseline after source-path/link-reference normalization. Solidity metadata changes are intentional.
  • Regenerated both dev-branch export checksum baselines and fixed locale-dependent manifest ordering (LC_ALL=C sort); all artifact hashes already match between local and CI output. The tracked ECDSA mainnet export.json and historical deployment records are unchanged.
  • Inspected the ECDSA npm tarball: all eleven Beacon snapshots, required task JS, source licenses, and provenance are included.
  • Neither package lockfile contains sortition-pools; ECDSA no longer installs the published Beacon package.
  • Added CI verification of the committed random-beacon-export deployment artifacts against recorded hashes, and recorded source hashes for the three vendored Thesis interfaces (previously undocumented).

This removes external legacy dependencies, not historical ABI/deployment compatibility. The frozen code is not a statement about the live protocol's operator-selection mechanism. Downstream packages still pinned to older npm releases need producer releases and consumer lockfile updates to remove their remaining transitive copies.

Supersedes #4328, including its unused direct Thesis dependency removal.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4f97fcad-cbb2-4d19-87fc-f0f11e5a0ffb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…shes

artifactSha256 in VENDOR.json records the pristine pre-stripping upstream
hash by design, so it can't detect tampering with the 11 committed
deployment artifact JSONs. Add committedSha256 alongside it and a new CI
job that checks the committed files against those hashes. Also inline the
LC_ALL=C sort step in the export-byte-identity regenerate message, which
previously omitted it and would reproduce the exact ordering bug this PR
fixed elsewhere.
The three vendored Thesis interfaces (IApproveAndCall, IERC20WithPermit,
IReceiveApproval) only had a bare interfaces.revision, unlike the nine
sortition sources which get a per-file sourceSha256 entry. Add the
matching interfaceSha256 map to both packages' VENDOR.json copies.
tasks/initialize.ts now imports the vendored .js task files by relative
path, which base tsconfig.json (unlike tsconfig.export.json) can't
resolve without allowJs, so tsc --noEmit / IDE tooling using the base
config reports TS2307.
…on-export README

The Source section claimed all bundled deploy scripts are TypeScript-
compiled output, while Format and Regeneration policy correctly carve
out the hand-written 05_approve_random_beacon_in_token_staking.js.
…-dependency

Resolve conflicts from the ethers v6 migration, ESLint 10 flat configs,
Prettier 3, Solhint 6, and TypeScript 6 changes on dev:

- .prettierignore: keep PR's legacy/ ignores + dev's .hardhat/ and export/
- .eslintignore: deleted (dev moved to ESLint 10 flat config); add
  tasks/legacy-random-beacon/ to eslint.config.mjs ignores instead
- package.json: keep PR's removal of @keep-network/random-beacon and
  @keep-network/sortition-pools from dependencies; add dev's types/ and
  utils/ to files array
- hardhat.config.ts: use dev's resolveRandomBeaconExport module import
  and setupTenderly call; keep PR's spread (no npm fallback) for
  development deployments; keep dev's typechain ethers-v6 target
- utils/random-beacon-export.ts: remove npm package fallback for
  artifacts (PR removed the package; bundled copy is the only fallback)
- tasks/index.ts: remove legacy-random-beacon/unlock-eth-accounts import
  (dev's random-beacon.ts module already loads it via the resolver)
- tasks/initialize.ts: use dev's import from ./random-beacon module
  instead of direct legacy JS imports
- tsconfig.json: take dev's strict config (allowJs no longer needed)
- export-baseline.sha256: keep PR's structure; regenerate after merge
- yarn.lock: regenerated for both packages (removes sortition-pools)
- npm-random-beacon.yml: take dev's yarn install --immutable (PR's
  solidity-contracts pin no longer needed; ethers v6 precheck is in TS)
- README.md: merge PR's frozen snapshot description with dev's ethers
  v6/ES2020 regeneration instructions
- Update resolveRandomBeaconExport tests: artifacts now resolve from
  the bundled copy (npm package was removed by the PR); the real-checkout
  test accepts either sibling or bundled path, just not node_modules
- Regenerate solidity/ecdsa/external/random-beacon-export/ deploy scripts
  and tasks from random-beacon prepack output (ES2020/ethers v6 from dev
  migration, replacing the PR's frozen ES5 scripts)
- Regenerate export-baseline.sha256 for both packages after the dev merge
  (Prettier 3, ESLint 10, Solhint 6, ethers v6, TypeScript 6 changes
  altered artifact hashes)
- Update bundled-beacon-export-freshness CI check to exclude LICENSE,
  VENDOR.json, and artifacts/ from the diff (PR added these frozen
  provenance files to the bundle alongside the deploy scripts)
@piotr-roslaniec
piotr-roslaniec merged commit 5080bf0 into dev Sep 14, 2026
38 checks passed
@piotr-roslaniec
piotr-roslaniec deleted the codex/remove-sortition-dependency branch September 14, 2026 06:14
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