Repository navigation
fix(edge-cases): fail closed instead of returning Ok from placeholders - #1469
Merged
greatest0fallt1me merged 1 commit intoOct 19, 2026
Merged
Conversation
The full build exported several edge-case entry points whose internals were placeholders returning Ok(()) without acting, and one that trapped on unchecked timestamp arithmetic when a market's end_time was in the past. - Remove handle_zero_stake_scenario, handle_partial_resolution and test_edge_case_scenarios from the contract surface (and their dead private helpers + the now-unused PartialData type). Zero-stake and partial resolution are already covered by cancel_event / extend_market and the real resolution path; test_edge_case_scenarios was a test helper exported by mistake. - implement_tie_breaking_mechanism now returns Error::InvalidInput on empty input (never panics) and applies one honest, documented rule: the lexicographically smallest outcome wins. The previous "strategies" all returned the first element. - detect_orphaned_markets and the remaining private placeholders fail closed with Error::InvalidState instead of succeeding silently. Refs Predictify-org#1461
baling-1
force-pushed
the
fix/edge-case-placeholders
branch
from
October 19, 2026 17:06
bf1d93d to
a677a35
Compare
|
@baling-1 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! 🚀 |
4 tasks
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
Closes #1461.
The full build exported several "edge case" entry points whose internals were
placeholders returning
Ok(())without acting, and one (handle_zero_stake_scenario)that trapped on unchecked timestamp arithmetic once a market's
end_timewas in thepast. Callers (operators, scripts, dashboards) were told a market was resolved,
cancelled or extended when nothing happened.
This PR stops exporting those placeholders, makes the remaining helpers fail closed
with typed errors, and removes the dead surface that would otherwise be carried into
the split-out contracts.
Entry point disposition
handle_zero_stake_scenariocancel_event/extend_market; computedmarket_agewith unchecked arithmetic that traps whenend_time < now; itsextend_for_participation/cancel_zero_stake_market/emergency_extension_for_stakeshelpers were emptyOk(())placeholders.handle_partial_resolutionresolve_with_partial_data/attempt_alternative_resolutionwere emptyOk(())placeholders. No admin auth, no state change.test_edge_case_scenarios#[contractimpl]#[cfg(test)].implement_tie_breaking_mechanismError::InvalidInputon empty input instead of panicking. One honest, documented rule: the lexicographically smallest outcome wins. The previous "strategies" all returned the first element.detect_orphaned_marketsError::InvalidStateinstead of a misleading empty list.validate_edge_case_handlingget_edge_case_statisticsPartialData+ private placeholdersPartialData,is_market_orphaned,get_all_market_ids, and thetie_break_by_*shims were only reachable from the removed entry points.No state-changing entry point was added; the remaining surface is read-only, so no new
auth is required.
Fail-closed / no silent success
Okwithout a state change or an explicit read-only purpose.grep -n 'Ok(())' contracts/predictify-hybrid/src/edge_cases.rsnow only matches the tworeturn sites inside
validate_edge_case_handlingandvalidate_edge_case_config. Both arepure validators whose documented contract is
Ok(())on valid input andErr(_)otherwise.Acceptance criteria
grep -n 'Ok(())' contracts/predictify-hybrid/src/edge_cases.rsshows no placeholder bodieson reachable paths (remaining lines justified above).
PredictifyHybridClient(asserted byedge_case_surface_tests.rsthrough the generatedContractFunctionSetregistry).implement_tie_breaking_mechanism(vec![])returnsInvalidInputwith no panic.end_timecan no longer trap (entry point removed).edge_casesis full-only and this change only deletes deadcode / entry points (
-457 / +195acrossedge_cases.rs,lib.rsand the new test).Test plan
New
contracts/predictify-hybrid/src/edge_case_surface_tests.rs:handle_zero_stake_scenarioabsent from the client surfacehandle_zero_stake_scenario_absent_from_client_surfacehandle_partial_resolutionabsent from the client surfacehandle_partial_resolution_absent_from_client_surfacetest_edge_case_scenariosabsent from the client surfacetest_edge_case_scenarios_absent_from_client_surfacesurface_probe_finds_exported_entry_pointimplement_tie_breaking_mechanism(vec![])→InvalidInput, no panicimplement_tie_breaking_mechanism_empty_returns_invalid_inputimplement_tie_breaking_mechanism_picks_lexicographically_smallestdetect_orphaned_markets_fails_closedVerification