Add bitcoin-regtest-up package#8827
Conversation
|
Code sync follow-up:
|
| process.kill(process.pid, result.signal); | ||
| } | ||
|
|
||
| process.exit(result.status ?? 0); |
There was a problem hiding this comment.
Wrapper exits zero when child is killed by signal
Low Severity
When the child process is killed by a signal, spawnSync returns status: null and signal: '<name>'. The expression result.status ?? 0 evaluates to 0, so process.exit(0) runs, making signal-based termination appear as a clean successful exit. The preceding process.kill(process.pid, result.signal) is ineffective because Node.js delivers signals asynchronously via the event loop, and process.exit(0) runs synchronously before the signal handler fires. Parent processes and CI scripts checking the exit code would incorrectly see success.
Reviewed by Cursor Bugbot for commit ab33647. Configure here.
| } | ||
|
|
||
| process.exit(result.status ?? 0); | ||
| `, |
There was a problem hiding this comment.
Generated wrapper uses CJS in ESM-incompatible way
Medium Severity
The generated node_modules/.bin/bitcoind and bitcoin-cli wrapper scripts use require('node:child_process'), but these extensionless files are written without any module-type hint. In consuming projects whose package.json declares "type": "module", Node.js resolves these wrappers as ESM (since there's no .cjs extension and the nearest package.json governs), causing require to be undefined at runtime. The foundryup sibling package avoids this by symlinking directly to extracted binaries instead of generating script wrappers.
Reviewed by Cursor Bugbot for commit bbe4c1f. Configure here.
|
@metamaskbot publish-preview |
1 similar comment
|
@metamaskbot publish-preview |
| } | ||
|
|
||
| return options; | ||
| } |
There was a problem hiding this comment.
Missing error handling crashes CLI without package.json
Medium Severity
readBitcoinRegtestInstallOptionsFromPackageJson calls readFileSync on package.json without any try-catch, so it throws an unhelpful ENOENT error if no package.json exists in the working directory. Since package config is optional (the function reads optional overrides), it should return empty options {} when the file is missing, matching how getBitcoinRegtestCacheDirectory gracefully handles a missing .yarnrc.yml. The CLI calls this function unconditionally on both the install and cache clean paths, so any invocation from a directory without package.json crashes.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 82e0808. Configure here.
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
82e0808 to
f7eec1a
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 4 total unresolved issues (including 3 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit faa5ead. Configure here.
| bitcoinCore, | ||
| platformKey, | ||
| 'Bitcoin Core archive', | ||
| ); |
There was a problem hiding this comment.
Partial config replaces default platforms
Medium Severity
When package.json includes a bitcoinCore block, installBitcoinRegtest uses that object instead of BITCOIN_REGTEST_DEFAULT_CORE, without merging platforms. A documented override for one platform (e.g. linux-x64) removes pinned defaults for other hosts, so install fails on macOS with no archive configured for that platform.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit faa5ead. Configure here.
Wires `bitcoin-regtest-up` (the BTC counterpart of Foundryup) into the extension so local BTC E2E tests can spawn a real `bitcoind -regtest`. - Adds `bitcoin-regtest-up` as a dev dependency. Sourced from `github:ulissesferreira/bitcoin-regtest-up` as a stopgap until the MetaMask-published version (MetaMask/core#8827) lands on npm. A follow-up commit will swap the spec and package name. - Adds a `bitcoin-regtest-up:install` script that downloads the pinned Bitcoin Core release and exposes `bitcoind` + `bitcoin-cli` under `node_modules/.bin`. Not run via `postinstall` — opt-in for BTC E2E devs only, unlike the universal Anvil install. - Allowlists the prototype repo in `approvedGitRepositories` so yarn 4 accepts the git spec. - Adds a short README under `test/e2e/seeder/bitcoin/` describing the local install + run flow. The actual BTC seeder lands in a separate PR. The PoC BTC seeder reads `node_modules/.bin/bitcoind` via its `binaryPath` option, so this bootstrap is sufficient on its own.
8fcd392 to
aad4451
Compare
aad4451 to
b323be6
Compare
Wires `bitcoin-regtest-up` (the BTC counterpart of Foundryup) into the extension so local BTC E2E tests can spawn a real `bitcoind -regtest`. - Adds `bitcoin-regtest-up` as a dev dependency. Sourced from `github:ulissesferreira/bitcoin-regtest-up` as a stopgap until the MetaMask-published version (MetaMask/core#8827) lands on npm. A follow-up commit will swap the spec and package name. - Adds a `bitcoin-regtest-up:install` script that downloads the pinned Bitcoin Core release and exposes `bitcoind` + `bitcoin-cli` under `node_modules/.bin`. Not run via `postinstall` — opt-in for BTC E2E devs only, unlike the universal Anvil install. - Allowlists the prototype repo in `approvedGitRepositories` so yarn 4 accepts the git spec. - Adds a short README under `test/e2e/seeder/bitcoin/` describing the local install + run flow. The actual BTC seeder lands in a separate PR. The PoC BTC seeder reads `node_modules/.bin/bitcoind` via its `binaryPath` option, so this bootstrap is sufficient on its own.
## Summary This PR is the **first of two PRs** splitting MetaMask#8827 into cleanly-reviewable pieces. It contains **only** the pure scaffold output of `yarn create-package` plus ownership configuration — zero implementation logic. ### What's included - `packages/bitcoin-regtest-up/` — scaffolded package skeleton (source placeholder, tests, CHANGELOG, README, LICENSE, jest/tsconfig configs) generated by `yarn create-package --name bitcoin-regtest-up --description "Bitcoin Core regtest runtime installer for MetaMask E2E tests"` - `tsconfig.json` / `tsconfig.build.json` — monorepo-level references updated by the tool - `yarn.lock` — updated by `yarn install` run inside the tool - `README.md` — package list updated by `yarn readme-content:update` - `.github/CODEOWNERS` — ownership entries for the package (alphabetical list after `foundryup` + Package Release section), mirroring the `foundryup`/`solana-test-validator-up` pattern with `@MetaMask/networks` added - `teams.json` — issue-label routing entry, directly after the `foundryup` entry ### What's NOT included No implementation source, no `bin` field, no new runtime dependencies, no `knip.config.ts` changes, no unrelated monorepo churn. ### Stacked PR The implementation (real installer source, CLI bin, tests, full README) follows in a stacked PR based on this branch. ## Verification ``` yarn workspace @metamask/bitcoin-regtest-up run build yarn workspace @metamask/bitcoin-regtest-up run test yarn constraints yarn lint:teams yarn readme-content:check ``` All passed ✓ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Boilerplate package creation and metadata only; no production runtime behavior or security-sensitive logic. > > **Overview** > Adds **`@metamask/bitcoin-regtest-up`** to the monorepo as a scaffold-only package (intended for a future Bitcoin Core regtest installer for E2E tests). The diff is **`yarn create-package`** output plus wiring—no real installer logic, CLI `bin`, or new runtime deps yet. > > **Monorepo integration:** `tsconfig.json` / `tsconfig.build.json` references, `yarn.lock`, and root **`README.md`** package list + dependency graph node. > > **Ownership:** **`.github/CODEOWNERS`** (joint ownership after `foundryup`, matching `java-tron-up` / `solana-test-validator-up` with **`@MetaMask/networks`**) and **`teams.json`** issue routing. > > The package currently ships placeholder **`greeter`** source and a sample Jest test so build/test pipelines pass until the stacked implementation PR lands. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 87095cc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
|
This PR has been superseded and split into two smaller PRs for easier review:
Closing in favor of those PRs. |


Description
Adds
@metamask/bitcoin-regtest-upto the core monorepo using the generated package structure, then replaces the scaffold with the existing Bitcoin Core regtest runtime installer implementation.Ownership follows the runtime tooling/platform pattern and includes Networks, matching the Tron Snap ownership direction.
Changes
packages/bitcoin-regtest-up.bitcoin-regtest-upCLI bin fromdist/bin/bitcoin-regtest-up.mjs.teams.jsonownership.30.2and updates the migrated README to match.Verification
yarn workspace @metamask/bitcoin-regtest-up run buildyarn workspace @metamask/bitcoin-regtest-up run testyarn eslint packages/bitcoin-regtest-upyarn constraintsyarn lint:misc --check packages/bitcoin-regtest-up/package.json packages/bitcoin-regtest-up/README.md packages/bitcoin-regtest-up/src/index.ts packages/bitcoin-regtest-up/src/install.ts packages/bitcoin-regtest-up/src/install.test.ts packages/bitcoin-regtest-up/src/bin/bitcoin-regtest-up.ts packages/bitcoin-regtest-up/jest.config.js .github/CODEOWNERS teams.json README.md tsconfig.json tsconfig.build.jsonyarn readme-content:checkyarn lint:teamsyarn workspace @metamask/bitcoin-regtest-up run changelog:validatenode packages/bitcoin-regtest-up/dist/bin/bitcoin-regtest-up.mjs --helpgit diff --checkNote
Low Risk
New standalone dev/CI tooling package with no changes to wallet controllers or production runtime paths; risk is limited to consumers opting into the installer CLI.
Overview
Introduces
@metamask/bitcoin-regtest-up, a new runtime installer (modeled on@metamask/foundryup) that downloads and caches pinned Bitcoin Core 30.2 for local dev/CI and exposesbitcoind/bitcoin-clivianode_modules/.binwrappers. The package does not start or seed a node—test harnesses own process lifecycle and regtest setup.The installer supports SHA-256 verification, platform-specific archives (darwin/linux arm64/x64), cache reuse with invalidation when binaries aren’t runnable, handling of alternate daemon layouts (
bitcoind,bitcoin-node,bitcoinlauncher), CLI/package.jsonoverrides, and a scopedcache cleancommand. Monorepo wiring adds CODEOWNERS /teams.json(mobile, extension, networks), README listing, tsconfig references, and yarn.lock workspace entry.Reviewed by Cursor Bugbot for commit f827182. Bugbot is set up for automated code reviews on this repo. Configure here.