You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scripts/deploy.sh deploys risk_registry twice and calls risk_registry/marketplace/price_oracleinitialize() with argument lists that don't match their current signatures #512
scripts/deploy.sh has several independent deployment-pipeline bugs:
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.
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).
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).
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
git checkout -b fix/deploy-sh-init-argument-drift
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.
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.
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).
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.
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).
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)
Description
scripts/deploy.shhas several independent deployment-pipeline bugs:risk_registryis deployed twice —RISK_REGISTRY_IDis set once aftertreasury, then overwritten by a seconddeploy_contract "risk_registry" ...call aftermarketplace. This wastes a real on-chaindeployment (with real fees on mainnet) and only the second instance is ever used.
marketplace.initializecall (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)— itnever passes
--risk_registryat all, and passes a--referrer_split_bpsthe functiondoesn't accept as a parameter (see issue Fix Reentrancy Guard in Financing Pool Contracts #2 for the related in-contract bug).
risk_registry.initializecall (lines 205-208) passes only--admin --invoice_nft— butthe real signature requires
staking_token,minimum_stake, andslash_percentage_bpsaswell (
contracts/risk_registry/src/lib.rs:72-79).price_oracle.initializecall (lines 210-213) passes--admin --base_currency, but thereal signature (
contracts/price_oracle/src/lib.rs) isinitialize(env, admin)— it takesno
base_currencyparameter at all; the oracle's(base, quote)pairs are registeredper-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.shas written cannot successfully bring up a workingprotocol on a real network — it will either error out on the first mismatched
invokecall, or(worse, if
stellar contract invokesilently ignores unknown flags) silently misconfigurerisk_registry's staking parameters andmarketplace'srisk_registrylink.Suggested Execution
git checkout -b fix/deploy-sh-init-argument-driftrisk_registrydeployment block; deploy it exactly once, in thedocumented dependency order at the top of the file's comment header.
STAKING_TOKEN,MINIMUM_STAKE,SLASH_PERCENTAGE_BPSenvironment-variableparameters (following the existing pattern for
TREASURY_FEE_BPSetc.) and pass them torisk_registry.initialize.marketplace.initializeinvocation to pass--risk_registry "$RISK_REGISTRY_ID"and drop
--referrer_split_bpsfrominitialize(moving it to a follow-upset_referrer_split_bpscall ifMARKETPLACE_REFERRER_BPSis non-zero, since that's thecontract's actual API for it).
price_oracle.initializeinvocation to drop--base_currency, and instead add apost-init step that registers initial price pairs via
set_priceifORACLE_BASE_CURRENCYand a seed price are supplied.
price_oracle's address+hash to the deployment manifest JSON (currently entirely absentfrom the
"contracts"object — see issue Optimize Invoice NFT Contracts #8), and re-verify everyinvokecall in thescript against the actual current contract signatures (grep each contract's
pub fn initialize).Acceptance Criteria
risk_registryis deployed exactly once indeploy.shinvoke ... initializecall indeploy.shpasses exactly the parameters the target contract's currentinitializefunction declares — no more, no fewerdeploy.shruns end-to-end against a local sandbox/testnet without anyinvokefailuredeployments/<network>.json) includesprice_oracle's address and WASM hashGuidelines: PR description must include
Closes #<issue-number>.Complexity: High (200 points)