Quellcode durchsuchen

validator/verification: Modify tx fee call location

parazyd vor 2 Jahren
Ursprung
Commit
d891d2e756
1 geänderte Dateien mit 14 neuen und 3 gelöschten Zeilen
  1. 14 3
      src/validator/verification.rs

+ 14 - 3
src/validator/verification.rs

@@ -360,7 +360,18 @@ pub async fn verify_transaction(
 
     if verify_fee {
         // Verify that the first call is the transaction fee and that it has no parents or children.
-        if tx.calls[0].data.contract_id != *MONEY_CONTRACT_ID || tx.calls[0].data.data[0] != 0x00 {
+        let Some(fee_call_parent_index) = tx.calls[0].parent_index else {
+            error!(
+                target: "validator::verification::verify_transaction",
+                "[VALIDATOR] Fee call does not have parent index",
+            );
+            return Err(TxVerifyFailed::InvalidFee.into())
+        };
+
+        if fee_call_parent_index != tx.calls.len() - 1 ||
+            tx.calls[0].data.contract_id != *MONEY_CONTRACT_ID ||
+            tx.calls[0].data.data[0] != 0x00
+        {
             error!(
                 target: "validator::verification::verify_transaction",
                 "[VALIDATOR] First tx call is not Money::Fee",
@@ -368,10 +379,10 @@ pub async fn verify_transaction(
             return Err(TxVerifyFailed::MissingFee.into())
         }
 
-        if tx.calls[0].parent_index.is_some() || !tx.calls[0].children_indexes.is_empty() {
+        if !tx.calls[0].children_indexes.is_empty() {
             error!(
                 target: "validator::verification::verify_transaction",
-                "[VALIDATOR] Fee call invalid (has parent/children)",
+                "[VALIDATOR] Fee call invalid (has children)",
             );
             return Err(TxVerifyFailed::InvalidFee.into())
         }