-
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
Add proof type #245
Conversation
src/many-migration/src/lib.rs
Outdated
@@ -554,7 +554,6 @@ impl<'a, T, E, IDX: AsRef<str>> Index<IDX> for MigrationSet<'a, T, E> { | |||
} | |||
|
|||
/// Kept for backward compatibility. | |||
#[deprecated = "Should use MigrationSet::load() instead."] |
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.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #245 +/- ##
==========================================
- Coverage 73.33% 73.17% -0.16%
==========================================
Files 175 177 +2
Lines 22715 23171 +456
==========================================
+ Hits 16657 16956 +299
- Misses 6058 6215 +157
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
First round of reviews.
Can you also add an issue where we have proper Proof tree algebra and can just pass the context around and collect keys as we go instead of returning them everywhere? Should simplify the code.
src/many-protocol/src/context.rs
Outdated
} | ||
} | ||
|
||
impl From<Context> for Cow<'_, Context> { |
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.
Cow
should support Into
or From
already, no? Also, why is this necessary?
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.
@hansl I'm going to remove this because I thought I would need this flexibility at the beginning of writing this PR but then quickly discovered that I only needed to ever move a single Context object between calls. For the record, though, I don't believe that Cow
comes with automatic From/Into
support except for a few specific cases. For user-defined types, one must define From
for Cow
support.
}) | ||
.collect::<Result<Vec<_>, _>>() | ||
}) | ||
.map_err(|error| ManyError::unknown(error.to_string())) |
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.
.map_err(|error| ManyError::unknown(error.to_string())) | |
.map_err(ManyError::unknown) |
)?; | ||
Ok(()) | ||
self.module_impl | ||
.send( |
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.
Proofs on a command (like send
or mint
) are senseless as they are executed in order and the root hash is being updated as we go through the block. So you can't actually use the proof for anything, really.
We should just return proofs on queries, wdyt?
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.
I think this makes sense. I can remove proof functionality from send
and mint
.
self.storage | ||
.prove_state(context, keys) | ||
.map(|error| ManyError::unknown(error.to_string())) | ||
.map(Err) | ||
.unwrap_or(Ok(())) | ||
.map(|_| account::CreateReturn { id }) |
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.
This should simplify with the other changes to prove_state
below to:
self.storage | |
.prove_state(context, keys) | |
.map(|error| ManyError::unknown(error.to_string())) | |
.map(Err) | |
.unwrap_or(Ok(())) | |
.map(|_| account::CreateReturn { id }) | |
self.storage.prove_state(context, keys)?; | |
Ok(account::CreateReturn { id }) |
Here and everywhere.
src/many-modules/src/_9_account.rs
Outdated
@@ -464,50 +465,55 @@ pub type AddFeaturesReturn = EmptyReturn; | |||
#[cfg_attr(test, mockall::automock)] | |||
pub trait AccountModuleBackend: Send { | |||
/// Create an account. | |||
fn create(&mut self, sender: &Address, args: CreateArgs) -> Result<CreateReturn, ManyError>; | |||
fn create(&mut self, sender: &Address, args: CreateArgs, context: Context) -> Result<CreateReturn, ManyError>; |
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.
Commands (that have mut self
) don't need to return a proof and cannot actually build a usable one.
src/many-protocol/src/context.rs
Outdated
} | ||
} | ||
|
||
impl From<(RequestMessage, Sender<ProofResult>)> for Context { |
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.
Additional; Can you make a proper new
method instead of Into
?
|
… of prove method of context
@@ -200,7 +200,7 @@ struct MessageOpt { | |||
data: Option<String>, | |||
|
|||
#[clap(long)] | |||
attribute: Option<u32>, | |||
proof: Option<bool>, |
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.
Doesn't have to be Option<bool>
, just set default value.
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.
OK
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.
Sorry, I can make a suggestion :) I was going quick through the PR
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.
Also noted that there's a missing description for this flag.
/// Request a proof of the value. This may cause an error if the server
/// does not support proofs, and might not work on all endpoints. Consult
/// the specification for more information.
#[clap(long, default_value = "false")]
proof: bool,
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.
Ah . . . I hadn't done it this way, but will now
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.
Done
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.
Assuming the proof
flag is properly updated, LGTM.
The proof type will be used to construct the response attribute arguments for proofs in many-framework where proofs are requested (via attribute 3).
Notes: