diff --git a/content/md/en/docs/build/genesis-configuration.md b/content/md/en/docs/build/genesis-configuration.md index 26c236dcb..f398bcb92 100644 --- a/content/md/en/docs/build/genesis-configuration.md +++ b/content/md/en/docs/build/genesis-configuration.md @@ -4,6 +4,11 @@ description: keywords: --- +
+ ⚠️ WARNING: This page contains outdated information. Please refer to the Rust docs for the most up-to-date documentation on this topic. +
+ + The first block produced by any blockchain is referred to as the genesis block. The hash associated with this block is the top-level parent of all blocks produced after that first block. diff --git a/content/md/en/docs/learn/light-clients-in-substrate-connect.md b/content/md/en/docs/learn/light-clients-in-substrate-connect.md index db4a718ec..45b6cff20 100644 --- a/content/md/en/docs/learn/light-clients-in-substrate-connect.md +++ b/content/md/en/docs/learn/light-clients-in-substrate-connect.md @@ -43,7 +43,7 @@ A few of the key benefits include: You can use Substrate Connect to connect to any Substrate-based blockchain. However, you must specify the correct name of the chain that you want to connect to. -There are a few well-known chain names that are defined for the [`WellKnownChain`](https://paritytech.github.io/substrate-connect/api/enums/connect_src.WellKnownChain.html) enumeration type. +There are a few well-known chain names that are defined for the [`WellKnownChain`](https://paritytech.github.io/substrate-connect/api/enums/_substrate_connect.WellKnownChain.html) enumeration type. You can connect to the following public blockchain networks using the name listed: diff --git a/content/md/en/docs/reference/frame-macros.md b/content/md/en/docs/reference/frame-macros.md index 9caea5157..6f5d3c864 100644 --- a/content/md/en/docs/reference/frame-macros.md +++ b/content/md/en/docs/reference/frame-macros.md @@ -3,6 +3,9 @@ title: FRAME macros description: keywords: --- +
+ ⚠️ WARNING: This section contains outdated information. Please refer to the Rust docs for the most up-to-date documentation on this topic. +
Substrate uses customized [Rust macros](https://doc.rust-lang.org/book/ch19-06-macros.html) to generate code and aggregate the logic from the pallets you implement for a runtime. These runtime macros allow you to focus on your runtime logic rather than spending time on encoding and decoding on-chain variables or duplicating the code required for [basic blockchain development](/learn/runtime-development#core-primitives). @@ -391,9 +394,9 @@ $vis type $StorageName<$some_generic> $optional_where_clause For more information, see the Rust documentation for [pallet::storage](https://paritytech.github.io/substrate/master/frame_support/attr.pallet.html#storage-palletstorage-optional) and the following storage data structures: -- [StorageDoubleMap](https://paritytech.github.io/substrate/master/frame_support/pallet_prelude/struct.StorageDoubleMap.html) -- [StorageMap](https://paritytech.github.io/substrate/master/frame_support/pallet_prelude/struct.StorageMap.html#implementations) -- [StorageValue](https://paritytech.github.io/substrate/master/frame_support/pallet_prelude/struct.StorageValue.html) +- [StorageDoubleMap](https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/types/struct.StorageDoubleMap.html) +- [StorageMap](https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/types/struct.StorageMap.html) +- [StorageValue](https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/types/struct.StorageValue.html) ### #[pallet::type_value] diff --git a/content/md/en/docs/reference/how-to-guides/consensus-models/create-a-hybrid-node.md b/content/md/en/docs/reference/how-to-guides/consensus-models/create-a-hybrid-node.md index 0fedff806..2873c0fb8 100644 --- a/content/md/en/docs/reference/how-to-guides/consensus-models/create-a-hybrid-node.md +++ b/content/md/en/docs/reference/how-to-guides/consensus-models/create-a-hybrid-node.md @@ -29,7 +29,7 @@ Customize the consensus mechanisms of a Substrate chain. We begin by creating the block import for Grandpa. In addition to the block import itself, we get back a `grandpa_link`. This link is a channel over which the block import can communicate with the background task that actually casts Grandpa votes. -The [details of the Grandpa protocol](https://research.web3.foundation/en/latest/polkadot/finality.html) are beyond the scope of this guide. +The [details of the Grandpa protocol](https://research.web3.foundation/Polkadot/protocols/finality) are beyond the scope of this guide. In `node/src/service.rs`, create the Grandpa block import: diff --git a/content/md/en/docs/reference/how-to-guides/index.md b/content/md/en/docs/reference/how-to-guides/index.md index faf607fd9..2c29d206a 100644 --- a/content/md/en/docs/reference/how-to-guides/index.md +++ b/content/md/en/docs/reference/how-to-guides/index.md @@ -34,8 +34,6 @@ See the following guides for help with benchmarking and weight configurations. - [Calculate fees](/reference/how-to-guides/weights/calculate-fees/) - [Add benchmarks](/reference/how-to-guides/weights/add-benchmarks/) -- [Use custom weights](/reference/how-to-guides/weights/use-custom-weights/) -- [Use conditional weights](/reference/how-to-guides/weights/use-conditional-weights/) ## Testing diff --git a/content/md/en/docs/reference/how-to-guides/pallet-design/implement-lockable-currency.md b/content/md/en/docs/reference/how-to-guides/pallet-design/implement-lockable-currency.md index d6ffd24d6..5a552830d 100644 --- a/content/md/en/docs/reference/how-to-guides/pallet-design/implement-lockable-currency.md +++ b/content/md/en/docs/reference/how-to-guides/pallet-design/implement-lockable-currency.md @@ -9,7 +9,7 @@ keywords: --- This guide shows you how to write a pallet that allows users to lock funds for staking and voting. -The [`LockableCurrency`](https://paritytech.github.io/substrate/master/frame_support/traits/trait.LockableCurrency.html) trait is useful in the context of economic systems that enforce accountability by collateralizing fungible resources. +The [`LockableCurrency`](https://paritytech.github.io/polkadot-sdk/master/frame_support/traits/tokens/currency/trait.LockableCurrency.html) trait is useful in the context of economic systems that enforce accountability by collateralizing fungible resources. You can use the Substrate [staking pallet](https://paritytech.github.io/substrate/master/pallet_staking/index.html) to manage locked funds in time-based increments. In this guide, we will implement the `set_lock`, `extend_lock` and `remove_lock` methods in our own custom pallet. @@ -22,7 +22,7 @@ You can use the template pallet in the [node template](https://github.com/substr ## Declare the necessary dependencies -The methods from [`LockableCurrency`](https://paritytech.github.io/substrate/master/frame_support/traits/trait.LockableCurrency.html) require us to import a few traits from `frame_support`. +The methods from [`LockableCurrency`](https://paritytech.github.io/polkadot-sdk/master/frame_support/traits/tokens/currency/trait.LockableCurrency.html) require us to import a few traits from `frame_support`. 1. Ensure you have the following traits imported in the top section of your pallet: @@ -162,5 +162,5 @@ The required methods are: ## Related material - [Currency trait](https://paritytech.github.io/substrate/master/frame_support/traits/tokens/currency/trait.Currency.html) -- [LockableCurrency](https://paritytech.github.io/substrate/master/frame_support/traits/trait.LockableCurrency.html) -- [LockIdentifier](https://paritytech.github.io/substrate/master/frame_support/traits/type.LockIdentifier.html) +- [LockableCurrency](https://paritytech.github.io/polkadot-sdk/master/frame_support/traits/tokens/currency/trait.LockableCurrency.html) +- [LockIdentifier](https://paritytech.github.io/polkadot-sdk/master/frame_support/traits/tokens/currency/type.LockIdentifier.html) diff --git a/content/md/en/docs/reference/how-to-guides/parachains/connect-to-a-relay-chain.md b/content/md/en/docs/reference/how-to-guides/parachains/connect-to-a-relay-chain.md index e0fc92b73..dc8402838 100644 --- a/content/md/en/docs/reference/how-to-guides/parachains/connect-to-a-relay-chain.md +++ b/content/md/en/docs/reference/how-to-guides/parachains/connect-to-a-relay-chain.md @@ -180,8 +180,8 @@ pub const fn deposit(items: u32, bytes: u32) -> Balance {} You can find this function for each relay chain in the Polkadot repository. For example: -- [Kusama](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/kusama/constants/src/lib.rs) -- [Polkadot](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/polkadot/constants/src/lib.rs) +- [Kusama](https://github.com/polkadot-fellows/runtimes/blob/main/relay/kusama/constants/src/lib.rs) +- [Polkadot](https://github.com/polkadot-fellows/runtimes/blob/main/relay/polkadot/constants/src/lib.rs) - [Rococo](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/rococo/constants/src/lib.rs) - [Westend](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/westend/constants/src/lib.rs) diff --git a/content/md/en/docs/reference/how-to-guides/weights/index.md b/content/md/en/docs/reference/how-to-guides/weights/index.md index 8285f4d88..54f710963 100644 --- a/content/md/en/docs/reference/how-to-guides/weights/index.md +++ b/content/md/en/docs/reference/how-to-guides/weights/index.md @@ -8,5 +8,3 @@ The _How-to_ guides in the _Weights_ category illustrate use benchmarks and weig - [Calculate fees](/reference/how-to-guides/weights/calculate-fees/) - [Add benchmarks](/reference/how-to-guides/weights/add-benchmarks/) -- [Use custom weights](/reference/how-to-guides/weights/use-custom-weights/) -- [Use conditional weights](/reference/how-to-guides/weights/use-conditional-weights/) diff --git a/content/md/en/docs/reference/how-to-guides/weights/use-conditional-weights.md b/content/md/en/docs/reference/how-to-guides/weights/use-conditional-weights.md deleted file mode 100644 index 58020cb07..000000000 --- a/content/md/en/docs/reference/how-to-guides/weights/use-conditional-weights.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -title: Use conditional weights -description: -keywords: - - weights - - benchmarking - - runtime ---- - -Substrate provides a mechanism known as [transaction weighting](/build/tx-weights-fees) to quantify the resources consumed while executing a transaction. -Typically, we use the weight functions returned from our benchmarking for this. -But Substrate also allow us to apply a totally different weight function based on certain condition. -We will walk through an example in this guide. -Once defined, it can be used directly in your pallet, written as such: - -`#[pallet::weight(Conditional(\)` - -## Objectives - -- Create and use custom weighting in your pallet. - -- Apply different weight functions based on certain condition on computing extrinsic's weight value. - -Here are the different traits we'll be implementing: - -- [\`WeighData\`](https://paritytech.github.io/substrate/master/frame_support/weights/trait.WeighData.html#): Weigh the data in a function. - \`pallet::weight\` expects whatever implements \`WeighData\` to replace \`T\` with a tuple of the dispatch arguments. -- [\`PaysFee\`](https://paritytech.github.io/substrate/master/frame_support/weights/trait.PaysFee.html): Designate whether the dispatch pays a fee or not. -- [\`ClassifyDispatch\`](https://paritytech.github.io/substrate/master/frame_support/weights/trait.ClassifyDispatch.html): A way to tell the runtime about the type of dispatch being made. - -## Write the Weight struct - -1. Open `lib.rs` file for your pallet in a text editor. - -1. Import `DispatchClass` and `Pays` by declaring `use frame_support::dispatch::{DispatchClass, Pays}`. - -1. Import `weights` primitives into the pallet. - - ```rust - use frame_support:: { - dispatch::{DispatchClass, Pays}, - }, - weights::Weight, - -1. Declare a struct called `Conditional` and write an implementation of `WeighData` for `Conditional` where the first parameter is the condition that evaluates to a boolean value. - - In the following example, if the condition is true, the weight will be linear to the input. - Otherwise the weight will be a constant. - - ```rust - pub struct Conditional(u32); - impl WeighData<(&bool, &u32)> for Conditional { - fn weigh_data(&self, (switch, val): (&bool, &u32)) -> Weight { - - // If the first parameter is true, then the weight is linear in the second parameter. - if *switch { - val.saturating_mul(self.0) - } - // Otherwise the weight is constant. - else { - self.0 - } - } - } - ``` - -## Classify dispatch calls - -Add `dispatch::{ClassifyDispatch, DispatchClass, Pays}` to your pallet's `frame_support` imports. -Since this implementation requires a [`DispatchClass`](https://paritytech.github.io/substrate/master/frame_support/dispatch/enum.DispatchClass.html), use `default` to classify all calls as normal: - -1. Open `lib.rs` file for your pallet in a text editor. - -1. Import `DispatchClass` and `Pays` by declaring `use frame_support::dispatch::{DispatchClass, Pays}`. - - ```rust - use frame_support::dispatch::{ClassifyDispatch, DispatchClass, Pays}; - // -- snip -- - - // Implement ClassifyDispatch - impl ClassifyDispatch for Conditional { - fn classify_dispatch(&self, _: T) -> DispatchClass { - Default::default() - } - } - ``` - -## Implement Pays - -Specify how `Pays` is used for the custom `WeighData` struct. -Setting this to `true` require the caller of this dispatch to pay a fee: - -1. Open `lib.rs` file for your pallet in a text editor. - -1. Implement `Pays` for the Conditional structure. - - ```rust - impl Pays for Conditional { - fn pays_fee(&self) -> bool { - true - } - } - ``` - -## Use the weighting struct for an extrinsic - -Use the conditional weighting struct on your pallet's extrinsics like this: - -```rust -#[pallet::weight(Conditional(200))] - fn example(origin: OriginFor, add_flag: bool, val: u32>) -> DispatchResult { - //... - } -``` - -## Examples - -- [Custom `WeightForSetDummy` struct in the Example pallet](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/examples/basic/src/lib.rs#L305-L350) - -## Related material - -- [Benchmarking](/test/benchmark) -- [Calculate fees](/reference/how-to-guides/weights/calculate-fees) -- [Use custom weights](/reference/how-to-guides/weights/use-custom-weights) diff --git a/content/md/en/docs/reference/how-to-guides/weights/use-custom-weights.md b/content/md/en/docs/reference/how-to-guides/weights/use-custom-weights.md deleted file mode 100644 index 7f2f87cc1..000000000 --- a/content/md/en/docs/reference/how-to-guides/weights/use-custom-weights.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -title: Use custom weights -description: -keywords: - - weights - - benchmarking - - runtime ---- - -Here, you'll learn how to use the weights in your pallet from the output of benchmarking your pallet's extrinsics. -It assumes that you have a file in your pallet's directory called `weights.rs`, containing the auto generated weights from running FRAME's benchmarking tool. - -## Goal - -Use weights generated by [FRAME's benchmarking tool](https://paritytech.github.io/substrate/master/frame_benchmarking/macro.benchmarks.html) in the extrinsics of your pallet. - -## Use Cases - -Using accurate weights generated from benchmarking for a pallet's extrinsics. - -## Steps - -### 1. Define the `WeightInfo` trait in your pallet's `weight.rs` file - -In order to use the `weights.rs` file generated by the benchmarking tool in your pallet (an example of Substrate [`pallet-example` weights here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/examples/basic/src/weights.rs)), -define a trait that will make it easy to access its functions. -For example: - -`pallets/example/src/weights.rs` - -```rust -pub trait WeightInfo { - fn example(len: usize,) -> Weight; -} -``` - -### 2. Include `WeightInfo` in your pallet - -In your pallet's `lib.rs`, declare `pub mod weights;` at the top and introduce -`pub use crate::weights::WeightInfo;` to expose the `WeightInfo` trait to your pallet. Then, -introduce a `WeightInfo` type into the `Config` trait of your pallet: - -`pallets/example/src/lib.rs` - -```rust -pub mod weights; -pub use weights::*; - -// -- snip -- - -pub trait Config: frame_system::Config { - // -- snip -- - - /// Information on runtime weights. - type WeightInfo: WeightInfo; -} -``` - -### 3. Write the custom weight declaration - -For each of your dispatchables, introduce an appropriate weights line to determine the weight using the -configured `WeightInfo` type. For example, `T::WeightInfo::example` would be the weight function -returned from `weights.rs` for the `example` extrinsic: - -`pallets/example/src/lib.rs` - -```rust -#[pallet::weight(T::WeightInfo::example(x.len()))] -fn example(origin: OriginFor, arg: Vec) -> DispatchResult { - // -- snip -- -} -``` - -### 4. Define the `WeightInfo` type in `Config` trait impls - -You'll need to define the `WeightInfo` trait in both your pallet's tests mockup `mock.rs` -and your Substrate `node`'s runtime. - -In your pallet's `Config` trait impl in `mock.rs`, introduce the following line to exclude weights -in our testing. - -In `pallets/example/src/mock.rs` or `pallets/example/src/test.rs`: - -```rust -impl Config for TestRuntime { - // -- snip -- - type WeightInfo = (); -} -``` - -In your pallet's `Config` trait impl in `runtime/src/lib.rs`, introduce the following line to -include weights in our runtime. - -```rust -impl pallet_example::Config for Runtime { - // -- snip -- - type WeightInfo = pallet_example::weights::SubstrateWeight; -} -``` - -Once you recompile your node, your extrinsic will now be using the custom weights defined in -`pallets/example/src/weights.rs`. - -## Examples - -- [Benchmarking in the Example pallet](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/examples/basic/src/benchmarking.rs) -- [Weights in the Example pallet](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/examples/basic/src/weights.rs) - -## Related material - -- [Benchmarking](/test/benchmark) -- [Calculate fees](/reference/how-to-guides/weights/calculate-fees) -- [Add benchmarks](/reference/how-to-guides/weights/add-benchmarks/) diff --git a/content/md/en/docs/tutorials/build-application-logic/use-macros-in-a-custom-pallet.md b/content/md/en/docs/tutorials/build-application-logic/use-macros-in-a-custom-pallet.md index 7ace105f4..c6aa96a7a 100644 --- a/content/md/en/docs/tutorials/build-application-logic/use-macros-in-a-custom-pallet.md +++ b/content/md/en/docs/tutorials/build-application-logic/use-macros-in-a-custom-pallet.md @@ -228,7 +228,7 @@ To implement the errors for the proof-of-existence pallet: To add a new claim to the blockchain, the proof-of-existence pallet requires a storage mechanism. To address this requirement, you can create a key-value map, where each claim points to the owner and the block number when the claim was made. -To create this key-value map, you can use the FRAME [`StorageMap`](https://paritytech.github.io/substrate/master/frame_support/pallet_prelude/struct.StorageMap.html). +To create this key-value map, you can use the FRAME [`StorageMap`](https://paritytech.github.io/polkadot-sdk/master/frame_support/storage/types/struct.StorageMap.html). To implement storage for the proof-of-existence pallet: diff --git a/content/md/en/docs/tutorials/collectibles-workshop/01-prepare.md b/content/md/en/docs/tutorials/collectibles-workshop/01-prepare.md index 3f9b7b990..911b0d1d6 100644 --- a/content/md/en/docs/tutorials/collectibles-workshop/01-prepare.md +++ b/content/md/en/docs/tutorials/collectibles-workshop/01-prepare.md @@ -58,7 +58,7 @@ If you don't have a preferred IDE, Visual Studio Code is a good choice. To interact with the blockchain and test your work as you build the Substrate collectibles application, you'll need a browser-based application that can connect to the Substrate node. For the workshop, you can connect to the node from the [Polkadot/Substrate Portal](https://polkadot.js.org/apps/) if you have Chrome or a Chromium-based browser. -- [ ] [Google Chrome](https://www.google.com/chrome/) or a Chromium-based browser, such as [Brave](https://brave.com/download/), [Microsoft Edge](https://www.microsoft.com/en-us/edge?form=MA13FJ&exp=e00), [Opera](https://www.opera.com/download), or [Vivaldi](https://vivaldi.com/download/). +- [ ] [Google Chrome](https://www.google.com/chrome/) or a Chromium-based browser, such as [Brave](https://brave.com/download/), [Microsoft Edge](https://www.microsoft.com/en-us/edge?ep=79&form=MA13KE&es=23), [Opera](https://www.opera.com/download), or [Vivaldi](https://vivaldi.com/download/). If you use a more restrictive browser—such as Firefox—you might find that connections between the Polkadot/Substrate Portal and the node are blocked for security or privacy reasons. diff --git a/content/md/en/docs/tutorials/integrate-with-tools/integrate-a-light-client-node.md b/content/md/en/docs/tutorials/integrate-with-tools/integrate-a-light-client-node.md index 163d8e5b4..7e2c10de0 100644 --- a/content/md/en/docs/tutorials/integrate-with-tools/integrate-a-light-client-node.md +++ b/content/md/en/docs/tutorials/integrate-with-tools/integrate-a-light-client-node.md @@ -30,7 +30,7 @@ By completing this tutorial, you will accomplish the following objectives: Before the light client can connect to a network, you must have a web application that specifies the network the light client should connect to, the nodes for it to communicate with, and the consensus-critical state it must have at genesis. This information is available in the [chain specification](/build/chain-spec/) file for the network. -Substrate Connect is preconfigured to recognize several chains that are defined in the [WellKnownChain](https://paritytech.github.io/substrate-connect/api/enums/connect_src.WellKnownChain.html) enumeration list. +Substrate Connect is preconfigured to recognize several chains that are defined in the [WellKnownChain](https://paritytech.github.io/substrate-connect/api/enums/_substrate_connect.WellKnownChain.html) enumeration list. These well-known chains are: - Polkadot identified as `polkadot` diff --git a/src/styles/tailwind-custom.css b/src/styles/tailwind-custom.css index ee1c38e58..99edd546b 100644 --- a/src/styles/tailwind-custom.css +++ b/src/styles/tailwind-custom.css @@ -220,3 +220,7 @@ div[aria-label='animation'] { nav ul li span svg { @apply dark:text-substrateDarkThemeBlue; } + +.warning { + @apply bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 my-4; +} \ No newline at end of file