Authorization slots#509
Open
franciscoaguirre wants to merge 12 commits into
Open
Conversation
bkontur
reviewed
May 11, 2026
34 tasks
4 tasks
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With authorization slots a single account can hold multiple authorizations. It's also possible for it to have authorizations in the future. This keeps bulletin much more flexible. Parallel alternative to #469.
Why
The existing single authorization model has a bunch of problems: cross-chain expiry alignment and auto-renewal across boundaries. #469 tightly couples Bulletin to its caller chain via a shared
PeriodDurationand afor_periodparameter onauthorize_account. This branch takes a different cut at the same problems: per-scopeBoundedVec<TimedAuthorization, 8>with explicit(starts_at, expiration)per slot, so windows are described locally without cross-chain coupling.Core design
pallets/transaction-storage/src/lib.rs):Authorizations(singleAuthorization<BlockNumber>per scope) →AuthorizationSlots: StorageMap<scope, BoundedVec<TimedAuthorization, MaxAuthorizationSlots>>. Each slot carries its own(starts_at, expiration)in relay-chain block numbers and an independentAuthorizationExtent.Config::RelayChainBlockNumberProvider(wired tocumulus_pallet_parachain_system::RelaychainDataProviderin both runtimes). Slot windows are relay-block-keyed so they're meaningful across cross-chain authorization flows; the oldAuthorizationPeriodconfig item is gone.starts_at <= relay_now < expiration. The vec is kept sorted by(expiration ASC, starts_at ASC)for deterministic SCALE encoding and a single forward scan when picking the earliest-expiring active slot.store(size)is the soft side: pick any earliest-expiring active slot; saturatebytesandtransactions. Over-cap stores still succeed; the priority boost inextension::AllowanceBasedPriorityis what demotes them.renew(size)is the hard side: per-slotbytes_permanent + size <= bytes_allowance(no cross-slot subsidy), plus the chain-wideMaxPermanentStorageSizecap. Rejects withPERMANENT_ALLOWANCE_EXCEEDED/CHAIN_PERMANENT_CAP_REACHEDrespectively.bytesandbytes_permanentare independent axes, both bounded per slot bybytes_allowance. An account granted 10 MiB can store 10 MiB and renew 10 MiB in the same window.prune_expireddrops only expired slots — drained slots persist (they can still serve low-prioritystore()until expiry). The prune skips the storage write when nothing's expired (precheck guard).starts_at <= relay_now) and share the sameexpiration. Pre-clamps the existing slot's saturatingbytes/transactionsat the old caps so the merge is a pure simplification — the folded extent equals what two separate slots would report.Extrinsic surface
authorize_account(origin, who, transactions, bytes)andauthorize_preimage(origin, content_hash, max_size)— unchanged signatures, route through internal helpers and apply the default window (relay_now,relay_now + DefaultAuthorizationWindow). Existing XCM authorizers continue to work without modification.authorize_account_window(..., starts_at: Option<u32>, expiration: u32)andauthorize_preimage_window(...).starts_at = Nonemeansrelay_now; explicit windows are validated againstMaxStartsAtFuture. Astarts_atin the past is accepted (already-active slot).refresh_account_authorization/refresh_preimage_authorization. The natural "refresh" is now to push another slot (additive merge handles the common case).TooManySlots(push would exceedMaxAuthorizationSlotsafter prune),InvalidWindow,RelayChainTimeUnavailable.Runtime config (bulletin-westend and bulletin-paseo)
runtimes/bulletin-{westend,paseo}/src/storage.rs:DefaultAuthorizationWindow = 14 * DAYS_RELAY = 201_600(relay 6 s blocks → 14 days),MaxStartsAtFuture = 30 * DAYS_RELAY,MaxAuthorizationSlots = 8.RelayChainBlockNumberProvider = cumulus_pallet_parachain_system::RelaychainDataProvider<Runtime>.runtimes/bulletin-{westend,paseo}/src/lib.rs:STORAGE_VERSION3 → 4;spec_version1_000_013 → 1_000_014.Migration v3 → v4 (multi-block)
pallets/transaction-storage/src/migrations.rs::v4::MigrateV3ToV4is aSteppedMigrationmodeled onv3::MigrateV2ToV3. Each step drains a few legacyAuthorizationsentries and translates them.bytes_allowance == 0. Otherwise emit a fresh slot inheriting(bytes_allowance, transactions_allowance)with(starts_at = relay_now, expiration = relay_now + DefaultAuthorizationWindow)and used counters reset. We don't try to translate v3's parachain-block expiration into a relay-block window — the two clocks don't align losslessly. Pre-existing renewed bytes from the old window remain inPermanentStorageUsedand age out viaon_initialize, so resetting per-accountbytes_permanentdoes not double-count.MbmMigrationsnext tov3::MigrateV2ToV3in both runtime tuples.TODO