Skip to content

feat(antnode): simulate replication and check if records are being st…#3286

Closed
RolandSherwin wants to merge 7 commits intomaidsafe:mainfrom
RolandSherwin:replication_simulation
Closed

feat(antnode): simulate replication and check if records are being st…#3286
RolandSherwin wants to merge 7 commits intomaidsafe:mainfrom
RolandSherwin:replication_simulation

Conversation

@RolandSherwin
Copy link
Copy Markdown
Member

@RolandSherwin RolandSherwin commented Nov 4, 2025

  • A simulation to test if our replication is working as intended and check if the records are being stored at the right location after uploading.

Comment thread ant-node/tests/simulate_replication.rs Outdated
@RolandSherwin RolandSherwin force-pushed the replication_simulation branch from e2f7369 to 728b2d7 Compare November 5, 2025 11:14
Copy link
Copy Markdown
Member

@maqi maqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put in Request changes as showing different result to the testnet runs

Comment thread ant-node/tests/simulate_replication.rs Outdated
@RolandSherwin RolandSherwin force-pushed the replication_simulation branch 2 times, most recently from 49a4cf8 to 93ee2cc Compare November 6, 2025 08:55
Copy link
Copy Markdown
Member

@maqi maqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best make the test to be executed as a separate CI run, so that the results can then be seen more explicitly.

Comment thread ant-node/tests/simulate_replication.rs Outdated

// Select payment targets based on mode
let paid_nodes: Vec<PeerId> = match payment_mode {
PaymentMode::SingleNode => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all candidates that got picked in the payment, even they got 0 paid, shall still accept the upload.
hence here, all 5 shall be included in the payment. otherwise will result in rejection of NotInPaymentList

@RolandSherwin RolandSherwin marked this pull request as ready for review November 6, 2025 11:59
@RolandSherwin RolandSherwin force-pushed the replication_simulation branch from cb7c094 to 872893f Compare November 7, 2025 11:49
- Replace middle-range fallback in is_in_range with simple farthest peer
  distance comparison to match production behavior
- Add majority accumulation requiring 2+ peers to report same record
  before storing (matches production consensus requirement)
- Fix closest peers self-inclusion to exclude self where production does
- Remove unused REPLICATION_FACTOR constant
- Update statistics output with simplified in-range metrics and new
  majority accumulation tracking
- Add SimulationExport structs for JSON serialization of results
- Export simulation config, round data, and coverage stats to JSON
- Add ASCII progress bars for coverage visualization
- Add coverage distribution histogram with bar charts
- Add storage distribution percentile visualization (min/p25/median/p75/max)
- Add configurable failure rate (10% default) to simulate node failures
- Inject failures between replication and verification phases
- Calculate fault tolerance metrics: data loss rate, critical risk rate,
  mean coverage, std dev, p1 coverage, and theoretical survival probability
- Include fault tolerance metrics in JSON export and terminal output
Split the large simulate_replication.rs file into organized modules:
- config.rs: Constants and simulation configuration
- counters.rs: Global atomic counters for statistics
- types.rs: Core data structures and ReplicationAccumulator
- node.rs: SimulatedNode implementation
- stats.rs: UploadStats and CoverageStats helpers
- export.rs: JSON export structures
- mod.rs: Main test function and report generation
Add multi-trial simulation capability with 95% confidence intervals:
- Extract single trial into reusable run_single_trial() function
- Add run_monte_carlo_simulation() that runs configurable trials
- Export results to monte_carlo_results.json with CI statistics
- Reset counters between trials for accurate per-trial metrics
- Restructure test modules for proper Rust 2018+ module paths
@RolandSherwin RolandSherwin force-pushed the replication_simulation branch from 872893f to 93295ca Compare January 20, 2026 10:20
@maqi
Copy link
Copy Markdown
Member

maqi commented Feb 11, 2026

Simulation somehow outdated and no longer necessary.

@maqi maqi closed this Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants