Conversation
feat: init nix flake
feat: add airdrop functionality
feat: initialize airdrop storage
feat: implement sapling verifier
feat: implement orchard verifier
feat: track airdrop nullifiers
feat: cv binding
chore: cargo fmt
feat: implement signature verification
chore: bump default event wait time
| &Address::Internal(InternalAddress::Airdrop), | ||
| token_addr, | ||
| &message.target, | ||
| Amount::from_u64(message.amount * ZAIR_SCALING_FACTOR), |
There was a problem hiding this comment.
This may wrap, consider using checked_mul or saturating_mul, or at least comment on why this is always safe.
There was a problem hiding this comment.
Changed to use Amount::from_u128 instead and casting amount before scaling.
| @@ -0,0 +1,126 @@ | |||
| //! Sapling VP related functions. | |||
There was a problem hiding this comment.
this file is almost identical to orchard.rs. Is it not possible to de-dup this (trait or generic helper)?
There was a problem hiding this comment.
Yes, this is something I would like to do eventually too, but it's not very easy to do in the current state with ZAIR. Postponing this for now.
| } | ||
|
|
||
| /// Sapling configuration storage keys. | ||
| pub mod sapling { |
There was a problem hiding this comment.
The sapling and orchard modules are nearly identical. Can this not be de-duplicated?
There was a problem hiding this comment.
Keeping the module prefixes, but added helper function to generate airdrop keys.
|
|
||
| /// Gets a key for the Sapling verifying key storage. | ||
| pub fn verifying_key() -> storage::Key { | ||
| storage::Key::from(ADDRESS.to_db_key()) |
There was a problem hiding this comment.
extract this duplicated code into a helper function.
| { | ||
| // Read verifying key from storage. | ||
| let vk_bytes: Vec<u8> = ctx | ||
| .read_bytes_post(&sapling_key::verifying_key())? |
There was a problem hiding this comment.
claude says all these should be read_bytes_pre, I can't verify this claim though. @mikdk
There was a problem hiding this comment.
Yeah, good catch. It definitely used to be read_bytes_pre, wonder when that happened 😄
| claim_data, | ||
| }) = action | ||
| { | ||
| if !verifiers.contains(&target) { |
| // Check if airdrop nullifiers have already been used. | ||
| check_airdrop_nullifiers( | ||
| ctx, | ||
| &claim_data, |
|
|
||
| /// Sapling configuration storage keys. | ||
| pub mod sapling { | ||
| use super::*; |
|
|
||
| /// Orchard configuration storage keys. | ||
| pub mod orchard { | ||
| use super::*; |
| CTX: VpEnv<'ctx> + namada_tx::action::Read<Err = Error>, | ||
| { | ||
| /// Run the validity predicate | ||
| pub fn validate_tx( |
There was a problem hiding this comment.
Clippy wants a # Errors doc section he+e.
ref: address review comments
No description provided.