contract/consensus: enable proper nullifiers check on stake and unstake

This commit is contained in:
aggstam
2023-06-23 16:17:25 +03:00
parent 0afaf50d65
commit 703986909a
2 changed files with 2 additions and 10 deletions

View File

@@ -116,7 +116,7 @@ pub(crate) fn consensus_stake_process_instruction_v1(
// validate this state transition.
let consensus_coins_db = db_lookup(cid, CONSENSUS_CONTRACT_STAKED_COINS_TREE)?;
let consensus_unstaked_coins_db = db_lookup(cid, CONSENSUS_CONTRACT_UNSTAKED_COINS_TREE)?;
let _money_nullifiers_db = db_lookup(*MONEY_CONTRACT_ID, MONEY_CONTRACT_NULLIFIERS_TREE)?;
let money_nullifiers_db = db_lookup(*MONEY_CONTRACT_ID, MONEY_CONTRACT_NULLIFIERS_TREE)?;
let money_coin_roots_db = db_lookup(*MONEY_CONTRACT_ID, MONEY_CONTRACT_COIN_ROOTS_TREE)?;
// ===================================
@@ -141,14 +141,10 @@ pub(crate) fn consensus_stake_process_instruction_v1(
}
// The nullifiers should not already exist. It is the double-mint protection.
// TODO: FIXME: This should be uncommented when Validator::verify_transaction
// works as Read->Write->Read->Write
/*
if !db_contains_key(money_nullifiers_db, &serialize(&input.nullifier))? {
msg!("[ConsensusStakeV1] Error: Missing nullifier");
return Err(MoneyError::StakeMissingNullifier.into())
}
*/
// Newly created coin for this call is in the output. Here we gather it,
// and we also check that it hasn't existed before.

View File

@@ -88,7 +88,7 @@ pub(crate) fn money_unstake_process_instruction_v1(
// Access the necessary databases where there is information to
// validate this state transition.
let money_coins_db = db_lookup(cid, MONEY_CONTRACT_COINS_TREE)?;
let _consensus_nullifiers_db =
let consensus_nullifiers_db =
db_lookup(*CONSENSUS_CONTRACT_ID, CONSENSUS_CONTRACT_NULLIFIERS_TREE)?;
let consensus_unstaked_coin_roots_db =
db_lookup(*CONSENSUS_CONTRACT_ID, CONSENSUS_CONTRACT_UNSTAKED_COIN_ROOTS_TREE)?;
@@ -148,14 +148,10 @@ pub(crate) fn money_unstake_process_instruction_v1(
}
// The nullifiers should already exist in the Consensus nullifier set
// TODO: FIXME: This should be uncommented when Validator::verify_transaction
// works as Read->Write->Read->Write
/*
if !db_contains_key(consensus_nullifiers_db, &serialize(&input.nullifier))? {
msg!("[MoneyUnstakeV1] Error: Nullifier not found in Consensus nullifier set");
return Err(MoneyError::MissingNullifier.into())
}
*/
// Newly created coin for this call is in the output. Here we gather it,
// and we also check that it hasn't existed before.