From 247d2f2ae29f84cf95d7554d57853b56c348f048 Mon Sep 17 00:00:00 2001 From: Gonza Montiel Date: Tue, 10 Feb 2026 16:16:09 -0300 Subject: [PATCH] fix: add non-zero challenge fees --- .../mainnet/src/configs/storagehub/mod.rs | 16 ++++++++++++++-- .../stagenet/src/configs/storagehub/mod.rs | 16 ++++++++++++++-- .../testnet/src/configs/storagehub/mod.rs | 16 ++++++++++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/operator/runtime/mainnet/src/configs/storagehub/mod.rs b/operator/runtime/mainnet/src/configs/storagehub/mod.rs index 79a71b14..08ced757 100644 --- a/operator/runtime/mainnet/src/configs/storagehub/mod.rs +++ b/operator/runtime/mainnet/src/configs/storagehub/mod.rs @@ -400,6 +400,18 @@ const MAX_CUSTOM_CHALLENGES_PER_BLOCK: u32 = 10; const TOTAL_MAX_CHALLENGES_PER_BLOCK: u32 = RANDOM_CHALLENGES_PER_BLOCK + MAX_CUSTOM_CHALLENGES_PER_BLOCK; +// Challenge fees are used to prevent spam. Keep them non-zero in production runtimes. +// For benchmarking builds we intentionally keep the absolute amounts tiny. +#[cfg(not(feature = "runtime-benchmarks"))] +const CHALLENGES_FEE_VALUE: Balance = HAVE / 1_000; // 0.001 HAVE +#[cfg(feature = "runtime-benchmarks")] +const CHALLENGES_FEE_VALUE: Balance = MICROHAVE / 1_000; + +#[cfg(not(feature = "runtime-benchmarks"))] +const PRIORITY_CHALLENGES_FEE_VALUE: Balance = HAVE / 100; // 0.01 HAVE +#[cfg(feature = "runtime-benchmarks")] +const PRIORITY_CHALLENGES_FEE_VALUE: Balance = MICROHAVE / 100; + #[cfg(feature = "runtime-benchmarks")] parameter_types! { pub const BenchmarkStakeToChallengePeriod: Balance = @@ -415,9 +427,9 @@ parameter_types! { pub const TargetTicksStorageOfSubmitters: u32 = 3; pub const ChallengeHistoryLength: BlockNumber = 100; pub const ChallengesQueueLength: u32 = 100; - pub const ChallengesFee: Balance = 0; + pub const ChallengesFee: Balance = CHALLENGES_FEE_VALUE; pub const ChallengeTicksTolerance: u32 = 50; - pub const PriorityChallengesFee: Balance = 0; + pub const PriorityChallengesFee: Balance = PRIORITY_CHALLENGES_FEE_VALUE; } impl pallet_proofs_dealer::Config for Runtime { diff --git a/operator/runtime/stagenet/src/configs/storagehub/mod.rs b/operator/runtime/stagenet/src/configs/storagehub/mod.rs index 79a71b14..08ced757 100644 --- a/operator/runtime/stagenet/src/configs/storagehub/mod.rs +++ b/operator/runtime/stagenet/src/configs/storagehub/mod.rs @@ -400,6 +400,18 @@ const MAX_CUSTOM_CHALLENGES_PER_BLOCK: u32 = 10; const TOTAL_MAX_CHALLENGES_PER_BLOCK: u32 = RANDOM_CHALLENGES_PER_BLOCK + MAX_CUSTOM_CHALLENGES_PER_BLOCK; +// Challenge fees are used to prevent spam. Keep them non-zero in production runtimes. +// For benchmarking builds we intentionally keep the absolute amounts tiny. +#[cfg(not(feature = "runtime-benchmarks"))] +const CHALLENGES_FEE_VALUE: Balance = HAVE / 1_000; // 0.001 HAVE +#[cfg(feature = "runtime-benchmarks")] +const CHALLENGES_FEE_VALUE: Balance = MICROHAVE / 1_000; + +#[cfg(not(feature = "runtime-benchmarks"))] +const PRIORITY_CHALLENGES_FEE_VALUE: Balance = HAVE / 100; // 0.01 HAVE +#[cfg(feature = "runtime-benchmarks")] +const PRIORITY_CHALLENGES_FEE_VALUE: Balance = MICROHAVE / 100; + #[cfg(feature = "runtime-benchmarks")] parameter_types! { pub const BenchmarkStakeToChallengePeriod: Balance = @@ -415,9 +427,9 @@ parameter_types! { pub const TargetTicksStorageOfSubmitters: u32 = 3; pub const ChallengeHistoryLength: BlockNumber = 100; pub const ChallengesQueueLength: u32 = 100; - pub const ChallengesFee: Balance = 0; + pub const ChallengesFee: Balance = CHALLENGES_FEE_VALUE; pub const ChallengeTicksTolerance: u32 = 50; - pub const PriorityChallengesFee: Balance = 0; + pub const PriorityChallengesFee: Balance = PRIORITY_CHALLENGES_FEE_VALUE; } impl pallet_proofs_dealer::Config for Runtime { diff --git a/operator/runtime/testnet/src/configs/storagehub/mod.rs b/operator/runtime/testnet/src/configs/storagehub/mod.rs index 7717475c..47f5801a 100644 --- a/operator/runtime/testnet/src/configs/storagehub/mod.rs +++ b/operator/runtime/testnet/src/configs/storagehub/mod.rs @@ -401,6 +401,18 @@ const MAX_CUSTOM_CHALLENGES_PER_BLOCK: u32 = 10; const TOTAL_MAX_CHALLENGES_PER_BLOCK: u32 = RANDOM_CHALLENGES_PER_BLOCK + MAX_CUSTOM_CHALLENGES_PER_BLOCK; +// Challenge fees are used to prevent spam. Keep them non-zero in production runtimes. +// For benchmarking builds we intentionally keep the absolute amounts tiny. +#[cfg(not(feature = "runtime-benchmarks"))] +const CHALLENGES_FEE_VALUE: Balance = HAVE / 1_000; // 0.001 HAVE +#[cfg(feature = "runtime-benchmarks")] +const CHALLENGES_FEE_VALUE: Balance = MICROHAVE / 1_000; + +#[cfg(not(feature = "runtime-benchmarks"))] +const PRIORITY_CHALLENGES_FEE_VALUE: Balance = HAVE / 100; // 0.01 HAVE +#[cfg(feature = "runtime-benchmarks")] +const PRIORITY_CHALLENGES_FEE_VALUE: Balance = MICROHAVE / 100; + #[cfg(feature = "runtime-benchmarks")] parameter_types! { pub const BenchmarkStakeToChallengePeriod: Balance = @@ -416,9 +428,9 @@ parameter_types! { pub const TargetTicksStorageOfSubmitters: u32 = 3; pub const ChallengeHistoryLength: BlockNumber = 100; pub const ChallengesQueueLength: u32 = 100; - pub const ChallengesFee: Balance = 0; + pub const ChallengesFee: Balance = CHALLENGES_FEE_VALUE; pub const ChallengeTicksTolerance: u32 = 50; - pub const PriorityChallengesFee: Balance = 0; + pub const PriorityChallengesFee: Balance = PRIORITY_CHALLENGES_FEE_VALUE; } impl pallet_proofs_dealer::Config for Runtime {