-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Create a Basic Proving Trie for the Runtime #3881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 31 commits
d50d5e4
7f4422e
bdc0c84
da385ab
6ab4bfb
1cfb29f
3080c7b
39b0fca
599f576
a1c8886
6bde2a3
ead7951
0cac048
acfe734
45f4287
efbe1c9
cfa62ce
885fd94
18a5c2e
5e3e518
f35cacc
e6c3759
89679c3
6e853ba
00a7aa9
ffbd656
0217d0f
f20038a
f934d8d
c92bd6a
266a89b
3034aab
1ceab64
c426a65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
| # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
|
||
| title: Introduce a Generic Proving Trie | ||
|
|
||
| doc: | ||
| - audience: Runtime Dev | ||
| description: | | ||
| This PR introduces a Proving Trie object which can be used inside the runtime. This can allow | ||
| for things like airdrops where a single hash is stored on chain representing the whole airdrop | ||
| and individuals present a proof of their inclusion in the airdrop. | ||
|
|
||
| crates: | ||
| - name: sp-runtime | ||
| bump: minor | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ pub mod generic; | |
| pub mod legacy; | ||
| mod multiaddress; | ||
| pub mod offchain; | ||
| pub mod proving_trie; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not too sure if it should be part of sp-runtime crate.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a binary trie available in Substrate? Does this trie work along side child tries?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the proof is to be run on child trie, there is no choice but to use this trie indeed.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I name this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not too sure anymore what was my point 🤦 |
||
| pub mod runtime_logger; | ||
| mod runtime_string; | ||
| #[cfg(feature = "std")] | ||
|
|
@@ -103,6 +104,8 @@ pub use crate::runtime_string::*; | |
| // Re-export Multiaddress | ||
| pub use multiaddress::MultiAddress; | ||
|
|
||
| use proving_trie::TrieError; | ||
|
|
||
| /// Re-export these since they're only "kind of" generic. | ||
| pub use generic::{Digest, DigestItem}; | ||
|
|
||
|
|
@@ -592,6 +595,8 @@ pub enum DispatchError { | |
| Unavailable, | ||
| /// Root origin is not allowed. | ||
| RootNotAllowed, | ||
| /// An error with tries. | ||
| Trie(TrieError), | ||
| } | ||
|
|
||
| /// Result of a `Dispatchable` which contains the `DispatchResult` and additional information about | ||
|
|
@@ -697,6 +702,12 @@ impl From<ArithmeticError> for DispatchError { | |
| } | ||
| } | ||
|
|
||
| impl From<TrieError> for DispatchError { | ||
| fn from(e: TrieError) -> DispatchError { | ||
| Self::Trie(e) | ||
| } | ||
| } | ||
|
|
||
| impl From<&'static str> for DispatchError { | ||
| fn from(err: &'static str) -> DispatchError { | ||
| Self::Other(err) | ||
|
|
@@ -721,6 +732,7 @@ impl From<DispatchError> for &'static str { | |
| Corruption => "State corrupt", | ||
| Unavailable => "Resource unavailable", | ||
| RootNotAllowed => "Root not allowed", | ||
| Trie(e) => e.into(), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -768,6 +780,10 @@ impl traits::Printable for DispatchError { | |
| Corruption => "State corrupt".print(), | ||
| Unavailable => "Resource unavailable".print(), | ||
| RootNotAllowed => "Root not allowed".print(), | ||
| Trie(e) => { | ||
| "Trie error: ".print(); | ||
| <&'static str>::from(*e).print(); | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.