Repository navigation
Backend verification and contract security: On-chain market validation, error code snapshots, emergency drain constraints - #1505
Merged
Conversation
…n, error code snapshots, emergency drain constraints (Netwalls#1402, Netwalls#1368, Netwalls#1367) Netwalls#1402 B-104: Verify POST /api/markets against the chain instead of trusting client fields - MarketVerificationService to validate markets exist on-chain before registration - Prevents users from registering fake market records that don't exist on-chain - Verifies contract address format (valid Stellar account) - Queries Soroban RPC to confirm market exists at provided contract - Validates client-provided metadata matches on-chain data - Rejects if client tries to override immutable chain data - Prevents creator spoofing by validating against authenticated user - Only indexer should create real market records via chain events Netwalls#1368 C-110: Snapshot-test ContractError discriminants shared with the frontend - Added comprehensive snapshot tests in errors.test.rs - Tests pin numeric error codes that frontend maps to error messages - Verifies all 23 error codes match snapshot (1, 2, 3, 10-15, 20-23, 30-32, 40-42, 50-52, 60) - Tests for uniqueness: no duplicate error codes - Tests for range integrity: proper organization by category with no overlaps - Failure message explicitly warns: "DO NOT CHANGE ERROR CODES - they are part of the contract API" - Documents that frontend/lib/errors.ts must be updated if codes change - Prevents silent frontend breakage from reordering or renumbering errors Netwalls#1367 C-109: Constrain Treasury::emergency_drain with timelock, events, and escrow protection - Implements 48-hour timelock before drain can execute - Prevents instant theft by requiring proposal → wait → execute pattern - Validates recipient against pre-approved emergency whitelist - Protects escrowed funds for open markets (cannot drain committed user funds) - Rate limiting: maximum 20% drain per 24-hour period - Comprehensive audit logging of all proposals and executions - Amount validation and re-checking before execution - Period-based rate limiting that resets every 24 hours - Cancel proposal function for admin control - Emits events for all drain operations for blockchain audit trail
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 #1367
Closes #1368
Closes #1402
… (#1402, #1368, #1367)
#1402 B-104: Verify POST /api/markets against the chain instead of trusting client fields
#1368 C-110: Snapshot-test ContractError discriminants shared with the frontend
#1367 C-109: Constrain Treasury::emergency_drain with timelock, events, and escrow protection