Skip to content

Commit

Permalink
Update preimage tool (#1338)
Browse files Browse the repository at this point in the history
* Fix preimage tool

* Update control/preimage/src/helpers.rs

Co-authored-by: Clara van Staden <[email protected]>

---------

Co-authored-by: Clara van Staden <[email protected]>
  • Loading branch information
vgeddes and claravanstaden authored Nov 27, 2024
1 parent f873fb1 commit 8e61c5c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ NOTE: To test an upgrade that has not executed yet on the relevant environment,
To update the runtime code binding, run the following commands:

```shell
subxt metadata --url ws://127.0.0.1:8000 -f bytes -o runtimes/polkadot/polkadot-metadata.bin
subxt metadata --url ws://127.0.0.1:8001 -f bytes -o runtimes/bridge-hub-polkadot/bridge-hub-metadata.bin
subxt metadata --url ws://127.0.0.1:8002 -f bytes -o runtimes/asset-hub-polkadot/asset-hub-metadata.bin
subxt metadata --url wss://polkadot-rpc.dwellir.com -f bytes -o runtimes/polkadot/polkadot-metadata.bin
subxt metadata --url wss://bridge-hub-polkadot-rpc.dwellir.com -f bytes -o runtimes/bridge-hub-polkadot/bridge-hub-metadata.bin
subxt metadata --url wss://asset-hub-polkadot-rpc.dwellir.com -f bytes -o runtimes/asset-hub-polkadot/asset-hub-metadata.bin
```

To update Westend/Paseo bindings, replace the chain name in the command, e.g. replace `runtimes/polkadot/polkadot-metadata.bin`
To update Westend/Paseo bindings, replace the chain name in the command, e.g. replace `runtimes/polkadot/polkadot-metadata.bin`
with `runtimes/westend/polkadot-metadata.bin`.
12 changes: 6 additions & 6 deletions control/preimage/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ use crate::bridge_hub_runtime::RuntimeCall as BridgeHubRuntimeCall;

#[cfg(any(feature = "polkadot", feature = "paseo"))]
pub mod asset_hub_polkadot_types {
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v3::multilocation::MultiLocation;
pub use crate::asset_hub_runtime::runtime_types::xcm::v3::{
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::location::Location;
pub use crate::asset_hub_runtime::runtime_types::staging_xcm::v4::{
junction::Junction::AccountKey20, junction::Junction::GlobalConsensus, junction::NetworkId,
junctions::Junctions::X2,
};
pub fn get_asset_id(chain_id: u64, key: [u8; 20]) -> MultiLocation {
return MultiLocation {
pub fn get_asset_id(chain_id: u64, key: [u8; 20]) -> Location {
return Location {
parents: 2,
interior: X2(
interior: X2([
GlobalConsensus(NetworkId::Ethereum { chain_id: chain_id }),
AccountKey20 {
network: None,
key: key,
},
),
]),
};
}
}
Expand Down
4 changes: 1 addition & 3 deletions control/preimage/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::Context;

use crate::bridge_hub_runtime::{self, RuntimeCall as BridgeHubRuntimeCall};

#[cfg(feature = "polkadot")]
use crate::relay_runtime::runtime_types::xcm::v2::OriginKind;
#[cfg(any(feature = "westend", feature = "paseo"))]
use crate::relay_runtime::runtime_types::xcm::v3::OriginKind;

use crate::relay_runtime::runtime_types::{
Expand Down Expand Up @@ -177,6 +174,7 @@ pub fn utility_force_batch(calls: Vec<RelayRuntimeCall>) -> RelayRuntimeCall {
)
}

#[cfg(any(feature = "westend", feature = "paseo"))]
pub fn sudo(call: Box<RelayRuntimeCall>) -> RelayRuntimeCall {
return RelayRuntimeCall::Sudo(
crate::relay_runtime::runtime_types::pallet_sudo::pallet::Call::sudo { call },
Expand Down
23 changes: 13 additions & 10 deletions control/preimage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use helpers::{force_xcm_version, send_xcm_asset_hub, send_xcm_bridge_hub, utilit
use sp_crypto_hashing::blake2_256;
use std::{io::Write, path::PathBuf};
use subxt::{OnlineClient, PolkadotConfig};

#[cfg(any(feature = "westend", feature = "paseo"))]
use crate::helpers::sudo;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -324,11 +326,11 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
.await?;
let call2 =
send_xcm_asset_hub(&context, vec![force_xcm_version(), set_ethereum_fee]).await?;
if cfg!(any(feature = "paseo", feature = "westend")) {
sudo(Box::new(utility_force_batch(vec![call1, call2])))
} else {
utility_force_batch(vec![call1, call2])
}
#[cfg(any(feature = "westend", feature = "paseo"))]
let final_call = sudo(Box::new(utility_force_batch(vec![call1, call2])));
#[cfg(not(any(feature = "westend", feature = "paseo")))]
let final_call = utility_force_batch(vec![call1, call2]);
final_call
}
Command::UpdateAsset(params) => {
let call = send_xcm_asset_hub(
Expand All @@ -339,11 +341,12 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> {
],
)
.await?;
if cfg!(any(feature = "paseo", feature = "westend")) {
sudo(Box::new(call))
} else {
call
}

#[cfg(any(feature = "westend", feature = "paseo"))]
let final_call = sudo(Box::new(call));
#[cfg(not(any(feature = "westend", feature = "paseo")))]
let final_call = call;
final_call
}
Command::GatewayOperatingMode(params) => {
let call = commands::gateway_operating_mode(&params.gateway_operating_mode);
Expand Down
Binary file modified control/runtimes/asset-hub-polkadot/asset-hub-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/bridge-hub-polkadot/bridge-hub-metadata.bin
Binary file not shown.
Binary file modified control/runtimes/polkadot/polkadot-metadata.bin
Binary file not shown.

0 comments on commit 8e61c5c

Please sign in to comment.