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

Conversation

@cecton
Copy link
Contributor

@cecton cecton commented May 13, 2020

Related to #7

cecton and others added 30 commits May 6, 2020 12:55
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
Forked at: d6ab13c
Parent branch: origin/master
@cecton cecton force-pushed the cecton-use-custom-block-announce-validator branch from db8cab2 to 6e43fd4 Compare May 15, 2020 12:13
cecton added 2 commits May 15, 2020 14:18
Forked at: d6ab13c
Parent branch: origin/master
@cecton cecton requested a review from bkchr May 15, 2020 12:33
Comment on lines 394 to 442
// run cumulus dave
let cumulus_dave_dir = tempdir().unwrap();
let mut cumulus_dave = Command::new(cargo_bin("cumulus-test-parachain-collator"))
.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;

// 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);

// 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_dave, 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;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

cecton added 2 commits May 18, 2020 17:17
Parent branch: origin/master
Forked at: 032595d
Parent branch: origin/master
Forked at: 032595d
@cecton cecton force-pushed the cecton-use-custom-block-announce-validator branch from f84d067 to c9f95a3 Compare May 18, 2020 15:21
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small nitpicks.


// run cumulus dave
let cumulus_dave_dir = tempdir().unwrap();
let mut cumulus_dave = Command::new(cargo_bin("cumulus-test-parachain-collator"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

// wait for parachain blocks to be produced
let number_of_blocks = 4;
let mut previous_blocks = HashSet::with_capacity(number_of_blocks);
loop {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect that these tests are split and not that we just grow this one test. Or that we make the tests based on each other (by reusing the db or similar).

However, we should at least start to refactor stuff into functions. You just copied the same code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just refactored. Should I go further or is it good for now?

}
}

pub struct DelayedBlockAnnounceValidator<B: BlockT>(Arc<Mutex<Option<Box<dyn BlockAnnounceValidator<B> + Send>>>>);
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Sorry, created #104

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cecton cecton requested a review from bkchr May 19, 2020 11:55
}
}

pub struct DelayedBlockAnnounceValidator<B: BlockT>(Arc<Mutex<Option<Box<dyn BlockAnnounceValidator<B> + Send>>>>);
Copy link
Member

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.

@cecton cecton merged commit adc88bf into master May 19, 2020
@cecton cecton deleted the cecton-use-custom-block-announce-validator branch May 20, 2020 06:43
Maharacha pushed a commit to Maharacha/cumulus that referenced this pull request May 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants