feat: add solver views for slash cooldown, active intents, per-token stats, routes - #321
Open
had3sgames wants to merge 1 commit into
Open
Conversation
… routes Adds four solver/integrator convenience views to intent_settlement: - get_slash_cooldown_remaining: seconds left in a solver's post-slash SLASH_COOLDOWN, sharing the exact comparison accept_intent uses via a new slash_cooldown_remaining helper. - get_solver_intents: enumerates a solver's currently Accepted intent ids via a new SolverIntents list, kept in sync in accept_intent, fill_intent (both branches), and slash_solver. - get_token_stats: per-dst-token cumulative volume/fees, tracked alongside the existing global TotalVolume counter in fill_intent. - set_solver_routes / get_solver_routes: optional, purely advisory per-solver src_chain/dst_token route declaration, bounded by a new MAX_ROUTE_ENTRIES cap; accept_intent behavior is unaffected. docs/solver-integration-guide.md and README's error table are updated to match. Note: the intent_settlement crate on main currently fails to build independently of this change -- several constants and Error variants referenced throughout lib.rs and test.rs (e.g. CANCEL_COOLDOWN, MAX_PROTOCOL_FEE_BPS, DEFAULT_MIN_BOND, InvalidConfig, AmountTooLarge) are used but never defined, apparently dropped in a prior merge. This predates and is unrelated to these 4 issues, so it was left untouched per scope; SLASH_COOLDOWN was restored since get_slash_cooldown_remaining (stellar-vortex-protocol#256) directly depends on it. No Rust toolchain was available in this environment to run cargo check/test, so these changes are unverified by CI locally -- please confirm CI passes on the PR. Closes: stellar-vortex-protocol#245 Closes: stellar-vortex-protocol#246 Closes: stellar-vortex-protocol#255 Closes: stellar-vortex-protocol#256
|
@had3sgames 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
Implements the 4 open issues assigned to @had3sgames as one combined PR:
get_slash_cooldown_remainingconvenience view #256 —get_slash_cooldown_remaining(solver) -> u64: seconds left in a solver's post-slashSLASH_COOLDOWN, sharing the exact comparisonaccept_intentuses via a new internalslash_cooldown_remaininghelper so the two can never disagree.get_solver_intentsview enumerating a solver's accepted intents #245 —get_solver_intents(solver) -> Vec<BytesN<32>>: enumerates a solver's currentlyAcceptedintent ids via a newSolverIntentslist, kept in sync inaccept_intent(append),fill_intent(removed on both the full-fill and partial-fill branches, since either way the solver relinquishes ownership), andslash_solver(removed).get_token_stats(token) -> (i128, i128): per-dst_tokencumulative volume/fees, incremented infill_intentalongside the existing globalTotalVolume, on every partial fill.set_solver_routes/get_solver_routes: optional, purely advisory per-solversrc_chain/dst_tokenroute declaration, bounded by a newMAX_ROUTE_ENTRIES(20) cap and a newError::TooManyRouteEntriesvariant.accept_intentdoes not enforce it.docs/solver-integration-guide.md(recovery flow, crash recovery, route declaration) and theREADME.mderror table are updated to match.Important note on validation
This environment has no Rust/cargo toolchain, so
cargo check/cargo testcould not be run. While reviewing, I also found that theintent_settlementcrate onmaincurrently fails to build independently of this change: several constants andErrorvariants referenced throughoutlib.rsandtest.rs— e.g.CANCEL_COOLDOWN,MAX_PROTOCOL_FEE_BPS,MIN_FILL_WINDOW_SECS,MIN_INTENT_EXPIRY_SECS,MIN_BOND_FLOOR,MAX_BATCH_SIZE,MAX_EXTENSION_DURATION,DEFAULT_MIN_BOND/DEFAULT_FILL_WINDOW/DEFAULT_INTENT_EXPIRY/DEFAULT_PROTOCOL_FEE_BPS,Error::InvalidConfig,Error::AmountTooLarge— are used but never defined. They appear to have been dropped frommainin a prior merge (they exist in commit2e36deebut not in the current tree). This predates and is unrelated to these 4 issues, so I left it untouched per scope, with one exception:SLASH_COOLDOWNwas restored (as aconst) sinceget_slash_cooldown_remaining(#256) directly depends on it and the issue text assumes it already exists.Please run CI on this PR to confirm, and consider a separate fix for the missing-constants regression on
main.Test plan
accept_intent/fill_intent/slash_solverbookkeeping changes forSolverIntentsand per-token statsCloses: #245
Closes: #246
Closes: #255
Closes: #256