fix(orchestrator): fanout succeeded inversion, memoize fee lookup, add toolchain docs - #1709
Merged
Baskarayelu merged 1 commit intoJul 30, 2026
Conversation
…d toolchain docs Closes Remitwise-Org#1336 Closes Remitwise-Org#1339 Closes Remitwise-Org#1345 Remitwise-Org#1336 — DX: document required Rust toolchain version - Add CONTRIBUTING.md with toolchain table, install/verify instructions, pre-PR checklist, and repo-specific rules - Add scripts/verify_toolchain.sh: idempotent script that checks rustc stable channel, wasm32-unknown-unknown + wasm32v1-none targets, rustfmt and clippy components, and cargo check; exits 1 with remediation hints Remitwise-Org#1345 — Fix: cross-contract call swallows the inner error - execute_flow_fanout used .is_err() on all three try_* calls and assigned the result to FanOutStepResult::succeeded, inverting both per-step flags and all_succeeded; changed to .is_ok() on s_ok / b_ok / i_ok Remitwise-Org#1339 — Perf: memoize the fee lookup across a batch - execute_flow_fanout previously made 6 individual instance().get() calls and used a hardcoded amount/3 split; replaced with FlowRouting::from_storage (single-pass) and one calculate_split cross-contract call whose result is reused for all three fan-out steps Tests (orchestrator/src/test.rs): - test_fanout_all_succeed_flags_are_true (happy path, Remitwise-Org#1345) - test_fanout_savings/bill/insurance_failure_reports_succeeded_false (Remitwise-Org#1345) - test_fanout_amounts_match_calculate_split_not_hardcoded_thirds (Remitwise-Org#1339) - test_fanout_rejects_zero_amount / test_fanout_rejects_short_split_vector
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 #1336
Closes #1339
Closes #1345
#1336 — DX: document required Rust toolchain version
New files:
CONTRIBUTING.md— toolchain version table (channel, components, targets), install instructions, idempotent verification steps, pre-PR checklist, and repo-specific rulesscripts/verify_toolchain.sh— idempotent script that checksrustcstable channel,wasm32-unknown-unknown+wasm32v1-nonetargets,rustfmtandclippycomponents, andcargo check; exits 1 with remediation hints on any failure#1345 — Fix: cross-contract call swallows the inner error
Root cause:
execute_flow_fanoutused.is_err()on all threetry_*downstream calls and assigned the result toFanOutStepResult::succeeded. This inverted the semantics: a successful call setsucceeded = falseand a failing call setsucceeded = true.all_succeededwas therefore always wrong.Fix (
orchestrator/src/lib.rs): Changed.is_err()→.is_ok()fors_ok,b_ok,i_ok.#1339 — Perf: memoize the fee lookup across a batch
Root cause:
execute_flow_fanoutmade 6 individualinstance().get()storage lookups and computed splits with a hardcodedamount / 3approximation instead of callingcalculate_split. This ignored the configured split percentages entirely.Fix (
orchestrator/src/lib.rs):FlowRouting::from_storage(&env)call (the same pattern used by all other flow paths)amount / 3with onecalculate_split(&amount)cross-contract call; the result is stored in a localVecand its four elements are reused for all three downstream steps — the fee schedule is fetched exactly once per batch invocationBefore vs after (for a 10 000-unit remittance with a 50/30/15/5 split):
Tests added (
orchestrator/src/test.rs)test_fanout_all_succeed_flags_are_truetest_fanout_savings_failure_reports_succeeded_falsetest_fanout_bill_failure_reports_succeeded_falsetest_fanout_insurance_failure_reports_succeeded_falsetest_fanout_amounts_match_calculate_split_not_hardcoded_thirdstest_fanout_rejects_zero_amounttest_fanout_rejects_short_split_vectorChecklist
verify_toolchain.shis idempotent and exits non-zero on any failureparams.rs/ contract storage)scripts/verify_toolchain.shis executable (chmod +x)