feat(solana): runtime config setters (re-target to contract-v2)#486
Merged
Conversation
Ports the six ink! owner config setters absent from the port: set_min_collateral, set_max_collateral, set_fulfillment_timeout, set_min_swap_amount, set_max_swap_amount, set_reservation_ttl. (set_consensus_threshold + set_halted already existed.) Also promotes the three Phase 9/10 deployment-static tunables to runtime Config fields with setters: reservation_fee_lamports, pool_window_secs, weights_update_min_interval_secs. Consts now seed the defaults at initialize; handlers read from Config. Floors translated to sensible secs/lamports (timeout >= 60s, min_swap 0 or >= 1000, ttl/window > 0). Bumps CONFIG_VERSION to 6.
anderdc
added a commit
that referenced
this pull request
Jun 19, 2026
…nables after v2 merge Merge origin/contract-v2 (#485 busy-model reservation rework, #486 runtime config setters) into the feature branch and reconcile with the economic-knob consolidation: - Keep all deploy-time economic levers in tunables.rs. The three values #486 promoted to runtime Config fields (reservation_fee_lamports, pool_window_secs, weights_update_min_interval_secs) live here as the initialize seed defaults; handlers read the live Config value. FEE_DIVISOR stays compile-time. - Set the deploy defaults: POOL_WINDOW_SECS 3 -> 60, RESERVATION_FEE_LAMPORTS 0.001 -> 0.02 SOL (both runtime-tunable via the #486 setters). - initialize.rs seeds from tunables; test_initialize version 5 -> 6. - integration_onchain: shrink the pool window to 3s in the shared setup via the new set_pool_window setter so the wall-clock on-chain tests don't each sleep a full minute (keeps the 60s deploy default; e2e ~2min not ~7min). Full LiteSVM suite green (60 passed); e2e.sh 24/24.
LandynDev
pushed a commit
that referenced
this pull request
Jun 22, 2026
…olidation (on contract-v2) (#484) * feat(solana): over-collateralize failed swaps to 1.1x (v2 #4) Add a dedicated tunables.rs for economic knobs. COLLATERAL_REQUIREMENT_BPS (1.10x) is compile-time bounded to [1.0x, 2.0x] via a const assert plus a unit test; required_collateral(sol_amount) is the shared helper. - vote_initiate now gates on collateral >= required_collateral(sol_amount) (was 1:1), so a miner must hold 1.1x the swap size to take it. - timeout_swap slashes 1.1x and refunds the entire slash to the user (the 0.1x is a penalty paid to the victim; no treasury/burn split). Tests: 4 tunables unit tests, a vote_initiate boundary-rejection test (2.1 SOL < 2.2 needed), and the 1.1x slash assertion in test_swap. Also fixes test_initialize (version 4 -> 5) left stale by the halt commit. Full LiteSVM suite green (58 passed); e2e.sh 24/24. * feat(solana): decaying anti-flashing fee on quote updates set_quote now charges a treasury-bound fee when overwriting a standing quote (first creation stays free beyond rent). The fee decays stepwise the longer the prior quote stood: 0.01 SOL if updated within 5 min, 0.001 SOL within 10 min, 0 thereafter. Discourages rapid quote-flashing without deterring miners from joining. - New QUOTE_UPDATE_FEE_* tiers + quote_update_fee(elapsed) in tunables.rs, compile-time asserted to decay over increasing windows. - Fee moves miner -> vault treasury (system CPI), preserving the vault invariant. SetQuote gains a vault account; QuoteSet gains update_fee. - Tests: tunables tier unit test + a test_quote decay walk (create free -> tier-1 -> tier-2 -> free). Updated all SetQuote callers for the new vault account. Full LiteSVM suite green (60 passed); e2e.sh 24/24. * refactor(solana): consolidate all economic levers into tunables.rs Move FEE_DIVISOR, RESERVATION_FEE_LAMPORTS, POOL_WINDOW_SECS and WEIGHTS_UPDATE_MIN_INTERVAL_SECS out of constants.rs into tunables.rs, so every deploy-time economic/policy knob lives in one file alongside the collateral-requirement and quote-fee tunables. constants.rs keeps only structural values (PDA seeds, request-type bytes, max string lengths, and SLOT_MS as a chain fact). Pure code-organization move — identical values, no behavior change. Imports updated across instructions + tests. Full LiteSVM suite green (60 passed); e2e.sh 24/24. * feat(solana): 60s pool window + 0.02 SOL reservation fee defaults; tunables after v2 merge Merge origin/contract-v2 (#485 busy-model reservation rework, #486 runtime config setters) into the feature branch and reconcile with the economic-knob consolidation: - Keep all deploy-time economic levers in tunables.rs. The three values #486 promoted to runtime Config fields (reservation_fee_lamports, pool_window_secs, weights_update_min_interval_secs) live here as the initialize seed defaults; handlers read the live Config value. FEE_DIVISOR stays compile-time. - Set the deploy defaults: POOL_WINDOW_SECS 3 -> 60, RESERVATION_FEE_LAMPORTS 0.001 -> 0.02 SOL (both runtime-tunable via the #486 setters). - initialize.rs seeds from tunables; test_initialize version 5 -> 6. - integration_onchain: shrink the pool window to 3s in the shared setup via the new set_pool_window setter so the wall-clock on-chain tests don't each sleep a full minute (keeps the 60s deploy default; e2e ~2min not ~7min). Full LiteSVM suite green (60 passed); e2e.sh 24/24.
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.
Re-lands the runtime config setters directly on
contract-v2.Why this exists: #483 was opened with base
feat/solana-haltand got merged into that branch instead ofcontract-v2, so the setters never reachedcontract-v2. #483 is closed/merged and can't be retargeted, so this is a fresh PR with the same changes cherry-picked onto currentcontract-v2. Supersedes #483.Contents (identical to #483)
set_min_collateral,set_max_collateral,set_fulfillment_timeout,set_min_swap_amount,set_max_swap_amount,set_reservation_ttl.reservation_fee_lamports,pool_window_secs,weights_update_min_interval_secs(consts now seed defaults atinitialize; handlers read from Config).timeout >= 60,min_swap 0 || >= 1000,ttl/window > 0); guard failures reuseInvalidAmount;msg!-only (matches existing setters).CONFIG_VERSION5 → 6.Cherry-picked clean onto current
contract-v2; type-checks clean. Touches different hunks than #485 (pool-busy), so the two don't conflict.