Skip to content

Commit 0e222f3

Browse files
committed
brush up docs
1 parent e77643f commit 0e222f3

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

tuxedo-core/src/constraint_checker.rs

+13-17
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,25 @@
66
//! Constraint Checkers can be used to codify the laws of a monetary system, a chemistry or physics simulation,
77
//! NFT kitties, public elections and much more.
88
//!
9-
//! By far the most common and most important way to write a constraint checker is with the `SimpleConstraintChecker`
10-
//! trait. It provides a single method called `check` which determines whether the relationship between the inputs
9+
//! The primary way for developers to write a constraint checker is with the `SimpleConstraintChecker`
10+
//! trait. It provides a method called `check` which determines whether the relationship between the inputs
1111
//! and outputs (and peeks) is valid. For example making sure no extra money was created, or making sure the chemical
1212
//! reaction balances.
1313
//!
1414
//! ## Inherents
1515
//!
1616
//! If you need to tap in to [Substrate's inherent system](https://docs.substrate.io/learn/transaction-types/#inherent-transactions)
17-
//! you may choose to implement the `ConstraintCheckerWithInherent` trait instead of the simple one. This trait is more complex
18-
//! but if you really need an inherent, it is required. Make sure you know what you are doing before
19-
//! you start writing an inherent.
17+
//! you may choose to also implement the `InherentHooks` trait for the same type that implements `SimpleConstraintChecker`.
18+
//! When installing a constraint checker in your runtime, make sure to wrap it with the `InherentAdapter` type.
19+
//! See the `inherents` module for more details.
2020
//!
2121
//! ## Constraint Checker Internals
2222
//!
2323
//! One of Tuxedo's killer features is its ability to aggregating pieces recursively.
2424
//! To achieve this we have to consider that many intermediate layers in the aggregation tree
2525
//! will have multiple inherent types. For this reason, we provide a much more flexible interface
26-
//! that the aggregation macro can use.
27-
//!
28-
//! The current design is based on a chain of blanket implementations. Each trait has a blanket
29-
//! impl for the next more complex one.
30-
//!
31-
//! `SimpleConstraintChecker` -> `ConstraintCheckerWithInherent` -> ConstraintChecker
32-
//! https://github.com/rust-lang/rust/issues/42721
26+
//! that the aggregation macro can use called `ConstraintChecker`. Do not implement `ConstraintChecker`
27+
//! directly.
3328
3429
use sp_core::H256;
3530
use sp_inherents::{CheckInherentsResult, InherentData};
@@ -58,15 +53,16 @@ pub trait SimpleConstraintChecker: Debug + Encode + Decode + Clone {
5853
) -> Result<TransactionPriority, Self::Error>;
5954
}
6055

61-
/// A single constraint checker that a transaction can choose to call. Checks whether the input
62-
/// and output data from a transaction meets the codified constraints.
56+
/// The raw and fully powerful `ConstraintChecker` interface used by the
57+
/// Tuxedo Executive.
6358
///
64-
/// You should never manually write a body to this function.
59+
/// You should never manually manually implement this trait.
6560
/// If you are:
66-
/// * Working on an inherent constraint checker -> Rely on the default body.
6761
/// * Working on a simple non-inherent constraint checker -> Use the `SimpleConstraintChecker` trait instead
6862
/// and rely on its blanket implementation.
69-
/// * Considering an aggregate constraint checker which is part inherent, part not -> let the macro handle it for you.
63+
/// * Working on an inherent constraint checker -> Implement `SimpleConstraintChecker` and `InherentHooks` and use the
64+
/// `InherentAdapter` wrapper type.
65+
/// * Considering an aggregate constraint checker that is part inherent, part not -> let the macro handle it for you.
7066
///
7167
/// If you are trying to implement some complex inherent logic that requires the interaction of
7268
/// multiple inherents, or features a variable number of inherents in each block, you might be

tuxedo-core/src/inherents.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ pub trait InherentHooks: SimpleConstraintChecker + Sized {
126126

127127
/// An adapter type to declare, at the runtime level, that Tuxedo pieces provide custom inherent hooks.
128128
///
129-
/// This adapter type satisfies the executive's expectations by implementing both `SimpleConstraintChecker`,
130-
/// and `InherentInternal`. The constraint checker just plumbs straight through to the underlying type.
129+
/// This adapter type satisfies the executive's expectations by implementing both `ConstraintChecker`.
131130
/// The inherent logic checks to be sure that exactly one inherent is present before plumbing through to
132-
/// the underlying `Tuxedo Inherent` implementation.
131+
/// the underlying `TuxedoInherent` implementation.
133132
///
134133
/// This type should encode exactly like the inner type.
135134
#[derive(

0 commit comments

Comments
 (0)