feat(queue-factory): add salt to deploy_queue to prevent front-running - #232
Open
jajafwangshak86-ops wants to merge 2 commits into
Open
Conversation
Stellar-Deejah#206) deploy_queue now accepts a salt: BytesN<32> and deploys the queue via env.deployer().with_current_contract(salt).deploy_v2(...) so the resulting contract address is deterministic but not predictable by a third party. Two calls using the same factory and WASM but different salts yield different addresses (verified by test_same_wasm_different_salt_yields_different_addresses). - sdk: add optional QueueDeploymentParams.salt (random salt auto-gen when omitted) - docs: document the salt arg, address derivation formula, and SDK behavior - SDK 22 migration: rewrite queue/enrollment/escrow/identity test suites to the generated-client pattern (Address::generate, env.register, mock_all_auths), add no_std headers for wasm builds, fix invalid Symbol literals, and enable wasm reference-types in .cargo/config.toml + patched host so deploy_v2 works. - examples: restore valid JSON (missing braces) in all example package.json so pnpm CI jobs can run.
|
@jajafwangshak86-ops is attempting to deploy a commit to the Deejah Team on Vercel. A member of the Team first needs to authorize it. |
…kend createApp now accepts the already-computed allowedOrigins (falling back to corsOriginsFromEnvironment when omitted), and the escrow/queue submit helpers forward the caller/queueId/admin args the SDK methods now require (deposit, advance, close). Resolves the pre-existing backend tsc errors.
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.
Closes #206
Problem
QueueFactory::deploy_queue()deployed queues with the default (empty) salt, making the resulting contract address fully predictable fromaddress(factory) + wasm_hash(queue.wasm) + salt. An attacker could pre-compute that address and front-run a legitimate deployment to seize/overwrite the queue address (especially risky for high-value product drops).Fix
Added a
salt: BytesN<32>parameter toQueueFactory::deploy_queueand pass it through to the Soroban deployer:Because the address is derived from the salt, two deployments using the same factory + WASM but different salts now yield different contract addresses — deterministic for the operator, but not predictable by a third party who lacks the salt.
Acceptance test
test_same_wasm_different_salt_yields_different_addressesdeploys twice from the same factory with the same WASM but two different salts and asserts the resulting addresses differ.SDK & docs
sdk/src/types.ts: added optionalsalt?: stringtoQueueDeploymentParams— when omitted the SDK auto-generates a random salt.docs/runbook-deployment.md: documented the--saltarg, the address derivation formulaqueue address = address(factory) + wasm_hash + salt, and random-salt guidance.Supporting / housekeeping changes
These were required to make the Rust CI gates (
test-rust,lint-rust) pass, and to unblock the pnpm-based CI jobs:queue,enrollment,escrow, andidentitytest suites to the generated-client pattern (Address::generate,env.register(Type, ()),mock_all_auths()) — the stale direct-call pattern and removed APIs (Address::new,BytesN::new, directImpl::method(env, ..)) no longer compile.#![cfg_attr(not(test), no_std)]headers so every contract builds forwasm32-unknown-unknown.+reference-typesincontracts/.cargo/config.tomland the vendored host (wasmi_helper.rs) sodeploy_v2of reference-types WASMs works in native tests.examples/*/package.json: restored valid JSON (missing braces) so all pnpm workspace CI jobs can run.Verification
cargo fmt -- --check✅cargo clippy -p lineproof-queue-factory -p lineproof-queue -p lineproof-enrollment -p lineproof-escrow -p lineproof-identity -- -D warnings✅cargo test --workspace✅ (90 tests)cargo build --target wasm32-unknown-unknown --release✅pnpm --filter @lineproof/sdk typecheck✅ /pnpm --filter @lineproof/sdk test✅ / frontend typecheck ✅