From b29fedf8285e888167da835d4c91d3bf6d624710 Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Fri, 11 Oct 2024 09:08:24 -0400 Subject: [PATCH] Return 0 during fee estimation --- .../src/vrf_provider/vrf_provider_component.cairo | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/contracts/src/vrf_provider/vrf_provider_component.cairo b/contracts/src/vrf_provider/vrf_provider_component.cairo index bcad9f5..27c2594 100644 --- a/contracts/src/vrf_provider/vrf_provider_component.cairo +++ b/contracts/src/vrf_provider/vrf_provider_component.cairo @@ -103,14 +103,21 @@ pub mod VrfProviderComponent { ref self: ComponentState, salt: Option ) -> felt252 { let caller = get_caller_address(); - let chain_id = starknet::get_execution_info().tx_info.unbox().chain_id; + let tx_info = starknet::get_execution_info().tx_info.unbox(); + + // Always return 0 during fee estimation to avoid leaking vrf info. + if tx_info.max_fee == 0 { + return 0; + } let seed = match salt { - Option::Some(s) => poseidon_hash_span(array![s, caller.into(), chain_id].span()), + Option::Some(s) => { + poseidon_hash_span(array![s, caller.into(), tx_info.chain_id].span()) + }, Option::None => { let nonce = self.VrfProvider_nonces.read(caller); self.VrfProvider_nonces.write(caller, nonce + 1); - poseidon_hash_span(array![nonce, caller.into(), chain_id].span()) + poseidon_hash_span(array![nonce, caller.into(), tx_info.chain_id].span()) } };