Skip to content

Inline pallets 2#601

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

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

Conversation

@illuzen

@illuzen illuzen commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Inline several pallets

  • transaction-payment
  • assets and assets-holder
  • referenda
  • conviction-voting
  • ranked-collective

Note

Medium Risk
Large vendored copies of fee, asset, and governance pallets increase maintenance and merge risk, but behavior should match upstream unless later patched locally.

Overview
Vendors several Polkadot SDK FRAME pallets into pallets/ and wires the workspace to use local path dependencies instead of crates.io version pins for pallet-assets, pallet-assets-holder, pallet-conviction-voting, pallet-ranked-collective, pallet-referenda, and the pallet-transaction-payment family (including RPC crates).

The workspace member list and root Cargo.toml / Cargo.lock are updated accordingly (e.g. impl-trait-for-tuples, sp-rpc, and extra dev-dependencies such as pallet-balances / sp-io on vendored crates). Vendored crate manifests note that upstream pallet macros still expand to expect/unwrap, so workspace restriction lints are not applied there.

For assets, this PR adds the full in-tree pallet-assets implementation plus pallet-assets-holder, which implements BalanceOnHold and fungibles hold traits so other pallets can reserve asset balances; pallet-assets is configured to use Holder for hold/freeze-aware transfers and account teardown.

Reviewed by Cursor Bugbot for commit 5bb6f43. Configure here.

illuzen and others added 8 commits June 22, 2026 10:19
Copy upstream pallet-transaction-payment (v45.0.0), its
-rpc-runtime-api (v45.0.0) and -rpc (v48.0.0) crates from polkadot-sdk
into pallets/ and switch the workspace dependencies from crates.io to
local paths. The three are version-coupled, so they are inlined together
to avoid two copies of pallet-transaction-payment in the tree. Adds
sp-rpc to the workspace dependencies for the -rpc crate.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-assets (v48.1.0) and pallet-assets-holder (v0.8.0)
from polkadot-sdk into pallets/ and switch the workspace dependencies
from crates.io to local paths. assets-holder depends on assets, so they
are inlined together to avoid two copies of pallet-assets in the tree.
Adds impl-trait-for-tuples to the workspace dependencies for pallet-assets.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-referenda v45.0.0 from polkadot-sdk into
pallets/referenda and switch the workspace dependency from crates.io to
the local path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-conviction-voting v45.0.0 from polkadot-sdk into
pallets/conviction-voting and switch the workspace dependency from
crates.io to the local path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy upstream pallet-ranked-collective v45.0.0 from polkadot-sdk into
pallets/ranked-collective and switch the workspace dependency from
crates.io to the local path.

Co-authored-by: Cursor <cursoragent@cursor.com>
The vendored referenda tests targeted the upstream scheduler. Adapt the
mock to the in-tree timestamp-aware pallet-scheduler (Moment/TimeProvider/
TimestampBucketSize instead of RuntimeEvent/BlockNumberProvider) and update
the alarm assertions to use BlockNumberOrTimestamp task addresses.

Co-authored-by: Cursor <cursoragent@cursor.com>
defensive_assert! only panics with debug_assertions, but CI runs tests in
--release. Gate the #[should_panic] variant to debug builds and add a
release-build counterpart asserting died still clears hold state without
panicking.

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

n13 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

I verified the inlined pallets against the actual upstream releases pulled from crates.io (the published polkadot-sdk source at each stated version). Here's the result.

Verdict: ✅ No production code was changed

All non-test source files are byte-for-byte identical to upstream. The only src/ deviations are 3 test/mock files, each matching a documented "fix tests" commit.

Methodology

Downloaded each crate at its declared version from crates.io and ran a recursive diff against the inlined src/ trees:

Crate Version src/ result
pallet-transaction-payment 45.0.0 identical
pallet-transaction-payment-rpc 48.0.0 identical
pallet-transaction-payment-rpc-runtime-api 45.0.0 identical
pallet-assets 48.1.0 identical (lib, functions, impl_fungibles, types, weights, benchmarking, migration, mock, tests…)
pallet-assets-holder 0.8.0 only tests.rs differs
pallet-referenda 45.0.0 only mock.rs + tests.rs differ
pallet-conviction-voting 45.0.0 identical
pallet-ranked-collective 45.0.0 identical

File sets also match exactly (no added/dropped source files; upstream's packaged Cargo.lock is correctly dropped).

The only source changes (test-only, all justified)

  1. assets-holder/src/tests.rs — splits the died_fails_if_holds_exist #[should_panic] test by build profile, because defensive_assert! only panics under debug_assertions but CI runs --release. Matches commit 5bb6f43.

  2. referenda/src/mock.rs — rewires the pallet_scheduler::Config mock to the in-tree timestamp-aware scheduler (Moment / TimeProvider / TimestampBucketSize instead of RuntimeEvent / BlockNumberProvider). Matches commit b765f02.

  3. referenda/src/tests.rs — imports qp_scheduler::BlockNumberOrTimestamp and updates two alarm assertions from (5, 0) to BlockNumberOrTimestamp::BlockNumber(5). Also drops one stray println!("Agenda #6: …") debug line (harmless, slightly beyond the strict scope of the commit message).

These are unavoidable: the upstream tests target the vanilla scheduler, but this repo already vendors a timestamp-aware scheduler.

Manifest / workspace changes (non-functional)

  • Each pallet Cargo.toml: crates.io/monorepo deps → workspace/path; [lints] workspace = true dropped (replaced with a comment, since upstream macros expand to expect/unwrap); cosmetic field/feature reordering. Feature lists (std/runtime-benchmarks/try-runtime) are content-identical to upstream. referenda adds a qp-scheduler dev-dep for the test fix.
  • Root Cargo.toml: adds the 8 crates as members, switches their deps from version pins to path, and adds impl-trait-for-tuples + sp-rpc workspace deps. Declared versions match the inlined versions exactly.
  • Cargo.lock: consistent (drops registry source for the now-local crates, adds dev-deps).

Minor notes (not blockers)

  • assets-holder dev-deps flip default-features = falsetrue for pallet-balances/sp-core/sp-io. Dev-deps only, so it can't affect runtime/WASM behavior.
  • The removed println! in referenda/tests.rs isn't mentioned in the commit message, but it's just debug noise.

Bottom line: the inlining is clean — production logic is an exact copy of the upstream releases, and the only edits are the minimum test/mock adaptations needed to compile against this repo's existing in-tree scheduler and --release CI.

@n13 n13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@illuzen illuzen merged commit 737d7e3 into main Jun 23, 2026
6 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