Răsfoiți Sursa

validator/verification: Fix tx fee call index

parazyd 2 ani în urmă
părinte
comite
7b42b1c1e2
1 a modificat fișierele cu 7 adăugiri și 3 ștergeri
  1. 7 3
      src/validator/verification.rs

+ 7 - 3
src/validator/verification.rs

@@ -365,12 +365,16 @@ pub async fn verify_transaction(
     // Table of public keys used for signature verification
     // Table of public keys used for signature verification
     let mut sig_table = vec![];
     let mut sig_table = vec![];
 
 
+    // Index of the Fee-paying call
+    let mut fee_call_idx = 0;
+
     if verify_fee {
     if verify_fee {
         let mut found_fee = false;
         let mut found_fee = false;
         // Verify that there is a Money::FeeV1 (0x00) call in the transaction
         // Verify that there is a Money::FeeV1 (0x00) call in the transaction
-        for call in tx.calls.iter() {
+        for (call_idx, call) in tx.calls.iter().enumerate() {
             if call.data.contract_id == *MONEY_CONTRACT_ID && call.data.data[0] == 0x00 {
             if call.data.contract_id == *MONEY_CONTRACT_ID && call.data.data[0] == 0x00 {
                 found_fee = true;
                 found_fee = true;
+                fee_call_idx = call_idx;
                 break
                 break
             }
             }
         }
         }
@@ -518,8 +522,8 @@ pub async fn verify_transaction(
         // TODO: Currently this doesn't account for signatures or ZK proofs
         // TODO: Currently this doesn't account for signatures or ZK proofs
         // TODO: Currently this doesn't account for WASM host functions
         // TODO: Currently this doesn't account for WASM host functions
 
 
-        // Deserialize the first call to find the paid fee
-        let fee: u64 = match deserialize_async(&tx.calls[0].data.data[1..9]).await {
+        // Deserialize the fee call to find the paid fee
+        let fee: u64 = match deserialize_async(&tx.calls[fee_call_idx].data.data[1..9]).await {
             Ok(v) => v,
             Ok(v) => v,
             Err(e) => {
             Err(e) => {
                 error!(
                 error!(