From bb1f12894e8b9a066938012e5dd93f3bac9fc37c Mon Sep 17 00:00:00 2001 From: Marco Granelli Date: Fri, 29 Sep 2023 18:55:09 +0200 Subject: [PATCH] Refactors verify sig host fn --- vp_prelude/src/lib.rs | 5 ++--- wasm/wasm_source/src/vp_implicit.rs | 5 ++--- wasm/wasm_source/src/vp_testnet_faucet.rs | 5 ++--- wasm/wasm_source/src/vp_user.rs | 5 ++--- wasm/wasm_source/src/vp_validator.rs | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/vp_prelude/src/lib.rs b/vp_prelude/src/lib.rs index 8c100840be7..e286df4b445 100644 --- a/vp_prelude/src/lib.rs +++ b/vp_prelude/src/lib.rs @@ -79,8 +79,7 @@ pub fn is_proposal_accepted(ctx: &Ctx, proposal_id: u64) -> VpResult { } /// Verify section signatures -// FIXME: this shall not be a VpResult -pub fn verify_signatures(ctx: &Ctx, tx: &Tx, owner: &Address) -> VpResult { +pub fn verify_signatures(ctx: &Ctx, tx: &Tx, owner: &Address) -> EnvResult<()> { let max_signatures_per_transaction = parameters::max_signatures_per_transaction(&ctx.pre())?; @@ -108,7 +107,7 @@ pub fn verify_signatures(ctx: &Ctx, tx: &Tx, owner: &Address) -> VpResult { ) }; - Ok(true) + Ok(()) } /// Checks whether a transaction is valid, which happens in two cases: diff --git a/wasm/wasm_source/src/vp_implicit.rs b/wasm/wasm_source/src/vp_implicit.rs index a67b40d357b..7caf79fbdc0 100644 --- a/wasm/wasm_source/src/vp_implicit.rs +++ b/wasm/wasm_source/src/vp_implicit.rs @@ -62,9 +62,8 @@ fn validate_tx( verifiers ); - let valid_sig = Lazy::new(|| { - matches!(verify_signatures(ctx, &tx_data, &addr), Ok(true)) - }); + let valid_sig = + Lazy::new(|| verify_signatures(ctx, &tx_data, &addr).is_ok()); if !is_valid_tx(ctx, &tx_data)? { return reject(); diff --git a/wasm/wasm_source/src/vp_testnet_faucet.rs b/wasm/wasm_source/src/vp_testnet_faucet.rs index 44b5adfb06e..08b209a081c 100644 --- a/wasm/wasm_source/src/vp_testnet_faucet.rs +++ b/wasm/wasm_source/src/vp_testnet_faucet.rs @@ -25,9 +25,8 @@ fn validate_tx( verifiers ); - let valid_sig = Lazy::new(|| { - matches!(verify_signatures(ctx, &tx_data, &addr), Ok(true)) - }); + let valid_sig = + Lazy::new(|| verify_signatures(ctx, &tx_data, &addr).is_ok()); if !is_valid_tx(ctx, &tx_data)? { return reject(); diff --git a/wasm/wasm_source/src/vp_user.rs b/wasm/wasm_source/src/vp_user.rs index 5f0b70b506f..f128a3b0917 100644 --- a/wasm/wasm_source/src/vp_user.rs +++ b/wasm/wasm_source/src/vp_user.rs @@ -63,9 +63,8 @@ fn validate_tx( verifiers ); - let valid_sig = Lazy::new(|| { - matches!(verify_signatures(ctx, &tx_data, &addr), Ok(true)) - }); + let valid_sig = + Lazy::new(|| verify_signatures(ctx, &tx_data, &addr).is_ok()); if !is_valid_tx(ctx, &tx_data)? { return reject(); diff --git a/wasm/wasm_source/src/vp_validator.rs b/wasm/wasm_source/src/vp_validator.rs index f1418e38e11..8721e7d373b 100644 --- a/wasm/wasm_source/src/vp_validator.rs +++ b/wasm/wasm_source/src/vp_validator.rs @@ -63,9 +63,8 @@ fn validate_tx( verifiers ); - let valid_sig = Lazy::new(|| { - matches!(verify_signatures(ctx, &tx_data, &addr), Ok(true)) - }); + let valid_sig = + Lazy::new(|| verify_signatures(ctx, &tx_data, &addr).is_ok()); if !is_valid_tx(ctx, &tx_data)? { return reject();