-
Notifications
You must be signed in to change notification settings - Fork 371
Use JustifiedBlockAnnounceValidator for parachain block announce validator #96
Changes from all commits
655dc45
9a47c09
32e81cf
df0f832
892d057
41f50ee
214e50d
cd131ff
3212554
0286a88
d38edea
3d162e0
62b544e
17887fc
a0eb356
9961be4
baa4357
fc408e4
22b64de
a978970
ee3832a
1267f80
368a582
de2b666
a17dd34
31768ce
68b0dcf
e2f3fdc
0361e14
cde8935
145ec00
0d21e75
671d5f9
a5c89b0
9697b62
a300ea9
87489c5
6f0075a
9c7af42
19b7942
6eca4f0
6e43fd4
2564cce
542eb35
ddb111f
d985af8
e4fb6aa
bf68f24
8c24090
a633fdd
865542d
56929d6
0b1f21b
c9f95a3
e7fe457
bb89a33
9cc6f21
5a257d6
934fd5c
21dba8c
File filter
Filter by extension
Conversations
Jump to
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ use assert_cmd::cargo::cargo_bin; | |
| use async_std::{net, task::sleep}; | ||
| use codec::Encode; | ||
| use futures::{future::FutureExt, join, pin_mut, select}; | ||
| use jsonrpsee::{raw::RawClient, transport::http::HttpTransportClient}; | ||
| use polkadot_primitives::parachain::{Info, Scheduling}; | ||
| use polkadot_primitives::Hash as PHash; | ||
| use polkadot_runtime::{Header, OnlyStakingAndClaims, Runtime, SignedExtra, SignedPayload}; | ||
|
|
@@ -144,6 +145,25 @@ async fn wait_for_tcp<A: net::ToSocketAddrs + std::fmt::Display>(address: A) { | |
| } | ||
| } | ||
|
|
||
| /// wait for parachain blocks to be produced | ||
| async fn wait_for_blocks(number_of_blocks: usize, mut client: &mut RawClient<HttpTransportClient>) { | ||
| let mut previous_blocks = HashSet::with_capacity(number_of_blocks); | ||
|
|
||
| loop { | ||
| let current_block_hash = Chain::block_hash(&mut client, None).await.unwrap().unwrap(); | ||
|
|
||
| if previous_blocks.insert(current_block_hash) { | ||
| eprintln!("new parachain block: {}", current_block_hash); | ||
|
|
||
| if previous_blocks.len() == number_of_blocks { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| sleep(Duration::from_secs(2)).await; | ||
| } | ||
| } | ||
|
|
||
| #[async_std::test] | ||
| #[ignore] | ||
| async fn integration_test() { | ||
|
|
@@ -310,13 +330,13 @@ async fn integration_test() { | |
| .await | ||
| .unwrap(); | ||
|
|
||
| // run cumulus | ||
| let cumulus_dir = tempdir().unwrap(); | ||
| let mut cumulus = Command::new(cargo_bin("cumulus-test-parachain-collator")) | ||
| // run cumulus charlie | ||
| let cumulus_charlie_dir = tempdir().unwrap(); | ||
| let mut cumulus_charlie = Command::new(cargo_bin("cumulus-test-parachain-collator")) | ||
| .stdout(Stdio::piped()) | ||
| .stderr(Stdio::piped()) | ||
| .arg("--base-path") | ||
| .arg(cumulus_dir.path()) | ||
| .arg(cumulus_charlie_dir.path()) | ||
| .arg("--unsafe-rpc-expose") | ||
| .arg("--rpc-port=27017") | ||
| .arg("--port=27117") | ||
|
|
@@ -329,35 +349,51 @@ async fn integration_test() { | |
| "--bootnodes=/ip4/127.0.0.1/tcp/27116/p2p/{}", | ||
| polkadot_bob_id | ||
| )) | ||
| .arg("--charlie") | ||
| .spawn() | ||
| .unwrap(); | ||
| let cumulus_helper = ChildHelper::new("cumulus", &mut cumulus); | ||
| let cumulus_charlie_helper = ChildHelper::new("cumulus-charlie", &mut cumulus_charlie); | ||
| wait_for_tcp("127.0.0.1:27017").await; | ||
|
|
||
| // connect rpc client to cumulus | ||
| let transport_client_cumulus = | ||
| let transport_client_cumulus_charlie = | ||
| jsonrpsee::transport::http::HttpTransportClient::new("http://127.0.0.1:27017"); | ||
| let mut client_cumulus = jsonrpsee::raw::RawClient::new(transport_client_cumulus); | ||
| let mut client_cumulus_charlie = | ||
| jsonrpsee::raw::RawClient::new(transport_client_cumulus_charlie); | ||
|
|
||
| // wait for parachain blocks to be produced | ||
| let number_of_blocks = 4; | ||
| let mut previous_blocks = HashSet::with_capacity(number_of_blocks); | ||
| loop { | ||
| let current_block_hash = Chain::block_hash(&mut client_cumulus, None) | ||
| .await | ||
| .unwrap() | ||
| .unwrap(); | ||
| wait_for_blocks(4, &mut client_cumulus_charlie).await; | ||
|
|
||
| if previous_blocks.insert(current_block_hash) { | ||
| eprintln!("new parachain block: {}", current_block_hash); | ||
| // run cumulus dave | ||
| let cumulus_dave_dir = tempdir().unwrap(); | ||
| let mut cumulus_dave = Command::new(cargo_bin("cumulus-test-parachain-collator")) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I said in #96 (comment) I also added a test in the integration test but it is not super useful, it will only detect something if the implementation is broken but not if the implementation returns always Success like the default implementation of BlockAnnounceValidator. So for example if the implementation is broken and no block at all are validated, then we would see on Dave that no block are being imported and the test would fail. |
||
| .stdout(Stdio::piped()) | ||
| .stderr(Stdio::piped()) | ||
| .arg("--base-path") | ||
| .arg(cumulus_dave_dir.path()) | ||
| .arg("--unsafe-rpc-expose") | ||
| .arg("--rpc-port=27018") | ||
| .arg("--port=27118") | ||
| .arg("--") | ||
| .arg(format!( | ||
| "--bootnodes=/ip4/127.0.0.1/tcp/27115/p2p/{}", | ||
| polkadot_alice_id | ||
| )) | ||
| .arg(format!( | ||
| "--bootnodes=/ip4/127.0.0.1/tcp/27116/p2p/{}", | ||
| polkadot_bob_id | ||
| )) | ||
| .arg("--dave") | ||
| .spawn() | ||
| .unwrap(); | ||
| let cumulus_dave_helper = ChildHelper::new("cumulus-dave", &mut cumulus_dave); | ||
| wait_for_tcp("127.0.0.1:27018").await; | ||
|
|
||
| if previous_blocks.len() == number_of_blocks { | ||
| break; | ||
| } | ||
| } | ||
| // connect rpc client to cumulus | ||
| let transport_client_cumulus_dave = | ||
| jsonrpsee::transport::http::HttpTransportClient::new("http://127.0.0.1:27018"); | ||
| let mut client_cumulus_dave = jsonrpsee::raw::RawClient::new(transport_client_cumulus_dave); | ||
|
|
||
| sleep(Duration::from_secs(2)).await; | ||
| } | ||
| wait_for_blocks(4, &mut client_cumulus_dave).await; | ||
| } | ||
| .fuse(); | ||
|
|
||
|
|
||
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.
Docs and especially why we do this! + an issue that we need to fix this.
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
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.
You should create an issue for this. And this should contain this info.
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.
Ok! Sorry, created #104
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