Skip to content

Inline pallets#600

Merged
illuzen merged 8 commits into
mainfrom
illuzen/inline-pallets
Jun 22, 2026
Merged

Inline pallets#600
illuzen merged 8 commits into
mainfrom
illuzen/inline-pallets

Conversation

@illuzen

@illuzen illuzen commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Just vendor / inline some pallets so we can have our trusted computing base fully under our control.


Note

High Risk
Inlining pallet-balances and related core FRAME pallets changes how account balances and issuance are built and reviewed; any drift from upstream Substrate behavior would affect the entire chain economy.

Overview
Moves several polkadot-sdk pallets from crates.io into the repo so the runtime’s trusted computing base is built from local sources.

Cargo.toml now resolves pallet-balances, pallet-preimage, pallet-recovery, pallet-timestamp, and pallet-utility via path = "./pallets/...", adds those crates to the workspace members, and wires a workspace frame alias for polkadot-sdk-frame. Cargo.lock is updated for path-based packages and dev-test dependencies (e.g. pallet-utility tests pulling in pallet-balances, pallet-collective, pallet-root-testing, pallet-timestamp).

The diff includes a full in-tree pallet-balances (v46.0.0): lib, currency/fungible impls, migrations, benchmarks, weights, and extensive unit tests—intended as a vendored copy rather than new balance semantics in this PR.

Reviewed by Cursor Bugbot for commit fdfa5b1. Configure here.

illuzen and others added 6 commits June 19, 2026 13:21
Copy upstream pallet-timestamp v44.0.0 from polkadot-sdk into
pallets/timestamp and switch the workspace dependency from crates.io to
the local path, so the pallet source is in-tree and auditable.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-balances v46.0.0 from polkadot-sdk into
pallets/balances and switch the workspace dependency from crates.io to
the local path, so the pallet source is in-tree and auditable.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-utility v45.0.0 from polkadot-sdk into
pallets/utility and switch the workspace dependency from crates.io to
the local path, so the pallet source is in-tree and auditable.

Dev-only test dependencies (pallet-collective, pallet-root-testing) are
pulled from crates.io at the matching v45 release line.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-preimage v45.0.0 from polkadot-sdk into
pallets/preimage and switch the workspace dependency from crates.io to
the local path, so the pallet source is in-tree and auditable.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-recovery v45.0.0 from polkadot-sdk into
pallets/recovery and switch the workspace dependency from crates.io to
the local path, so the pallet source is in-tree and auditable.

This pallet uses the polkadot-sdk-frame umbrella crate, so add `frame`
(polkadot-sdk-frame v0.14.0) to the workspace dependencies.

Co-authored-by: Cursor <cursoragent@cursor.com>
@n13

n13 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Review: PR #600 "Inline pallets" (link)

What it does

Vendors 5 polkadot-sdk pallets from crates.io into pallets/, switching the workspace deps from version = "..." to path = "./pallets/...":

Pallet Version Notes
pallet-timestamp 44.0.0
pallet-balances 46.0.0
pallet-utility 45.0.0
pallet-preimage 45.0.0
pallet-recovery 45.0.0 pulls in frame (polkadot-sdk-frame 0.14.0) umbrella crate

Fidelity — verified clean

I downloaded each exact upstream version from crates.io and diffed against the vendored copies. Every src/ file is byte-for-byte identical to upstream. The only differences are the expected, correct ones:

  • Omitted crates.io packaging artifacts (.cargo_vcs_info.json, Cargo.lock, Cargo.toml.orig) — correct.
  • Cargo.toml rewritten to use workspace deps. Versions line up with the workspace (frame-support 45.1.0 satisfies ^45.0.0, sp-core 39.0.0, sp-runtime 45.0.0, sp-io 44.0.0, etc.), so no resolved-version drift vs. the previous crates.io deps.

So the trusted-computing-base goal is met with no behavioral change.

The dev-dependencies were correctly reconstructed (crates.io strips them): pallet-balances for recovery; pallet-collective 45.0.0 + pallet-root-testing 21.0.0 + pallet-timestamp for utility. Cargo.lock changes are limited to the path switch plus those two new dev-deps. Scope is clean — nothing outside Cargo.{toml,lock} and pallets/.

Blocking issue — Clippy CI is failing ❌

🤖 Analysis (Clippy & Doc) fails: could not compile pallet-balances (lib) due to 13 errors.

Root cause: each vendored Cargo.toml uses

[lints]
workspace = true

which inherits the workspace's strict production lints:

[workspace.lints.clippy]
# Deny unwrap and panic in production code (runtime & pallets)
# Test code can opt-out using: #![allow(clippy::unwrap_used, clippy::panic)]
panic = "deny"
unwrap_used = "deny"
# Also deny expect_used for consistency
expect_used = "deny"

Upstream uses unwrap()/expect()/panic! throughout (lib + benchmarks + tests), and its real manifest sets [lints.clippy.all] = "allow", which is why it passes upstream CI. Applying Quantus's deny lints to verbatim third-party code breaks the build.

Recommended fix (preserves verbatim vendoring): replace [lints] workspace = true in each vendored Cargo.toml with upstream's own permissive lint table (the allow-all clippy config from Cargo.toml.orig). Editing the .rs files to add #![allow(...)] would work too but breaks the "identical to upstream" property and complicates future syncs, so I'd avoid it.

Other notes

  • Build & Test Matrix (ubuntu/macos) is still pending — compilation/tests not yet confirmed. Worth waiting on before merge.
  • Adding the polkadot-sdk-frame umbrella (for recovery) is a heavyweight dependency, but it's exactly what upstream recovery requires — acceptable.

Verdict

Vendoring is faithful and the wiring is correct — this is a clean, low-risk-of-drift change despite the "High Risk" label. Don't merge until the Clippy lint config on the vendored crates is fixed and the build matrix goes green.

Want me to apply the lint-config fix (swap [lints] workspace = true for the upstream permissive table in each vendored Cargo.toml)?

@n13

n13 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

I think we need to change the lint settings in the vendored crates to be less strict, as suggested above

illuzen and others added 2 commits June 19, 2026 20:46
`derive_dev_account` is Quantus-authored code, so it must follow the
project's no-expect/unwrap/panic policy. Return a `Result` and propagate
failures via `?`, and have the genesis builder `assert!` on the result
(consistent with the surrounding genesis assertions).

Co-authored-by: Cursor <cursoragent@cursor.com>
FRAME's pallet macros (#[pallet::pallet], #[pallet::storage],
#[pallet::error], ...) expand to code that uses expect/unwrap, which
trips the workspace clippy restriction lints. The other vendored pallets
(scheduler, treasury, frame-system) already opt out, so drop the
`[lints] workspace = true` table from balances, timestamp, utility,
preimage and recovery for consistency. The no-expect/unwrap/panic policy
remains enforced on Quantus-authored crates.

Co-authored-by: Cursor <cursoragent@cursor.com>
@illuzen illuzen merged commit 3fc401f into main Jun 22, 2026
5 checks passed
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