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

Commit

Permalink
Merge branch 'master' into rk-pov-distribution-2590
Browse files Browse the repository at this point in the history
  • Loading branch information
eskimor committed Mar 27, 2021
2 parents eb47465 + 2612716 commit 071bcca
Show file tree
Hide file tree
Showing 39 changed files with 1,332 additions and 437 deletions.
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ build-linux-release:
# extra features when building on `rococo-v1` branch and manual build on PRs
- if: $CI_COMMIT_REF_NAME == "rococo-v1"
variables:
EXTRA_FLAGS: "--features=real-overseer -Cdebug-assertions=y"
EXTRA_FLAGS: "--features=real-overseer"
RUSTFLAGS: "-Cdebug-assertions=y"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
variables:
EXTRA_FLAGS: "--features=real-overseer"
Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion bridges/modules/ethereum/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

use super::*;
use super::{
BridgeStorage,
RawOrigin,
HeadersByNumber,
Instance,
Config,
};

use crate::test_utils::{
build_custom_header, build_genesis_header, insert_header, validator_utils::*, validators_change_receipt,
Expand Down
2 changes: 1 addition & 1 deletion bridges/relays/ethereum/src/substrate_sync_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use std::fmt::Debug;
use std::{collections::HashSet, time::Duration};

pub mod consts {
use super::*;
use super::Duration;

/// Interval at which we check new Ethereum blocks.
pub const ETHEREUM_TICK_INTERVAL: Duration = Duration::from_secs(5);
Expand Down
2 changes: 1 addition & 1 deletion erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
primitives = { package = "polkadot-primitives", path = "../primitives" }
novelpoly = { package = "reed-solomon-novelpoly", version = "=0.0.3" }
novelpoly = { package = "reed-solomon-novelpoly", version = "1.0.0" }
parity-scale-codec = { version = "2.0.0", default-features = false, features = ["std", "derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
2 changes: 1 addition & 1 deletion node/collation-generation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl CollationGenerationSubsystem {
let metrics = self.metrics.clone();
if let Err(err) = handle_new_activations(
config.clone(),
activated.into_iter().map(|v| v.0),
activated.into_iter().map(|v| v.hash),
ctx,
metrics,
sender,
Expand Down
3 changes: 2 additions & 1 deletion node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ async fn handle_from_overseer(
FromOverseer::Signal(OverseerSignal::ActiveLeaves(update)) => {
let mut actions = Vec::new();

for (head, _span) in update.activated {
for activated in update.activated {
let head = activated.hash;
match import::handle_new_head(
ctx,
state,
Expand Down
4 changes: 2 additions & 2 deletions node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ where
FromOverseer::Signal(OverseerSignal::ActiveLeaves(
ActiveLeavesUpdate { activated, .. })
) => {
for (activated, _span) in activated.into_iter() {
for activated in activated.into_iter() {
let _timer = subsystem.metrics.time_block_activated();
process_block_activated(ctx, subsystem, activated).await?;
process_block_activated(ctx, subsystem, activated.hash).await?;
}
}
FromOverseer::Signal(OverseerSignal::BlockFinalized(hash, number)) => {
Expand Down
14 changes: 11 additions & 3 deletions node/core/av-store/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use polkadot_primitives::v1::{
};
use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_subsystem::{
ActiveLeavesUpdate, errors::RuntimeApiError, jaeger, messages::AllMessages,
ActiveLeavesUpdate, errors::RuntimeApiError, jaeger, messages::AllMessages, ActivatedLeaf,
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use sp_keyring::Sr25519Keyring;
Expand Down Expand Up @@ -240,7 +240,11 @@ fn runtime_api_error_does_not_stop_the_subsystem() {
overseer_signal(
&mut virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: vec![(new_leaf, Arc::new(jaeger::Span::Disabled))].into(),
activated: vec![ActivatedLeaf {
hash: new_leaf,
number: 1,
span: Arc::new(jaeger::Span::Disabled),
}].into(),
deactivated: vec![].into(),
}),
).await;
Expand Down Expand Up @@ -885,7 +889,11 @@ async fn import_leaf(
overseer_signal(
virtual_overseer,
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
activated: vec![(new_leaf, Arc::new(jaeger::Span::Disabled))].into(),
activated: vec![ActivatedLeaf {
hash: new_leaf,
number: 1,
span: Arc::new(jaeger::Span::Disabled),
}].into(),
deactivated: vec![].into(),
}),
).await;
Expand Down
16 changes: 8 additions & 8 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ mod tests {
use polkadot_primitives::v1::{BlockData, GroupRotationInfo, HeadData, PersistedValidationData, ScheduledCore};
use polkadot_subsystem::{
messages::{RuntimeApiRequest, RuntimeApiMessage},
ActiveLeavesUpdate, FromOverseer, OverseerSignal,
ActiveLeavesUpdate, FromOverseer, OverseerSignal, ActivatedLeaf,
};
use polkadot_node_primitives::InvalidCandidate;
use sp_keyring::Sr25519Keyring;
Expand Down Expand Up @@ -1534,10 +1534,11 @@ mod tests {
) {
// Start work on some new parent.
virtual_overseer.send(FromOverseer::Signal(
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(
test_state.relay_parent,
Arc::new(jaeger::Span::Disabled),
)))
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf {
hash: test_state.relay_parent,
number: 1,
span: Arc::new(jaeger::Span::Disabled),
})))
).await;

// Check that subsystem job issues a request for a validator set.
Expand Down Expand Up @@ -2759,10 +2760,9 @@ mod tests {
signed_c.clone(),
);
virtual_overseer.send(FromOverseer::Communication{ msg: statement }).await;


// Not deterministic which message comes first:
for _ in 1..2 {
for _ in 0..2 {
match virtual_overseer.recv().await {
AllMessages::Provisioner(
ProvisionerMessage::ProvisionableData(
Expand Down Expand Up @@ -2791,7 +2791,7 @@ mod tests {
}
}
}

// Subsystem requests PoV and requests validation.
// Now we pass.
assert_matches!(
Expand Down
1 change: 1 addition & 0 deletions node/metered-channel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = "Channels with attached Meters"
[dependencies]
futures = "0.3.12"
futures-timer = "3.0.2"
derive_more = "0.99"

[dev-dependencies]
assert_matches = "1.4.0"
Expand Down
31 changes: 20 additions & 11 deletions node/metered-channel/src/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@

//! Metered variant of bounded mpsc channels to be able to extract metrics.
use super::*;
use futures::{channel::mpsc, task::Poll, task::Context, sink::SinkExt, stream::Stream};

use std::result;
use std::pin::Pin;

use super::Meter;


/// Create a wrapped `mpsc::channel` pair of `MeteredSender` and `MeteredReceiver`.
pub fn channel<T>(capacity: usize, name: &'static str) -> (MeteredSender<T>, MeteredReceiver<T>) {
Expand Down Expand Up @@ -54,8 +60,7 @@ impl<T> Stream for MeteredReceiver<T> {
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
match mpsc::Receiver::poll_next(Pin::new(&mut self.inner), cx) {
Poll::Ready(x) => {
// always use Ordering::SeqCst to avoid underflows
self.meter.fill.fetch_sub(1, Ordering::SeqCst);
self.meter.note_received();
Poll::Ready(x)
}
other => other,
Expand All @@ -78,7 +83,7 @@ impl<T> MeteredReceiver<T> {
pub fn try_next(&mut self) -> Result<Option<T>, mpsc::TryRecvError> {
match self.inner.try_next()? {
Some(x) => {
self.meter.fill.fetch_sub(1, Ordering::SeqCst);
self.meter.note_received();
Ok(Some(x))
}
None => Ok(None),
Expand Down Expand Up @@ -131,17 +136,22 @@ impl<T> MeteredSender<T> {
where
Self: Unpin,
{
self.meter.fill.fetch_add(1, Ordering::SeqCst);
self.meter.note_sent();
let fut = self.inner.send(item);
futures::pin_mut!(fut);
fut.await
fut.await.map_err(|e| {
self.meter.retract_sent();
e
})
}

/// Attempt to send message or fail immediately.
pub fn try_send(&mut self, msg: T) -> result::Result<(), mpsc::TrySendError<T>> {
self.inner.try_send(msg)?;
self.meter.fill.fetch_add(1, Ordering::SeqCst);
Ok(())
self.meter.note_sent();
self.inner.try_send(msg).map_err(|e| {
self.meter.retract_sent();
e
})
}
}

Expand All @@ -159,7 +169,6 @@ impl<T> futures::sink::Sink<T> for MeteredSender<T> {
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match Pin::new(&mut self.inner).poll_close(cx) {
val @ Poll::Ready(_)=> {
self.meter.fill.store(0, Ordering::SeqCst);
val
}
other => other,
Expand All @@ -169,7 +178,7 @@ impl<T> futures::sink::Sink<T> for MeteredSender<T> {
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
match Pin::new(&mut self.inner).poll_flush(cx) {
val @ Poll::Ready(_)=> {
self.meter.fill.fetch_add(1, Ordering::SeqCst);
self.meter.note_sent();
val
}
other => other,
Expand Down
Loading

0 comments on commit 071bcca

Please sign in to comment.