feat(twap-monitor): wire OrderPostError retry_hint on submit (BLEU-829)#6
Open
brunota20 wants to merge 3 commits into
Open
feat(twap-monitor): wire OrderPostError retry_hint on submit (BLEU-829)#6brunota20 wants to merge 3 commits into
brunota20 wants to merge 3 commits into
Conversation
After \`cow_api::submit_order\` returns Err, decode the orderbook's
typed \`ApiError\` JSON from \`host-error.data\` and dispatch on
\`OrderPostErrorKind::is_retriable()\`:
- retriable (InsufficientFee, TooManyLimitOrders,
PriceExceedsMarketPrice) -> RetryAction::TryNextBlock — leave
the watch in place so the next block re-attempts.
- permanent (InvalidSignature, WrongOwner, DuplicateOrder,
UnsupportedToken, InvalidAppData, ...) -> RetryAction::Drop —
delete watch:{owner}:{params_hash} and any stale next_block /
next_epoch entries the lifecycle layer may have written.
- typed payload missing or unparseable -> TryNextBlock (safe
default: a flaky orderbook should not poison a still-valid
watch).
A \`RetryAction::Backoff { seconds }\` variant is defined for the
BLEU-829 contract but has no producer: cowprotocol's surface today
is bool-only (no server-supplied delay). The variant is kept so the
dispatcher can grow into it once a hint shows up (e.g. server
\`Retry-After\` header or a richer typed error).
## Host follow-up
\`cow_api::submit_order\` in nullislabs/shepherd PR #8 stuffs the
formatted error string into \`host-error.message\` with \`data: None\`
and \`code: 0\`. \`try_decode_api_error\` reads from \`host-error.data\`
already, so once the host forwards the upstream JSON the dispatch
becomes data-driven without further module changes. Test
\`classify_missing_data_defaults_to_try_next_block\` documents the
current fallback; the four other classify tests lock the
intended semantics for when the host catches up.
Tests: 5 new (retriable / permanent / unknown / missing-data /
malformed-data). Total 29 host tests. \`.wasm\` 298 KB (was 273 KB;
adds the typed ApiError decode + the small dispatcher).
Note: this branch also picks up the dev/m2-base bump to
bleu/cow-rs main (\`57f5f55\`), which lands BLEU-822
(\`OrderPostErrorKind\`) + BLEU-823 — both now visible through the
\`cowprotocol\` re-exports.
Linear: BLEU-829.
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
When `cow_api::submit_order` returns Err, decode the orderbook's typed `ApiError` JSON from `host-error.data` and dispatch on `OrderPostErrorKind::is_retriable()`:
A `RetryAction::Backoff { seconds }` variant is defined for completeness with the BLEU-829 contract but has no producer today: cowprotocol's surface is `retry_hint() -> bool` (no server-supplied delay). The slot stays so the dispatcher can grow into it once a hint exists (server `Retry-After` header or a richer typed error).
Host follow-up
`cow_api::submit_order` in nullislabs/shepherd PR #8 currently stuffs the formatted error string into `host-error.message` with `data: None` and hardcoded `code: 0`. `try_decode_api_error` reads from `host-error.data`, so once the host forwards the upstream JSON the dispatch becomes data-driven without further module changes. Test `classify_missing_data_defaults_to_try_next_block` documents today's fallback; the four other `classify_*` tests lock the intended semantics for the post-host-fix world.
dev/m2-base bump
This branch consumes `bleu/cow-rs` at `57f5f55` (= main with #4 BLEU-822 + #5 BLEU-823 in). The bump was pushed as a single commit on `dev/m2-base` so PR #2 / #3 / #4 / #5 don't need to carry it — they rebase / fast-forward through it cleanly.
Stacks on #5 (BLEU-828 submission).
Linear: BLEU-829.
Test plan