Conversation
Files with rust version - Cargo.toml - rust-toolchain.toml - README.md
aeddf0e to
c46740e
Compare
Patches in Cargo.toml does not support features and default-features.
f61f67d to
c2a2393
Compare
There was a problem hiding this comment.
Great improvment!
added minor comments.
also
fn verify_unique_spent_nullifiers(bundle: &Bundle<Authorized, i64, OrchardZSA>) -> bool {
let mut seen = HashSet::new();
bundle
.actions()
.iter()
.all(|action| seen.insert(action.nullifier().to_bytes()))
}to simplify
| .take(MIN_ACTIONS.saturating_sub(outputs.len())), | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
consider
if hm.len() == 1 {
if let Some((spends, outputs)) = hm.get_mut(&AssetBase::native()) {
let pad_spends = MIN_ACTIONS.saturating_sub(spends.len());
let pad_outputs = MIN_ACTIONS.saturating_sub(outputs.len());
spends.extend(iter::repeat_with(|| (SpendInfo::dummy(AssetBase::native(), rng), None)).take(pad_spends));
outputs.extend(iter::repeat_with(|| (OutputInfo::dummy(rng, AssetBase::native()), None)).take(pad_outputs));
}
}There was a problem hiding this comment.
or even more general
// If native asset exists, pad spends and outputs to meet the minimum action requirements.
if let Some((spends, outputs)) = hm.get_mut(&AssetBase::native()) {
let pad_spends = MIN_ACTIONS.saturating_sub(spends.len());
let pad_outputs = MIN_ACTIONS.saturating_sub(outputs.len());
spends.extend(iter::repeat_with(|| (SpendInfo::dummy(AssetBase::native(), rng), None)).take(pad_spends));
outputs.extend(iter::repeat_with(|| (OutputInfo::dummy(rng, AssetBase::native()), None)).take(pad_outputs));
}it is 1 only if MIN_ACTIONS is 2. this one captures bigger values for MIN_ACTIONS
There was a problem hiding this comment.
I kept the first suggested version
There was a problem hiding this comment.
will it work for MIN_ACTIONS > 2 (the entire function)?
There was a problem hiding this comment.
As discussed offline, it will work when MIN_ACTIONS > 2.
I added some comments to clarify the meaning of the two if
|
|
||
| assert_eq!( | ||
| bundle.actions.head.verify(&bundle.ik), | ||
| Err(AssetBaseCannotBeIdentityPoint) |
There was a problem hiding this comment.
ideally we have one test that gets this error. in this version we have none.
There was a problem hiding this comment.
As explained in the last item of the PR description, it is now impossible to test this error.
To test this error, we have to choose an ik and an asset_desc_hash such that the AssetBase derived from them is equal to the identity point.
There was a problem hiding this comment.
The drawback of the modification in the verify function is the fact that it is no longer possible to test AssetBaseCannotBeIdentityPoint error (see previous comment).
The advantage is the fact that the verify function (line 167) is now simpler and faster.
| } | ||
|
|
||
| (merkle_path1.into(), merkle_path2.into(), root.into()) | ||
| (merkle_paths, root.into()) |
There was a problem hiding this comment.
for let (mut awaiting_nullifier_bundle, _) = IssueBundle::new( line 156
mut not needed.
There was a problem hiding this comment.
The mut is required for the add_recipient inside the assert! line 166.
There was a problem hiding this comment.
Another option is to remove the mut line 156 and clone awaiting_nullifier_bundle inside the assert line 166.
There was a problem hiding this comment.
i see. both are acceptable.
PaulLaux
left a comment
There was a problem hiding this comment.
Approved pending #178 (comment)
IssueAction::verify(...)by moving theAssetBaseCannotBeIdentityPointcheck outside the loop.action_verify_invalid_for_asset_base_as_identity,issue_bundle_cannot_be_signed_with_asset_base_identity_pointandissue_bundle_verify_fail_asset_base_identity_pointtests because it is now very difficult to create a test for this case. To create a test for this case, we have to choose anikand anasset_desc_hashsuch that theAssetBasederived from them is equal to the identity point.