mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
CI: markdown link checker (#7145)
* change (CI): markdown link checker * Fix some invalid doc links (re-run of cargo-unleash gen-readme w/ fixes). * Fix some invalid doc links * Fix some invalid doc links * Fix some links * Fix some links * Apply @bkchr suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix more links * Fix more links * typo * Fix more links * Fix more links * Ignore valid link .. check wrongly sees it as invalid * Fix style issue * Fix style issue * change (CI): update style guide link * change (lib): suggestions Co-authored-by: Dan Forbes <dan@danforbes.dev> Co-authored-by: Steve Degosserie <steve@parity.io> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Collection of allocator implementations.
|
||||
|
||||
This crate provides the following allocator implementations:
|
||||
- A freeing-bump allocator: [`FreeingBumpHeapAllocator`](freeing_bump::FreeingBumpHeapAllocator)
|
||||
- A freeing-bump allocator: [`FreeingBumpHeapAllocator`](https://docs.rs/sp-allocator/latest/sp_allocator/struct.FreeingBumpHeapAllocator.html)
|
||||
|
||||
License: Apache-2.0
|
||||
@@ -3,8 +3,8 @@ Substrate runtime api
|
||||
The Substrate runtime api is the crucial interface between the node and the runtime.
|
||||
Every call that goes into the runtime is done with a runtime api. The runtime apis are not fixed.
|
||||
Every Substrate user can define its own apis with
|
||||
[`decl_runtime_apis`](macro.decl_runtime_apis.html) and implement them in
|
||||
the runtime with [`impl_runtime_apis`](macro.impl_runtime_apis.html).
|
||||
[`decl_runtime_apis`](https://docs.rs/sp-api/latest/sp_api/macro.decl_runtime_apis.html) and implement them in
|
||||
the runtime with [`impl_runtime_apis`](https://docs.rs/sp-api/latest/sp_api/macro.impl_runtime_apis.html).
|
||||
|
||||
Every Substrate runtime needs to implement the [`Core`] runtime api. This api provides the basic
|
||||
functionality that every runtime needs to export.
|
||||
|
||||
@@ -1,11 +1,58 @@
|
||||
A set of election algorithms to be used with a substrate runtime, typically within the staking
|
||||
sub-system. Notable implementation include
|
||||
sub-system. Notable implementation include:
|
||||
|
||||
- [`seq_phragmen`]: Implements the Phragmén Sequential Method. An un-ranked, relatively fast
|
||||
election method that ensures PJR, but does not provide a constant factor approximation of the
|
||||
maximin problem.
|
||||
- [`balance_solution`]: Implements the star balancing algorithm. This iterative process can
|
||||
increase a solutions score, as described in [`evaluate_support`].
|
||||
- [`phragmms`]: Implements a hybrid approach inspired by Phragmén which is executed faster but
|
||||
it can achieve a constant factor approximation of the maximin problem, similar to that of the
|
||||
MMS algorithm.
|
||||
- [`balance_solution`]: Implements the star balancing algorithm. This iterative process can push
|
||||
a solution toward being more `balances`, which in turn can increase its score.
|
||||
|
||||
### Terminology
|
||||
|
||||
This crate uses context-independent words, not to be confused with staking. This is because the
|
||||
election algorithms of this crate, while designed for staking, can be used in other contexts as
|
||||
well.
|
||||
|
||||
`Voter`: The entity casting some votes to a number of `Targets`. This is the same as `Nominator`
|
||||
in the context of staking. `Target`: The entities eligible to be voted upon. This is the same as
|
||||
`Validator` in the context of staking. `Edge`: A mapping from a `Voter` to a `Target`.
|
||||
|
||||
The goal of an election algorithm is to provide an `ElectionResult`. A data composed of:
|
||||
- `winners`: A flat list of identifiers belonging to those who have won the election, usually
|
||||
ordered in some meaningful way. They are zipped with their total backing stake.
|
||||
- `assignment`: A mapping from each voter to their winner-only targets, zipped with a ration
|
||||
denoting the amount of support given to that particular target.
|
||||
|
||||
```rust
|
||||
// the winners.
|
||||
let winners = vec![(1, 100), (2, 50)];
|
||||
let assignments = vec![
|
||||
// A voter, giving equal backing to both 1 and 2.
|
||||
Assignment {
|
||||
who: 10,
|
||||
distribution: vec![(1, Perbill::from_percent(50)), (2, Perbill::from_percent(50))],
|
||||
},
|
||||
// A voter, Only backing 1.
|
||||
Assignment { who: 20, distribution: vec![(1, Perbill::from_percent(100))] },
|
||||
];
|
||||
|
||||
// the combination of the two makes the election result.
|
||||
let election_result = ElectionResult { winners, assignments };
|
||||
|
||||
```
|
||||
|
||||
The `Assignment` field of the election result is voter-major, i.e. it is from the perspective of
|
||||
the voter. The struct that represents the opposite is called a `Support`. This struct is usually
|
||||
accessed in a map-like manner, i.e. keyed vy voters, therefor it is stored as a mapping called
|
||||
`SupportMap`.
|
||||
|
||||
Moreover, the support is built from absolute backing values, not ratios like the example above.
|
||||
A struct similar to `Assignment` that has stake value instead of ratios is called an
|
||||
`StakedAssignment`.
|
||||
|
||||
|
||||
More information can be found at: https://arxiv.org/abs/2004.12990
|
||||
|
||||
|
||||
@@ -7,18 +7,19 @@ maps to an external function call. These external functions are exported by the
|
||||
and they map to the same implementation as the native calls.
|
||||
|
||||
# Using a type in a runtime interface
|
||||
|
||||
<!-- markdown-link-check-disable -->
|
||||
Any type that should be used in a runtime interface as argument or return value needs to
|
||||
implement [`RIType`]. The associated type [`FFIType`](RIType::FFIType) is the type that is used
|
||||
in the FFI function to represent the actual type. For example `[T]` is represented by an `u64`.
|
||||
The slice pointer and the length will be mapped to an `u64` value. For more information see
|
||||
this [table](#ffi-type-and-conversion). The FFI function definition is used when calling from
|
||||
the wasm runtime into the node.
|
||||
implement [`RIType`]. The associated type [`FFIType`](https:/docs.rs/sp-runtime-interface/latest/sp_runtime_interface/trait.RIType.html#associatedtype.FFIType)
|
||||
is the type that is used in the FFI function to represent the actual type. For example `[T]` is
|
||||
represented by an `u64`. The slice pointer and the length will be mapped to an `u64` value.
|
||||
For more information see this [table](https:/docs.rs/sp-runtime-interface/latest/sp_runtime_interface/#ffi-type-and-conversion).
|
||||
The FFI function definition is used when calling from the wasm runtime into the node.
|
||||
|
||||
Traits are used to convert from a type to the corresponding [`RIType::FFIType`].
|
||||
Traits are used to convert from a type to the corresponding
|
||||
[`RIType::FFIType`](https:/docs.rs/sp-runtime-interface/latest/sp_runtime_interface/trait.RIType.html#associatedtype.FFIType).
|
||||
Depending on where and how a type should be used in a function signature, a combination of the
|
||||
following traits need to be implemented:
|
||||
|
||||
<!-- markdown-link-check-enable -->
|
||||
1. Pass as function argument: [`wasm::IntoFFIValue`] and [`host::FromFFIValue`]
|
||||
2. As function return value: [`wasm::FromFFIValue`] and [`host::IntoFFIValue`]
|
||||
3. Pass as mutable function argument: [`host::IntoPreallocatedFFIValue`]
|
||||
@@ -26,7 +27,7 @@ following traits need to be implemented:
|
||||
The traits are implemented for most of the common types like `[T]`, `Vec<T>`, arrays and
|
||||
primitive types.
|
||||
|
||||
For custom types, we provide the [`PassBy`](pass_by::PassBy) trait and strategies that define
|
||||
For custom types, we provide the [`PassBy`](https://docs.rs/sp-runtime-interface/latest/sp_runtime_interface/pass_by#PassBy) trait and strategies that define
|
||||
how a type is passed between the wasm runtime and the node. Each strategy also provides a derive
|
||||
macro to simplify the implementation.
|
||||
|
||||
@@ -52,7 +53,7 @@ trait RuntimeInterface {
|
||||
```
|
||||
|
||||
For more information on declaring a runtime interface, see
|
||||
[`#[runtime_interface]`](attr.runtime_interface.html).
|
||||
[`#[runtime_interface]`](https://docs.rs/sp-runtime-interface/latest/sp_runtime_interface/attr.runtime_interface.html).
|
||||
|
||||
# FFI type and conversion
|
||||
|
||||
@@ -80,9 +81,9 @@ the host side and how they are converted into the corresponding type.
|
||||
| `[u8; N]` | `u32` | `v.as_ptr()` |
|
||||
| `*const T` | `u32` | `Identity` |
|
||||
| `Option<T>` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr() 32bit</code> |
|
||||
| [`T where T: PassBy<PassBy=Inner>`](pass_by::Inner) | Depends on inner | Depends on inner |
|
||||
| [`T where T: PassBy<PassBy=Codec>`](pass_by::Codec) | `u64`| <code>v.len() 32bit << 32 | v.as_ptr() 32bit</code> |
|
||||
| [`T where T: PassBy<PassBy=Inner>`](https://docs.rs/sp-runtime-interface/latest/sp_runtime_interface/pass_by#Inner) | Depends on inner | Depends on inner |
|
||||
| [`T where T: PassBy<PassBy=Codec>`](https://docs.rs/sp-runtime-interface/latest/sp_runtime_interface/pass_by#Codec) | `u64`| <code>v.len() 32bit << 32 | v.as_ptr() 32bit</code> |
|
||||
|
||||
`Identity` means that the value is converted directly into the corresponding FFI type.
|
||||
|
||||
License: Apache-2.0
|
||||
License: Apache-2.0
|
||||
|
||||
@@ -26,16 +26,17 @@
|
||||
//! # Using a type in a runtime interface
|
||||
//!
|
||||
//! Any type that should be used in a runtime interface as argument or return value needs to
|
||||
//! implement [`RIType`]. The associated type [`FFIType`](RIType::FFIType) is the type that is used
|
||||
//! in the FFI function to represent the actual type. For example `[T]` is represented by an `u64`.
|
||||
//! The slice pointer and the length will be mapped to an `u64` value. For more information see
|
||||
//! this [table](#ffi-type-and-conversion). The FFI function definition is used when calling from
|
||||
//! the wasm runtime into the node.
|
||||
//! implement [`RIType`]. The associated type [`FFIType`](./trait.RIType.html#associatedtype.FFIType)
|
||||
//! is the type that is used in the FFI function to represent the actual type. For example `[T]` is
|
||||
//! represented by an `u64`. The slice pointer and the length will be mapped to an `u64` value.
|
||||
//! For more information see this [table](#ffi-type-and-conversion).
|
||||
//! The FFI function definition is used when calling from the wasm runtime into the node.
|
||||
//!
|
||||
//! Traits are used to convert from a type to the corresponding [`RIType::FFIType`].
|
||||
//! Traits are used to convert from a type to the corresponding
|
||||
//! [`RIType::FFIType`](./trait.RIType.html#associatedtype.FFIType).
|
||||
//! Depending on where and how a type should be used in a function signature, a combination of the
|
||||
//! following traits need to be implemented:
|
||||
//!
|
||||
//! <!-- markdown-link-check-enable -->
|
||||
//! 1. Pass as function argument: [`wasm::IntoFFIValue`] and [`host::FromFFIValue`]
|
||||
//! 2. As function return value: [`wasm::FromFFIValue`] and [`host::IntoFFIValue`]
|
||||
//! 3. Pass as mutable function argument: [`host::IntoPreallocatedFFIValue`]
|
||||
@@ -43,7 +44,7 @@
|
||||
//! The traits are implemented for most of the common types like `[T]`, `Vec<T>`, arrays and
|
||||
//! primitive types.
|
||||
//!
|
||||
//! For custom types, we provide the [`PassBy`](pass_by::PassBy) trait and strategies that define
|
||||
//! For custom types, we provide the [`PassBy`](./pass_by#PassBy) trait and strategies that define
|
||||
//! how a type is passed between the wasm runtime and the node. Each strategy also provides a derive
|
||||
//! macro to simplify the implementation.
|
||||
//!
|
||||
@@ -69,7 +70,7 @@
|
||||
//! ```
|
||||
//!
|
||||
//! For more information on declaring a runtime interface, see
|
||||
//! [`#[runtime_interface]`](attr.runtime_interface.html).
|
||||
//! [`#[runtime_interface]`](./attr.runtime_interface.html).
|
||||
//!
|
||||
//! # FFI type and conversion
|
||||
//!
|
||||
@@ -97,8 +98,8 @@
|
||||
//! | `[u8; N]` | `u32` | `v.as_ptr()` |
|
||||
//! | `*const T` | `u32` | `Identity` |
|
||||
//! | `Option<T>` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr() 32bit</code> |
|
||||
//! | [`T where T: PassBy<PassBy=Inner>`](pass_by::Inner) | Depends on inner | Depends on inner |
|
||||
//! | [`T where T: PassBy<PassBy=Codec>`](pass_by::Codec) | `u64`| <code>v.len() 32bit << 32 | v.as_ptr() 32bit</code> |
|
||||
//! | [`T where T: PassBy<PassBy=Inner>`](./pass_by#Inner) | Depends on inner | Depends on inner |
|
||||
//! | [`T where T:PassBy<PassBy=Codec>`](./pass_by#Codec)|`u64`|<code>v.len() 32bit << 32 |v.as_ptr() 32bit</code>|
|
||||
//!
|
||||
//! `Identity` means that the value is converted directly into the corresponding FFI type.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user