Skip to content

Commit

Permalink
Merge pull request ProvableHQ#1486 from AleoHQ/feat/split-fee
Browse files Browse the repository at this point in the history
Remove fee check for `credits.aleo/split` calls
  • Loading branch information
howardwu authored Apr 25, 2023
2 parents 0c16290 + 2f224b3 commit 6678175
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 22 additions & 0 deletions synthesizer/src/block/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ impl<N: Network> Transaction<N> {
// Otherwise, return 'false'.
false
}

/// Returns `true` if this is a `split` transaction.
#[inline]
pub fn is_split(&self) -> bool {
// Case 1 - The transaction contains 1 transition, which calls 'credits.aleo/split'.
if let Self::Execute(_, execution, _) = self {
// Ensure there is 1 transition.
if execution.len() == 1 {
// Retrieve the transition.
if let Ok(transition) = execution.get(0) {
// Check if it calls 'credits.aleo/split'.
if transition.program_id().to_string() == "credits.aleo"
&& transition.function_name().to_string() == "split"
{
return true;
}
}
}
}
// Otherwise, return 'false'.
false
}
}

/// A helper enum for iterators and consuming iterators over a transaction.
Expand Down
5 changes: 3 additions & 2 deletions synthesizer/src/vm/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
if let Err(error) = Transaction::check_execution_size(execution) {
bail!("Invalid transaction size (execution): {error}");
}
// Ensure the fee is present, if the transaction is not a coinbase.
if !transaction.is_coinbase() && fee.is_none() {
// TODO (raychu86): Remove `is_split` check once batch executions are supported.
// Ensure the fee is present, if the transaction is not a coinbase or split.
if !transaction.is_coinbase() && !transaction.is_split() && fee.is_none() {
bail!("Transaction is missing a fee (execution)");
}
// Verify the fee.
Expand Down

0 comments on commit 6678175

Please sign in to comment.