Skip to content

Commit

Permalink
Merge branch 'master' into bkchr-message-queue-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored Oct 24, 2024
2 parents 5b7ca7c + 0596928 commit cfe988b
Show file tree
Hide file tree
Showing 31 changed files with 540 additions and 164 deletions.
4 changes: 1 addition & 3 deletions .gitlab/pipeline/zombienet/bridges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- if: $CI_COMMIT_REF_NAME =~ /^gh-readonly-queue.*$/
variables:
DOCKER_IMAGES_VERSION: ${CI_COMMIT_SHORT_SHA}
- !reference [.build-refs, rules]
- !reference [ .build-refs, rules ]
before_script:
- echo "Zombienet Tests Config"
- echo "${ZOMBIENET_IMAGE}"
Expand Down Expand Up @@ -47,8 +47,6 @@
- cp -r /tmp/bridges-tests-run-*/bridge_hub_rococo_local_network/*.log ./zombienet-logs/
# copy logs of westend nodes
- cp -r /tmp/bridges-tests-run-*/bridge_hub_westend_local_network/*.log ./zombienet-logs/
tags:
- zombienet-polkadot-integration-test

zombienet-bridges-0001-asset-transfer-works:
extends:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/pipeline/zombienet/polkadot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ zombienet-polkadot-functional-0010-validator-disabling:
--local-dir="${LOCAL_DIR}/functional"
--test="0010-validator-disabling.zndsl"

zombienet-polkadot-functional-0011-async-backing-6-seconds-rate:
.zombienet-polkadot-functional-0011-async-backing-6-seconds-rate:
extends:
- .zombienet-polkadot-common
script:
Expand Down
2 changes: 2 additions & 0 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ where
// Final destination is a 32-byte account on AssetHub
Destination::AccountId32 { id } =>
Ok(Location::new(0, [AccountId32 { network: None, id }])),
// Forwarding to a destination parachain is not allowed for PNA and is validated on the
// Ethereum side. https://github.com/Snowfork/snowbridge/blob/e87ddb2215b513455c844463a25323bb9c01ff36/contracts/src/Assets.sol#L216-L224
_ => Err(ConvertMessageError::InvalidDestination),
}?;

Expand Down
26 changes: 20 additions & 6 deletions bridges/snowbridge/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ where

fn convert(&mut self) -> Result<(Command, [u8; 32]), XcmConverterError> {
let result = match self.peek() {
Ok(ReserveAssetDeposited { .. }) => self.send_native_tokens_message(),
Ok(ReserveAssetDeposited { .. }) => self.make_mint_foreign_token_command(),
// Get withdraw/deposit and make native tokens create message.
Ok(WithdrawAsset { .. }) => self.send_tokens_message(),
Ok(WithdrawAsset { .. }) => self.make_unlock_native_token_command(),
Err(e) => Err(e),
_ => return Err(XcmConverterError::UnexpectedInstruction),
}?;
Expand All @@ -222,7 +222,9 @@ where
Ok(result)
}

fn send_tokens_message(&mut self) -> Result<(Command, [u8; 32]), XcmConverterError> {
fn make_unlock_native_token_command(
&mut self,
) -> Result<(Command, [u8; 32]), XcmConverterError> {
use XcmConverterError::*;

// Get the reserve assets from WithdrawAsset.
Expand Down Expand Up @@ -271,7 +273,12 @@ where
ensure!(reserve_assets.len() == 1, TooManyAssets);
let reserve_asset = reserve_assets.get(0).ok_or(AssetResolutionFailed)?;

// If there was a fee specified verify it.
// Fees are collected on AH, up front and directly from the user, to cover the
// complete cost of the transfer. Any additional fees provided in the XCM program are
// refunded to the beneficiary. We only validate the fee here if its provided to make sure
// the XCM program is well formed. Another way to think about this from an XCM perspective
// would be that the user offered to pay X amount in fees, but we charge 0 of that X amount
// (no fee) and refund X to the user.
if let Some(fee_asset) = fee_asset {
// The fee asset must be the same as the reserve asset.
if fee_asset.id != reserve_asset.id || fee_asset.fun > reserve_asset.fun {
Expand Down Expand Up @@ -328,7 +335,9 @@ where
/// # BuyExecution
/// # DepositAsset
/// # SetTopic
fn send_native_tokens_message(&mut self) -> Result<(Command, [u8; 32]), XcmConverterError> {
fn make_mint_foreign_token_command(
&mut self,
) -> Result<(Command, [u8; 32]), XcmConverterError> {
use XcmConverterError::*;

// Get the reserve assets.
Expand Down Expand Up @@ -377,7 +386,12 @@ where
ensure!(reserve_assets.len() == 1, TooManyAssets);
let reserve_asset = reserve_assets.get(0).ok_or(AssetResolutionFailed)?;

// If there was a fee specified verify it.
// Fees are collected on AH, up front and directly from the user, to cover the
// complete cost of the transfer. Any additional fees provided in the XCM program are
// refunded to the beneficiary. We only validate the fee here if its provided to make sure
// the XCM program is well formed. Another way to think about this from an XCM perspective
// would be that the user offered to pay X amount in fees, but we charge 0 of that X amount
// (no fee) and refund X to the user.
if let Some(fee_asset) = fee_asset {
// The fee asset must be the same as the reserve asset.
if fee_asset.id != reserve_asset.id || fee_asset.fun > reserve_asset.fun {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description: Check if the Rococo parachains started producing blocks reliably
Network: ./bridge_hub_westend_local_network.toml
Creds: config

# ensure that initialization has completed
asset-hub-rococo-collator1: reports block height is at least 10 within 180 seconds
bridge-hub-rococo-collator1: reports block height is at least 10 within 180 seconds

5 changes: 3 additions & 2 deletions bridges/testing/environments/rococo-westend/spawn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ start_zombienet $TEST_DIR $westend_def westend_dir westend_pid
echo

if [[ $init -eq 1 ]]; then
run_zndsl ${BASH_SOURCE%/*}/rococo-start.zndsl $rococo_dir
run_zndsl ${BASH_SOURCE%/*}/westend-start.zndsl $westend_dir

rococo_init_log=$logs_dir/rococo-init.log
echo -e "Setting up the rococo side of the bridge. Logs available at: $rococo_init_log\n"

westend_init_log=$logs_dir/westend-init.log
echo -e "Setting up the westend side of the bridge. Logs available at: $westend_init_log\n"

Expand All @@ -47,7 +49,6 @@ if [[ $init -eq 1 ]]; then
westend_init_pid=$!
wait -n $rococo_init_pid $westend_init_pid


$helper_script init-bridge-hub-rococo-local >> $rococo_init_log 2>&1 &
rococo_init_pid=$!
$helper_script init-bridge-hub-westend-local >> $westend_init_log 2>&1 &
Expand Down
4 changes: 2 additions & 2 deletions bridges/testing/environments/rococo-westend/start_relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ messages_relayer_log=$logs_dir/relayer_messages.log
echo -e "Starting rococo-westend messages relayer. Logs available at: $messages_relayer_log\n"
start_background_process "$helper_script run-messages-relay" $messages_relayer_log messages_relayer_pid

run_zndsl ${BASH_SOURCE%/*}/rococo.zndsl $rococo_dir
run_zndsl ${BASH_SOURCE%/*}/westend.zndsl $westend_dir
run_zndsl ${BASH_SOURCE%/*}/rococo-bridge.zndsl $rococo_dir
run_zndsl ${BASH_SOURCE%/*}/westend-bridge.zndsl $westend_dir

eval $__finality_relayer_pid="'$finality_relayer_pid'"
eval $__parachains_relayer_pid="'$parachains_relayer_pid'"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description: Check if the Westend parachains started producing blocks reliably
Network: ./bridge_hub_westend_local_network.toml
Creds: config

# ensure that initialization has completed
asset-hub-westend-collator1: reports block height is at least 10 within 180 seconds
bridge-hub-westend-collator1: reports block height is at least 10 within 180 seconds

9 changes: 4 additions & 5 deletions polkadot/node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,12 @@ pub fn new_full<
Some(backoff)
};

// Running approval voting in parallel is enabled by default on all networks except Polkadot and
// Kusama, unless explicitly enabled by the commandline option.
// Running approval voting in parallel is enabled by default on all networks except Polkadot
// unless explicitly enabled by the commandline option.
// This is meant to be temporary until we have enough confidence in the new system to enable it
// by default on all networks.
let enable_approval_voting_parallel = (!config.chain_spec.is_kusama() &&
!config.chain_spec.is_polkadot()) ||
enable_approval_voting_parallel;
let enable_approval_voting_parallel =
!config.chain_spec.is_polkadot() || enable_approval_voting_parallel;

let disable_grandpa = config.disable_grandpa;
let name = config.network.node_name.clone();
Expand Down
14 changes: 13 additions & 1 deletion polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ use sp_staking::SessionIndex;
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::{latest::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm};
use xcm::{
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
};
use xcm_builder::PayOverXcm;

pub use frame_system::Call as SystemCall;
Expand Down Expand Up @@ -2622,6 +2625,15 @@ sp_api::impl_runtime_apis! {
genesis_config_presets::preset_names()
}
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_teleporter(asset, location)
}
}
}

#[cfg(all(test, feature = "try-runtime"))]
Expand Down
14 changes: 13 additions & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ use sp_staking::SessionIndex;
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::{latest::prelude::*, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm};
use xcm::{
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
};
use xcm_builder::PayOverXcm;

use xcm_runtime_apis::{
Expand Down Expand Up @@ -2791,4 +2794,13 @@ sp_api::impl_runtime_apis! {
genesis_config_presets::preset_names()
}
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
XcmPallet::is_trusted_teleporter(asset, location)
}
}
}
11 changes: 11 additions & 0 deletions prdoc/pr_5194.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: "FRAME: Support instantiable pallets in tasks."

doc:
- audience: Runtime Dev
description: |
In FRAME, tasks can now be used in instantiable pallet. Also some fix for expansion with
conditional compilation in construct runtine.

crates:
- name: frame-support-procedural
bump: patch
7 changes: 7 additions & 0 deletions prdoc/pr_6192.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: '[pallet-revive] fix hardcoded gas in tests'
doc:
- audience: Runtime Dev
description: Fix hardcoded gas limits in tests
crates:
- name: pallet-revive
bump: patch
32 changes: 32 additions & 0 deletions prdoc/pr_6212.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "Added Trusted Query API calls for Westend and Rococo chains"

doc:
- audience: Runtime Dev
description: |
Added is_trusted_reserve and is_trusted_teleporter API calls to relay chains.
Given an asset and a location, they return if the chain trusts that location as a reserve or teleporter for that asset respectively.
You can implement them on your runtime by simply calling a helper function on `pallet-xcm`.
```rust
impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
```

- audience: Runtime User
description: |
There's a new runtime API to check if a chain trust a Location as a reserve or teleporter for a given Asset.
It's implemented in all the relays and system parachains in Westend and Rococo.

crates:
- name: westend-runtime
bump: minor
- name: rococo-runtime
bump: minor
9 changes: 9 additions & 0 deletions prdoc/pr_6218.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Enable approval-voting-parallel by default on kusama

doc:
- audience: Node Dev
description: |
Enable approval-voting-parallel by default on kusama
crates:
- name: polkadot-service
bump: patch
30 changes: 22 additions & 8 deletions substrate/frame/revive/src/evm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,7 @@ pub trait EthExtra {
Default::default(),
)
.into();

log::debug!(target: LOG_TARGET, "Checking Ethereum transaction fees:
dispatch_info: {info:?}
encoded_len: {encoded_len:?}
fees: {actual_fee:?}
");
log::debug!(target: LOG_TARGET, "try_into_checked_extrinsic: encoded_len: {encoded_len:?} actual_fee: {actual_fee:?} eth_fee: {eth_fee:?}");

if eth_fee < actual_fee {
log::debug!(target: LOG_TARGET, "fees {eth_fee:?} too low for the extrinsic {actual_fee:?}");
Expand Down Expand Up @@ -490,19 +485,38 @@ mod test {
}
}

fn estimate_gas(&mut self) {
let dry_run = crate::Pallet::<Test>::bare_eth_transact(
Account::default().account_id(),
self.tx.to,
self.tx.value.try_into().unwrap(),
self.tx.input.clone().0,
Weight::MAX,
u64::MAX,
|call| {
let call = RuntimeCall::Contracts(call);
let uxt: Ex = sp_runtime::generic::UncheckedExtrinsic::new_bare(call).into();
uxt.encoded_size() as u32
},
crate::DebugInfo::Skip,
crate::CollectEvents::Skip,
);
self.tx.gas = ((dry_run.fee + GAS_PRICE as u64) / (GAS_PRICE as u64)).into();
}

/// Create a new builder with a call to the given address.
fn call_with(dest: H160) -> Self {
let mut builder = Self::new();
builder.tx.to = Some(dest);
builder.tx.gas = U256::from(516_708u128);
builder.estimate_gas();
builder
}

/// Create a new builder with an instantiate call.
fn instantiate_with(code: Vec<u8>, data: Vec<u8>) -> Self {
let mut builder = Self::new();
builder.tx.input = Bytes(code.into_iter().chain(data.into_iter()).collect());
builder.tx.gas = U256::from(1_035_070u128);
builder.estimate_gas();
builder
}

Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ where
to: Some(dest),
..Default::default()
};

let eth_dispatch_call = crate::Call::<T>::eth_transact {
payload: tx.dummy_signed_payload(),
gas_limit: result.gas_required,
Expand All @@ -1238,7 +1239,7 @@ where
)
.into();

log::debug!(target: LOG_TARGET, "Call dry run Result: dispatch_info: {dispatch_info:?} len: {encoded_len:?} fee: {fee:?}");
log::debug!(target: LOG_TARGET, "bare_eth_call: len: {encoded_len:?} fee: {fee:?}");
EthContractResult {
gas_required: result.gas_required,
storage_deposit: result.storage_deposit.charge_or_zero(),
Expand Down
Loading

0 comments on commit cfe988b

Please sign in to comment.