Jelajahi Sumber

contract/consensus: Don't check signature in StakeV1, it's already checked in Money.

parazyd 3 tahun lalu
induk
melakukan
01b6b6b1d9

+ 7 - 4
src/contract/consensus/src/entrypoint/stake_v1.rs

@@ -25,7 +25,7 @@ use darkfi_money_contract::{
     MONEY_CONTRACT_COIN_ROOTS_TREE, MONEY_CONTRACT_NULLIFIERS_TREE,
     MONEY_CONTRACT_COIN_ROOTS_TREE, MONEY_CONTRACT_NULLIFIERS_TREE,
 };
 };
 use darkfi_sdk::{
 use darkfi_sdk::{
-    crypto::{pasta_prelude::*, ContractId, MerkleNode, CONSENSUS_CONTRACT_ID, MONEY_CONTRACT_ID},
+    crypto::{pasta_prelude::*, ContractId, MerkleNode, PublicKey, MONEY_CONTRACT_ID},
     db::{db_contains_key, db_lookup, db_set},
     db::{db_contains_key, db_lookup, db_set},
     error::{ContractError, ContractResult},
     error::{ContractError, ContractResult},
     merkle_add, msg,
     merkle_add, msg,
@@ -48,8 +48,11 @@ pub(crate) fn consensus_stake_get_metadata_v1(
 
 
     // Public inputs for the ZK proofs we have to verify
     // Public inputs for the ZK proofs we have to verify
     let mut zk_public_inputs: Vec<(String, Vec<pallas::Base>)> = vec![];
     let mut zk_public_inputs: Vec<(String, Vec<pallas::Base>)> = vec![];
-    // Public keys for the transaction signatures we have to verify
-    let signature_pubkeys = vec![params.input.signature_public];
+    // We are already verifying this input's signature through `Money::Stake`,
+    // so it's redundant to verify it here again. However it's important to
+    // compare it with the previous call when we do the state transition to
+    // ensure they're the same.
+    let signature_pubkeys: Vec<PublicKey> = vec![];
 
 
     // Grab the minting epoch of the verifying slot
     // Grab the minting epoch of the verifying slot
     let epoch = get_verifying_slot_epoch();
     let epoch = get_verifying_slot_epoch();
@@ -95,7 +98,7 @@ pub(crate) fn consensus_stake_process_instruction_v1(
     let input = &params.input;
     let input = &params.input;
     let output = &params.output;
     let output = &params.output;
 
 
-    // Verify value commits match
+    // Verify value commitments match
     if output.value_commit != input.value_commit {
     if output.value_commit != input.value_commit {
         msg!("[ConsensusStakeV1] Error: Value commitments do not match");
         msg!("[ConsensusStakeV1] Error: Value commitments do not match");
         return Err(MoneyError::ValueMismatch.into())
         return Err(MoneyError::ValueMismatch.into())

+ 1 - 1
src/contract/money/src/error.rs

@@ -20,7 +20,7 @@ use darkfi_sdk::error::ContractError;
 
 
 #[derive(Debug, Clone, thiserror::Error)]
 #[derive(Debug, Clone, thiserror::Error)]
 // TODO: Make generic contract common errors like
 // TODO: Make generic contract common errors like
-// NextCallFunctionMissmatch
+// NextCallFunctionMismatch
 pub enum MoneyError {
 pub enum MoneyError {
     #[error("Missing inputs in transfer call")]
     #[error("Missing inputs in transfer call")]
     TransferMissingInputs,
     TransferMissingInputs,