-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cumulus: add SignedSchedulingInfo PVF verification #12097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iulianbarbu
wants to merge
203
commits into
master
Choose a base branch
from
ib-signed-scheduling-info-verify
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,209
−274
Open
Changes from 189 commits
Commits
Show all changes
203 commits
Select commit
Hold shift + click to select a range
dfc51e2
Remove redundant implicit view from prospective parachains.
eskimor c7de64b
Move relay chain scope things to relay chain scope.
eskimor 29276ed
Remove pointless GetMinimumRelayParents message
eskimor dcb2173
refactor: simplify backing implicit view to use per-relay-parent allowed
eskimor a7394aa
Fix tests
eskimor c57807f
Add prdoc
eskimor c1440a5
Fix statement-distribution tests
eskimor d268ed7
Fix benchmakrs + major version bumps
eskimor d1dc0da
Fix backing tests.
eskimor 61f13f5
Remove performance difference note - unrelated.
eskimor d80f3f6
Fix tests.
eskimor 44e74de
Reduce bits checked for v1 identification.
d548ee6
First attempt in introducing new CandidateDescriptor
eskimor ec09e00
Cleanup + simplerversion checking.
eskimor a640e54
Cleanup + make it typecheck.
eskimor 1737e88
Remove yet unused SchedulingInfo.
eskimor 42d5001
Drop v3 candidates in the runtime.
eskimor 549244a
Code simplification + fixes.
eskimor f9ccd1b
Simplification + fixes
eskimor b2655fe
Better future upgrade behavior + better docs.
eskimor bd9ee57
Maintain old behavior when node feature is not set.
eskimor 4cdf77e
v2 cleanup + fixes for v3.
eskimor c343c3f
Fixes
eskimor e1aaa39
Fixes.
eskimor f8dfbd1
Add new accessor functions
eskimor 2611b50
Make it typecheck
eskimor 851f950
Fix type without blowing up Debug
eskimor 754eb8a
Compilation fixes
eskimor 18af332
Fixes.
eskimor 5813ea9
Fix runtime tests.
eskimor 94eff27
Check scheduling session and scheduling parent in the runtime
eskimor f288d35
Towards V3 candidate descriptors with explicit scheduling_parent
eskimor 1aba9f6
Candidate validation changes + collation generation comment
eskimor 87559f0
Dispute coordinator goes scheduling parent
eskimor 4754276
refactor: improve type safety and terminology for scheduling parent
eskimor 4057523
collator-protocol: Support V3 collation protocol with explicit
eskimor a5c135d
More verified files.
eskimor c4ad28e
Introduce explicit scheduling_parent and pass to PVF via
eskimor 12f19ba
Add comment about safety
eskimor e391bff
Remove runtime debug statements.
eskimor 1fa7d33
Fix malus
eskimor 53565cd
polkadot: fixes and cosmetic changes
iulianbarbu c84d49c
allowed_relay_parents_for -> allowed_relay_parents
eskimor 12c24dc
Merge remote-tracking branch 'origin/master' into rk-prospective-para…
eskimor b188cc8
Fixes for merge
eskimor 59867cc
Cleanup: Remove redundant node feature check
eskimor 4fb5c86
Properly check session index of candidate
eskimor b3960e8
Merge remote-tracking branch 'origin/rk-prospective-parachains-cleanu…
eskimor 9e4e529
Further fixes
eskimor 4ccfe15
Fmt fixes
eskimor 183b4fd
Remove unused imports
eskimor 83dd94c
PVF fixes
eskimor 1da3167
More fixes
eskimor aa4ab4f
More fixes
eskimor 5a2d8f1
Fixes
eskimor deb6d35
Fmt fixes
eskimor 3b3e310
Add tests for failure cases raised by Alin
eskimor 968e6c3
Fix claim queue handling.
eskimor f5a418d
Fixes
eskimor d1ff88e
Test fixes
eskimor ade3224
Simpler algorithm
eskimor 1daa156
Fixes.
eskimor 8b1aea3
Somehow missed this
eskimor 84fecfa
Make clippy happy
eskimor 0ff2d90
Merge branch 'rk-prospective-parachains-cleanup' into rk-prep-new-can…
eskimor 2bcfc51
Update docs, remove obsolete test.
eskimor 6767af4
Address review feedbacks
eskimor d00a17b
polkadot: fix peer view update (#11183)
iulianbarbu 76bf4d3
Cumulus: Add V3 ValidationParamsExtension support
eskimor c176f3e
Finished implementation with passing e2e test by Claude - not reviewed
eskimor e63cddf
Add resubmission support with SignedSchedulingInfo
eskimor 4c10511
Add runtime-enforced MaxClaimQueueOffset for claim queue security
eskimor acd5818
Update cumulus/primitives/core/src/scheduling.rs
eskimor 6d35516
Add Copy
eskimor 9aec3b5
cumulus: implement scheduling related runtime APIs
iulianbarbu caf8305
polkadot(tests): fixes and added more logs
iulianbarbu 783a5e6
cumulus: cosmetic changes
iulianbarbu 83103b4
fix(cumulus): update omni-node runtime constraints
iulianbarbu 85fe262
cumulus: add the peer_id field to SignedSchedulingInfo
iulianbarbu 51ea583
docs: add mention about resubmission
iulianbarbu 740be68
polkadot: fix collation-generation
iulianbarbu 5f1374e
polkadot: fix primitives test-helpers
iulianbarbu 9760d92
cumulus: fix cumulus test runtime
iulianbarbu b3b3d96
cumulus: reuse ApprovedPeerId instead of a new Multihash
iulianbarbu 27e6867
polkadot: tests related changes
iulianbarbu 1c8065a
cumulus: polish
iulianbarbu ec87cd2
cumulus: added scheduling v3 disabled runtime
iulianbarbu d0421a2
polkadot(tests): polish v3 candidate zn-sdk tests
iulianbarbu 85c318b
polkadot: fix peer view updates
iulianbarbu c4212a1
fix: compilation issue
iulianbarbu 9f7f85b
polkadot(tests): polish
iulianbarbu 0ee0ad0
Merge branch 'master' of github.com:paritytech/polkadot-sdk into rk-c…
iulianbarbu f3e075e
polkadot: leftovers after merge
iulianbarbu 44732c8
docs(sdk): fix identation & commenting
iulianbarbu 4278fbc
cumulus: remove generated docs files
iulianbarbu 8d8861f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into rk-c…
iulianbarbu 2140b1d
cumulus: add scheduling info for descendants start
iulianbarbu 3a8f605
tests: check elastic scaling v2/v3 backwards compatiblity
iulianbarbu 268be0a
Merge branch 'master' of github.com:paritytech/polkadot-sdk into rk-c…
iulianbarbu 3229ce6
docs: fix comment indent
iulianbarbu 1aeb2ef
cumulus: extract v3 scheduling validation to its own fn
iulianbarbu f3605ee
cumulus: apply cargo fmt to scheduling validation
iulianbarbu 1383509
cumulus: deduce scheduling parent from scheduling proof
iulianbarbu 9fbdded
Apply suggestions from code review
iulianbarbu f53307d
cumulus: skip relay parents only when rc tip is session change
iulianbarbu b48fc3f
cumulus: guard skipping removing by v3
iulianbarbu 4991b9e
cumulus: lookahead & basic should not be V3 concerned
iulianbarbu 85e98a8
cumulus: unite collation building for v3/v2 paths
iulianbarbu fbd8b61
cumulus: initialize vars closer to usage
iulianbarbu 9166cbb
cumulus: remove MaxClaimQueueOffset config type
iulianbarbu 531ab92
cumulus: simplify cqo usage & hash retrieval
iulianbarbu 3067acd
cumulus: add comment to rp_data descedants
iulianbarbu caf6311
cumulus: cqo value determined base on v3 enabled
iulianbarbu 826a50c
Merge branch 'master' of github.com:paritytech/polkadot-sdk into rk-c…
iulianbarbu b4ec301
ci: enable scheduling v3 tests
iulianbarbu bb6c6ee
cumulus(misc): polish comments and renamings
iulianbarbu ad6ea58
polkadot(tests): test with experimental validators too
iulianbarbu 83ffe08
Update from github-actions[bot] running command 'fmt'
github-actions[bot] 60265e5
ffix compilation issue
iulianbarbu 964ea4e
fix some more clippy
iulianbarbu 956df0f
templates: fix max_claim_queue_offset usage
iulianbarbu 1329414
Merge branch 'master' into rk-cumulus-v3-integration
iulianbarbu 7bfe1ad
yap: already has relay parent offset const
iulianbarbu 0950d6e
staking-async: impl max_claim_queue_offset
iulianbarbu 0fa1f7f
cumulus: support relay parent offset zero
iulianbarbu 11b841d
cumulus: ignore slot offset when v3 enabled
iulianbarbu 8c0d8ec
polkadot(tests): make backing groups bigger
iulianbarbu b464208
Update from github-actions[bot] running command 'fmt'
github-actions[bot] cc2e1be
polkadot(tests): fix es v3 test
iulianbarbu ce638c0
prdoc: add all modified crates
iulianbarbu 2bba2c9
prdoc: update 10742 with the crates again
iulianbarbu a5a200d
prdoc: fix indent
iulianbarbu 7a56e3e
prdoc: update bumps
iulianbarbu 91229a7
Merge branch 'master' into rk-cumulus-v3-integration
iulianbarbu 4d1c66b
prdoc: fix according to check-semver
iulianbarbu 5704265
polkadot(tests): add v3 with relay parent offset collators test
iulianbarbu 128b584
Cargo.toml: fix formatting
iulianbarbu 325c48d
Merge branch 'master' into rk-cumulus-v3-integration
iulianbarbu 12c6450
Merge branch 'master' into rk-cumulus-v3-integration
iulianbarbu 88f499d
[branch rk-cumulus-v3-integration] SchedulingInfo: cosmetics (#11666)
serban300 6dc7dd7
Add V2 collator to scheduling_v3 tests for mixed fleet coverage (#11636)
mchristou e48f672
[rk-cumulus-v3-integration branch] offset_relay_parent_find_descendan…
serban300 86c47d5
CR comments
serban300 edbf49a
Merge remote-tracking branch 'upstream/master' into rk-cumulus-v3-int…
serban300 12af431
Fix conflicts
serban300 6832a93
Fix conflicts: polishing
serban300 5666cac
More polishing
serban300 09335ef
Adjust ParachainBlockData::new
serban300 0bfb273
build_collation() -> undo unneded change
serban300 7ea68dd
Merge commit 'fa31c1dbb23153fbfbae3e48143543af0fff6b0f' into rk-cumul…
serban300 4bf80bd
Merge commit '6e8ca55095e6bdb540f193c560cdc0419637a6d1' into rk-cumul…
serban300 bd78783
Polishing
serban300 2806bd9
Check if v3 is enabled on relay chain
serban300 6eab9ac
Merge branch 'master' into rk-cumulus-v3-integration
alindima 6e6d82a
Addressing part of the CR comments
serban300 285b604
More CR comments
serban300 e0cab9f
scheduling_v3_es_collator_with_v3_validators -> 6 validators
serban300 671c8a9
offset_relay_parent_find_descendants fix
serban300 3f1a46e
Use max_relay_parent_session_age only when v3 is enabled
serban300 ddee4b5
More CR comments
serban300 26d3f20
fix
serban300 841ea47
Fix cumulus-test-runtime relay-parent-offset
serban300 672c454
fix
serban300 336b406
fix
serban300 e60861c
Merge branch 'master' into rk-cumulus-v3-integration
serban300 a76aaf3
Update prdoc
serban300 4c6a627
typo
serban300 ab50e41
prdoc fixes
serban300 ea9f0d5
More CR comments
serban300 79c0640
Apply suggestions from code review
serban300 b8f129d
simplification
serban300 5af100e
Some doc improvements (#12058)
eskimor f634ec9
More CR comments
serban300 d8deedf
Merge remote-tracking branch 'upstream/master' into rk-cumulus-v3-int…
serban300 a85d1cf
More CR comments
serban300 4a66485
More comments
serban300 d9670aa
fix
serban300 11b7746
cumulus: clean scheduling proof verifying primitive
iulianbarbu 2b6f9d0
cumulus: make type bounded plain bytes
iulianbarbu fc162cd
More comments
serban300 951d242
Naming
serban300 a888450
cosmetics
serban300 0bf0e1d
cumulus: add SignedSchedulingInfo PVF verification
iulianbarbu 0711917
verify scheduling signature from internal_scheduling_parent
mchristou 112d3ab
fix resubmission verifier and peer overrides
mchristou 5fc563f
review feedback
mchristou 06b9862
Merge remote-tracking branch 'origin/master' into ib-signed-schedulin…
mchristou 0b346e4
changes from feedback
mchristou 420846a
fixes
mchristou b1f26a5
address review feedback
mchristou aaec6c3
prdoc
mchristou 89ef822
add ed25519 coverage to the verifier tests
mchristou ab6ba86
Update Cargo.lock
mchristou ec17859
polishing
mchristou d1f5273
move the verify call into the seal-verification scope
mchristou 34dc4b3
remove unused dep
mchristou 0fa1474
Cleanup UMP signal handling (#12240)
eskimor 2cd6fe6
review feedback
mchristou 2d17025
ci fixes
mchristou 5a5722c
address review feedback
mchristou 6b97ec1
fixes
mchristou d79a10a
more fixes
mchristou cb7e905
ci fix
mchristou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||
| // This file is part of Cumulus. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! V3 scheduling signature verifier backed by parachain Aura authorities. | ||
| //! | ||
| //! Implements [`VerifySchedulingSignature`] for parachains running Aura: derives the | ||
| //! parachain slot from the BABE pre-digest of the relay header at | ||
| //! `internal_scheduling_parent`, looks up the eligible Aura author from this pallet's | ||
| //! cached authority set, and verifies the 64-byte signature in [`SignedSchedulingInfo`] | ||
| //! over the encoded [`SchedulingInfoPayload`]. | ||
|
|
||
| use crate::{Authorities, Config}; | ||
| use codec::{Decode, Encode}; | ||
| use cumulus_primitives_core::{ | ||
| relay_chain::{Header as RelayChainHeader, RELAY_CHAIN_SLOT_DURATION_MILLIS}, | ||
| SignedSchedulingInfo, VerifySchedulingSignature, | ||
| }; | ||
| use sp_application_crypto::RuntimeAppPublic; | ||
| use sp_consensus_aura::Slot; | ||
| use sp_consensus_babe::digests::CompatibleDigestItem as BabeDigestItem; | ||
|
|
||
| /// Verifier for V3 [`SignedSchedulingInfo`] against parachain Aura authorities. | ||
| /// | ||
| /// Wired by the parachain runtime as | ||
| /// `type SchedulingSignatureVerifier = AuraSchedulingVerifier<Runtime>;` on | ||
| /// [`cumulus_pallet_parachain_system::Config`]. The relay slot duration is the | ||
| /// global [`polkadot_primitives::RELAY_CHAIN_SLOT_DURATION_MILLIS`] (6000 ms), | ||
| /// which is fixed across Polkadot, Kusama, Westend, and Rococo. | ||
| /// | ||
| /// `T` is the runtime; the Aura crypto is derived from | ||
| /// [`pallet_aura::Config::AuthorityId`] (typically `sr25519` or `ed25519`). The | ||
| /// signature blob in [`SignedSchedulingInfo`] is decoded into | ||
| /// `<T::AuthorityId as RuntimeAppPublic>::Signature` and verified with the | ||
| /// authority's own `verify` method, matching the existing Aura seal verification path. | ||
| pub struct AuraSchedulingVerifier<T>(core::marker::PhantomData<T>); | ||
|
|
||
| impl<T> VerifySchedulingSignature for AuraSchedulingVerifier<T> | ||
| where | ||
| T: Config, | ||
| T: pallet_timestamp::Config, | ||
| { | ||
| const V3_SCHEDULING_ENABLED: bool = true; | ||
|
|
||
| fn verify( | ||
| signed_info: &SignedSchedulingInfo, | ||
| internal_scheduling_parent_header: &RelayChainHeader, | ||
| ) -> bool { | ||
| if signed_info.payload.internal_scheduling_parent != | ||
| internal_scheduling_parent_header.hash() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| // 1. Decode relay slot from the BABE pre-digest of the internal_scheduling_parent header. | ||
| // The eligible parachain author is determined by *this* slot, anchoring the signature to | ||
| // a specific block (the one being submitted/resubmitted) rather than to a moving relay | ||
| // tip. `check_scheduling` proves this header is the actual relay block at | ||
| // internal_scheduling_parent — it can't be substituted. | ||
| let relay_slot: Slot = match internal_scheduling_parent_header | ||
| .digest | ||
| .logs() | ||
| .iter() | ||
| .find_map(|log| BabeDigestItem::as_babe_pre_digest(log)) | ||
| { | ||
| Some(pre_digest) => pre_digest.slot(), | ||
| None => return false, | ||
| }; | ||
|
|
||
| // 2. Convert relay slot to parachain slot. Both slot durations are in milliseconds; the | ||
| // relay slot duration is the global Polkadot/Kusama/Westend/Rococo value re-exported by | ||
| // polkadot-primitives, and the para slot duration is read from pallet-aura. Fail closed | ||
| // on overflow rather than saturating, so an out-of-range relay slot can't quietly | ||
| // produce a wrong author index. | ||
|
iulianbarbu marked this conversation as resolved.
Outdated
|
||
| let para_slot_duration: u64 = | ||
| match TryInto::<u64>::try_into(pallet_aura::Pallet::<T>::slot_duration()) { | ||
| Ok(d) if d > 0 => d, | ||
| _ => return false, | ||
| }; | ||
|
|
||
| let para_slot: u64 = match u64::from(relay_slot) | ||
| .checked_mul(RELAY_CHAIN_SLOT_DURATION_MILLIS) | ||
| .and_then(|product| product.checked_div(para_slot_duration)) | ||
| { | ||
| Some(s) => s, | ||
| None => return false, | ||
| }; | ||
|
|
||
| // 3. Look up the eligible Aura author. Use the cached authority set rather than | ||
| // `pallet_aura::Authorities` because aura-ext's cache is captured at on_initialize for | ||
| // verification of the current PoV. | ||
| let authorities = Authorities::<T>::get(); | ||
| if authorities.is_empty() { | ||
| return false; | ||
| } | ||
| let author_idx = (para_slot % authorities.len() as u64) as usize; | ||
|
mchristou marked this conversation as resolved.
Outdated
|
||
| let author = &authorities[author_idx]; | ||
|
|
||
| // 4. Decode the 64-byte signature blob as the authority's expected signature type and | ||
| // verify over the encoded SchedulingInfoPayload. | ||
| let signature = match <T::AuthorityId as RuntimeAppPublic>::Signature::decode( | ||
| &mut &signed_info.signature[..], | ||
| ) { | ||
| Ok(sig) => sig, | ||
| Err(_) => return false, | ||
| }; | ||
|
|
||
| author.verify(&signed_info.payload.encode(), &signature) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.