Skip to content

fix: make calculate_fee_split read-only - #675

Open
Akinsuyiphilip wants to merge 4 commits into
Betta-Pay:mainfrom
Akinsuyiphilip:fix/498-fee-read-neutral
Open

fix: make calculate_fee_split read-only#675
Akinsuyiphilip wants to merge 4 commits into
Betta-Pay:mainfrom
Akinsuyiphilip:fix/498-fee-read-neutral

Conversation

@Akinsuyiphilip

Copy link
Copy Markdown

Closes #498

Summary

Make calculate_fee_split a genuinely read-only fee quote operation.

Problem

calculate_fee_split previously reused storage helpers intended for mutating
payment paths. Those helpers could refresh merchant and settlement-rule TTLs
and emit bootstrap_fallback whenever no explicit rule was configured.

Because the quote endpoint is publicly callable, an attacker could repeatedly
invoke it to:

  • Keep merchant and rule entries alive indefinitely.
  • Prevent natural storage eviction.
  • Generate unbounded fallback events and indexing noise.

This made a read path observable as a storage mutation and created avoidable
resource costs for the contract and downstream consumers.

Changes

  • Added a side-effect-free settlement-rule resolver for read paths.
  • Updated calculate_fee_split to use the read-only resolver.
  • Prevented fee quote reads from extending merchant or rule TTLs.
  • Prevented fee quote reads from emitting bootstrap_fallback.
  • Preserved TTL refreshes and fallback telemetry for state-changing payment
    operations.
  • Added regression coverage for TTL neutrality and event neutrality.

Security and behavior

calculate_fee_split still validates the merchant and amount and returns the
same fee split, but it no longer writes persistent storage or emits events.
Callers can safely use it for off-chain quotes without keeping otherwise
expirable entries alive or spamming fallback telemetry.

Testing

Added/updated coverage for:

  • calculate_fee_split_read_is_ttl_and_event_neutral
  • Bootstrap fallback behavior on state-changing paths
  • Existing settlement and event-topic regressions

Validation:

cargo test --workspace

4 common tests passed
59 governance tests passed
88 settlement tests passed
All doc-tests passed

Akinsuyiphilip and others added 4 commits August 27, 2026 16:21
Align the settlement timelock with the seven-day recovery window and reject scheduled execution while recovery is pending, preventing compromised-admin upgrades and transfers from racing past recovery.

Generated with Codebuff 🤖

Co-Authored-By: Codebuff <noreply@codebuff.com>
Keep calculate_fee_split neutral for storage TTLs and bootstrap telemetry so untrusted callers cannot keep merchants warm or spam events.

Generated with Codebuff 🤖

Co-Authored-By: Codebuff <noreply@codebuff.com>
Use the Soroban testutils traits correctly and keep the regression focused on storage TTL and event neutrality.

Generated with Codebuff 🤖

Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Akinsuyiphilip Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calculate_fee_split is a read that extorts TTL bumps and event spam

1 participant