Skip to content

Commit

Permalink
Polkadot staging update (#1356)
Browse files Browse the repository at this point in the history
* Fix mandatory headers scanning in on-demand relay (#1306)

* more logging in on-demand headerss

* remove `maximal_headers_difference` concept from on-demand-relay

* another leftover from previous on-demand version

* removed extra log

* fmt

* increase relay balance guard limits for Polkadot<>Kusama bridge (#1308)

* fix benchmarks before using it in Polkadot/Kusama/Rococo runtimes (#1309)

* Endow relayer account at target chain in message benchmarks (#1310)

* endow relayer account at target chain in message benchmarks

* pick another line

* expose fee multiplier metrics in messages relay (#1312)

* Fix issues from cargo deny (#1311)

* update libp2p-core (RUSTSEC-2022-0009)

* update thread_local (RUSTSEC-2022-0006)

* time 0.2 -> time 0.3

* ignore RUSTSEC-2021-0130

* proper migration to time 0.3

* fix clippy?

* Revert "fix clippy?"

This reverts commit 53bc289.

* Add some tests to check integrity of chain constants + bridge configuration (#1316)

* add some tests to check integrity of chain constants + bridge configuration

* try to use named parameters where possible

* Encode and estimate Rococo/Wococo/Kusama/Polkadot messages (#1322)

* encode and estimate Rococo/Wococo/Kusama/Polkadot messages

* allow send-message for non-bundled chains

* weight -> dispatch-weight

* fmt

* fix spelling

* impl Decode for SignedExtensions (otherwise transaction resubmitter panicks) (#1325)

* use mortal transactions in transaction resubmitter (#1326)

* Using-same-fork metric for finality and complex relay (#1327)

* using_same_fork metric in finality relay

* support `using_different_forks` in messages relay

* added dashboards and alerts

* lockfile

* fix typo in alert expression (#1329)

* removed extra *_RUNTIME_VERSION consts from relay code (#1330)

* Reinitialize bridge relay subcommand (#1331)

* reinitialize bridge subcommand

* PolkadotToKusama in reinit-bridge

* fix clippy issues (#1332)

* Revert "Revert "override conversion rate in estimate-message-fee RPC (#1189)" (#1275)" (#1333)

This reverts commit ed7def6.

* Override conversion rate when computing message fee (#1261)

* override conversion rate when message is sent

* spelling + fmt

* add --conversion-rate-override cli option

* try to read conversion rate from cmd output

* fix output

* fmt

* fi typo in generator script (#1334)

* override conversion rate in tokens swap generator (#1335)

* fix conversion rate override in token swap (#1336)

* synchronize relay cli changes and token swap generator script (#1337)

* fixed mess with conversion rates (#1338)

* fix generator scripts to be consistent with updatedrelay output (#1339)

* Increase rate from metric when estimating fee (#1340)

* ignore errors when dumping logs and container is missing

* fixed typo

* print correct payload length

* increase conversion rate a bit when estimating fee (to avoid message rejects when rate update tx is active)

* fmt

* fix conversion rate metric in dashboards (#1341)

* get rid of '[No Data] Messages from Millau to Rialto are not being delivered' warnings (#1342)

* use DecodeLimit when decoding incoming calls (#1344)

* update regex to 1.5.5 (#1345)

* edition = "2021" (#1346)

* Mortal conversion rate updater transactions (#1257)

* merge all similar update_conversion_rate functions

* stall timeout in conversion rate update loop

* fmt

* fix

* added alerts for relay balances (#1347)

* replace From<>InboundLaneApi with direct storage reads (#1348)

* added no_stack_overflow_when_decoding_nested_call_during_dispatch test (#1349)

* ignore more "increase" alerts that are sometimes signalling NoData at startup (#1351)

* Support dedicated lanes for pallets (#962)

* pass call origin to the message verifier

* is_outbound_lane_enabled -> is_message_accepted

* trait SenderOrigin

* only accept messages from token swap pallet to token swap lane

* tests for edge cases of pay_delivery_and_dispatch_fee

* fixed origin verification

* fmt

* fix benchmarks compilation

* fix TODO with None account and non-zero message fee (already covered by tests)

* revert cargo fmt changes temporarily

* Update Substrate/Polkadot/Cumulus references (#1353)

* cumulus: 4e95228
polkadot: 975e780ae0d988dc033f400ba822d14b326ee5b9
substrate: 89fcb3e4f62d221d4e161a437768e77d6265889e

* fix refs

* sync changes from paritytech/polkadot#3828

* sync changes from paritytech/polkadot#4387

* sync changes from paritytech/polkadot#3940

* sync with changes from paritytech/polkadot#4493

* sync with changes from paritytech/polkadot#4958

* sync with changes from paritytech/polkadot#3889

* sync with changes from paritytech/polkadot#5033

* sync with changes from paritytech/polkadot#5065

* compilation fixes

* fixed prometheus endpoint startup (it now requires to be spawned within tokio context)

* update chain versions (#1358)

* update parity-scale-codec to 3.1.2 (#1359)

* fix parse_transaction on Rialto+Millau (#1360)
  • Loading branch information
svyatonik authored Mar 21, 2022
2 parents 92ddc3e + 02fd3d4 commit f220d2f
Show file tree
Hide file tree
Showing 160 changed files with 6,146 additions and 2,910 deletions.
2,469 changes: 1,362 additions & 1,107 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# See the `deployments/README.md` for all the available `PROJECT` values.

FROM paritytech/bridges-ci:latest as builder
FROM docker.io/paritytech/bridges-ci:latest as builder
WORKDIR /parity-bridges-common

COPY . .
Expand All @@ -19,7 +19,7 @@ RUN cargo build --release --verbose -p ${PROJECT} && \

# In this final stage we copy over the final binary and do some checks
# to make sure that everything looks good.
FROM ubuntu:20.04 as runtime
FROM docker.io/library/ubuntu:20.04 as runtime

# show backtraces
ENV RUST_BACKTRACE 1
Expand Down
4 changes: 2 additions & 2 deletions bin/millau/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name = "millau-bridge-node"
description = "Substrate node compatible with Millau runtime"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
edition = "2021"
build = "build.rs"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/parity-bridges-common/"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
clap = { version = "3.0", features = ["derive"] }
clap = { version = "3.1", features = ["derive"] }
jsonrpc-core = "18.0"
serde_json = "1.0.59"

Expand Down
10 changes: 4 additions & 6 deletions bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use sc_finality_grandpa::SharedVoterState;
use sc_keystore::LocalKeystore;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_consensus::SlotData;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use std::{sync::Arc, time::Duration};

Expand Down Expand Up @@ -141,7 +140,7 @@ pub fn new_partial(
telemetry.as_ref().map(|x| x.handle()),
)?;

let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;

let import_queue =
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams {
Expand All @@ -152,7 +151,7 @@ pub fn new_partial(
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Expand Down Expand Up @@ -349,7 +348,6 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let raw_slot_duration = slot_duration.slot_duration();

let aura = sc_consensus_aura::start_aura::<AuraPair, _, _, _, _, _, _, _, _, _, _, _>(
StartAuraParams {
Expand All @@ -362,9 +360,9 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
raw_slot_duration,
slot_duration,
);

Ok((timestamp, slot))
Expand Down
12 changes: 8 additions & 4 deletions bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
name = "millau-runtime"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
edition = "2021"
homepage = "https://substrate.dev"
repository = "https://github.com/paritytech/parity-bridges-common/"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
hex-literal = "0.3"
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
libsecp256k1 = { version = "0.7", optional = true, default-features = false, features = ["hmac"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
serde = { version = "1.0", optional = true, features = ["derive"] }

# Bridge dependencies
Expand Down Expand Up @@ -65,6 +65,10 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

[dev-dependencies]
bridge-runtime-common = { path = "../../runtime-common", features = ["integrity-test"] }
static_assertions = "1.1"

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }

Expand Down Expand Up @@ -120,7 +124,7 @@ std = [
]
runtime-benchmarks = [
"bridge-runtime-common/runtime-benchmarks",
"frame-benchmarking",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"libsecp256k1",
Expand Down
64 changes: 7 additions & 57 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#![recursion_limit = "256"]
// Runtime-generated enums
#![allow(clippy::large_enum_variant)]
// Runtime-generated DecodeLimit::decode_all_With_depth_limit
#![allow(clippy::unnecessary_mut_passed)]
// From construct_runtime macro
#![allow(clippy::from_over_into)]

Expand Down Expand Up @@ -52,7 +50,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, MultiSignature, MultiSigner, Perquintill,
ApplyExtrinsicResult, FixedPointNumber, FixedU128, MultiSignature, MultiSigner, Perquintill,
};
use sp_std::prelude::*;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -456,10 +454,9 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
type MessageDeliveryAndDispatchPayment =
pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
Runtime,
(),
WithRialtoMessagesInstance,
pallet_balances::Pallet<Runtime>,
GetDeliveryConfirmationTransactionFee,
RootAccountForPayments,
>;
type OnMessageAccepted = ();
type OnDeliveryConfirmed =
Expand Down Expand Up @@ -525,7 +522,7 @@ construct_runtime!(
BridgeRialtoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage},
BridgeDispatch: pallet_bridge_dispatch::{Pallet, Event<T>},
BridgeRialtoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event<T>, Config<T>},
BridgeRialtoTokenSwap: pallet_bridge_token_swap::{Pallet, Call, Storage, Event<T>},
BridgeRialtoTokenSwap: pallet_bridge_token_swap::{Pallet, Call, Storage, Event<T>, Origin<T>},

// Westend bridge modules.
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Config<T>, Storage},
Expand All @@ -544,6 +541,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
Expand Down Expand Up @@ -757,10 +755,12 @@ impl_runtime_apis! {
fn estimate_message_delivery_and_dispatch_fee(
_lane_id: bp_messages::LaneId,
payload: ToRialtoMessagePayload,
rialto_to_this_conversion_rate: Option<FixedU128>,
) -> Option<Balance> {
estimate_message_dispatch_and_delivery_fee::<WithRialtoMessageBridge>(
&payload,
WithRialtoMessageBridge::RELAYER_FEE_PERCENT,
rialto_to_this_conversion_rate,
).ok()
}

Expand All @@ -777,12 +777,6 @@ impl_runtime_apis! {
}
}

impl bp_rialto::FromRialtoInboundLaneApi<Block> for Runtime {
fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState {
BridgeRialtoMessages::inbound_unrewarded_relayers_state(lane)
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Expand Down Expand Up @@ -860,7 +854,7 @@ impl_runtime_apis! {
fn prepare_outbound_message(
params: MessageParams<Self::AccountId>,
) -> (rialto_messages::ToRialtoMessagePayload, Balance) {
prepare_outbound_message::<WithRialtoMessageBridge>(params)
(prepare_outbound_message::<WithRialtoMessageBridge>(params), Self::message_fee())
}

fn prepare_message_proof(
Expand Down Expand Up @@ -918,7 +912,6 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeRialtoGrandpa);
add_benchmark!(params, batches, pallet_bridge_token_swap, BridgeRialtoTokenSwap);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
Expand Down Expand Up @@ -951,49 +944,6 @@ where
#[cfg(test)]
mod tests {
use super::*;
use bp_runtime::Chain;
use bridge_runtime_common::messages;

#[test]
fn ensure_millau_message_lane_weights_are_correct() {
type Weights = pallet_bridge_messages::weights::MillauWeight<Runtime>;

pallet_bridge_messages::ensure_weights_are_correct::<Weights>(
bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT,
bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT,
bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT,
bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT,
DbWeight::get(),
);

let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add(
messages::target::maximal_incoming_message_size(bp_millau::Millau::max_extrinsic_size()),
);
pallet_bridge_messages::ensure_able_to_receive_message::<Weights>(
bp_millau::Millau::max_extrinsic_size(),
bp_millau::Millau::max_extrinsic_weight(),
max_incoming_message_proof_size,
messages::target::maximal_incoming_message_dispatch_weight(
bp_millau::Millau::max_extrinsic_weight(),
),
);

let max_incoming_inbound_lane_data_proof_size =
bp_messages::InboundLaneData::<()>::encoded_size_hint(
bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE,
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX as _,
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX as _,
)
.unwrap_or(u32::MAX);
pallet_bridge_messages::ensure_able_to_receive_confirmation::<Weights>(
bp_millau::Millau::max_extrinsic_size(),
bp_millau::Millau::max_extrinsic_weight(),
max_incoming_inbound_lane_data_proof_size,
bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX,
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
DbWeight::get(),
);
}

#[test]
fn call_size() {
Expand Down
Loading

0 comments on commit f220d2f

Please sign in to comment.