Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to polkadot-sdk commit b9b73eb2758edc8af140fea60fdc51f890eefc48 #1943

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,006 changes: 655 additions & 351 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[workspace]
resolver = "2"
members = ["crates/*"]

# hotfix for https://github.com/paritytech/polkadot-sdk/issues/7653
[patch.'https://github.com/w3f/fflonk']
fflonk = { git = "https://www.github.com/w3f/fflonk", rev = "be95d4c971b1d15b5badfc06ff13f5c07987d484" }
2 changes: 1 addition & 1 deletion crates/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ crossterm = "0.28.1"
itertools = "0.13.0"
alloy-json-abi = "0.8.20"

polkavm-linker = "0.18.0"
polkavm-linker = "0.21.0"

contract-metadata = { version = "6.0.0-alpha", path = "../metadata" }
ink_metadata = { git = "https://github.com/use-ink/ink", branch = "master" }
Expand Down
8 changes: 6 additions & 2 deletions crates/build/templates/new/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false }
ink = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11", default-features = false }

[dev-dependencies]
ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master" }
ink_e2e = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11" }

[lib]
path = "lib.rs"
Expand All @@ -20,3 +20,7 @@ std = [
]
ink-as-dependency = []
e2e-tests = []

# hotfix for https://github.com/paritytech/polkadot-sdk/issues/7653
[patch.'https://github.com/w3f/fflonk']
fflonk = { git = "https://www.github.com/w3f/fflonk", rev = "be95d4c971b1d15b5badfc06ff13f5c07987d484" }
10 changes: 5 additions & 5 deletions crates/cargo-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ jsonschema = "0.28"
schemars = "0.8"
comfy-table = "7.1.1"

ink_metadata = { git = "https://github.com/use-ink/ink", branch = "master" }
ink_env = { git = "https://github.com/use-ink/ink", branch = "master" }
ink_metadata = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11" }
ink_env = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11" }

# dependencies for extrinsics (deploying and calling a contract)
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
subxt = { version = "0.38.1", features = ["substrate-compat"] }
hex = "0.4.3"

sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067"}
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067"}
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48", default-features = false}
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48" }

[build-dependencies]
anyhow = "1.0.95"
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067" }
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48" }
current_platform = "0.2.0"
which = "7.0.1"

Expand Down
17 changes: 12 additions & 5 deletions crates/cargo-contract/src/cmd/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use std::{
use super::{
config::SignerConfig,
display_contract_exec_result,
display_contract_exec_result_debug,
display_dry_run_result_warning,
offer_map_account_if_needed,
parse_account,
Expand All @@ -51,6 +50,7 @@ use anyhow::{
};
use contract_build::name_value_println;
use contract_extrinsics::{
fetch_contract_info,
pallet_revive_primitives::StorageDeposit,
CallCommandBuilder,
CallExec,
Expand All @@ -59,6 +59,7 @@ use contract_extrinsics::{
TokenMetadata,
};
use contract_transcode::Value;
use sp_core::Decode;
use sp_weights::Weight;
use subxt::{
config::{
Expand Down Expand Up @@ -123,7 +124,8 @@ impl CallCommand {
&self,
) -> Result<(), ErrorVariant>
where
<C as Config>::AccountId: IntoVisitor + FromStr + EncodeAsType,
<C as Config>::AccountId:
IntoVisitor + FromStr + EncodeAsType + Decode + AsRef<[u8]> + Display,
<<C as Config>::AccountId as FromStr>::Err: Display,
C::Balance: From<u128>
+ Display
Expand All @@ -132,9 +134,11 @@ impl CallCommand {
+ Serialize
+ Debug
+ EncodeAsType
+ IntoVisitor
+ Zero,
<C::ExtrinsicParams as ExtrinsicParams<C>>::Params:
From<<DefaultExtrinsicParams<C> as ExtrinsicParams<C>>::Params>,
<C as Config>::Hash: IntoVisitor,
{
let contract = parse_account(&self.contract)
.map_err(|e| anyhow::anyhow!("Failed to parse contract option: {}", e))?;
Expand Down Expand Up @@ -177,6 +181,12 @@ impl CallCommand {
.value(value)
.done()
.await?;

// assert that the contract even exists
let _ =
fetch_contract_info::<C, C>(&contract, call_exec.rpc(), call_exec.client())
.await?;

let metadata = call_exec.client().metadata();

if !self.extrinsic_cli_opts.execute {
Expand Down Expand Up @@ -204,9 +214,6 @@ impl CallCommand {
println!("{}", dry_run_result.to_json()?);
} else {
dry_run_result.print();
display_contract_exec_result_debug::<_, DEFAULT_KEY_COL_WIDTH, _>(
&result,
)?;
display_dry_run_result_warning("message");
};
}
Expand Down
15 changes: 8 additions & 7 deletions crates/cargo-contract/src/cmd/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use super::{
config::SignerConfig,
display_contract_exec_result,
display_contract_exec_result_debug,
display_dry_run_result_warning,
offer_map_account_if_needed,
parse_balance,
Expand Down Expand Up @@ -75,6 +74,7 @@ use subxt::{
scale_encode::EncodeAsType,
sp_runtime::traits::Zero,
},
utils::H160,
Config,
};

Expand Down Expand Up @@ -193,9 +193,6 @@ impl InstantiateCommand {
println!("{}", dry_run_result.to_json()?);
} else {
print_instantiate_dry_run_result(&dry_run_result);
display_contract_exec_result_debug::<_, DEFAULT_KEY_COL_WIDTH, _>(
&result,
)?;
display_dry_run_result_warning("instantiate");
}
Ok(())
Expand Down Expand Up @@ -371,7 +368,7 @@ where
Some(instantiate_exec.transcoder()),
&instantiate_exec.client().metadata(),
)?;
let contract_address = instantiate_exec_result.contract_address.to_string();
let contract_address = instantiate_exec_result.contract_address;
if output_json {
let display_instantiate_result = InstantiateResult {
code_hash: instantiate_exec_result
Expand Down Expand Up @@ -429,7 +426,7 @@ pub fn print_default_instantiate_preview<C: Config + Environment + SignerConfig<
pub struct InstantiateResult {
/// Instantiated contract hash
#[serde(skip_serializing_if = "Option::is_none")]
pub contract: Option<String>,
pub contract: Option<H160>,
/// Instantiated code hash
#[serde(skip_serializing_if = "Option::is_none")]
pub code_hash: Option<String>,
Expand All @@ -456,7 +453,11 @@ pub fn print_instantiate_dry_run_result<Balance: Serialize>(
format!("{:?}", result.reverted),
DEFAULT_KEY_COL_WIDTH
);
name_value_println!("Contract", result.contract, DEFAULT_KEY_COL_WIDTH);
name_value_println!(
"Contract",
format!("{:?}", result.contract),
DEFAULT_KEY_COL_WIDTH
);
name_value_println!(
"Gas consumed",
result.gas_consumed.to_string(),
Expand Down
34 changes: 1 addition & 33 deletions crates/cargo-contract/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ use crate::{
PathBuf,
Weight,
};
use anyhow::{
Context,
Result,
};
use anyhow::Result;
use colored::Colorize;
use contract_build::{
name_value_println,
Expand Down Expand Up @@ -101,7 +98,6 @@ use subxt::{
},
utils::H160,
};
//use contract_transcode::env_types::H160;

/// Arguments required for creating and sending an extrinsic to a Substrate node.
#[derive(Clone, Debug, clap::Args)]
Expand Down Expand Up @@ -217,41 +213,13 @@ pub fn display_contract_exec_result<R, const WIDTH: usize, Balance>(
where
Balance: Debug,
{
let mut debug_message_lines = std::str::from_utf8(&result.debug_message)
.context("Error decoding UTF8 debug message bytes")?
.lines();
name_value_println!("Gas Consumed", format!("{:?}", result.gas_consumed), WIDTH);
name_value_println!("Gas Required", format!("{:?}", result.gas_required), WIDTH);
name_value_println!(
STORAGE_DEPOSIT_KEY,
format!("{:?}", result.storage_deposit),
WIDTH
);

// print debug messages aligned, only first line has key
if let Some(debug_message) = debug_message_lines.next() {
name_value_println!("Debug Message", format!("{debug_message}"), WIDTH);
}

for debug_message in debug_message_lines {
name_value_println!("", format!("{debug_message}"), WIDTH);
}
Ok(())
}

pub fn display_contract_exec_result_debug<R, const WIDTH: usize, Balance>(
result: &ContractResult<R, Balance>,
) -> Result<()> {
let mut debug_message_lines = std::str::from_utf8(&result.debug_message)
.context("Error decoding UTF8 debug message bytes")?
.lines();
if let Some(debug_message) = debug_message_lines.next() {
name_value_println!("Debug Message", format!("{debug_message}"), WIDTH);
}

for debug_message in debug_message_lines {
name_value_println!("", format!("{debug_message}"), WIDTH);
}
Ok(())
}

Expand Down
16 changes: 8 additions & 8 deletions crates/extrinsics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ subxt = "0.38.1"
hex = "0.4.3"
derivative = "2.2.0"

sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067", default-features = false }
pallet-revive = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067"}
pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067", default-features = false, features = ["unstable-hostfn", "scale"] }
sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48" }
sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48", default-features = false }
pallet-revive = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48"}
pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "b9b73eb2758edc8af140fea60fdc51f890eefc48", default-features = false, features = ["unstable-hostfn", "scale"] }

ink_metadata = { git = "https://github.com/use-ink/ink", branch = "master" }
ink_env = { git = "https://github.com/use-ink/ink", branch = "master" }
ink_metadata = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11" }
ink_env = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11" }

[dev-dependencies]
ink = { git = "https://github.com/use-ink/ink", branch = "master" }
ink = { git = "https://github.com/use-ink/ink", branch = "cmichi-upgrade-to-latest-polkadot-sdk-feb-11" }
assert_cmd = "2.0.16"
regex = "1.11.1"
predicates = "3.1.3"
Expand Down
5 changes: 5 additions & 0 deletions crates/extrinsics/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ where
&self.client
}

/// Returns the rpc.
pub fn rpc(&self) -> &LegacyRpcMethods<C> {
&self.rpc
}

/// Returns the contract message transcoder.
pub fn transcoder(&self) -> &ContractMessageTranscoder {
&self.transcoder
Expand Down
7 changes: 1 addition & 6 deletions crates/extrinsics/src/contract_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,7 @@ where
.at(best_block)
.fetch(&contract_info_address)
.await?
.ok_or_else(|| {
anyhow!(
"No contract information was found for contract {:?}",
contract
)
})?;
.ok_or_else(|| anyhow!("No contract was found for address {:?}", contract))?;

let contract_info_raw = ContractInfoRaw::<C, E>::new(*contract, contract_info_value)?;
let addr = contract_info_raw.get_addr();
Expand Down
12 changes: 4 additions & 8 deletions crates/extrinsics/src/env_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ pub fn compare_node_env_with_contract(
)
}

// todo should be compared against the `pallet_revive::Currency` config.
// the `pallet_balances` one is not necessarily used as the `pallet_revive::Currency`.
compare_if_possible(
node_registry,
contract_metadata,
Expand All @@ -175,28 +177,22 @@ pub fn compare_node_env_with_contract(
node_registry,
contract_metadata,
verbosity,
// the `wasm` here is because `pallet-revive` still uses that name for their
// module
// we use `wasm` here, as that is what `pallet-revive` still uses as a name for
// this module
vec!["pallet_revive", "wasm", "CodeInfo"],
"owner",
)?;
compare_if_possible(
node_registry,
contract_metadata,
verbosity,
//#[cfg(not(test))]
//vec!["sp_runtime", "generic", "header", "Header"],
//#[cfg(test)]
vec!["sp_runtime", "generic", "header", "Header"],
"parent_hash",
)?;
compare_if_possible(
node_registry,
contract_metadata,
verbosity,
//#[cfg(not(test))]
//vec!["sp_runtime", "generic", "header", "Header"],
//#[cfg(test)]
vec!["sp_runtime", "generic", "header", "Header"],
"number",
)?;
Expand Down
Loading
Loading