@openzeppelin/compact-deployer 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -6
- package/README.md +116 -81
- package/dist/config/compact-config.d.ts +5 -0
- package/dist/config/compact-config.js +65 -19
- package/dist/config/compact-config.js.map +1 -1
- package/dist/config/patterns.d.ts +20 -0
- package/dist/config/patterns.js +68 -0
- package/dist/config/patterns.js.map +1 -0
- package/dist/config/schema.d.ts +314 -46
- package/dist/config/schema.js +44 -11
- package/dist/config/schema.js.map +1 -1
- package/dist/deployer.d.ts +11 -1
- package/dist/deployer.js +106 -29
- package/dist/deployer.js.map +1 -1
- package/dist/errors.d.ts +9 -1
- package/dist/errors.js +11 -3
- package/dist/errors.js.map +1 -1
- package/dist/loaders/artifact.d.ts +2 -0
- package/dist/loaders/artifact.js +4 -3
- package/dist/loaders/artifact.js.map +1 -1
- package/dist/loaders/contract-resolve.d.ts +3 -2
- package/dist/loaders/contract-resolve.js +8 -3
- package/dist/loaders/contract-resolve.js.map +1 -1
- package/dist/loaders/init-state.d.ts +7 -3
- package/dist/loaders/init-state.js +9 -3
- package/dist/loaders/init-state.js.map +1 -1
- package/dist/loaders/signing-key.d.ts +3 -0
- package/dist/loaders/signing-key.js +6 -0
- package/dist/loaders/signing-key.js.map +1 -1
- package/dist/runDeploy.d.ts +7 -1
- package/dist/runDeploy.js +7 -2
- package/dist/runDeploy.js.map +1 -1
- package/dist/services/chain-state.d.ts +7 -4
- package/dist/services/chain-state.js +14 -5
- package/dist/services/chain-state.js.map +1 -1
- package/dist/services/contract-state.d.ts +2 -2
- package/dist/services/contract-state.js +2 -2
- package/dist/services/contract-state.js.map +1 -1
- package/dist/services/deploy-tx.d.ts +16 -5
- package/dist/services/deploy-tx.js +17 -7
- package/dist/services/deploy-tx.js.map +1 -1
- package/dist/services/fragment-size.d.ts +8 -0
- package/dist/services/fragment-size.js +19 -0
- package/dist/services/fragment-size.js.map +1 -0
- package/dist/services/maintenance-tx.d.ts +12 -5
- package/dist/services/maintenance-tx.js +13 -2
- package/dist/services/maintenance-tx.js.map +1 -1
- package/dist/services/wallet-cache.d.ts +3 -3
- package/dist/services/wallet-cache.js +2 -2
- package/dist/services/wallet-cache.js.map +1 -1
- package/dist/services/wallet-sync.js +3 -3
- package/dist/services/wallet-sync.js.map +1 -1
- package/dist/wallet/handler.d.ts +1 -1
- package/dist/wallet/handler.js +5 -3
- package/dist/wallet/handler.js.map +1 -1
- package/package.json +19 -19
- package/proof-server.yml +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,18 +6,37 @@ file.
|
|
|
6
6
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
7
7
|
and this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## 0.3.0 (2026-09-24)
|
|
10
10
|
|
|
11
11
|
### Added
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
- `
|
|
15
|
-
-
|
|
13
|
+
- `[contracts]` pattern keys, so one entry covers many contracts: a name pattern (`"Mock*"`) or a directory pattern (`"**/test/mocks/*"`) matched under the new `[profile].src_dir`. `{name}` expands to the contract name and `artifact` defaults to it. See the README's "Patterns" section (#193)
|
|
14
|
+
- `initialPrivateState` on `DeployerOptions` and `RunDeployOptions` sets the initial private state in code and overrides `[contracts.X].init_private_state`. A `private_state_id` with no initial private state from either source fails with exit 2, and so does an in-code state with no `private_state_id` (#193)
|
|
15
|
+
- `witnesses` on `DeployerOptions` and `RunDeployOptions` sets the witness implementations in code and overrides `[contracts.X].witnesses` (#193)
|
|
16
|
+
- `record` on `DeployerOptions` and `RunDeployOptions`, default `true`. With `false` a deploy reads and writes no deployments ledger, so it never resumes and `deploymentsFile` is `''` (#193)
|
|
17
|
+
- With no fragment budget, a later deploy of the same artifact on the same network starts at the size an earlier halving in the process settled on, instead of every circuit (#193)
|
|
16
18
|
|
|
17
19
|
### Changed
|
|
18
20
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
+
- **Breaking:** the deploy stack moves to Ledger v9. Compile artifacts with `compact compile +0.34.0`; an older one fails at submit with `Version mismatch`. Versions in the README's "Supported stack" (#192)
|
|
22
|
+
- **Breaking:** signing and verifying keys are tagged `{ tag, value }`, not hex. `SigningKey.ledgerKey` gives that form and `ChainSnapshot.committee` is `SignatureVerifyingKey[]`. `signing_key_file` on disk is unchanged (#192)
|
|
23
|
+
- yarn and pnpm need one resolution, `@midnightntwrk/ledger-v9`, down from six (#192)
|
|
24
|
+
- `proof_server = "auto"` boots `midnightntwrk/proof-server:9.0.0-rc.6` (#192)
|
|
25
|
+
- `@midnightntwrk/ledger-v9` moves from 1.0.0-rc.3 to 1.0.0-rc.5. npm now needs the pin too, as `overrides`. Update the yarn / pnpm resolution to match (#193)
|
|
26
|
+
- **Breaking:** `CompactConfigData.contracts` holds partial entries, which `CompactConfig.contract(name)` merges and validates. `listContracts()` returns exact keys only; `listPatterns()` returns the pattern keys (#193)
|
|
27
|
+
|
|
28
|
+
## 0.2.0 (2026-09-15)
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Fragmented deploy for contracts too large for one block, driven by `--circuits-per-tx` / `[contracts.X].circuits_per_tx`, with resume from chain state and a strict verify before `confirmed`. See the README's "Large contracts" section (#174)
|
|
33
|
+
- `DeployResult` gains `fragments` and `circuits`; both appear in `--json`, alongside a failed fragmented deploy's `address`, `circuitsOnChain`, `circuitsPending`, and `txId` (#174)
|
|
34
|
+
- Exit codes `7` (`BlockLimitError`: the deploy tx was refused as too large at the configured or minimum fragment size) and `8` (`FragmentDeployError`: fragmented deploy incomplete and resumable) (#174)
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- `DeploymentRecord` gains a `partial` member. A single-tx deploy still writes only `pending` then `confirmed`, so an exhaustive `switch` on `status` needs a new arm only if it reads records from a split deploy (#174)
|
|
39
|
+
- A deploy that fits one transaction is unchanged: same transaction, same `pending` then `confirmed` records, no chain read and no maintenance transaction (#174)
|
|
21
40
|
|
|
22
41
|
## 0.1.0 (2026-09-09)
|
|
23
42
|
|
package/README.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
compact-deploy Token --network local
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
> **Status: developer-preview,
|
|
7
|
+
> **Status: developer-preview, local standalone only.** No public network runs the Ledger v9 stack yet. Mainnet unsupported: unaudited, no hardware signer, no multisig, no tx retry, no upgrade tooling.
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
11
|
-
- Node.js >= 24
|
|
11
|
+
- Node.js >= 24. The deployer uses `await using` / `AsyncDisposableStack`.
|
|
12
12
|
|
|
13
13
|
## Quick start
|
|
14
14
|
|
|
@@ -24,16 +24,14 @@ The deploy result lands in `deployments/compact/<network>.json`.
|
|
|
24
24
|
|
|
25
25
|
## Install & run
|
|
26
26
|
|
|
27
|
-
The `compact-deploy` bin ships in `@openzeppelin/compact-cli`. Install it as a dev dependency of the project that holds your compiled artifacts
|
|
27
|
+
The `compact-deploy` bin ships in `@openzeppelin/compact-cli`. Install it as a dev dependency of the project that holds your compiled artifacts:
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
npm i -D @openzeppelin/compact-cli # or pnpm/yarn
|
|
31
31
|
npx compact-deploy Token --network local # resolves the local install
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
> **Ephemeral `npx @openzeppelin/compact-cli compact-deploy …` (no local install)** is fine for `--help`, `--version`, and `--dry-run` / validation, but **not reliable for a real deploy**: npx fetches the CLI into its own cache tree, so its `compact-runtime` differs from your project's and the submit fails with `expected instance of ContractMaintenanceAuthority`. Install it locally for real deploys.
|
|
34
|
+
Install it locally for any real deploy. The deployer and your artifacts must share one physical `@midnight-ntwrk/compact-runtime` copy, and an ephemeral `npx @openzeppelin/compact-cli …` fetches its own, failing the submit with `expected instance of ContractMaintenanceAuthority`. Ephemeral is fine for `--help`, `--version` and `--dry-run`.
|
|
37
35
|
|
|
38
36
|
## Supported stack
|
|
39
37
|
|
|
@@ -41,32 +39,27 @@ The deployer pins one Midnight stack, and artifacts have to be compiled against
|
|
|
41
39
|
|
|
42
40
|
| Component | Version |
|
|
43
41
|
|---|---|
|
|
44
|
-
| `@midnight-ntwrk/compact-runtime` | 0.
|
|
45
|
-
| `@
|
|
46
|
-
| `@midnight-ntwrk/
|
|
47
|
-
| `@midnight-ntwrk/
|
|
48
|
-
| `@midnight-ntwrk/
|
|
49
|
-
|
|
|
42
|
+
| `@midnight-ntwrk/compact-runtime` | 0.19.0 |
|
|
43
|
+
| `@midnightntwrk/ledger-v9` | 1.0.0-rc.5 |
|
|
44
|
+
| `@midnight-ntwrk/compact-js` | 2.5.5-rc.8 |
|
|
45
|
+
| `@midnight-ntwrk/midnight-js-*` | 5.0.0-beta.7 |
|
|
46
|
+
| `@midnight-ntwrk/testkit-js` | 5.0.0-beta.7 |
|
|
47
|
+
| `@midnightntwrk/wallet-sdk-facade` | 5.0.0-beta.2 |
|
|
48
|
+
| Compact compiler | 0.34.0 |
|
|
49
|
+
|
|
50
|
+
Compile with `compact compile +0.34.0`. An older artifact fails at submit with `Version mismatch`.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
The ledger and the wallet SDK sit under the `@midnightntwrk` scope, no hyphen. Everything else keeps `@midnight-ntwrk`.
|
|
53
|
+
|
|
54
|
+
Every package manager needs one pin, because the stack's packages ask for different ledger versions and a second ledger copy breaks every deploy. With npm:
|
|
52
55
|
|
|
53
56
|
```json
|
|
54
|
-
"
|
|
55
|
-
"@
|
|
56
|
-
"@midnight-ntwrk/wallet-sdk-address-format": "3.1.2",
|
|
57
|
-
"@midnight-ntwrk/wallet-sdk-dust-wallet": "4.1.0",
|
|
58
|
-
"@midnight-ntwrk/wallet-sdk-facade": "4.0.1",
|
|
59
|
-
"@midnight-ntwrk/wallet-sdk-shielded": "3.0.1",
|
|
60
|
-
"@midnight-ntwrk/wallet-sdk-unshielded-wallet": "3.1.0"
|
|
57
|
+
"overrides": {
|
|
58
|
+
"@midnightntwrk/ledger-v9": "1.0.0-rc.5"
|
|
61
59
|
}
|
|
62
60
|
```
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Compile with the pinned compiler: `compact compile +0.31.1`. The current default compactc (0.34.x) emits code for compact-runtime 0.19.0, and the deploy then fails with a `Version mismatch` runtime error.
|
|
67
|
-
|
|
68
|
-
- As of 2026-09, `OpenZeppelin/compact-contracts` `main` is on compact-runtime 0.19.0 / ledger-v9 1.0.0-rc.3, so contracts built there are not deployable with this tool today.
|
|
69
|
-
- Moving the deployer to the v9 stack is pending a published `@midnight-ntwrk/ledger-v9`: `@midnight-ntwrk/compact-js` 2.5.3 depends on an unpublished ledger-v9 alpha, which yarn rejects with `YN0082`.
|
|
62
|
+
yarn takes the same entry under `resolutions`, and pnpm under `pnpm.overrides`. Nothing else in the stack floats.
|
|
70
63
|
|
|
71
64
|
## CLI
|
|
72
65
|
|
|
@@ -93,62 +86,63 @@ compact-deploy <Contract>
|
|
|
93
86
|
|
|
94
87
|
Exit codes: `0` ok · `2` config error (includes a pending or partial deploy record without `--force`) · `3` wallet error · `5` deploy tx failed or not confirmed · `6` deployments ledger unreadable or unwritable · `7` the deploy tx was refused as too large at the configured or minimum fragment size · `8` fragmented deploy incomplete · `1` unexpected.
|
|
95
88
|
|
|
96
|
-
A deploy writes
|
|
89
|
+
A deploy writes `status: "pending"` (address, txId) as soon as the node accepts the tx, then `status: "confirmed"` (txHash, blockHeight) on finalization. A dropped connection or `--tx-timeout` leaves the pending record in place; the next deploy of that contract refuses until you check the tx on chain and pass `--force`.
|
|
97
90
|
|
|
98
91
|
## Large contracts
|
|
99
92
|
|
|
100
|
-
The node rejects a deploy tx above the per-block extrinsic limit with `1010: Invalid Transaction: Transaction would exhaust the block limits`. Weight grows with circuit count, so past roughly 15 circuits a single-tx deploy stops landing
|
|
93
|
+
The node rejects a deploy tx above the per-block extrinsic limit with `1010: Invalid Transaction: Transaction would exhaust the block limits`. Weight grows with circuit count, so past roughly 15 circuits a single-tx deploy stops landing.
|
|
94
|
+
|
|
95
|
+
`--circuits-per-tx <n>` (or `[contracts.X].circuits_per_tx`) splits it: fragment 0's verifier keys ride the deploy tx, each further fragment is one `MaintenanceUpdate` batching `VerifierKeyInsert`s.
|
|
101
96
|
|
|
102
|
-
- `--circuits-per-tx <n>` (or `[contracts.X].circuits_per_tx`) splits the deploy: fragment 0's verifier keys ride the deploy tx, each further fragment is one `MaintenanceUpdate` batching `VerifierKeyInsert`s.
|
|
103
97
|
- Left unset, the deployer submits the largest batch it can and halves on a refusal, down to a single circuit. There is no pre-flight weight check.
|
|
104
|
-
- Set at or above the circuit count, it pins a single-tx deploy and disables halving: a refusal is exit 7, never a split.
|
|
105
|
-
-
|
|
98
|
+
- Set at or above the circuit count, it pins a single-tx deploy and disables halving: a refusal is exit 7, never a split.
|
|
99
|
+
- A size found by halving is remembered in memory: later deploys of the same artifact on the same network, in the same process, start there. A set budget and a resume ignore it.
|
|
106
100
|
- Fragments are ordered by sorted circuit name, so a rerun rebuilds the same plan.
|
|
107
|
-
-
|
|
108
|
-
-
|
|
101
|
+
- One `deploy()` call does the deploy, every insert, and a byte-for-byte check of every on-chain key against the artifact. Only that check writes `confirmed`.
|
|
102
|
+
- Between fragment 0 landing and the last insert the contract is live with a subset of its circuits, ordered by name rather than by dependency. Keep every circuit safe to call alone, or hold traffic until the deploy confirms.
|
|
109
103
|
- A constructor that creates or spends a Zswap coin cannot be split: exit 2.
|
|
110
|
-
- A
|
|
111
|
-
|
|
112
|
-
A split deploy writes `status: "partial"` (address, txId, `circuitsOnChain`, `circuitsPending`) instead of `pending`. Re-running the same deploy command resumes it: the remaining circuits come from chain state, not from the record. Resume is refused with exit 2 unless the recorded address exists, its maintenance committee holds this signing key, and every on-chain key matches the artifact. If the deploy tx is not seen within `--tx-timeout` and no state is readable yet, the run exits 8 instead: the tx may still be landing, so check the address on an explorer before reaching for `--force`. `--force` on a `partial` head abandons it (rotated into history) and deploys a new contract at a new address.
|
|
104
|
+
- A committee with a threshold above 1 is refused, since the deployer holds one key: exit 2.
|
|
113
105
|
|
|
114
|
-
|
|
106
|
+
### Resuming
|
|
115
107
|
|
|
116
|
-
A
|
|
108
|
+
A split deploy writes `status: "partial"` (address, txId, `circuitsOnChain`, `circuitsPending`). Re-running the same command resumes it from chain state, not from the record.
|
|
117
109
|
|
|
118
|
-
|
|
110
|
+
- Resume is refused with exit 2 unless the recorded address exists, its committee holds this signing key, and every on-chain key matches the artifact.
|
|
111
|
+
- Exit 8 means the deploy tx was not seen within `--tx-timeout`. It may still be landing, so check the address on an explorer before reaching for `--force`.
|
|
112
|
+
- If every circuit is on chain but the indexer never serves the deploy tx, copy `txHash` and `blockHeight` from an explorer into the record and re-run. That confirms without a new transaction.
|
|
113
|
+
- `--force` on a `partial` head abandons it and deploys a new contract at a new address.
|
|
114
|
+
- A resume stores the signing key if the private-state store lacks it. It never restores `initialPrivateState`, which exists only inside the original constructor run.
|
|
115
|
+
- The guard cannot tell two deploys of the same artifact with the same key apart. Do not hand-edit a `partial` record's `address`, or a sibling deploy will receive this run's remaining keys.
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
The properties this path has to hold are listed in [docs/invariants.md](./docs/invariants.md).
|
|
117
|
+
Results carry `fragments` (transactions the address has taken; `0` on a dry-run) and `circuits` (keys verified on chain). A `--json` failure adds `address`, `circuitsOnChain`, `circuitsPending`, and the failed insert's `txId`.
|
|
123
118
|
|
|
124
119
|
## Deploying to real networks (preprod, preview, testnet)
|
|
125
120
|
|
|
126
|
-
>
|
|
121
|
+
> Nothing public is deployable today: preprod is still on the v8 ledger and preview is null-routed. Local standalone (`make env-up`) is the only working target. The rules below apply once a public network moves to v9.
|
|
127
122
|
|
|
128
|
-
- **First sync is slow**
|
|
129
|
-
- **Bump
|
|
130
|
-
- **
|
|
131
|
-
- **
|
|
132
|
-
- **
|
|
133
|
-
- **Tip gate is tolerant**: sync completes once every sub-wallet is within 50 events of the tip, not at an exact gap of 0. On a live network the global dust stream advances continuously, so an exact-match gate would never fire.
|
|
123
|
+
- **First sync is slow** on a long-history chain, tens of minutes from genesis. Cache makes reruns near-instant, but raise `--sync-timeout` for the first run.
|
|
124
|
+
- **Bump the Node heap** for long-history chains: `NODE_OPTIONS="--max-old-space-size=8192"`.
|
|
125
|
+
- **Lower `--sync-batch-size`** on a memory-constrained host. Larger replays a long dust history faster but costs memory per batch.
|
|
126
|
+
- **Persist the sync knobs**: `sync_timeout` and `sync_batch_size` under `[networks.X]`. Precedence is CLI > TOML > default.
|
|
127
|
+
- **The tip gate is tolerant**: sync completes within 50 events of the tip. On a live network the dust stream advances continuously, so an exact gate would never fire.
|
|
134
128
|
- **Seed source**: `--seed-file`, `MN_DEPLOYER_SEED`, or `[wallet].keystore`. The `wallet = { source = "local" }` shorthand is dev-preset only.
|
|
135
129
|
|
|
136
130
|
## Wallet cache
|
|
137
131
|
|
|
138
|
-
After each successful sync the deployer writes `<compact.toml dir>/.states/<network>-<seed-hash>-<kind>.gz
|
|
132
|
+
After each successful sync the deployer writes `<compact.toml dir>/.states/<network>-<seed-hash>-<kind>.gz`, one file per shielded / dust / unshielded sub-wallet. The next run restores from it instead of re-syncing from genesis.
|
|
139
133
|
|
|
140
|
-
- Contents: gzipped sub-wallet state (UTXOs, checkpoint). No private keys
|
|
141
|
-
- Keyed by SHA-256(seed) + network ID, so `local`
|
|
142
|
-
- Bust it
|
|
143
|
-
-
|
|
144
|
-
- Resolved against the `compact.toml` directory, not the shell CWD
|
|
145
|
-
-
|
|
146
|
-
- Library callers
|
|
134
|
+
- Contents: gzipped sub-wallet state (UTXOs, checkpoint). No private keys; those are re-derived from the seed each run.
|
|
135
|
+
- Keyed by SHA-256(seed) + network ID, so `local` and `preprod` keep separate caches.
|
|
136
|
+
- Bust it with `--no-cache` or `rm -rf .states/`. Corrupt or version-mismatched files fall back to a fresh sync.
|
|
137
|
+
- Writes are best-effort and never block a deploy.
|
|
138
|
+
- Resolved against the `compact.toml` directory, not the shell CWD. Same for the LevelDB private-state store (`<compact.toml dir>/midnight-level-db/`).
|
|
139
|
+
- Run one `compact-deploy` at a time per project. A second concurrent run fails on the LevelDB lock, and two runs on one seed race the cache.
|
|
140
|
+
- Library callers running several deploys in one process must pass their own `privateStateProvider`. The default LevelDB store holds its lock until the process exits.
|
|
147
141
|
- `.states/` is gitignored.
|
|
148
142
|
|
|
149
143
|
### Importing a pre-warmed state file
|
|
150
144
|
|
|
151
|
-
|
|
145
|
+
Drop in a `wallet.serializeState()` snapshot from a prior session:
|
|
152
146
|
|
|
153
147
|
```
|
|
154
148
|
compact-deploy <Contract> --network preprod \
|
|
@@ -157,13 +151,12 @@ compact-deploy <Contract> --network preprod \
|
|
|
157
151
|
--seed-cache-from-unshielded /path/to/unshielded.json
|
|
158
152
|
```
|
|
159
153
|
|
|
160
|
-
- The dust file is the one that matters on
|
|
161
|
-
-
|
|
162
|
-
- The
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
- Ignored under `--no-cache` (with a warning), since load is disabled in that mode.
|
|
154
|
+
- The dust file is the one that matters on a long-history chain. The other two are optional.
|
|
155
|
+
- Raw JSON or gzipped, detected by magic bytes.
|
|
156
|
+
- The previous cache is kept at `<target>.gz.bak`, never deleted. Roll back with `mv .states/<target>.gz.bak .states/<target>.gz`.
|
|
157
|
+
- The write is atomic: `<target>.gz.tmp` first, then renamed over `<target>.gz`.
|
|
158
|
+
- A restore failure warns and falls through to a fresh sync, so the deploy still completes.
|
|
159
|
+
- Ignored under `--no-cache`.
|
|
167
160
|
|
|
168
161
|
## Wallet seed resolution
|
|
169
162
|
|
|
@@ -232,34 +225,55 @@ signing_key_file = "./deploy/Vault.signingkey"
|
|
|
232
225
|
circuits_per_tx = 8
|
|
233
226
|
```
|
|
234
227
|
|
|
235
|
-
`proof_server`: a URL pins the server; `"auto"` spawns a `testcontainers`-managed proof-server container for the
|
|
228
|
+
`proof_server`: a URL pins the server; `"auto"` spawns a `testcontainers`-managed proof-server container for the deploy; omitting it falls back to `PROOF_SERVER_PORT`, then to `http://127.0.0.1:6300`.
|
|
229
|
+
|
|
230
|
+
`"auto"` needs Docker and boots the `proof-server.yml` shipped in this package, pinning `midnightntwrk/proof-server:9.0.0-rc.6`. To boot a different image, put your own `proof-server.yml` in the directory you run `compact-deploy` from; it wins over the packaged one.
|
|
231
|
+
|
|
232
|
+
### Patterns
|
|
233
|
+
|
|
234
|
+
One `[contracts]` entry can cover many contracts. A key is one of:
|
|
235
|
+
|
|
236
|
+
- `Token`: exact, that contract only.
|
|
237
|
+
- `"Mock*"`: a name pattern (holds `*`, `?`, `[` or `{`), matched against the contract name.
|
|
238
|
+
- `"**/test/mocks/*"`: a directory pattern (holds `/`), matched against the contract's source path under `[profile].src_dir`, `.compact` included. The source of `<name>` is the unique `<src_dir>/**/<name>.compact`, skipping `node_modules` and dot-directories. A second match is an error.
|
|
239
|
+
|
|
240
|
+
Every matching pattern applies in file order, a later one overriding an earlier one field by field. The exact entry applies last. `{name}` in any string value expands to the contract name, and `artifact` defaults to it. `runDeploy(Contract)` searches exact keys only.
|
|
236
241
|
|
|
237
|
-
|
|
242
|
+
```toml
|
|
243
|
+
[profile]
|
|
244
|
+
src_dir = "contracts/src"
|
|
245
|
+
|
|
246
|
+
[contracts."**/test/mocks/*"]
|
|
247
|
+
signing_key_file = "./deploy/{name}.signingkey"
|
|
248
|
+
|
|
249
|
+
# Inherits signing_key_file from the pattern above.
|
|
250
|
+
[contracts.MockToken]
|
|
251
|
+
args = ["MyToken", "MTK", 18]
|
|
252
|
+
```
|
|
238
253
|
|
|
239
254
|
## Keystore format
|
|
240
255
|
|
|
241
|
-
|
|
256
|
+
An Ethereum V3 JSON keystore (scrypt + AES-128-CTR) tagged `version: "midnight-1"`, so other tooling does not mis-read it as an Ethereum key. The encrypted secret is a 32-byte Midnight wallet seed (hex).
|
|
242
257
|
|
|
243
|
-
## Known issues
|
|
258
|
+
## Known issues
|
|
244
259
|
|
|
245
|
-
1. **
|
|
260
|
+
1. **Preprod runs the v8 ledger.** Its transactions carry the `midnight:transaction[v9]` header tag, which `@midnightntwrk/ledger-v9` rejects on deserialize. **Workaround:** none until preprod upgrades; use local standalone.
|
|
246
261
|
|
|
247
|
-
2. **
|
|
262
|
+
2. **Preview endpoints are null-routed.** `rpc.preview` and `indexer.preview` resolve to `0.0.0.0`, which blocks every consumer of testkit-js's `PreviewTestEnvironment`. **Workaround:** none on public testnet; use local standalone.
|
|
248
263
|
|
|
249
|
-
|
|
250
|
-
A cold preprod dry run reached chain tip on all three sub-wallets (~37 min) and ended at the expected `UnfundedWalletError`.
|
|
264
|
+
3. **The faucet is manual.** Fund the wallet's `unshielded` address, logged at startup, before running.
|
|
251
265
|
|
|
252
|
-
|
|
266
|
+
4. **Dust fee overhead breaks faucet wallets.** testkit-js defaults `additionalFeeOverhead` to `5e20` against a faucet wallet's `~3e15` dust, giving `Insufficient Funds: could not balance dust`. The deployer overrides to `5e14`; library users building their own provider must mirror that.
|
|
253
267
|
|
|
254
|
-
|
|
268
|
+
5. **Long-history dust sync exhausts the default Node heap.** The deployer raises the sync batch size to 5000 ([midnight-wallet#425](https://github.com/midnightntwrk/midnight-wallet/issues/425)), but a first sync on a long-history chain can still pass V8's ~2 GB default old-space. Set `NODE_OPTIONS="--max-old-space-size=8192"` for that run; cache fixes the rest.
|
|
255
269
|
|
|
256
|
-
|
|
270
|
+
6. **The root `@midnightntwrk/ledger-v9` resolution is load-bearing.** `compact-js` declares it as a range, so without the pin yarn nests a second ledger copy and deploys fail. Do not drop it on a bump.
|
|
257
271
|
|
|
258
|
-
|
|
272
|
+
7. **`@midnight-ntwrk/compact-runtime` resolves to two copies**, `0.19.0-rc.0` under `compact-js` and `midnight-js-protocol` against `0.19.0` everywhere else. The integration suite deploys on that tree, including the pruned constructor path through `compact-js`. Forcing one `0.19.0` copy with a resolution also deploys, the split path included.
|
|
259
273
|
|
|
260
274
|
## Programmatic API
|
|
261
275
|
|
|
262
|
-
The package has no barrel entrypoint
|
|
276
|
+
The package has no barrel entrypoint. Each module is its own subpath export, so an import names the module it comes from and pulls in only that module.
|
|
263
277
|
|
|
264
278
|
| Subpath | Exports |
|
|
265
279
|
|---|---|
|
|
@@ -273,7 +287,7 @@ The package has no barrel entrypoint: each module is its own subpath export, so
|
|
|
273
287
|
| `/providers/proof-server` | `ProofServer` |
|
|
274
288
|
| `/wallet/handler` · `/wallet/keystore` · `/wallet/seeds` | `WalletHandler`, `Keystore`, `classifySeed`, `localPrefundedSeed` |
|
|
275
289
|
|
|
276
|
-
Curried form
|
|
290
|
+
Curried form. Pass the compiled `Contract` class and the constructor args become typed parameters:
|
|
277
291
|
|
|
278
292
|
```ts
|
|
279
293
|
import { runDeploy } from "@openzeppelin/compact-deployer/run-deploy";
|
|
@@ -287,7 +301,7 @@ const result = await runDeploy(Contract, { network: "local" })(
|
|
|
287
301
|
console.log(result.address);
|
|
288
302
|
```
|
|
289
303
|
|
|
290
|
-
Options-object form
|
|
304
|
+
Options-object form. Name the contract as it appears in `compact.toml`, with args from the TOML or inline:
|
|
291
305
|
|
|
292
306
|
```ts
|
|
293
307
|
import { runDeploy } from "@openzeppelin/compact-deployer/run-deploy";
|
|
@@ -301,4 +315,25 @@ const result = await runDeploy({
|
|
|
301
315
|
console.log(result.address);
|
|
302
316
|
```
|
|
303
317
|
|
|
304
|
-
Every option has a `process.argv` default (`--network`, `--config`, `--dry-run`, …), so the same script works with flags at the call site. On failure `runDeploy` sets `process.exitCode` and rethrows
|
|
318
|
+
Every option has a `process.argv` default (`--network`, `--config`, `--dry-run`, …), so the same script works with flags at the call site. On failure `runDeploy` sets `process.exitCode` and rethrows; it never calls `process.exit`, so catch it if you want that code to reach the shell.
|
|
319
|
+
|
|
320
|
+
Three options suit a caller that deploys many contracts from code, such as a test harness. `Deployer.prepare` and `runDeploy` both take them, with no argv flag:
|
|
321
|
+
|
|
322
|
+
- `initialPrivateState` and `witnesses` override `[contracts.X].init_private_state` and `[contracts.X].witnesses`. A `private_state_id` and an initial private state come together: `prepare` throws `ConfigError` when one lacks the other.
|
|
323
|
+
- `record: false` skips the deployments ledger. Nothing is read or written, so every deploy is fresh and `deploymentsFile` is `''`.
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
import { Deployer } from "@openzeppelin/compact-deployer/deployer";
|
|
327
|
+
|
|
328
|
+
await using deployer = await Deployer.prepare({
|
|
329
|
+
contract: "MockToken",
|
|
330
|
+
network: "local",
|
|
331
|
+
logger,
|
|
332
|
+
walletProvider, // one wallet shared across deploys
|
|
333
|
+
privateStateProvider, // e.g. testkit-js inMemoryPrivateStateProvider()
|
|
334
|
+
initialPrivateState: { secretKey },
|
|
335
|
+
witnesses,
|
|
336
|
+
record: false,
|
|
337
|
+
});
|
|
338
|
+
const { address } = await deployer.deploy();
|
|
339
|
+
```
|
|
@@ -23,9 +23,14 @@ export declare class CompactConfig {
|
|
|
23
23
|
get deploymentsDir(): string;
|
|
24
24
|
get wallet(): WalletConfig | undefined;
|
|
25
25
|
hasNetwork(name: string): boolean;
|
|
26
|
+
/** Whether any `[contracts]` key, exact or pattern, applies to `name`. */
|
|
26
27
|
hasContract(name: string): boolean;
|
|
27
28
|
listNetworks(): string[];
|
|
29
|
+
/** Names with an exact `[contracts.X]` key. */
|
|
28
30
|
listContracts(): string[];
|
|
31
|
+
/** Name and directory pattern keys, in file order. */
|
|
32
|
+
listPatterns(): string[];
|
|
29
33
|
network(name: string): NetworkConfig;
|
|
34
|
+
/** Merges every `[contracts]` key that applies to `name`, then validates the result. */
|
|
30
35
|
contract(name: string): ContractConfig;
|
|
31
36
|
}
|
|
@@ -3,7 +3,8 @@ import { readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
4
4
|
import { parse as parseToml } from 'smol-toml';
|
|
5
5
|
import { ConfigError } from "../errors.js";
|
|
6
|
-
import {
|
|
6
|
+
import { indexSources, keyKind, resolveEntry, sourceOf, } from "./patterns.js";
|
|
7
|
+
import { configSchema, contractSchema, } from "./schema.js";
|
|
7
8
|
/**
|
|
8
9
|
* Parsed + validated `compact.toml` with the resolved project root.
|
|
9
10
|
* Single source of truth for the pipeline; `network` / `contract`
|
|
@@ -20,10 +21,14 @@ export class CompactConfig {
|
|
|
20
21
|
*/
|
|
21
22
|
rootDir;
|
|
22
23
|
#data;
|
|
23
|
-
|
|
24
|
+
/** Set when a directory pattern exists. */
|
|
25
|
+
#sources;
|
|
26
|
+
#resolved = new Map();
|
|
27
|
+
constructor(data, configPath, sources) {
|
|
24
28
|
this.#data = data;
|
|
25
29
|
this.configPath = configPath;
|
|
26
30
|
this.rootDir = dirname(configPath);
|
|
31
|
+
this.#sources = sources;
|
|
27
32
|
}
|
|
28
33
|
/** Walks up from `cwd` Foundry-style when `explicitPath` is omitted. */
|
|
29
34
|
static async load(explicitPath, cwd = process.cwd()) {
|
|
@@ -49,18 +54,21 @@ export class CompactConfig {
|
|
|
49
54
|
}
|
|
50
55
|
const result = configSchema.safeParse(parsed);
|
|
51
56
|
if (!result.success) {
|
|
52
|
-
|
|
53
|
-
.map((i) => {
|
|
54
|
-
// A TOML document always parses to a table, so an issue can
|
|
55
|
-
// never land at the empty root path.
|
|
56
|
-
/* v8 ignore next */
|
|
57
|
-
const at = i.path.join('.') || '(root)';
|
|
58
|
-
return ` - ${at}: ${i.message}`;
|
|
59
|
-
})
|
|
60
|
-
.join('\n');
|
|
61
|
-
throw new ConfigError(`compact.toml validation failed:\n${issues}`);
|
|
57
|
+
throw new ConfigError(`compact.toml validation failed:\n${formatIssues(result.error.issues)}`);
|
|
62
58
|
}
|
|
63
|
-
|
|
59
|
+
const { contracts, profile } = result.data;
|
|
60
|
+
const sources = profile.src_dir !== undefined &&
|
|
61
|
+
Object.keys(contracts).some((key) => keyKind(key) === 'directory')
|
|
62
|
+
? await indexSources(resolve(dirname(configPath), profile.src_dir))
|
|
63
|
+
: undefined;
|
|
64
|
+
const config = new CompactConfig(result.data, configPath, sources);
|
|
65
|
+
// With a directory pattern, `configSchema` cannot check exact entries:
|
|
66
|
+
// whether the pattern applies needs the source index.
|
|
67
|
+
if (sources) {
|
|
68
|
+
for (const name of config.listContracts())
|
|
69
|
+
config.contract(name);
|
|
70
|
+
}
|
|
71
|
+
return config;
|
|
64
72
|
}
|
|
65
73
|
get defaultNetwork() {
|
|
66
74
|
return this.#data.profile.default_network;
|
|
@@ -77,14 +85,20 @@ export class CompactConfig {
|
|
|
77
85
|
hasNetwork(name) {
|
|
78
86
|
return Object.hasOwn(this.#data.networks, name);
|
|
79
87
|
}
|
|
88
|
+
/** Whether any `[contracts]` key, exact or pattern, applies to `name`. */
|
|
80
89
|
hasContract(name) {
|
|
81
|
-
return
|
|
90
|
+
return this.#resolve(name) !== undefined;
|
|
82
91
|
}
|
|
83
92
|
listNetworks() {
|
|
84
93
|
return Object.keys(this.#data.networks);
|
|
85
94
|
}
|
|
95
|
+
/** Names with an exact `[contracts.X]` key. */
|
|
86
96
|
listContracts() {
|
|
87
|
-
return Object.keys(this.#data.contracts);
|
|
97
|
+
return Object.keys(this.#data.contracts).filter((key) => keyKind(key) === 'exact');
|
|
98
|
+
}
|
|
99
|
+
/** Name and directory pattern keys, in file order. */
|
|
100
|
+
listPatterns() {
|
|
101
|
+
return Object.keys(this.#data.contracts).filter((key) => keyKind(key) !== 'exact');
|
|
88
102
|
}
|
|
89
103
|
network(name) {
|
|
90
104
|
const n = this.#data.networks[name];
|
|
@@ -93,14 +107,46 @@ export class CompactConfig {
|
|
|
93
107
|
}
|
|
94
108
|
return n;
|
|
95
109
|
}
|
|
110
|
+
/** Merges every `[contracts]` key that applies to `name`, then validates the result. */
|
|
96
111
|
contract(name) {
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
|
|
112
|
+
const cached = this.#resolved.get(name);
|
|
113
|
+
if (cached)
|
|
114
|
+
return cached;
|
|
115
|
+
const resolved = this.#resolve(name);
|
|
116
|
+
if (!resolved) {
|
|
117
|
+
const available = [
|
|
118
|
+
...this.listContracts(),
|
|
119
|
+
...this.listPatterns().map((key) => `"${key}"`),
|
|
120
|
+
].join(', ');
|
|
121
|
+
const noSource = this.#sources && !this.#sources.byName.has(name)
|
|
122
|
+
? ` (no ${name}.compact under ${this.#sources.dir})`
|
|
123
|
+
: '';
|
|
124
|
+
throw new ConfigError(`Contract "${name}" not defined. Available: ${available}${noSource}`);
|
|
125
|
+
}
|
|
126
|
+
const result = contractSchema.safeParse(resolved.entry);
|
|
127
|
+
if (!result.success) {
|
|
128
|
+
const keys = resolved.keys.map((key) => `"${key}"`).join(', ');
|
|
129
|
+
throw new ConfigError(`compact.toml validation failed for contract "${name}" (from ${keys}):\n${formatIssues(result.error.issues, ['contracts', name])}`);
|
|
100
130
|
}
|
|
101
|
-
|
|
131
|
+
this.#resolved.set(name, result.data);
|
|
132
|
+
return result.data;
|
|
133
|
+
}
|
|
134
|
+
#resolve(name) {
|
|
135
|
+
const source = this.#sources && sourceOf(name, this.#sources);
|
|
136
|
+
return resolveEntry(name, this.#data.contracts, source);
|
|
102
137
|
}
|
|
103
138
|
}
|
|
139
|
+
function formatIssues(issues, prefix = []) {
|
|
140
|
+
return issues
|
|
141
|
+
.map((i) => {
|
|
142
|
+
// A TOML document always parses to a table, so an issue can
|
|
143
|
+
// never land at the empty root path.
|
|
144
|
+
/* v8 ignore next */
|
|
145
|
+
const at = [...prefix, ...i.path].join('.') || '(root)';
|
|
146
|
+
return ` - ${at}: ${i.message}`;
|
|
147
|
+
})
|
|
148
|
+
.join('\n');
|
|
149
|
+
}
|
|
104
150
|
function resolveExplicit(p, cwd) {
|
|
105
151
|
const abs = isAbsolute(p) ? p : resolve(cwd, p);
|
|
106
152
|
if (!existsSync(abs)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact-config.js","sourceRoot":"","sources":["../../src/config/compact-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compact-config.js","sourceRoot":"","sources":["../../src/config/compact-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,OAAO,EAEP,YAAY,EAEZ,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,YAAY,EACZ,cAAc,GAGf,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACf,UAAU,CAAS;IAC5B;;;;;;OAMG;IACM,OAAO,CAAS;IAChB,KAAK,CAAoB;IAClC,2CAA2C;IAClC,QAAQ,CAA0B;IAClC,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEvD,YACE,IAAuB,EACvB,UAAkB,EAClB,OAAgC;QAEhC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B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A4D;QAC5D,qCAAqC;QACrC,oBAAoB;QACpB,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC;QACxD,OAAO,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,eAAe,CAAC,CAAS,EAAE,GAAW;IAC7C,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAChD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,WAAW,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC/C,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,SAAS,CAAC;QACrC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ContractEntry } from './schema.ts';
|
|
2
|
+
export type KeyKind = 'exact' | 'name' | 'directory';
|
|
3
|
+
/** Every `[contracts]` key that applies to a contract, and their merged entry. */
|
|
4
|
+
export interface ResolvedEntry {
|
|
5
|
+
keys: string[];
|
|
6
|
+
entry: ContractEntry;
|
|
7
|
+
}
|
|
8
|
+
/** `.compact` source paths under `dir`, relative and `/`-separated, by contract name. */
|
|
9
|
+
export interface SourceIndex {
|
|
10
|
+
dir: string;
|
|
11
|
+
byName: ReadonlyMap<string, readonly string[]>;
|
|
12
|
+
}
|
|
13
|
+
/** A key holding `/` is a directory pattern, one holding `*`, `?`, `[` or `{` a name pattern. */
|
|
14
|
+
export declare function keyKind(key: string): KeyKind;
|
|
15
|
+
/** Merges matching patterns in file order, then the exact key; a later key wins field by field. */
|
|
16
|
+
export declare function resolveEntry(name: string, contracts: Readonly<Record<string, ContractEntry>>, source: string | undefined): ResolvedEntry | undefined;
|
|
17
|
+
/** Indexes the `.compact` sources under `dir`, skipping `node_modules` and dot-directories. */
|
|
18
|
+
export declare function indexSources(dir: string): Promise<SourceIndex>;
|
|
19
|
+
/** The unique source of `name`, if any; several throw a {@link ConfigError}. */
|
|
20
|
+
export declare function sourceOf(name: string, index: SourceIndex): string | undefined;
|