Skip to content

fix(orchestrator): fanout succeeded inversion, memoize fee lookup, add toolchain docs - #1709

Merged
Baskarayelu merged 1 commit into
Remitwise-Org:mainfrom
webthreejunkie-sudo:fix/1336-1339-1345-toolchain-docs-fanout-fixes
Jul 30, 2026
Merged

fix(orchestrator): fanout succeeded inversion, memoize fee lookup, add toolchain docs#1709
Baskarayelu merged 1 commit into
Remitwise-Org:mainfrom
webthreejunkie-sudo:fix/1336-1339-1345-toolchain-docs-fanout-fixes

Conversation

@webthreejunkie-sudo

Copy link
Copy Markdown
Contributor

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 rules
  • 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 on any failure

#1345 — Fix: cross-contract call swallows the inner error

Root cause: execute_flow_fanout used .is_err() on all three try_* downstream calls and assigned the result to FanOutStepResult::succeeded. This inverted the semantics: a successful call set succeeded = false and a failing call set succeeded = true. all_succeeded was therefore always wrong.

Fix (orchestrator/src/lib.rs): Changed .is_err().is_ok() for s_ok, b_ok, i_ok.


#1339 — Perf: memoize the fee lookup across a batch

Root cause: execute_flow_fanout made 6 individual instance().get() storage lookups and computed splits with a hardcoded amount / 3 approximation instead of calling calculate_split. This ignored the configured split percentages entirely.

Fix (orchestrator/src/lib.rs):

  • Replaced 6 individual storage reads with a single FlowRouting::from_storage(&env) call (the same pattern used by all other flow paths)
  • Replaced amount / 3 with one calculate_split(&amount) cross-contract call; the result is stored in a local Vec and its four elements are reused for all three downstream steps — the fee schedule is fetched exactly once per batch invocation

Before vs after (for a 10 000-unit remittance with a 50/30/15/5 split):

Before (hardcoded thirds) After (memoised split)
savings 3 334 3 000
bills 3 333 1 500
insurance 3 333 500

Tests added (orchestrator/src/test.rs)

Test Issue
test_fanout_all_succeed_flags_are_true #1345 happy path
test_fanout_savings_failure_reports_succeeded_false #1345 failure path
test_fanout_bill_failure_reports_succeeded_false #1345 failure path
test_fanout_insurance_failure_reports_succeeded_false #1345 failure path
test_fanout_amounts_match_calculate_split_not_hardcoded_thirds #1339
test_fanout_rejects_zero_amount explicit failure mode
test_fanout_rejects_short_split_vector explicit failure mode

Checklist

  • Change matches the summary of each issue
  • Tests cover happy path + explicit failure mode for each fix
  • verify_toolchain.sh is idempotent and exits non-zero on any failure
  • No hard-coded limits in call sites (thresholds read from params.rs / contract storage)
  • No unrelated refactors or style-only changes
  • scripts/verify_toolchain.sh is executable (chmod +x)

…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
@Baskarayelu
Baskarayelu merged commit ebf80a3 into Remitwise-Org:main Jul 30, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: cross-contract call swallows the inner error Perf: memoize the fee lookup across a batch DX: document the required Rust toolchain version

2 participants