Skip to content

feat(tests): add multi-chain fraud proof local testbed simulation (#747) - #804

Open
CHKM001 wants to merge 1 commit into
MDTechLabs:mainfrom
CHKM001:feat/multi-chain-fraud-proof-testbed
Open

feat(tests): add multi-chain fraud proof local testbed simulation (#747)#804
CHKM001 wants to merge 1 commit into
MDTechLabs:mainfrom
CHKM001:feat/multi-chain-fraud-proof-testbed

Conversation

@CHKM001

@CHKM001 CHKM001 commented Jul 27, 2026

Copy link
Copy Markdown

PR #747 [CORE] Build Multi-Chain Fraud Proof Local Testbed Simulation

Summary

Constructs an end-to-end local testing environment that simulates invalid state transitions, relayer failures, and fraud proof challenges between isolated local EVM and Soroban chain instances. Enables deterministic, repeatable fraud proof testing without external node dependencies.

What Changed

New Files

File Description
tests/simulation/multi-chain-environment.ts In-memory EVM and Soroban chain simulators, bridge relay, and MultiChainTestbed orchestrator
tests/simulation/fraud-injector.ts Deterministic fraud injection toolkit with 4 attack vectors
tests/simulation/fraud-proof-suite.spec.ts End-to-end Jest test suite with 21 tests across 7 describe blocks
tests/simulation/jest.config.js Dedicated Jest config using testEnvironment: 'node' to avoid jsdom issues

Modified Files

File Change
package.json Added test:simulation script

Architecture

MultiChainTestbed (orchestrator)
├── EVMChainSimulator (Anvil-like)
│   ├── Blocks with deterministic state roots
│   ├── Account balances & bridge lock operations
│   ├── State root assertion submission
│   ├── Fraud proof challenge acceptance
│   └── Proposer slashing
├── SorobanChainSimulator (Stellar/Soroban)
│   ├── Ledger production
│   ├── Cross-chain settlement receipt
│   └── Contract state management
├── BridgeRelay
│   ├── EVM → Soroban message passing
│   ├── Replay protection (processed message tracking)
│   └── Relayer health control (outage simulation)
└── FraudInjector
    ├── Invalid state root injection
    ├── Relayer message tampering (amount/asset/recipient)
    ├── Relayer failure simulation
    └── Double spend / replay attack

Test Coverage (21 tests, all passing)

Suite Tests What it validates
Multi-chain environment 4 Chain boot, relay, balance tracking, insufficient balance
Invalid state root fraud 3 Detection, proof building, ChallengeMonitor integration
Relayer message tampering 4 Amount/asset/recipient tamper detection, fraud reporting
Relayer failure 2 Offline halt, recovery resume
Double spend / replay 2 Replay blocking, guard enforcement
Challenge window expiry 2 Alert lifecycle, expired window rejection
Bridge recovery after fraud 3 Post-slash honest flow, relayer recovery, concurrent fraud vectors
Full E2E workflow 1 6-phase pipeline: boot → honest validation → fraud injection → detection → challenge → slash → recovery

How to Run

pnpm test:simulation

Or directly:

node node_modules/jest/bin/jest.js --config ./tests/simulation/jest.config.js

Design Decisions

  • Pure TypeScript simulation — No external node dependencies (Anvil, local validators). Keeps tests fast and CI-friendly.
  • testEnvironment: 'node' — Avoids the repo's default jsdom setup which breaks EventEmitter and BigInt operations used in chain simulation.
  • Deterministic clock — All time-dependent logic (challenge windows, alert thresholds) uses an injectable now() function for reproducible test assertions.
  • ChallengeMonitor integration — Tests validate the full ChallengeMonitor lifecycle (track → detect → alert → expire → untrack) alongside the simulation.

Acceptance Criteria

  • Executes automated end-to-end fraud proof challenge workflow in local integration tests
  • Validates proper bridge recovery after successful fraud resolution
  • Orchestrates lightweight local EVM and non-EVM node instances
  • Injects fraudulent messages and invalid state roots into source contracts
  • Asserts that challenger daemons detect fraud, submit valid challenge proofs, and trigger on-chain slashing

Closes #747

…TechLabs#747)

- Add EVM and Soroban chain simulators with deterministic block production
- Add bridge relay with replay protection and health control
- Add fraud injector with 4 attack vectors (invalid state root, relayer tamper, relayer failure, double spend)
- Add ChallengeMonitor integration for fraud detection lifecycle
- Add end-to-end test suite with 21 tests across 7 describe blocks
- Add dedicated jest config (node environment) and test:simulation script
@CHKM001

CHKM001 commented Jul 27, 2026

Copy link
Copy Markdown
Author

hello @mijinummi
I have done the work and made a PR but it seems the bot has not auto accessed it
What can I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant