Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Executor Environment parameterization #6161

Merged
merged 171 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 140 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
6222398
Re-apply changes without Diener, rebase to the lastest master
s0me0ne-unkn0wn Sep 28, 2022
a370fbd
Cache pruning
s0me0ne-unkn0wn Oct 4, 2022
7066c67
Bit-pack InstantiationStrategy
s0me0ne-unkn0wn Oct 4, 2022
0dce199
Move ExecutorParams version inside the structure itself
s0me0ne-unkn0wn Oct 4, 2022
10c8320
Rework runtime API and executor parameters storage
s0me0ne-unkn0wn Oct 7, 2022
7f103c6
Pass executor parameters through backing subsystem
s0me0ne-unkn0wn Oct 7, 2022
143c483
Update Cargo.lock
s0me0ne-unkn0wn Oct 7, 2022
ba4eb37
Introduce `ExecutorParams` to approval voting subsys
s0me0ne-unkn0wn Oct 9, 2022
1c75f37
Introduce `ExecutorParams` to dispute coordinator
s0me0ne-unkn0wn Oct 9, 2022
003d345
`cargo fmt`
s0me0ne-unkn0wn Oct 9, 2022
631c50a
Simplify requests from backing subsys
s0me0ne-unkn0wn Oct 10, 2022
acc62b1
Fix tests
s0me0ne-unkn0wn Oct 10, 2022
8c10587
Replace manual config cloning with `.clone()`
s0me0ne-unkn0wn Oct 10, 2022
ddd1224
Move constants to module
s0me0ne-unkn0wn Oct 12, 2022
02a0e79
Parametrize executor performing PVF pre-check
s0me0ne-unkn0wn Oct 15, 2022
834c409
Fix Malus
s0me0ne-unkn0wn Oct 15, 2022
f229866
Fix test runtime
s0me0ne-unkn0wn Oct 15, 2022
49ee795
Introduce session executor params as a constant defined by session info
s0me0ne-unkn0wn Oct 15, 2022
48241ad
Use Parity SCALE codec instead of hand-crafted binary encoding
s0me0ne-unkn0wn Oct 15, 2022
a6107d9
Get rid of constants; Add docs
s0me0ne-unkn0wn Oct 16, 2022
ee2df7c
Get rid of constants
s0me0ne-unkn0wn Oct 16, 2022
719ea9b
Minor typo
s0me0ne-unkn0wn Oct 16, 2022
59325fb
Fix Malus after rebase
s0me0ne-unkn0wn Oct 16, 2022
27abf65
`cargo fmt`
s0me0ne-unkn0wn Oct 16, 2022
a3ab251
Use transparent SCALE encoding instead of explicit
s0me0ne-unkn0wn Oct 16, 2022
9ff7b52
Clean up
s0me0ne-unkn0wn Oct 18, 2022
f25f326
Get rid of relay parent to session index mapping
s0me0ne-unkn0wn Oct 26, 2022
b6348ae
Join environment type and version in a single enum element
s0me0ne-unkn0wn Oct 27, 2022
67ef6df
Use default execution parameters if running an old runtime
s0me0ne-unkn0wn Oct 27, 2022
6f2b58d
`unwrap()` -> `expect()`
s0me0ne-unkn0wn Oct 28, 2022
3908bf6
Correct API version
s0me0ne-unkn0wn Oct 28, 2022
a1c37dc
Constants are back in town
s0me0ne-unkn0wn Nov 1, 2022
5431da5
Use constants for execution environment types
s0me0ne-unkn0wn Nov 1, 2022
267ae8b
Artifact separation, first try
s0me0ne-unkn0wn Nov 3, 2022
81fa27d
Get rid of explicit version
s0me0ne-unkn0wn Nov 3, 2022
830f729
PVF execution queue worker separation
s0me0ne-unkn0wn Nov 11, 2022
3d77649
Worker handshake
s0me0ne-unkn0wn Nov 12, 2022
9f3c1c1
Global renaming
s0me0ne-unkn0wn Nov 13, 2022
37f2e5b
Minor fixes resolving discussions
s0me0ne-unkn0wn Nov 14, 2022
d52bb93
Two-stage requesting of executor params to make use of runtime API cache
s0me0ne-unkn0wn Nov 15, 2022
6249955
Proper error handling in pvf-checker
s0me0ne-unkn0wn Nov 17, 2022
d294768
Executor params storage bootstrapping
s0me0ne-unkn0wn Nov 17, 2022
b7347e9
Propagate migration to v3 network runtimes
s0me0ne-unkn0wn Nov 17, 2022
3f80564
Fix storage versioning
s0me0ne-unkn0wn Nov 18, 2022
2dc734e
Ensure `ExecutorParams` serialization determinism; Add comments
s0me0ne-unkn0wn Nov 18, 2022
241b5fc
Rename constants to make things a bit more deterministic
s0me0ne-unkn0wn Nov 18, 2022
0d3a8cc
Tidy up a structure of active PVFs
s0me0ne-unkn0wn Nov 18, 2022
929501b
Minor formatting
s0me0ne-unkn0wn Nov 18, 2022
c3475f4
Fix comment
s0me0ne-unkn0wn Nov 18, 2022
d989a99
Merge remote-tracking branch 'origin/master' into s0me0ne/executor-pa…
s0me0ne-unkn0wn Nov 18, 2022
45293b5
Add try-runtime hooks
s0me0ne-unkn0wn Nov 18, 2022
2ba2102
Add storage version write on upgrade
s0me0ne-unkn0wn Nov 19, 2022
04b1b10
Add pre- and post-upgrade assertions
s0me0ne-unkn0wn Nov 19, 2022
049b414
Require to specify environment type; Remove redundant `impl`s
s0me0ne-unkn0wn Nov 21, 2022
22d7875
Add `ExecutorParamHash` creation from `H256`
s0me0ne-unkn0wn Nov 25, 2022
0d06cd3
Fix candidate validation subsys tests
s0me0ne-unkn0wn Nov 25, 2022
a85038d
Return splittable error from executor params request fn
s0me0ne-unkn0wn Nov 25, 2022
d0cc192
Revert "Return splittable error from executor params request fn"
s0me0ne-unkn0wn Nov 25, 2022
1f3d9ac
Decompose approval voting metrics
s0me0ne-unkn0wn Nov 25, 2022
e924ebf
Use more relevant errors
s0me0ne-unkn0wn Nov 25, 2022
48a6616
Minor formatting fix
s0me0ne-unkn0wn Nov 25, 2022
60676aa
Assert a valid environment type instead of checking
s0me0ne-unkn0wn Nov 25, 2022
f25326b
Fix `try-runtime` hooks
s0me0ne-unkn0wn Nov 29, 2022
aa703a6
Merge remote-tracking branch 'origin/master' into s0me0ne/executor-pa…
s0me0ne-unkn0wn Nov 29, 2022
9dc79ec
After-merge fixes
s0me0ne-unkn0wn Nov 29, 2022
16f77e7
Add migration logs
s0me0ne-unkn0wn Nov 30, 2022
f1ec476
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Nov 30, 2022
a51e57e
Remove dead code
s0me0ne-unkn0wn Nov 30, 2022
af45aea
Fix tests
s0me0ne-unkn0wn Nov 30, 2022
76170d8
Fix tests
s0me0ne-unkn0wn Nov 30, 2022
5ae6164
Back to the strongly typed implementation
s0me0ne-unkn0wn Dec 1, 2022
d1aac61
Promote strong types to executor interface
s0me0ne-unkn0wn Dec 1, 2022
2439ae6
Remove stale comment
s0me0ne-unkn0wn Dec 1, 2022
1988355
Move executor params to `SessionInfo`: primitives and runtime
s0me0ne-unkn0wn Dec 4, 2022
a2dc782
Move executor params to `SessionInfo`: node
s0me0ne-unkn0wn Dec 4, 2022
ce042c8
Try to bump primitives and API version
s0me0ne-unkn0wn Dec 11, 2022
674038d
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Dec 11, 2022
52d7049
Get rid of `MallocSizeOf`
s0me0ne-unkn0wn Dec 12, 2022
84d53a1
Bump target API version to v4
s0me0ne-unkn0wn Dec 12, 2022
5c26c5e
Make use of session index already in place
s0me0ne-unkn0wn Dec 13, 2022
a89dff9
Merge branch 's0me0ne/executor-params-v3' into s0me0ne/executor-params
s0me0ne-unkn0wn Dec 13, 2022
03c4886
Back to v3
s0me0ne-unkn0wn Dec 15, 2022
c161ed6
Fix all the tests
s0me0ne-unkn0wn Dec 15, 2022
af35b7b
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Dec 15, 2022
cdd62e7
Add migrations to all the runtimes
s0me0ne-unkn0wn Dec 16, 2022
a51f955
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Dec 19, 2022
d3ef27b
Make use of existing `SessionInfo` in approval voting subsys
s0me0ne-unkn0wn Dec 21, 2022
3431c20
Rename `TARGET` -> `LOG_TARGET`
s0me0ne-unkn0wn Dec 21, 2022
96b921b
Bump all the primitives to v3
s0me0ne-unkn0wn Dec 21, 2022
883208a
Fix Rococo ParachainHost API version
s0me0ne-unkn0wn Dec 21, 2022
1229596
Use `RollingSessionWindow` to acquire `ExecutorParams` in disputes
s0me0ne-unkn0wn Dec 23, 2022
6d1e1b9
Fix nits from discussions; add comments
s0me0ne-unkn0wn Dec 24, 2022
32e6f1f
Re-evaluate queue logic
s0me0ne-unkn0wn Dec 25, 2022
39aae8f
Rework job assignment in execution queue
s0me0ne-unkn0wn Dec 25, 2022
b6195e9
Add documentation
s0me0ne-unkn0wn Dec 27, 2022
bb369ed
Use `RuntimeInfo` to obtain `SessionInfo` (with blackjack and caching)
s0me0ne-unkn0wn Dec 27, 2022
3be2229
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Dec 28, 2022
cc97fb1
Couple `Pvf` with `ExecutorParams` wherever possible
s0me0ne-unkn0wn Dec 30, 2022
8a7d9d6
Put members of `PvfWithExecutorParams` under `Arc` for cheap cloning
s0me0ne-unkn0wn Jan 2, 2023
ca08d65
Fix comment
s0me0ne-unkn0wn Jan 2, 2023
877a0e4
Fix CI tests
s0me0ne-unkn0wn Jan 2, 2023
5e5d9c0
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 2, 2023
996538f
Fix clippy warnings
s0me0ne-unkn0wn Jan 2, 2023
029b82b
Address nits from discussions
s0me0ne-unkn0wn Jan 3, 2023
74ccff8
Add a placeholder for raw data
s0me0ne-unkn0wn Jan 3, 2023
ad61bd2
Fix non exhaustive match
s0me0ne-unkn0wn Jan 4, 2023
abd0fc1
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 4, 2023
924fd97
Remove redundant reexports and fix imports
s0me0ne-unkn0wn Jan 4, 2023
553be9d
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 4, 2023
0dbc3fb
Keep only necessary semantic features, as discussed
s0me0ne-unkn0wn Jan 5, 2023
eb43480
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 5, 2023
3dee590
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 5, 2023
535f494
Rework `RuntimeInfo` to support mock implementation for tests
s0me0ne-unkn0wn Jan 6, 2023
3bdfc68
Remove unneeded bound
s0me0ne-unkn0wn Jan 6, 2023
28e3614
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 7, 2023
1ee2697
`cargo fmt`
s0me0ne-unkn0wn Jan 7, 2023
17a84f2
Revert "Remove unneeded bound"
s0me0ne-unkn0wn Jan 9, 2023
3728a41
Merge branch 's0me0ne/executor-params-runtime-info' into s0me0ne/exec…
s0me0ne-unkn0wn Jan 9, 2023
31c3fa9
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 9, 2023
7527152
Fix PVF host tests
s0me0ne-unkn0wn Jan 10, 2023
b099dda
Fix PVF checker tests
s0me0ne-unkn0wn Jan 10, 2023
a594a19
Fix overseer declarations
s0me0ne-unkn0wn Jan 10, 2023
a8834c1
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 10, 2023
9b03239
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 11, 2023
f965783
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 12, 2023
7496dca
Simplify tests
s0me0ne-unkn0wn Jan 13, 2023
056c055
`MAX_KEEP_WAITING` timeout based on `BACKGING_EXECUTION_TIMEOUT`
s0me0ne-unkn0wn Jan 15, 2023
a8ab836
Add a unit test for varying executor parameters
s0me0ne-unkn0wn Jan 15, 2023
c9b7dde
Minor fixes from discussions
s0me0ne-unkn0wn Jan 16, 2023
1e12da2
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 16, 2023
8b6f478
Add prechecking max. memory parameter (see paritytech/srlabs_findings…
s0me0ne-unkn0wn Jan 16, 2023
e4b5909
Fix and improve a test
s0me0ne-unkn0wn Jan 16, 2023
e39b991
Remove `ExecutionEnvironment` and `RawData`
s0me0ne-unkn0wn Jan 17, 2023
f092002
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 17, 2023
d4e8db8
New primitives versioning in parachain host API
s0me0ne-unkn0wn Jan 17, 2023
7776b73
`disputes()` implementation for Kusama and Polkadot
s0me0ne-unkn0wn Jan 18, 2023
29bec0e
Move `ExecutorParams` from `vstaging` to stable primitives
s0me0ne-unkn0wn Jan 18, 2023
7930340
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 18, 2023
c258bd4
Move disputes from `vstaging` to stable implementation
s0me0ne-unkn0wn Jan 18, 2023
95d790c
Fix `try-runtime`
s0me0ne-unkn0wn Jan 18, 2023
c79a404
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 19, 2023
6aa31c4
Fixes after merge
s0me0ne-unkn0wn Jan 19, 2023
ba19715
Move `ExecutorParams` to the bottom of `SessionInfo`
s0me0ne-unkn0wn Jan 19, 2023
630edbd
Revert "Move executor params to `SessionInfo`: primitives and runtime"
s0me0ne-unkn0wn Jan 19, 2023
c559bd9
Always use fresh activated live hash in pvf precheck
s0me0ne-unkn0wn Jan 19, 2023
f157395
Fixing tests (broken commit)
s0me0ne-unkn0wn Jan 20, 2023
f155042
Fix candidate validation tests
s0me0ne-unkn0wn Jan 20, 2023
7f10d92
Fix PVF host test
s0me0ne-unkn0wn Jan 20, 2023
8e7d31d
Minor fixes
s0me0ne-unkn0wn Jan 20, 2023
7d2305b
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 30, 2023
5a04b6a
Address discussions
s0me0ne-unkn0wn Jan 30, 2023
8877933
Restore migration
s0me0ne-unkn0wn Jan 30, 2023
4315ff7
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Jan 30, 2023
a182847
Fix `use` to only include what is needed instead of `*`
s0me0ne-unkn0wn Jan 31, 2023
7e16619
Add comment to never touch `DEFAULT_CONFIG`
s0me0ne-unkn0wn Jan 31, 2023
106ddbf
Update migration to set default `ExecutorParams` for `dispute_period`
s0me0ne-unkn0wn Jan 31, 2023
3879459
Use `earliest_stored_session` instead of calculations
s0me0ne-unkn0wn Feb 1, 2023
d5e064a
Nit
s0me0ne-unkn0wn Feb 1, 2023
7ba4a98
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Feb 7, 2023
d67c3cf
Add logs
s0me0ne-unkn0wn Feb 7, 2023
38687d2
Treat any runtime error as `NotSupported` again
s0me0ne-unkn0wn Feb 8, 2023
277efe5
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Feb 8, 2023
b58ac44
Always return default executor params if not available
s0me0ne-unkn0wn Feb 10, 2023
c32c93c
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Feb 10, 2023
5c1e9e4
Revert "Always return default executor params if not available"
s0me0ne-unkn0wn Feb 10, 2023
6f2c0c9
Add paritytech/substrate#9997 workaround
s0me0ne-unkn0wn Feb 13, 2023
17a66e1
`cargo fmt`
s0me0ne-unkn0wn Feb 13, 2023
83e8fe4
Remove migration (again!)
s0me0ne-unkn0wn Feb 13, 2023
96f7a45
Bump executor params to API v4 (backport from #6698)
s0me0ne-unkn0wn Feb 14, 2023
69d4ae6
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Feb 14, 2023
5e0dbfd
Merge branch 'master' into s0me0ne/executor-params
s0me0ne-unkn0wn Feb 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use polkadot_node_primitives::approval::{
self as approval_types, AssignmentCert, AssignmentCertKind, DelayTranche, RelayVRFStory,
};
use polkadot_primitives::{
AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex, IndexedVec, SessionInfo,
ValidatorIndex,
v3::SessionInfo, AssignmentId, AssignmentPair, CandidateHash, CoreIndex, GroupIndex,
IndexedVec, ValidatorIndex,
};
use sc_keystore::LocalKeystore;
use sp_application_crypto::ByteArray;
Expand Down
6 changes: 5 additions & 1 deletion node/core/approval-voting/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ pub(crate) mod tests {
use polkadot_node_subsystem::messages::{AllMessages, ApprovalVotingMessage};
use polkadot_node_subsystem_test_helpers::make_subsystem_context;
use polkadot_node_subsystem_util::database::Database;
use polkadot_primitives::{Id as ParaId, IndexedVec, SessionInfo, ValidatorId, ValidatorIndex};
use polkadot_primitives::{
v3::SessionInfo, Id as ParaId, IndexedVec, ValidatorId, ValidatorIndex,
};
pub(crate) use sp_consensus_babe::{
digests::{CompatibleDigestItem, PreDigest, SecondaryVRFPreDigest},
AllowedSlots, BabeEpochConfiguration, Epoch as BabeEpoch,
Expand Down Expand Up @@ -712,6 +714,7 @@ pub(crate) mod tests {

fn dummy_session_info(index: SessionIndex) -> SessionInfo {
SessionInfo {
executor_params: Default::default(),
validators: Default::default(),
discovery_keys: Vec::new(),
assignment_keys: Vec::new(),
Expand Down Expand Up @@ -1166,6 +1169,7 @@ pub(crate) mod tests {
let irrelevant = 666;
let session_info =
SessionInfo {
executor_params: Default::default(),
validators: IndexedVec::<ValidatorIndex, ValidatorId>::from(
vec![Sr25519Keyring::Alice.public().into(); 6],
),
Expand Down
12 changes: 9 additions & 3 deletions node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ use polkadot_node_subsystem_util::{
TimeoutExt,
};
use polkadot_primitives::{
ApprovalVote, BlockNumber, CandidateHash, CandidateIndex, CandidateReceipt, DisputeStatement,
GroupIndex, Hash, SessionIndex, SessionInfo, ValidDisputeStatementKind, ValidatorId,
ValidatorIndex, ValidatorPair, ValidatorSignature,
v3::SessionInfo, ApprovalVote, BlockNumber, CandidateHash, CandidateIndex, CandidateReceipt,
DisputeStatement, ExecutorParams, GroupIndex, Hash, SessionIndex, ValidDisputeStatementKind,
ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature,
};
use sc_keystore::LocalKeystore;
use sp_application_crypto::Pair;
Expand Down Expand Up @@ -745,6 +745,7 @@ enum Action {
relay_block_hash: Hash,
candidate_index: CandidateIndex,
session: SessionIndex,
executor_params: ExecutorParams,
candidate: CandidateReceipt,
backing_group: GroupIndex,
},
Expand Down Expand Up @@ -960,6 +961,7 @@ async fn handle_actions<Context>(
relay_block_hash,
candidate_index,
session,
executor_params,
candidate,
backing_group,
} => {
Expand Down Expand Up @@ -1000,6 +1002,7 @@ async fn handle_actions<Context>(
ctx,
metrics.clone(),
session,
executor_params,
candidate,
validator_index,
block_hash,
Expand Down Expand Up @@ -2238,6 +2241,7 @@ fn process_wakeup(
relay_block_hash: relay_block,
candidate_index: i as _,
session: block_entry.session(),
executor_params: session_info.executor_params.clone(),
candidate: candidate_receipt,
backing_group,
});
Expand Down Expand Up @@ -2271,6 +2275,7 @@ async fn launch_approval<Context>(
ctx: &mut Context,
metrics: Metrics,
session_index: SessionIndex,
executor_params: ExecutorParams,
candidate: CandidateReceipt,
validator_index: ValidatorIndex,
block_hash: Hash,
Expand Down Expand Up @@ -2399,6 +2404,7 @@ async fn launch_approval<Context>(
validation_code,
candidate.clone(),
available_data.pov,
executor_params,
APPROVAL_EXECUTION_TIMEOUT,
val_tx,
))
Expand Down
3 changes: 2 additions & 1 deletion node/core/approval-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ impl ChainBuilder {

fn session_info(keys: &[Sr25519Keyring]) -> SessionInfo {
SessionInfo {
executor_params: Default::default(),
validators: keys.iter().map(|v| v.public().into()).collect(),
discovery_keys: keys.iter().map(|v| v.public().into()).collect(),
assignment_keys: keys.iter().map(|v| v.public().into()).collect(),
Expand Down Expand Up @@ -2426,7 +2427,7 @@ pub async fn handle_double_assignment_import(
assert_eq!(candidate_index, c_index);
},
AllMessages::CandidateValidation(
CandidateValidationMessage::ValidateFromExhaustive(_, _, _, _, timeout, tx),
CandidateValidationMessage::ValidateFromExhaustive(_, _, _, _, _, timeout, tx),
) if timeout == APPROVAL_EXECUTION_TIMEOUT => {
tx.send(Ok(ValidationResult::Valid(Default::default(), Default::default())))
.unwrap();
Expand Down
46 changes: 38 additions & 8 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ use polkadot_node_subsystem::{
};
use polkadot_node_subsystem_util::{
self as util, request_from_runtime, request_session_index_for_child, request_validator_groups,
request_validators, Validator,
request_validators, runtime::RuntimeInfo, Validator,
};
use polkadot_primitives::{
BackedCandidate, CandidateCommitments, CandidateHash, CandidateReceipt, CollatorId,
CommittedCandidateReceipt, CoreIndex, CoreState, Hash, Id as ParaId, SigningContext,
ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation,
CommittedCandidateReceipt, CoreIndex, CoreState, ExecutorParams, Hash, Id as ParaId,
SigningContext, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation,
};
use sp_keystore::SyncCryptoStorePtr;
use statement_table::{
generic::AttestedCandidate as TableAttestedCandidate,
v2::{
v3::{
SignedStatement as TableSignedStatement, Statement as TableStatement,
Summary as TableSummary,
},
Expand Down Expand Up @@ -119,14 +119,16 @@ impl ValidatedCandidateCommand {

/// The candidate backing subsystem.
pub struct CandidateBackingSubsystem {
runtime: RuntimeInfo,
keystore: SyncCryptoStorePtr,
metrics: Metrics,
}

impl CandidateBackingSubsystem {
/// Create a new instance of the `CandidateBackingSubsystem`.
pub fn new(keystore: SyncCryptoStorePtr, metrics: Metrics) -> Self {
Self { keystore, metrics }
let runtime = RuntimeInfo::new(Some(keystore.clone()));
Self { runtime, keystore, metrics }
}
}

Expand All @@ -137,7 +139,7 @@ where
{
fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = async move {
run(ctx, self.keystore, self.metrics)
run(ctx, self.runtime, self.keystore, self.metrics)
.await
.map_err(|e| SubsystemError::with_origin("candidate-backing", e))
}
Expand All @@ -150,6 +152,7 @@ where
#[overseer::contextbounds(CandidateBacking, prefix = self::overseer)]
async fn run<Context>(
mut ctx: Context,
mut runtime: RuntimeInfo,
keystore: SyncCryptoStorePtr,
metrics: Metrics,
) -> FatalResult<()> {
Expand All @@ -159,6 +162,7 @@ async fn run<Context>(
loop {
let res = run_iteration(
&mut ctx,
&mut runtime,
keystore.clone(),
&metrics,
&mut jobs,
Expand All @@ -179,6 +183,7 @@ async fn run<Context>(
#[overseer::contextbounds(CandidateBacking, prefix = self::overseer)]
async fn run_iteration<Context>(
ctx: &mut Context,
runtime: &mut RuntimeInfo,
keystore: SyncCryptoStorePtr,
metrics: &Metrics,
jobs: &mut HashMap<Hash, JobAndSpan<Context>>,
Expand All @@ -205,6 +210,7 @@ async fn run_iteration<Context>(
&mut *ctx,
update,
jobs,
&mut *runtime,
&keystore,
&background_validation_tx,
&metrics,
Expand Down Expand Up @@ -266,6 +272,7 @@ async fn handle_active_leaves_update<Context>(
ctx: &mut Context,
update: ActiveLeavesUpdate,
jobs: &mut HashMap<Hash, JobAndSpan<Context>>,
runtime: &mut RuntimeInfo,
keystore: &SyncCryptoStorePtr,
background_validation_tx: &mpsc::Sender<(Hash, ValidatedCandidateCommand)>,
metrics: &Metrics,
Expand Down Expand Up @@ -319,6 +326,21 @@ async fn handle_active_leaves_update<Context>(
let session_index = try_runtime_api!(session_index);
let cores = try_runtime_api!(cores);

let ext_session_info =
match runtime.get_session_info_by_index(ctx.sender(), parent, session_index).await {
Ok(esi) => esi,
Err(e) => {
gum::warn!(
target: LOG_TARGET,
err = ?e,
"Failed to get session info for job",
);

return Ok(())
},
};
let executor_params = ext_session_info.session_info.executor_params.clone();

drop(_span);
let _span = span.child("validator-construction");

Expand Down Expand Up @@ -389,6 +411,7 @@ async fn handle_active_leaves_update<Context>(
unbacked_candidates: HashMap::new(),
backed: HashSet::new(),
keystore: keystore.clone(),
executor_params,
table: Table::default(),
table_context,
background_validation_tx: background_validation_tx.clone(),
Expand Down Expand Up @@ -428,6 +451,7 @@ struct CandidateBackingJob<Context> {
/// that we've sent the provisioner the backed candidate.
backed: HashSet<CandidateHash>,
keystore: SyncCryptoStorePtr,
executor_params: ExecutorParams,
table: Table<TableContext>,
table_context: TableContext,
background_validation_tx: mpsc::Sender<(Hash, ValidatedCandidateCommand)>,
Expand Down Expand Up @@ -643,13 +667,14 @@ async fn request_candidate_validation(
sender: &mut impl overseer::CandidateBackingSenderTrait,
candidate_receipt: CandidateReceipt,
pov: Arc<PoV>,
executor_params: ExecutorParams,
) -> Result<ValidationResult, Error> {
let (tx, rx) = oneshot::channel();

sender
.send_message(CandidateValidationMessage::ValidateFromChainState(
candidate_receipt,
pov,
executor_params,
BACKING_EXECUTION_TIMEOUT,
tx,
))
Expand All @@ -671,6 +696,7 @@ struct BackgroundValidationParams<S: overseer::CandidateBackingSenderTrait, F> {
candidate: CandidateReceipt,
relay_parent: Hash,
pov: PoVData,
executor_params: ExecutorParams,
n_validators: usize,
span: Option<jaeger::Span>,
make_command: F,
Expand All @@ -689,6 +715,7 @@ async fn validate_and_make_available(
relay_parent,
pov,
n_validators,
executor_params,
span,
make_command,
} = params;
Expand Down Expand Up @@ -729,7 +756,8 @@ async fn validate_and_make_available(
.with_pov(&pov)
.with_para_id(candidate.descriptor().para_id)
});
request_candidate_validation(&mut sender, candidate.clone(), pov.clone()).await?
request_candidate_validation(&mut sender, candidate.clone(), pov.clone(), executor_params)
.await?
};

let res = match v {
Expand Down Expand Up @@ -957,6 +985,7 @@ impl<Context> CandidateBackingJob<Context> {
candidate: candidate.clone(),
relay_parent: self.parent,
pov: PoVData::Ready(pov),
executor_params: self.executor_params.clone(),
n_validators: self.table_context.validators.len(),
span,
make_command: ValidatedCandidateCommand::Second,
Expand Down Expand Up @@ -1208,6 +1237,7 @@ impl<Context> CandidateBackingJob<Context> {
candidate: attesting.candidate,
relay_parent: self.parent,
pov,
executor_params: self.executor_params.clone(),
n_validators: self.table_context.validators.len(),
span,
make_command: ValidatedCandidateCommand::Attest,
Expand Down
Loading