fix: restore main to a compiling, fully testable state - #669
Merged
IbrahimIjai merged 9 commits intoAug 23, 2026
Conversation
added 9 commits
August 22, 2026 19:42
- Rename oracle::register_market_for_circuit_breaker to register_market_for_breaker (35 chars exceeded Soroban's 32-char contract function name limit). Regenerated docs/auth-audit.md. - Update all market_token::initialize test call sites for the new long_token/short_token parameters, reordering token creation before market token registration where needed. - Fix cascading test-only compilation errors surfaced once the above compiled: stale CreateOrderParams/PositionProps field lists, oracle event-testing API (soroban-sdk 25.3.1), missing Ledger/Events trait imports, and several call sites left behind by unrelated signature changes (reader::initialize, fee_handler::initialize, liquidation_handler::liquidate_position, adl_handler::execute_adl, fee_handler::claim_fees, order_cleanup::cancel_expired_order, data_store::set_u128 key type).
Restored one import (max_pnl_factor_for_adl_key) that clippy --fix incorrectly removed as unused — it's only referenced from the #[cfg(test)] module, which the fix pass analyzed separately from the lib target.
Mechanical literal reformatting only (e.g. 1_000_0000 -> 10_000_000); no numeric values changed.
env.budget() -> env.cost_estimate().budget(), register_contract() -> register(), deployer.deploy() -> deploy_v2(wasm_hash, ()). All same-behavior renames per soroban-sdk 25.3.1 deprecation notices.
…ent lints - Add #[allow(clippy::too_many_arguments)] to functions already at 8-9 params, matching the existing precedent in libs/swap_utils and libs/pricing_utils. - Rewrite two manual if/else zero-checks before division as checked_div (data_store::record_keeper_execution, funding_rate.rs test helper) — same behavior, clippy-preferred idiom. - Remove a stray duplicate doc-comment block in reader.rs left behind by an earlier edit; its real function (get_protocol_stats) already has its own doc a few lines down.
World/TestWorld structs commonly hold addresses (role_store, vaults) that individual tests don't read directly but that keep the deployed contracts alive for the call graph under test. Matches this file's own #[allow(dead_code)] precedent already used on contractclient trait declarations.
- Deduplicate a repeated Ledger trait import in order_handler's test module (two use statements brought in the same trait). - Move adl_handler's max_pnl_factor_for_adl_key import into its #[cfg(test)] module — it's only used there, so clippy's --lib pass (which excludes cfg(test)) correctly flagged it unused at crate scope; the earlier crate-level fix for this kept recurring across fix passes for that reason. - Add the missing #[allow(dead_code)] to reader's IMarketToken client trait, matching every sibling trait in the same file. - Move adl_handler's load_market_props helper above its test module (clippy::items_after_test_module) — a pure relocation, same body. - Silence dead_code on zero_amount_validation.rs's World struct and an unused bench constant, consistent with the other test fixtures.
Roughly half this codebase's events already use the newer #[contractevent] macro (role_store, fee_handler, data_store, referral_storage, insurance_fund_router, order_cleanup, ...); the rest still call the deprecated env.events().publish((topic,), data) directly (market_token, oracle, deposit/withdrawal/order/liquidation/ adl handlers, exchange_router, market_factory, order_cleanup helper libs). Migrating the remainder to #[contractevent] changes the on-chain topic/data encoding for each event — a real ABI-facing change that belongs in its own reviewed PR, not folded into a compilation-restoration fix. Suppressing the warning at the crate level (with an explanatory comment) matches this repo's own existing precedent for the deprecated lint in test_faucet/test_token.
8 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
mainhas not compiled since 25 Jul 2026 (009cefb). This restores it to a compiling, fully testable state — mechanical fixes only, no behavioural or logic changes.Class 1 — oracle wouldn't compile
Soroban caps contract function names at 32 characters.
register_market_for_circuit_breaker(35 chars) exceeded that, and since most of the workspace depends onoracle, this single error stopped the entire build.register_market_for_breaker(27 chars). It's an uncalled, dead public entrypoint (kept per the issue's instructions — not removed, since that's a separate API decision), so nothing in this repo invokes it, but it is a public contract entrypoint and its name is part of the on-chain ABI.docs/auth-audit.mdis regenerated (python3 scripts/gen_auth_audit.py) to reflect the new name and pick up other drift that had accumulated since the doc was last generated. If any off-chain caller (frontend, indexer, keeper script) invokes this function by name, it needs updating.Class 2 — test-only compilation errors, once Class 1 cleared
market_token::initializegained two parameters (long_token,short_token) without updating its ~35#[cfg(test)]call sites across the workspace. Fixed each one — mostly reordering token creation to happen before market-token registration, since the new params need the token addresses up front.Cargo halts at the first failing crate, so fixing that cascaded into a long tail of further test-only breakage that had been silently accumulating (570 test functions were added between 18 Jun and 28 Jul, none of which had run since). Iterated until
cargo check --workspace --all-targetswas clean:Events::all()renamed,Val: From<Symbol>no longer holds — now usestopics.contains(&symbol_short!(..).to_val())and asserts the emitted event viasoroban_sdk::vec![...]equality instead of decoding it back out).CreateOrderParams/PositionPropsstruct literals (missing/extraexpiry_ledgerfield) left behind by an earlier field addition.reader::initialize,fee_handler::initialize,liquidation_handler::liquidate_position,adl_handler::execute_adl,fee_handler::claim_fees,order_cleanup::cancel_expired_order,data_store::set_u128's key type,order_handler::create_order's now-explicit caller argument.soroban_sdk::testutils::{Ledger, Events, BytesN}trait imports for methods that had always needed them but were never reached because compilation failed earlier.Clippy
cargo clippy --workspace --all-targets -- -D warningswas not passing before this PR either (400+ pre-existing warnings, unrelated to the two classes above — mostly literal digit-grouping style, a few genuinely dead test-fixture fields, deprecated SDK renames). Since it's in this issue's acceptance criteria, fixed all of it:1_000_0000→10_000_000) — same value, different underscore placement.env.budget()→env.cost_estimate().budget(),register_contract(None, X)→register(X, ()),deployer.deploy(hash)→deploy_v2(hash, ()).#[allow(clippy::too_many_arguments)]added to the dozen functions already at 8–9 params, matching the existing precedent inlibs/swap_utilsandlibs/pricing_utils.#[allow(dead_code)]on test-fixtureWorld/TestWorldstructs whose fields aren't all read by every test in the file — matches this codebase's existing precedent for the same lint oncontractclienttrait stubs.checked_div(same behaviour).reader.rsremoved, and one helper function moved above its#[cfg(test)] mod testsblock (clippy::items_after_test_module) — pure relocation/dedup, same code.env.events().publish((topic,), data)API instead of the newer#[contractevent]macro (which roughly half the codebase's events already use). Migrating the rest changes the on-chain topic/data encoding for each event — a real ABI-facing change, not a lint fix, and out of scope for a compilation-restoration PR per the issue's own "no behavioural changes" instruction. Suppressed with#![allow(deprecated)]at the crate level (with an explanatory comment), matching this repo's own existing precedent for the same lint intest_faucet/test_token.Test results
cargo test --workspace --no-fail-fast:None of the 37 are new — they were unreachable before this PR (the crate wouldn't compile), so there was no way to know whether they were live bugs or untested. Per the issue's scope, no assertions were changed to force a green suite. Full breakdown, grouped by crate/root-cause cluster, is tracked in #668.
Verification
cargo check --workspaceexits 0cargo clippy --workspace --all-targets -- -D warningsexits 0cargo test --workspacecompiles and runs to completion (528 passed / 37 failed / 5 ignored — see Triage the 37 pre-existing test failures uncovered by #529 #668)stellar contract buildsucceeds for all 23 contracts inCONTRACTS(mx/common.mk)docs/auth-audit.mdregenerated and in sync (python3 scripts/gen_auth_audit.py --check)Closes #529