Skip to content

scripts/deploy.sh deploys risk_registry twice and calls risk_registry/marketplace/price_oracle initialize() with argument lists that don't match their current signatures #512

Description

@OxDev-max

Description

scripts/deploy.sh has several independent deployment-pipeline bugs:

  1. Duplicate deployment (lines 152-153 and 164-165): risk_registry is deployed twice —
    RISK_REGISTRY_ID is set once after treasury, then overwritten by a second
    deploy_contract "risk_registry" ... call after marketplace. This wastes a real on-chain
    deployment (with real fees on mainnet) and only the second instance is ever used.
  2. marketplace.initialize call (lines 195-203) passes
    --admin --invoice_nft --financing_pool --treasury --access_control --fee_bps --referrer_split_bps
    — but the contract's real signature (contracts/marketplace/src/lib.rs:63-72) is
    (admin, invoice_nft, financing_pool, treasury, access_control, risk_registry, fee_bps) — it
    never passes --risk_registry at all, and passes a --referrer_split_bps the function
    doesn't accept as a parameter (see issue Fix Reentrancy Guard in Financing Pool Contracts #2 for the related in-contract bug).
  3. risk_registry.initialize call (lines 205-208) passes only --admin --invoice_nft — but
    the real signature requires staking_token, minimum_stake, and slash_percentage_bps as
    well (contracts/risk_registry/src/lib.rs:72-79).
  4. price_oracle.initialize call (lines 210-213) passes --admin --base_currency, but the
    real signature (contracts/price_oracle/src/lib.rs) is initialize(env, admin) — it takes
    no base_currency parameter at all; the oracle's (base, quote) pairs are registered
    per-pair via set_price, not via a single "base currency" at init time.

Requirements and Context

Beyond the compile-time relevance of #1/#2, these are runtime bugs: even once the
workspace and contracts compile, deploy.sh as written cannot successfully bring up a working
protocol on a real network — it will either error out on the first mismatched invoke call, or
(worse, if stellar contract invoke silently ignores unknown flags) silently misconfigure
risk_registry's staking parameters and marketplace's risk_registry link.

Suggested Execution

  1. git checkout -b fix/deploy-sh-init-argument-drift
  2. Remove the duplicate risk_registry deployment block; deploy it exactly once, in the
    documented dependency order at the top of the file's comment header.
  3. Add STAKING_TOKEN, MINIMUM_STAKE, SLASH_PERCENTAGE_BPS environment-variable
    parameters (following the existing pattern for TREASURY_FEE_BPS etc.) and pass them to
    risk_registry.initialize.
  4. Fix the marketplace.initialize invocation to pass --risk_registry "$RISK_REGISTRY_ID"
    and drop --referrer_split_bps from initialize (moving it to a follow-up
    set_referrer_split_bps call if MARKETPLACE_REFERRER_BPS is non-zero, since that's the
    contract's actual API for it).
  5. Fix the price_oracle.initialize invocation to drop --base_currency, and instead add a
    post-init step that registers initial price pairs via set_price if ORACLE_BASE_CURRENCY
    and a seed price are supplied.
  6. Add price_oracle's address+hash to the deployment manifest JSON (currently entirely absent
    from the "contracts" object — see issue Optimize Invoice NFT Contracts #8), and re-verify every invoke call in the
    script against the actual current contract signatures (grep each contract's pub fn initialize).
  7. Validate the full script end-to-end against a local Soroban sandbox or testnet.

Acceptance Criteria

  • risk_registry is deployed exactly once in deploy.sh
  • Every invoke ... initialize call in deploy.sh passes exactly the parameters the target contract's current initialize function declares — no more, no fewer
  • deploy.sh runs end-to-end against a local sandbox/testnet without any invoke failure
  • The deployment manifest (deployments/<network>.json) includes price_oracle's address and WASM hash

Guidelines: PR description must include Closes #<issue-number>.
Complexity: High (200 points)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions