Skip to content

Commit

Permalink
chore: change order of ops on nullifier validation
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Oct 28, 2024
1 parent 6c62f8f commit 64bde60
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions world-chain-builder/src/pool/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,16 @@ where
transaction: &Tx,
payload: &PbhPayload,
) -> Result<(), TransactionValidationError> {
// Validate the root first to prevent invalidating a valid transaction with a root that has
// not landed on chain yet
self.validate_root(payload)?;
let date = chrono::Utc::now();
self.validate_external_nullifier(date, payload)?;

// Create db transaction and insert the nullifier hash
// We do this first to prevent repeatedly validating the same transaction
let db_tx = self.pbh_db.tx_mut()?;
let mut cursor = db_tx.cursor_write::<ValidatedPbhTransactionTable>()?;
cursor.insert(payload.nullifier_hash.to_be_bytes().into(), EmptyValue)?;

let date = chrono::Utc::now();
self.validate_external_nullifier(date, payload)?;

let res = verify_proof(
payload.root,
payload.nullifier_hash,
Expand Down

0 comments on commit 64bde60

Please sign in to comment.