Repository navigation
Feat(split): fee waiver system, circuit breaker, compute estimation & payment batching (#922, #923, #924, #925) - #987
Open
Able-faz-system wants to merge 4 commits into
Conversation
…-split#922) - Add FeeWaiver record (grantor, grant time, expiry, reason) per whitelisted creator - Add grant_fee_waiver / extend_fee_waiver admin controls (SuperAdmin) - Expired waivers no longer exempt creators from platform fees at release - Add permissionless purge_expired_fee_waivers; grants purge lapsed entries first - Add bounded fee waiver audit log and fw_exp / fw_purge events - Add get_fee_waiver, list_fee_waivers, get_fee_waiver_audit_log read functions
- Add Closed / Open / HalfOpen states, kept in sync with the issue Stellar-split#297 flag - Add begin_circuit_recovery / complete_circuit_recovery with a probation period - Add report_circuit_failure: auto-trip on a failure threshold within a ledger window, immediate re-open on failure during recovery - Add per-operation exemption list honoured by require_fn_not_paused guards - Add configurable thresholds, transition history log and cb_state / cb_fail / cb_exmpt events - Extend CircuitBreakerStatus with state, ledgers and failure count
- Add per-operation linear cost model with built-in defaults and admin overrides - Add estimate_operation_cost with calibration learned from reported usage - Add record_compute_usage tracking (min / max / last / totals / error vs estimate) - Cache estimates in temporary storage, invalidated by a model version counter - Add per-operation profiling, get_compute_cost_report and reset_operation_profile
- Add PaymentBatch struct with open / add / remove / cancel collection flow - Validate items on add and again at execution; merge repeated invoice entries - Enforce configurable batch size limit (default 25, max 50) - Execute atomically with a single token transfer via shared _pool_pay accounting - Report per-batch cost savings vs individual payments and track cumulative stats
|
@Able-faz-system 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds four features to the
splitcontract. Each issue has its own commit. The fee waiver, circuit breaker and compute estimation featuresalready existed in a basic form; they are extended here, and the existing function names keep working.
#922 Fee waiver system
FeeWaiverrecord for each whitelisted creator: who granted it, when, the expiry (0= never) and a reason.grant_fee_waiverandextend_fee_waiver.add_fee_waiverandremove_fee_waivernow also keep the record up todate.
creator_has_active_fee_waiver, so an expired waiver no longer removes the platform fee.purge_expired_fee_waivers, callable by anyone. New grants purge expired waivers first, so lapsed entries don't count toward the 100-entry limit.get_fee_waiver,list_fee_waiversandget_fee_waiver_audit_log. New events:fw_expandfw_purge.#923 Circuit breaker pattern
Closed(normal),Open(tripped) andHalfOpen(recovering). It stays in sync with theexisting breaker flag, so all current pause guards still apply.
begin_circuit_recoverymovesOpentoHalfOpen.complete_circuit_recoverymovesHalfOpentoClosedonce a configurable waitingperiod has passed.
deactivate_circuit_breakerremains as an emergency override.report_circuit_failure. The breaker trips after N failures within a ledger window (default 3 in about1 hour), or after a single failure while
HalfOpen.refund).require_fn_not_pausedenforces this.set_circuit_breaker_config. Every state change is kept in a history log (latest 50) and emits acb_stateevent. Thereare also new
cb_failandcb_exmptevents.CircuitBreakerStatusnow also returns the state, the ledgers when the breaker opened and when recovery started, and the current failure count.#924 Compute budget estimation
create,pay,release,refundandbatch_pay. Admins can override them withset_operation_cost_model.estimate_operation_costreturns raw and adjusted instruction counts, memory, fee and whether the call fits the budget.record_compute_usage. This feeds an adjustment factor that keeps estimates close to measured costs (target:within 10%).
get_operation_profileandget_compute_cost_report.reset_operation_profileclears a profile.#925 Payment batching
PaymentBatchwith a collection flow:open_payment_batch,add_to_payment_batch,remove_from_payment_batchandcancel_payment_batch.set_payment_batch_limit. Going over the limit panics withBatchLimitExceeded.execute_payment_batchis all-or-nothing: one token transfer, then the shared_pool_paylogic credits each invoice. If any item fails, the wholecall is reverted.
BatchExecutionReportwith the batched vs. unbatched cost estimate and the savings in basis points (about 36% for 2 invoicesand 63% for 5 under the default model).
get_batching_statstracks cumulative figures.pool_paynow uses the same_pool_payhelper; its behaviour is unchanged.Other
contracts/split/src/test.rs.docs/ISSUE_922_*.mdthroughdocs/ISSUE_925_*.md.Closes #922
Closes #923
Closes #924
Closes #925