Commit 05c5eb4
chore: vendor dfx-core identity/network resolution, drop external dfx-core dependency (#10640)
## Why
`ic-sns-cli` and `ic-sns-testing` depended on the external
[`dfx-core`](https://crates.io/crates/dfx-core) crate. `dfx-core`
re-exports
`ic-agent` in its public API, so its **major version is bumped in
lockstep with
`ic-agent`** — every `ic-agent` upgrade in this repo requires a matching
`dfx-core` release.
Once the [`dfinity/sdk`](https://github.com/dfinity/sdk) repo is
archived, those
`dfx-core` releases can no longer be cut, which would block this
monorepo from
upgrading `ic-agent` at all. It also drags in a pile of outdated
transitive deps
(`bip32 0.4`, `tiny-bip39`, `sec1 0.3`, `handlebars`, `byte-unit`, …)
that other
teams have hit while trying to upgrade their own dependencies.
SNS only uses a small, self-contained slice of `dfx-core`: resolving a
dfx
identity + network into an `ic_agent::Agent`, and resolving an identity
name to
a principal. This PR vendors just that slice as a new internal crate and
removes
the external `dfx-core` dependency.
This direction was approved by the NNS team, who own `ic-sns-cli`: <!--
TODO: NNS discussion link -->.
## What
- New crate **`rs/sns/dfx-core-vendored`** — a trimmed, in-tree subset
of
`dfx-core 0.4.0` exposing two functions:
- `get_agent(network, identity) -> Agent`
- `get_identity_principal(name) -> Principal`
- `ic-sns-cli` and `ic-sns-testing` rewired onto it; the `dfx-core`
dependency
removed from both crates and from the workspace (`Cargo.toml`,
`bazel/rust.MODULE.bazel`, lockfiles).
- The keyring/encrypted-PEM deps `dfx-core` used to pull in
(`aes-gcm`, `argon2`, `dialoguer`, `keyring`, `security-framework`)
become
direct deps of the new crate; the unused ones (`bip32 0.4`,
`tiny-bip39`,
`sec1 0.3`, `handlebars`, `byte-unit`, `dunce`, `tar`, `flate2`, …) drop
out of
the graph.
## Behaviour
No user-facing change. dfx identities are untouched
(`~/.config/dfx/identity/…`)
and the SNS CLI behaves as before for the supported cases:
- **Identities:** plaintext PEM, password-encrypted PEM, OS keyring, and
HSM —
all still load exactly as dfx loads them.
- **Networks:** `ic` (mainnet), `local` (shared or project, honouring a
running
replica's `webserver-port`), and explicit IC HTTP endpoint URLs (e.g.
`sns-testing --network http://127.0.0.1:8080`).
Not vendored (unused by SNS): identity creation/rename/removal/export,
wallets,
the extension manager, playground networks, and general
`dfx.json`/`networks.json`
parsing beyond the `local` bind. `IdentityManager::new` no longer
auto-creates a
default identity for `InitializeIdentity::Allow` (that is dfx's job),
but SNS only
ever calls it with `Disallow`, so there is no behavioural change in
practice.
See `rs/sns/dfx-core-vendored/README.md` for how to verify the subset
against
upstream and the maintenance expectations (the crate is treated as
frozen
vendored code — the only expected changes are the mechanical adjustments
to track
future `ic-agent` majors, which is the whole reason it exists).
## Reviewing the vendored crate
The crate is derived from **`dfx-core 0.4.0`** (which itself depends on
`ic-agent 0.47`, this workspace's version). Most modules are copied at
the **same
relative path** as upstream and trimmed; two files (`network.rs`,
`lib.rs`) are
reimplementations. To confirm the copied modules really are a subset:
```sh
diff -ur sdk/src/dfx-core/src ic/rs/sns/dfx-core-vendored/src
```
That diff is ~2,530 lines, but the review surface is tiny:
| | Lines | Notes |
| --- | --- | --- |
| Deletions (trimmed-out code) | ~1,865 | Skim-only |
| `Only in …` notices for dropped files | 34 | ~60 dropped files/dirs,
collapsed to one line each |
| **Additions** | **~190** | The only lines to actually read |
Of the ~190 additions:
- **~150 are the two reimplementations** — `lib.rs` (+112) and
`network.rs`
(~300 lines, which shows only as `Only in …/vendored: network.rs`, so
review it
directly). These need normal code review; there is no upstream
counterpart to
diff against.
- **~39 across all 19 copied modules**, and none of it is rustfmt noise:
~25 shortened `use` statements (each verifiably a subset of upstream's
imports,
since imports are dropped alongside the code that used them), 9
doc-comment
lines (two `Unlike upstream …` notes), and 5 code lines for the edits
those
notes describe (`_initialize_identity` ignored, the
`NoIdentityConfigurationFound`
early-return, and `password_prompt` dropping its `PromptMode` argument).
(Don't run `diff -urN`: it expands every dropped file into a full
deletion,
ballooning to ~11,000 lines for no benefit.)
## Testing
- `cargo build` + `cargo clippy` (`-D warnings`, per
`ci/scripts/rust-lint.sh`)
on `dfx-core-vendored`, `ic-sns-cli`, `ic-sns-testing`.
- `bazel build` of the new crate and all `//rs/sns/cli/...` +
`//rs/sns/testing/...`
targets.
- `bazel test`:
- `//rs/sns/cli:sns_test`, `//rs/sns/cli:sns_doctest`,
`//rs/sns/testing:sns_testing_test`
- `//rs/sns/testing:sns_testing_ci` (full PocketIC NNS + SNS lifecycle)
- `//rs/nervous_system/integration_tests:sns_extension_test`
- After merging the latest `master`, the crate compiles cleanly against
the
upgraded `ic-agent` / `ic-identity-hsm 0.47`, with no `dfx-core` release
required — a live confirmation of the decoupling.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>1 parent cff5e90 commit 05c5eb4
35 files changed
Lines changed: 1816 additions & 2294 deletions
File tree
- bazel
- rs/sns
- cli
- src
- dfx-core-vendored
- src
- config
- error
- foundation
- fs
- identity
- json
- testing
- src
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
419 | 420 | | |
420 | 421 | | |
421 | 422 | | |
| |||
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
646 | | - | |
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
| |||
393 | 407 | | |
394 | 408 | | |
395 | 409 | | |
396 | | - | |
397 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
398 | 416 | | |
399 | 417 | | |
400 | 418 | | |
| |||
903 | 921 | | |
904 | 922 | | |
905 | 923 | | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
906 | 935 | | |
907 | 936 | | |
908 | 937 | | |
| |||
1472 | 1501 | | |
1473 | 1502 | | |
1474 | 1503 | | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
1475 | 1508 | | |
1476 | 1509 | | |
1477 | 1510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| |||
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
158 | | - | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
| 12 | + | |
14 | 13 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
41 | 19 | | |
42 | 20 | | |
43 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments