feat: settle a market on an index's rate of change - #1416
Conversation
Time Submission Status
Submit or update total time with: Add time on top of previous submission with: See available commands to help comply with our Guidelines. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAction ID 12 is now classified as a binary attestation action. Unit tests verify the classification. End-to-end tests cover index-change market creation, attestation, settlement, open bounds, and bucket boundaries. ChangesIndex Change Settlement
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change narrowly enables settlement for index rate-of-change markets while preserving explicit handling for unrelated action IDs; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@holdex pr submit-time 4h |
Migration 055 made
index_change_in_rangeattestable in #1415. A market on it can be created and attested today and then cannot be settled:parse_attestation_booleanfalls past the binary branch to itsaction_id > 9guard and returns "unsupported action_id 12".That is worse than a market waiting. The settlement scheduler matches "unsupported action_id" against
permanentSettleErrorSignatures, so it quarantines such a market as a permanent failure instead of retrying it. Both PRs belong in one release for that reason.The change
IsBinaryActionaccepts action 12, soparse_attestation_booleanroutes it toparseBinaryActionResultand reads the boolean the action already returns.Membership is explicit rather than a widened bound. Ids 10 and 11,
get_high_valueandget_low_value, sit between the migration 040 family and action 12. They are numeric, and settlement reads a numeric result as "value > 0 = YES", so a market on either would resolve YES for essentially any price stream. Raising the upper bound to 12 would admit both of them silently, and whether they should ever settle is a product question rather than a side effect of this one.Nothing else in the node needed to change, and it is worth saying why:
settle_marketnever looks at an action id. It callstn_utils.parse_attestation_booleanand takes the boolean back.EncodeDataPointsABIwritesabi.encode(bool)for any single-row, single-boolean result, sorequest_attestationhas been storing action 12's result in exactly the formparseBinaryActionResultexpects since feat: attest an index's rate of change at a point in time #1415.validate_attestation_date_rangealready routes id 12.No migration, and no SQL of any kind.
Tests
tests/streams/order_book/index_change_settlement_test.gocarries four end-to-end tests. They are the first markets in this repository to settle through a binary action at all:settlement_test.gosettles numericget_last_recordthroughout, andbinary_actions_test.gocalls the binary actions without ever settling one, soparseBinaryActionResulthad no end-to-end coverage before this.Every market in the file settles on the same movement. The stream holds 100.00 one day before the attestation point and 102.00 a minute before it, so the change is exactly 2%.
[1%, 3%)settles YES and a market on[3%, 5%)settles NO. The NO case earns its place: the action returns FALSE rather than raising, so a market that should resolve NO has to reach settlement rather than fail its attestation.create_marketandrequest_attestationboth succeed andsettle_marketreports "Attestation not found" from then on.[min, max)rule is asserted: the boundary belongs to the bucket it opens and to no other. Under the inclusive comparisonvalue_in_rangeuses, both adjacent buckets would resolve YES and a trader holding YES in each would be paid twice.Two unit tests in
extensions/tn_utils/precompiles_test.gopin which ids settle as booleans, covering the 10/11 gap rather than only the members, and check that the constant, the name map and the predicate still agree. Those run in the PR job, which skipstests/streams.Verification
go test -tags kwiltest ./extensions/tn_utils/andgo test -tags kwiltest ./tests/streams/order_book/, both green locally.Problem
Summary by CodeRabbit
Bug Fixes
Tests