diff --git a/Cargo.lock b/Cargo.lock index 18db9dd..7924d2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6143,6 +6143,20 @@ dependencies = [ "hash-db", ] +[[package]] +name = "merkleized-metadata" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f313fcff1d2a4bcaa2deeaa00bf7530d77d5f7bd0467a117dde2e29a75a7a17a" +dependencies = [ + "array-bytes 6.2.3", + "blake3", + "frame-metadata", + "parity-scale-codec", + "scale-decode", + "scale-info", +] + [[package]] name = "merlin" version = "3.0.0" @@ -6615,7 +6629,7 @@ dependencies = [ [[package]] name = "neuroweb-node" -version = "1.5.1" +version = "1.5.0" dependencies = [ "clap", "cumulus-client-cli", @@ -14796,6 +14810,29 @@ dependencies = [ "sp-arithmetic 23.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", ] +[[package]] +name = "scale-bits" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57b1e7f6b65ed1f04e79a85a57d755ad56d76fdf1e9bddcc9ae14f71fcdcf54" +dependencies = [ + "parity-scale-codec", + "scale-type-resolver", +] + +[[package]] +name = "scale-decode" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" +dependencies = [ + "derive_more", + "parity-scale-codec", + "scale-bits", + "scale-type-resolver", + "smallvec", +] + [[package]] name = "scale-info" version = "2.11.3" @@ -14822,6 +14859,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-type-resolver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" + [[package]] name = "schannel" version = "0.1.23" @@ -17458,13 +17501,22 @@ name = "substrate-wasm-builder" version = "17.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0#8c8edacf8942298c3807a2e192860da9e7e4996a" dependencies = [ + "array-bytes 6.2.3", "build-helper", "cargo_metadata", "console", "filetime", + "frame-metadata", + "merkleized-metadata", + "parity-scale-codec", "parity-wasm", "polkavm-linker", + "sc-executor 0.32.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", + "sp-core 28.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", + "sp-io 30.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", "sp-maybe-compressed-blob 11.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", + "sp-tracing 16.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", + "sp-version 29.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.11.0)", "strum 0.26.3", "tempfile", "toml 0.8.15", @@ -19501,55 +19553,3 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", -] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", -] - -[[package]] -name = "zstd" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" -dependencies = [ - "zstd-safe 6.0.6", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-safe" -version = "6.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/README.md b/README.md index d2850f0..a8fb13b 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ To run a full network with multiple NeuroWeb nodes (collators and non-collators) #### Run A Relay Chain To start a relay chain we recommend reading and following instructions in [Cumulus Workshop](https://docs.substrate.io/tutorials/build-a-parachain/prepare-a-local-relay-chain/). + NeuroWeb is currently compatible with Polkadot v1.11.0 version. #### Parachain Nodes (Collators) diff --git a/node/Cargo.toml b/node/Cargo.toml index 66b18d0..bc20ed6 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "neuroweb-node" -version = "1.5.1" +version = "1.5.0" authors = ["TraceLabs"] description = "NeuroWeb - Cumulus FRAME-based Substrate Node" license = "GPL-3.0-only" diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 0a74b11..d1f8144 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "neuroweb-runtime" -version = "1.5.1" +version = "1.5.2" authors = ["TraceLabs"] description = "NeuroWeb Runtime - Cumulus FRAME-based Substrate Runtime" license = "GPL-3.0-only" @@ -11,9 +11,6 @@ edition = "2021" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] -[build-dependencies] -substrate-wasm-builder = { workspace = true } - [dependencies] codec = { workspace = true } hex-literal = { workspace = true, optional = true } @@ -101,6 +98,9 @@ pallet-democracy = { workspace = true } pallet-identity = { workspace = true } pallet-preimage = { workspace = true } +[build-dependencies] +substrate-wasm-builder = { workspace = true, optional = true } + [features] default = ["std"] std = [ @@ -166,6 +166,7 @@ std = [ "sp-session/std", "sp-std/std", "sp-transaction-pool/std", + "substrate-wasm-builder", "sp-version/std", "xcm-builder/std", "xcm-executor/std", @@ -232,3 +233,5 @@ try-runtime = [ "pallet-xcm/try-runtime", "parachain-info/try-runtime", ] + +metadata-hash = ["substrate-wasm-builder/metadata-hash"] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5c13a4d..45c002d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -141,7 +141,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("origintrail-parachain"), impl_name: create_runtime_str!("neuroweb"), authoring_version: 1, - spec_version: 135, + spec_version: 136, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -1456,6 +1456,8 @@ impl_runtime_apis! { estimate: bool, access_list: Option)>>, ) -> Result { + use pallet_evm::GasWeightMapping as _; + let config = if estimate { let mut config = ::config().clone(); config.estimate = true; @@ -1464,8 +1466,49 @@ impl_runtime_apis! { None }; - let is_transactional = false; + let is_transactional = false; let validate = true; + + // Estimated encoded transaction size must be based on the heaviest transaction + // type (EIP1559Transaction) to be compatible with all transaction types. + let mut estimated_transaction_len = data.len() + + // pallet ethereum index: 1 + // transact call index: 1 + // Transaction enum variant: 1 + // chain_id 8 bytes + // nonce: 32 + // max_priority_fee_per_gas: 32 + // max_fee_per_gas: 32 + // gas_limit: 32 + // action: 21 (enum varianrt + call address) + // value: 32 + // access_list: 1 (empty vec size) + // 65 bytes signature + 258; + + if access_list.is_some() { + estimated_transaction_len += access_list.encoded_size(); + } + + + let gas_limit = if gas_limit > U256::from(u64::MAX) { + u64::MAX + } else { + gas_limit.low_u64() + }; + let without_base_extrinsic_weight = true; + + let (weight_limit, proof_size_base_cost) = + match ::GasWeightMapping::gas_to_weight( + gas_limit, + without_base_extrinsic_weight + ) { + weight_limit if weight_limit.proof_size() > 0 => { + (Some(weight_limit), Some(estimated_transaction_len as u64)) + } + _ => (None, None), + }; + ::Runner::call( from, to, @@ -1477,11 +1520,10 @@ impl_runtime_apis! { nonce, access_list.unwrap_or_default(), is_transactional, - validate, - // TODO we probably want to support external cost recording in non-transactional calls - None, - None, - config.as_ref().unwrap_or_else(|| ::config()), + validate, + weight_limit, + proof_size_base_cost, + config.as_ref().unwrap_or(::config()), ).map_err(|err| err.error.into()) } @@ -1496,6 +1538,8 @@ impl_runtime_apis! { estimate: bool, access_list: Option)>>, ) -> Result { + use pallet_evm::GasWeightMapping as _; + let config = if estimate { let mut config = ::config().clone(); config.estimate = true; @@ -1504,8 +1548,48 @@ impl_runtime_apis! { None }; - let is_transactional = false; + let is_transactional = false; let validate = true; + + let mut estimated_transaction_len = data.len() + + // from: 20 + // value: 32 + // gas_limit: 32 + // nonce: 32 + // 1 byte transaction action variant + // chain id 8 bytes + // 65 bytes signature + 190; + + if max_fee_per_gas.is_some() { + estimated_transaction_len += 32; + } + if max_priority_fee_per_gas.is_some() { + estimated_transaction_len += 32; + } + if access_list.is_some() { + estimated_transaction_len += access_list.encoded_size(); + } + + + let gas_limit = if gas_limit > U256::from(u64::MAX) { + u64::MAX + } else { + gas_limit.low_u64() + }; + let without_base_extrinsic_weight = true; + + let (weight_limit, proof_size_base_cost) = + match ::GasWeightMapping::gas_to_weight( + gas_limit, + without_base_extrinsic_weight + ) { + weight_limit if weight_limit.proof_size() > 0 => { + (Some(weight_limit), Some(estimated_transaction_len as u64)) + } + _ => (None, None), + }; + ::Runner::create( from, data, @@ -1515,12 +1599,11 @@ impl_runtime_apis! { max_priority_fee_per_gas, nonce, access_list.unwrap_or_default(), - is_transactional, + is_transactional, validate, - // TODO we probably want to support external cost recording in non-transactional calls - None, - None, - config.as_ref().unwrap_or_else(|| ::config()), + weight_limit, + proof_size_base_cost, + config.as_ref().unwrap_or(::config()), ).map_err(|err| err.error.into()) } @@ -1682,7 +1765,7 @@ impl_runtime_apis! { fn get_preset(id: &Option) -> Option> { get_preset::(id, |_| None) } - + fn preset_names() -> Vec { vec![] }