-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add proof type #245
Merged
Merged
Add proof type #245
Changes from 3 commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
1853d5a
Add proof type
MavenRain a7f129e
Remove deprecation warnings
MavenRain 587d080
Clippy error
MavenRain b936af9
Rename Proof to ProofOperation
MavenRain ef86b26
Introduce context type
MavenRain d0b6455
Introduce concept of Context to many-module macros
MavenRain 98415a8
Want to be able to add context to the balance call but can't
MavenRain e0f07ad
Fix macro for context expansion
MavenRain 27e611f
Rectified merge with main branch
MavenRain cc04eef
Only look for proof transmission if requested
MavenRain aef8b1f
Add convenience methods to Context
MavenRain 4996045
Add context to mint and burn functions
MavenRain bdc5cf9
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain b4c9b15
Move toward collecting proof from context in ProofOperation form
MavenRain 7a8a46a
Move toward collecting proof from context in ProofOperation form
MavenRain a15e9f9
Relax iterator requirement to something implementing IntoIterator
MavenRain 576f50d
Now working with fallible attribute list after CborAny decoding
MavenRain 493e43f
Remove unneeded method
MavenRain cab84be
Post monorepo merge of many-framework portion of PR
MavenRain 248b1bd
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain e9e9ae0
Proving store concept
MavenRain 15d24ba
Proving store changes moved to separate branch
MavenRain 16a5577
Refactor get_multiple_balances
MavenRain 1a41d0c
Add ability to supply request attribute
MavenRain c55748f
Print AttributeSet from the response when many message is sent
MavenRain a76a93e
Too many arguments warnings
MavenRain 99c4d6c
Additional Clippy warning overcome
MavenRain b01b76b
Rectify merge with main branch
MavenRain 7865fb0
Revert staging settings in PR
MavenRain dd13ef6
Mint proving and fix bats test fail
MavenRain 609627c
cargo fmt
MavenRain 09e109b
Burn proving
MavenRain 93114cb
Remove commented code
MavenRain de7e7e6
Add context to leddger.info call
MavenRain 2df8976
ledger.info proving
MavenRain d963f8f
Add context to token send
MavenRain 77cb0f1
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain 266b939
Fixes to unbreak 3 feature tests
MavenRain b2b00ba
Complete token send proving
MavenRain 1302cec
Verify acl refactor to expose keys
MavenRain 355e5ac
Get next subresource surfaces keys
MavenRain 513b82c
Update symbols returns keys
MavenRain 54a3f00
create token surfaces keys
MavenRain 48f4960
Token create proving
MavenRain 389a661
Surface key from get-owner
MavenRain 943de64
Update token method propagates keys
MavenRain e1e2690
Cargo lock changes
MavenRain 03b2e46
Token update proving
MavenRain 00d778a
Add/remove extended info keys surfaced from storage methods
MavenRain 3f8304f
Try to clear weird CI compiler error
MavenRain 2d9a4e3
Adding context to token extended info calls
MavenRain 566e1a4
Token extended info proving
MavenRain d26017b
Keys needed for idstore
MavenRain 05fd23e
idstore store keys added
MavenRain 705f5f5
Context added to data interface
MavenRain b55f37b
Data proving
MavenRain 0980a2a
TODO for account endpoints
MavenRain bb80056
Fix enum variant used in round-trip decoding test
MavenRain 83f7cfe
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain 8e25cef
Account creation proving
MavenRain 35c3b79
Account creation proving
MavenRain 71873b2
Small refactor
MavenRain 747b211
rectified merge with main
MavenRain dd2b70a
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain 88e62d6
KV store account proof
MavenRain 84d4adc
Up to KvStore set description for proving
MavenRain a7f90c0
Account proving
MavenRain e2873c4
Rectified merge with main branch
MavenRain ad9c5b8
Refactor attribute to proof parameter in CLI and refactor return type…
MavenRain 5958211
Remove proof functionality from send command
MavenRain 5163736
Remove proof functionality from mint/burn
MavenRain c983f14
TryFrom for Proof to CborAny
MavenRain 4c987de
Remove proof support from ledger token command calls
MavenRain 50aca99
Remove proof functionality from account commands
MavenRain fecb5a9
Constructor for Context made
MavenRain 09842be
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain 692bba2
Default proof command line value
MavenRain a11eb34
Overcome clippy error
MavenRain 18fc554
Use default clap option for proof boolean
MavenRain 7e5d801
Try to fix bats error, attempt 1
MavenRain 373c55b
Refactoring proof argument calculation in main
MavenRain 8dc5d19
Pattern-match option for proof argument calculation
MavenRain a3f668f
Prefer collect to from_iter
MavenRain bff164c
Prefer collect to from_iter, second change
MavenRain 0832ad4
Prefer collect to from_iter, third change
MavenRain c4e575b
Merge https://github.com/liftedinit/many-rs into oobi/proof
MavenRain 230050d
Fix lock files
MavenRain 411b8ad
Some bazel changes
MavenRain 728cb06
Format changes made
MavenRain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
use { | ||
derive_more::{From, Into}, | ||
minicbor::{ | ||
decode, | ||
encode::{Error, Write}, | ||
Decode, Decoder, Encode, Encoder, | ||
}, | ||
}; | ||
|
||
#[derive(Clone, Debug, Eq, From, Into, PartialEq)] | ||
pub struct Key(Vec<u8>); | ||
|
||
#[derive(Clone, Debug, Eq, From, Into, PartialEq)] | ||
pub struct Value(Vec<u8>); | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub enum Proof { | ||
Child, | ||
KeyValueHash(Vec<u8>), | ||
KeyValuePair(Key, Value), | ||
NodeHash(Vec<u8>), | ||
Parent, | ||
} | ||
|
||
impl<C> Encode<C> for Proof { | ||
fn encode<W: Write>(&self, e: &mut Encoder<W>, _: &mut C) -> Result<(), Error<W::Error>> { | ||
use Proof::{Child, KeyValueHash, KeyValuePair, NodeHash, Parent}; | ||
match &self { | ||
Child => e.u8(0x11), | ||
KeyValueHash(hash) => e.array(2).and_then(|e| e.u8(1)).and_then(|e| e.bytes(hash)), | ||
KeyValuePair(Key(key), Value(value)) => e | ||
.array(3) | ||
.and_then(|e| e.u8(3)) | ||
.and_then(|e| e.bytes(key)) | ||
.and_then(|e| e.bytes(value)), | ||
NodeHash(hash) => e.array(2).and_then(|e| e.u8(2)).and_then(|e| e.bytes(hash)), | ||
Parent => e.u8(0x10), | ||
} | ||
.map(|_| ()) | ||
} | ||
} | ||
|
||
impl<'d, C> Decode<'d, C> for Proof { | ||
fn decode(d: &mut Decoder<'d>, _: &mut C) -> Result<Self, decode::Error> { | ||
use { | ||
minicbor::data::Type::{ | ||
Array, ArrayIndef, Bool, Break, Bytes, BytesIndef, Int, Map, MapIndef, Null, | ||
Simple, String, StringIndef, Tag, Undefined, Unknown, F16, F32, F64, I16, I32, I64, | ||
I8, U16, U32, U64, U8, | ||
}, | ||
Proof::{Child, KeyValueHash, KeyValuePair, NodeHash, Parent}, | ||
}; | ||
d.datatype().and_then(|datatype| match datatype { | ||
Array | ArrayIndef => match d.array() { | ||
Err(_) | Ok(None) => Err(decode::Error::message( | ||
"Error parsing array type into array", | ||
)), | ||
Ok(Some(array_length)) if array_length == 2 => { | ||
d.u8().and_then(|value| match value { | ||
1 => d.bytes().map(|hash| KeyValueHash(hash.to_vec())), | ||
2 => d.bytes().map(|hash| NodeHash(hash.to_vec())), | ||
variant => Err(decode::Error::unknown_variant(variant.into())), | ||
}) | ||
} | ||
Ok(Some(array_length)) if array_length == 3 => { | ||
d.u8().and_then(|_| d.bytes()).and_then(|key| { | ||
d.bytes() | ||
.map(|value| KeyValuePair(key.to_vec().into(), value.to_vec().into())) | ||
}) | ||
} | ||
Ok(Some(array_length)) => Err(decode::Error::message(format!( | ||
"Unexpected array size {array_length}" | ||
))), | ||
}, | ||
U8 => d.u8().and_then(|value| match value { | ||
0x10 => Ok(Parent), | ||
0x11 => Ok(Child), | ||
variant => Err(decode::Error::unknown_variant(variant.into())), | ||
}), | ||
Bool | Break | Bytes | BytesIndef | F16 | F32 | F64 | I8 | I16 | I32 | I64 | Int | ||
| Map | MapIndef | Null | Simple | String | StringIndef | Tag | U16 | U32 | U64 | ||
| Undefined | Unknown(_) => Err(decode::Error::message("Expected either array or u8")), | ||
}) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::Proof; | ||
#[test] | ||
fn round_trip_parent() -> Result<(), ()> { | ||
assert_eq!( | ||
minicbor::decode::<Proof>(minicbor::to_vec(Proof::Parent).map_err(|_| ())?.as_slice()) | ||
.map_err(|_| ())?, | ||
Proof::Parent | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn round_trip_child() -> Result<(), ()> { | ||
assert_eq!( | ||
minicbor::decode::<Proof>(minicbor::to_vec(Proof::Child).map_err(|_| ())?.as_slice()) | ||
.map_err(|_| ())?, | ||
Proof::Child | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn round_trip_key_value_hash() -> Result<(), ()> { | ||
let key_value_hash = Proof::KeyValueHash(vec![1, 2, 3]); | ||
assert_eq!( | ||
minicbor::decode::<Proof>( | ||
minicbor::to_vec(key_value_hash.clone()) | ||
.map_err(|_| ())? | ||
.as_slice() | ||
) | ||
.map_err(|_| ())?, | ||
key_value_hash | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn round_trip_node_hash() -> Result<(), ()> { | ||
let node_hash = Proof::KeyValueHash(vec![1, 2, 3]); | ||
assert_eq!( | ||
minicbor::decode::<Proof>( | ||
minicbor::to_vec(node_hash.clone()) | ||
.map_err(|_| ())? | ||
.as_slice() | ||
) | ||
.map_err(|_| ())?, | ||
node_hash | ||
); | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn round_trip_key_value_pair() -> Result<(), ()> { | ||
let key_value_pair = Proof::KeyValuePair(vec![1, 2, 3].into(), vec![4, 5, 6].into()); | ||
assert_eq!( | ||
minicbor::decode::<Proof>( | ||
minicbor::to_vec(key_value_pair.clone()) | ||
.map_err(|_| ())? | ||
.as_slice() | ||
) | ||
.map_err(|_| ())?, | ||
key_value_pair | ||
); | ||
Ok(()) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These warnings were triggering on builds. Either these should be removed, or they should be re-added along with the remedies for the places where they are currently being used.