Przeglądaj źródła

validator: renamed GasData fields

skoupidi 1 rok temu
rodzic
commit
233407d001
3 zmienionych plików z 20 dodań i 18 usunięć
  1. 1 1
      src/validator/consensus.rs
  2. 11 9
      src/validator/fees.rs
  3. 8 8
      src/validator/verification.rs

+ 1 - 1
src/validator/consensus.rs

@@ -784,7 +784,7 @@ impl Fork {
 
             // Update accumulated total gas
             total_gas_used += tx_gas_used;
-            total_gas_paid += gas_data.gas_paid;
+            total_gas_paid += gas_data.paid;
 
             // Push the tx hash into the unproposed transactions vector
             unproposed_txs.push(unproposed_tx);

+ 11 - 9
src/validator/fees.rs

@@ -100,19 +100,21 @@ pub fn circuit_gas_use(zkbin: &ZkBinary) -> u64 {
 /// resource consumption across different transactions.
 #[derive(Default, Clone, Eq, PartialEq, Debug, SerialEncodable, SerialDecodable)]
 pub struct GasData {
-    pub gas_paid: u64,
-    pub wasm_gas_used: u64,
-    pub zk_circuit_gas_used: u64,
-    pub signature_gas_used: u64,
-    pub deploy_gas_used: u64,
+    /// Transaction paid fee
+    pub paid: u64,
+    /// Wasm calls gas consumption
+    pub wasm: u64,
+    /// ZK circuits gas consumption
+    pub zk_circuits: u64,
+    /// Signature fee
+    pub signatures: u64,
+    /// Contract deployment gas
+    pub deployments: u64,
 }
 
 impl GasData {
     /// Calculates the total gas used by summing all individual gas usage fields.
     pub fn total_gas_used(&self) -> u64 {
-        self.wasm_gas_used +
-            self.zk_circuit_gas_used +
-            self.signature_gas_used +
-            self.deploy_gas_used
+        self.wasm + self.zk_circuits + self.signatures + self.deployments
     }
 }

+ 8 - 8
src/validator/verification.rs

@@ -696,7 +696,7 @@ pub async fn verify_transaction(
 
             let deploy_gas_used = deploy_runtime.gas_used();
             debug!(target: "validator::verification::verify_transaction", "The gas used for deployment call {:?} of transaction {}: {}", call, tx_hash, deploy_gas_used);
-            gas_data.deploy_gas_used += deploy_gas_used;
+            gas_data.deployments += deploy_gas_used;
         }
 
         // At this point we're done with the call and move on to the next one.
@@ -705,13 +705,13 @@ pub async fn verify_transaction(
         debug!(target: "validator::verification::verify_transaction", "The gas used for WASM call {:?} of transaction {}: {}", call, tx_hash, wasm_gas_used);
 
         // Append the used wasm gas
-        gas_data.wasm_gas_used += wasm_gas_used;
+        gas_data.wasm += wasm_gas_used;
     }
 
     // The signature fee is tx_size + fixed_sig_fee * n_signatures
-    gas_data.signature_gas_used = (PALLAS_SCHNORR_SIGNATURE_FEE * tx.signatures.len() as u64) +
+    gas_data.signatures = (PALLAS_SCHNORR_SIGNATURE_FEE * tx.signatures.len() as u64) +
         serialize_async(tx).await.len() as u64;
-    debug!(target: "validator::verification::verify_transaction", "The gas used for signature of transaction {}: {}", tx_hash, gas_data.signature_gas_used);
+    debug!(target: "validator::verification::verify_transaction", "The gas used for signature of transaction {}: {}", tx_hash, gas_data.signatures);
 
     // The ZK circuit fee is calculated using a function in validator/fees.rs
     for zkbin in circuits_to_verify.iter() {
@@ -719,7 +719,7 @@ pub async fn verify_transaction(
         debug!(target: "validator::verification::verify_transaction", "The gas used for ZK circuit in namespace {} of transaction {}: {}", zkbin.namespace, tx_hash, zk_circuit_gas_used);
 
         // Append the used zk circuit gas
-        gas_data.zk_circuit_gas_used += zk_circuit_gas_used;
+        gas_data.zk_circuits += zk_circuit_gas_used;
     }
 
     // Store the calculated total gas used to avoid recalculating it for subsequent uses
@@ -748,10 +748,10 @@ pub async fn verify_transaction(
             );
             return Err(TxVerifyFailed::InsufficientFee.into())
         }
-        debug!(target: "validator::verification::verify_transaction", "The gas paid for transaction {}: {}", tx_hash, gas_data.gas_paid);
+        debug!(target: "validator::verification::verify_transaction", "The gas paid for transaction {}: {}", tx_hash, gas_data.paid);
 
         // Store paid fee
-        gas_data.gas_paid = fee;
+        gas_data.paid = fee;
     }
 
     // When we're done looping and executing over the tx's contract calls and
@@ -943,7 +943,7 @@ pub async fn verify_transactions(
 
         // Update accumulated total gas
         total_gas_used += tx_gas_used;
-        total_gas_paid += gas_data.gas_paid;
+        total_gas_paid += gas_data.paid;
     }
 
     if !erroneous_txs.is_empty() {