Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into bkchr-coretime-zomb…
Browse files Browse the repository at this point in the history
…ienet
  • Loading branch information
bkchr committed Jan 8, 2024
2 parents aa72e1d + dbff87c commit 5648298
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 49 deletions.
41 changes: 26 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ proc-macro = true
syn = "2.0.48"
proc-macro2 = "1.0.64"
quote = "1.0.33"
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ impl<T: Config> BlockNumberProvider for RelaychainDataProvider<T> {
fn current_block_number() -> relay_chain::BlockNumber {
Pallet::<T>::validation_data()
.map(|d| d.relay_parent_number)
.unwrap_or_default()
.unwrap_or_else(|| Pallet::<T>::last_relay_block_number())
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
21 changes: 14 additions & 7 deletions docs/sdk/src/reference_docs/runtime_vs_smart_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@
//!
//! ## Comparative Table
//!
//! | Aspect | Runtime | Smart Contracts |
//! | Aspect | Runtime
//! | Smart Contracts |
//! |-----------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------|
//! | **Design Philosophy** | Core logic of a blockchain, allowing broad and deep customization. | Designed for DApps deployed on the blockchain runtime.|
//! | **Development Complexity** | Requires in-depth knowledge of Rust and Substrate. Suitable for complex blockchain architectures. | Easier to develop with knowledge of Smart Contract languages like Solidity or [ink!](https://use.ink/). |
//! | **Upgradeability and Flexibility** | Offers comprehensive upgradeability with migration logic and on-chain governance, allowing modifications to the entire blockchain logic without hard forks. | Less flexible in upgrade migrations but offers more straightforward deployment and iteration. |
//! | **Performance and Efficiency** | More efficient, optimized for specific needs of the blockchain. | Can be less efficient due to its generic nature (e.g. the overhead of a virtual machine). |
//! | **Security Considerations** | Security flaws can affect the entire blockchain. | Security risks usually localized to the individual contract. |
//! | **Weighing and Metering** | Operations can be weighed, allowing for precise benchmarking. | Execution is metered, allowing for measurement of resource consumption. |
//! | **Design Philosophy** | Core logic of a blockchain, allowing broad and deep customization.
//! | Designed for DApps deployed on the blockchain runtime.| | **Development Complexity** | Requires in-depth knowledge of Rust and Substrate. Suitable for complex blockchain architectures. | Easier to develop with knowledge of Smart Contract languages like Solidity or [ink!](https://use.ink/). |
//! | **Upgradeability and Flexibility** | Offers comprehensive upgradeability with migration logic
//! and on-chain governance, allowing modifications to the entire blockchain logic without hard
//! forks. | Less flexible in upgrade migrations but offers more straightforward deployment and
//! iteration. | | **Performance and Efficiency** | More efficient, optimized for specific needs of
//! the blockchain. | Can be less efficient due to its generic nature (e.g. the overhead of a
//! virtual machine). | | **Security Considerations** | Security flaws can affect the entire
//! blockchain. | Security risks usually localized to the individual
//! contract. | | **Weighing and Metering** | Operations can be weighed, allowing for precise
//! benchmarking. | Execution is metered, allowing for measurement of resource
//! consumption. |
//!
//! We will now explore these differences in more detail.
//!
Expand Down
6 changes: 3 additions & 3 deletions polkadot/node/core/candidate-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,21 +773,21 @@ trait ValidationBackend {
if num_death_retries_left > 0 {
num_death_retries_left -= 1;
} else {
break;
break
},

Err(ValidationError::PossiblyInvalid(PossiblyInvalidError::JobError(_))) =>
if num_job_error_retries_left > 0 {
num_job_error_retries_left -= 1;
} else {
break;
break
},

Err(ValidationError::Internal(_)) =>
if num_internal_retries_left > 0 {
num_internal_retries_left -= 1;
} else {
break;
break
},

Ok(_) | Err(ValidationError::Invalid(_) | ValidationError::Preparation(_)) => break,
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/core/candidate-validation/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ fn candidate_validation_retry_on_error_helper(
ExecutorParams::default(),
exec_kind,
&Default::default(),
));
))
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/gum/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ proc-macro = true
syn = { version = "2.0.48", features = ["extra-traits", "full"] }
quote = "1.0.28"
proc-macro2 = "1.0.56"
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"
expander = "2.0.0"

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions polkadot/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sp-consensus = { path = "../../substrate/primitives/consensus/common" }
sp-consensus-babe = { path = "../../substrate/primitives/consensus/babe" }
sc-chain-spec = { path = "../../substrate/client/chain-spec" }
sc-rpc = { path = "../../substrate/client/rpc" }
sc-rpc-spec-v2 = { path = "../../substrate/client/rpc-spec-v2" }
sc-consensus-babe = { path = "../../substrate/client/consensus/babe" }
sc-consensus-babe-rpc = { path = "../../substrate/client/consensus/babe/rpc" }
sc-consensus-beefy = { path = "../../substrate/client/consensus/beefy" }
Expand Down
6 changes: 6 additions & 0 deletions polkadot/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ where
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_consensus_beefy_rpc::{Beefy, BeefyApiServer};
use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer};
use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer};
use sc_sync_state_rpc::{SyncState, SyncStateApiServer};
use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer};

Expand All @@ -134,6 +135,11 @@ where
finality_provider,
} = grandpa;

let chain_name = chain_spec.name().to_string();
let genesis_hash = client.hash(0).ok().flatten().expect("Genesis block exists; qed");
let properties = chain_spec.properties();

io.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?;
io.merge(StateMigration::new(client.clone(), backend.clone(), deny_unsafe).into_rpc())?;
io.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
Expand Down
2 changes: 1 addition & 1 deletion prdoc/pr_2862.prdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: Return latest known relay chain block number in on_initialize et all
title: Return latest known relay chain block number in `on_initialize` etc.

doc:
- audience: Runtime Dev
Expand Down
7 changes: 7 additions & 0 deletions substrate/bin/node-template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,12 @@ where
// to call into the runtime.
// `module.merge(YourRpcTrait::into_rpc(YourRpcStruct::new(ReferenceToClient, ...)))?;`

// You probably want to enable the `rpc v2 chainSpec` API as well
//
// let chain_name = chain_spec.name().to_string();
// let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");
// let properties = chain_spec.properties();
// module.merge(ChainSpec::new(chain_name, genesis_hash, properties).into_rpc())?;

Ok(module)
}
2 changes: 1 addition & 1 deletion substrate/client/chain-spec/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
proc-macro = true

[dependencies]
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"
proc-macro2 = "1.0.56"
quote = "1.0.28"
syn = "2.0.48"
2 changes: 1 addition & 1 deletion substrate/client/consensus/beefy/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ where
// The block is imported as part of some chain sync.
// The voter doesn't need to process it now.
// It will be detected and processed as part of the voter state init.
return Ok(inner_import_result);
return Ok(inner_import_result)
},
}

Expand Down
2 changes: 1 addition & 1 deletion substrate/client/consensus/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ where
header =
wait_for_parent_header(backend.blockchain(), header, HEADER_SYNC_DELAY).await?;
}
return Ok(state);
return Ok(state)
}

// No valid voter-state persisted, re-initialize from pallet genesis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ impl Notifications {
peerset_rejected,
incoming_index,
};
return self.report_reject(index).map_or((), |_| ());
return self.report_reject(index).map_or((), |_| ())
}

trace!(
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/tracing/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
proc-macro = true

[dependencies]
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"
proc-macro2 = "1.0.56"
quote = { version = "1.0.28", features = ["proc-macro"] }
syn = { version = "2.0.48", features = ["extra-traits", "full", "parsing", "proc-macro"] }
6 changes: 3 additions & 3 deletions substrate/frame/contracts/fixtures/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn collect_entries(contracts_dir: &Path, out_dir: &Path) -> Vec<Entry> {
.filter_map(|file| {
let path = file.expect("file exists; qed").path();
if path.extension().map_or(true, |ext| ext != "rs") {
return None;
return None
}

let entry = Entry::new(path);
Expand Down Expand Up @@ -307,7 +307,7 @@ fn find_workspace_root(current_dir: &Path) -> Option<PathBuf> {
let cargo_toml_contents =
std::fs::read_to_string(current_dir.join("Cargo.toml")).ok()?;
if cargo_toml_contents.contains("[workspace]") {
return Some(current_dir);
return Some(current_dir)
}
}

Expand All @@ -325,7 +325,7 @@ fn main() -> Result<()> {

let entries = collect_entries(&contracts_dir, &out_dir);
if entries.is_empty() {
return Ok(());
return Ok(())
}

let tmp_dir = tempfile::tempdir()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ proc-macro = true
syn = { version = "2.0.48", features = ["full", "visit"] }
quote = "1.0.28"
proc-macro2 = "1.0.56"
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"

[dev-dependencies]
parity-scale-codec = "3.6.1"
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/staking/reward-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
proc-macro = true

[dependencies]
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"
proc-macro2 = "1.0.56"
quote = "1.0.28"
syn = { version = "2.0.48", features = ["full", "visit"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn expand_outer_task(
let mut task_paths = Vec::new();
for decl in pallet_decls {
if decl.find_part("Task").is_none() {
continue;
continue
}

let variant_name = &decl.name;
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/support/procedural/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ workspace = true
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"
proc-macro2 = "1.0.56"
quote = "1.0.28"
syn = { version = "2.0.48", features = ["extra-traits", "full", "visit"] }
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ fn last_runtime_upgrade_spec_version_usage() {
// a runtime upgrade in the pipeline of being applied, you should use the spec version
// of this upgrade.
if System::last_runtime_upgrade_spec_version() > 1337 {
return Weight::zero();
return Weight::zero()
}

// Do the migration.
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/api/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ quote = "1.0.28"
syn = { version = "2.0.48", features = ["extra-traits", "fold", "full", "visit"] }
proc-macro2 = "1.0.56"
blake2 = { version = "0.10.4", default-features = false }
proc-macro-crate = "2.0.1"
proc-macro-crate = "3.0.0"
expander = "2.0.0"
Inflector = "0.11.4"

Expand Down
Loading

0 comments on commit 5648298

Please sign in to comment.