-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Make ValidationPool accepts execution mode to run custom command or in process validation #1622
Conversation
Forked at: bf7ccb8 Parent branch: origin/master
@@ -132,6 +132,9 @@ pub struct ServiceBuilder<C, N, P, SC, SP> { | |||
pub keystore: KeyStorePtr, | |||
/// The maximum block-data size in bytes. | |||
pub max_block_data_size: Option<u64>, | |||
/// The validation worker is called using the subcommand `--nocapture validation_worker` instead | |||
/// of `validation-worker`, suitable for test environment. | |||
pub test_mode: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we pass an enum here:
enum ValidationExecutionMode {
Local,
Remote {
binary: Path,
args: Vec<String>,
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point!
I don't know if we need that much flexibility 🤔 do you think? Nobody touched this except me recently and only for testing.
Well! I don't mind changing it for an enum! Should I proceed with the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this makes this parameter also more clear on what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 8a5aa08
service/src/lib.rs
Outdated
@@ -391,6 +393,15 @@ pub fn new_full<RuntimeApi, Executor>( | |||
|
|||
polkadot_network_service.register_availability_store(availability_store.clone()); | |||
|
|||
let execution_mode = if test_mode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let execution_mode = if test_mode { | |
let execution_mode = if !test_mode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait what. Why? The whole point was to get this on the worker args for the tests. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment, this makes no sense. In test mode you don't want to start the external worker and do it as thread instead. You mixed the concepts here totally. You should read the code of the validation again that decides on whether to start a validation worker or to run it inside the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no it's fine I get it now!
So Local would be use by the integration test on cumulus because we don't need it to be interruptible (or any more sophisticated), just need it to run for a few seconds during the test and everything is stopped anyway (because tests have their own process in Rust which is great I think).
Remote is the currently supported case in polkadot (and polkadot's tests!) where a background tasks is ran by spawning a new child process.
ez pz
let (cmd, args) = match execution_mode { | ||
ValidationExecutionMode::Local => ( | ||
env::current_exe()?, | ||
WORKER_ARGS.iter().map(|x| x.to_string()).collect() | ||
), | ||
ValidationExecutionMode::Remote { binary, args } => (binary, args), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait. You clear did not understand what Local and Remote mean here.
Local => Run the verification inside the current process
Remote => Use the given external command and args to start a worker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually would prefer an enum option to use default args and executable name. Defaults should work in all cases other than testing, and requiring the user to always specify executable/args would be bad API design. It is very much an internal implementation details and it only leaks away because tests require special handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you mean by enum option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An enum value that does not require setting executable name for out-of-process validation. E.g. RemoteDefault
or simply Remote
. Basically something like this:
pub enum ValidationExecutionMode {
InProcess,
ExternalProcessSelfHost,
ExternalProcessCustomHost {
binary: PathBuf,
args: Vec<String>,
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Sounds reasonable.
service/src/lib.rs
Outdated
@@ -391,6 +393,15 @@ pub fn new_full<RuntimeApi, Executor>( | |||
|
|||
polkadot_network_service.register_availability_store(availability_store.clone()); | |||
|
|||
let execution_mode = if test_mode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment, this makes no sense. In test mode you don't want to start the external worker and do it as thread instead. You mixed the concepts here totally. You should read the code of the validation again that decides on whether to start a validation worker or to run it inside the process.
Some tests rely on the interruptable execution support. I would prefer all test to run as close to the real world usage as possible. The current version of this PR supports out of process execution for tests and I see no problem with that. |
Yeah and that is totally find and is still supported. I also don't want to remove support for this. However, @cecton had the problem that she wrote an integration tests and was not aware of the remote test execution. And this lead to some nested loop of always starting the same process over and over again. For our integration test usage it is totally fine to run the validation in the process and that is what this pr is about. So, what I imagined is the following:
|
Right, but this PR fixes that. It allows for tests to run in external process.
Are you sure about that? This might not be important for unit tests, but integration tests should be as close to real life behaviour as possible. |
Yeah I know, but it is also weird to replicate always this extra test that is being called as the worker. The worker only exists to make validation interruptable and more observabale. I'm not that convinced that this feature is that important to test. |
Yes I know it sounds weird but as far as cumulus is concerned we don't really test that polkadot can run its validation in a subprocess properly. That is a test done in polkadot. We trust that polkadot is working and is tested. In cumulus we only care that both chains interact properly. Thus the simplest (and with less pitfalls) implementation is better.
No no I was very aware of that. I did made the subcommand for the original integration tests. I just forgot about it and this time no error message warned me of my mistake (1). What I mean is: this is a human mistake and this is a pitfall. (1) in the original integration test the command failed when received arguments it couldn't parse. Here it's the test binary that is ran and it doesn't fail easily, it tries to find a test called "validation-worker", filters out everything, and exit with a status 0. This is pure evil. |
Parent branch: origin/master Forked at: bf7ccb8
…n process validation (#1622) Squashed commit of the following: commit 3eec1ef Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 11:43:47 2020 +0200 CLEANUP Forked at: bf7ccb8 Parent branch: origin/master commit 50ba484 Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 11:42:07 2020 +0200 Add test commit 33ced08 Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 11:21:57 2020 +0200 Run validation inside the same process commit 4e113ba Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 10:25:06 2020 +0200 Adapt code to review suggestions commit f46e7a7 Merge: 6301515 e2ebf25 Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 10:03:04 2020 +0200 Merge commit e2ebf25 (no conflict) Parent branch: origin/master Forked at: bf7ccb8 commit 6301515 Merge: 7f57373 01ffc66 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:09:27 2020 +0200 Merge commit 01ffc66 (no conflict) Parent branch: origin/master Forked at: bf7ccb8 commit 7f57373 Merge: 1fd2987 00202d3 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:09:22 2020 +0200 Merge commit 00202d3 (conflicts) Parent branch: origin/master Forked at: bf7ccb8 commit 1fd2987 Merge: 41cb5b5 62cf5b9 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:05:23 2020 +0200 Merge commit 62cf5b9 (no conflict) Parent branch: origin/master Forked at: bf7ccb8 commit 41cb5b5 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:03:31 2020 +0200 Update service/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> commit 8a5aa08 Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 19:06:36 2020 +0200 WIP Forked at: bf7ccb8 Parent branch: origin/master commit b7a97df Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:56:21 2020 +0200 Fix test commit e28eed7 Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:37:13 2020 +0200 Update validation/src/validation_service/mod.rs commit 8c880f7 Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:02:45 2020 +0200 Propagate test mode all the way down to ValidationPool commit d32b42a Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:27:56 2020 +0200 Initial commit Forked at: bf7ccb8 Parent branch: origin/master
…n process validation (#1622) Squashed commit of the following: commit 3eec1ef Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 11:43:47 2020 +0200 CLEANUP Forked at: bf7ccb8 Parent branch: origin/master commit 50ba484 Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 11:42:07 2020 +0200 Add test commit 33ced08 Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 11:21:57 2020 +0200 Run validation inside the same process commit 4e113ba Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 10:25:06 2020 +0200 Adapt code to review suggestions commit f46e7a7 Merge: 6301515 e2ebf25 Author: Cecile Tonglet <cecile@parity.io> Date: Wed Sep 2 10:03:04 2020 +0200 Merge commit e2ebf25 (no conflict) Parent branch: origin/master Forked at: bf7ccb8 commit 6301515 Merge: 7f57373 01ffc66 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:09:27 2020 +0200 Merge commit 01ffc66 (no conflict) Parent branch: origin/master Forked at: bf7ccb8 commit 7f57373 Merge: 1fd2987 00202d3 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:09:22 2020 +0200 Merge commit 00202d3 (conflicts) Parent branch: origin/master Forked at: bf7ccb8 commit 1fd2987 Merge: 41cb5b5 62cf5b9 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:05:23 2020 +0200 Merge commit 62cf5b9 (no conflict) Parent branch: origin/master Forked at: bf7ccb8 commit 41cb5b5 Author: Cecile Tonglet <cecile@parity.io> Date: Tue Aug 25 01:03:31 2020 +0200 Update service/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> commit 8a5aa08 Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 19:06:36 2020 +0200 WIP Forked at: bf7ccb8 Parent branch: origin/master commit b7a97df Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:56:21 2020 +0200 Fix test commit e28eed7 Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:37:13 2020 +0200 Update validation/src/validation_service/mod.rs commit 8c880f7 Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:02:45 2020 +0200 Propagate test mode all the way down to ValidationPool commit d32b42a Author: Cecile Tonglet <cecile@parity.io> Date: Fri Aug 21 15:27:56 2020 +0200 Initial commit Forked at: bf7ccb8 Parent branch: origin/master
bot merge |
Trying merge. |
Related to paritytech/cumulus#199
Also related to paritytech/cumulus#201 for the actual use
This change will make the polkadot test service use the "test mode" of the validation pool.I
alsomoved the test flag from the validate_candidate to the pool directly which looks like a refactoring but my actual goalwasis to pass the test mode all the way down to the Validation pool. This will be done for v1 of the validation.