Skip to content

feat: introducing new WRS algorithm#2224

Open
AnnaR-prog wants to merge 1 commit intomainfrom
wrs_algo_feature
Open

feat: introducing new WRS algorithm#2224
AnnaR-prog wants to merge 1 commit intomainfrom
wrs_algo_feature

Conversation

@AnnaR-prog
Copy link
Contributor

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • read the contribution guide
  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the main branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

@AnnaR-prog AnnaR-prog changed the title Wrs algo feature feat: Wrs algo feature Feb 17, 2026
@AnnaR-prog AnnaR-prog changed the title feat: Wrs algo feature feat: introducing new WRS algorithm Feb 17, 2026
@AnnaR-prog AnnaR-prog force-pushed the wrs_algo_feature branch 2 times, most recently from 45b6f32 to ada3215 Compare February 17, 2026 13:31
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 41.31702% with 1007 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
protocol/provideroptimizer/provider_optimizer.go 42.27% 131 Missing and 11 partials ⚠️
protocol/metrics/consumer_metrics_manager.go 27.52% 128 Missing and 1 partial ⚠️
protocol/provideroptimizer/weighted_selector.go 72.24% 115 Missing and 11 partials ⚠️
utils/score/adaptive_max_calculator.go 52.53% 89 Missing and 14 partials ⚠️
protocol/rpcprovider/rpcprovider.go 0.00% 96 Missing ⚠️
protocol/lavasession/consumer_session_manager.go 31.35% 77 Missing and 4 partials ⚠️
protocol/metrics/consumer_optimizer_qos_client.go 0.00% 61 Missing ⚠️
utils/score/score_store.go 11.76% 58 Missing and 2 partials ⚠️
protocol/rpcconsumer/rpcconsumer.go 0.00% 46 Missing ⚠️
protocol/rpcsmartrouter/rpcsmartrouter.go 4.16% 46 Missing ⚠️
... and 10 more
Flag Coverage Δ
consensus 8.71% <38.43%> (+0.09%) ⬆️
protocol 34.49% <42.01%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
protocol/common/cobra_common.go 0.00% <ø> (ø)
protocol/common/endpoints.go 0.00% <ø> (ø)
protocol/lavasession/provider_types.go 65.09% <ø> (ø)
protocol/metrics/provider_metrics.go 0.00% <ø> (ø)
protocol/provideroptimizer/selection_weight.go 100.00% <100.00%> (+14.75%) ⬆️
utils/lavalog.go 15.00% <100.00%> (-0.29%) ⬇️
protocol/lavasession/consumer_types.go 75.50% <80.00%> (+3.57%) ⬆️
protocol/parser/parser.go 69.54% <50.00%> (-0.21%) ⬇️
protocol/rpcprovider/rpcprovider_server.go 9.71% <0.00%> (-0.03%) ⬇️
protocol/statetracker/updaters/pairing_updater.go 67.34% <50.00%> (-0.53%) ⬇️
... and 16 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Feb 17, 2026

Test Results

7 files  ±    0  0 suites   - 86   0s ⏱️ - 31m 50s
0 tests  - 3 459  0 ✅  - 3 458  0 💤  - 1  0 ❌ ±0 
0 runs   - 3 685  0 ✅  - 3 684  0 💤  - 1  0 ❌ ±0 

Results for commit d3d9d64. ± Comparison against base commit 1ed0795.

♻️ This comment has been updated with latest results.

@NadavLevi NadavLevi force-pushed the wrs_algo_feature branch 3 times, most recently from b35cc46 to 8d10d7d Compare February 18, 2026 12:36
…e normalization, metrics, and test tooling

This squashes the full `wrs_algo_feature` history into a single change-set on top of `origin/main`.

- Replace legacy tier-based provider selection with a weighted-random selection (WRS) path, including:
  - stake-based weighting, normalization tweaks, and guardrails against invalid/NaN weights
  - block-availability / requested-block gating and related tuning
  - deterministic RNG hooks and stronger concurrency/edge-case test coverage
- Add Phase-2 adaptive normalization for latency/sync parameters (P10–P90 + global T-Digest), plus config/tuning changes.
- Expand consumer/provider selection observability:
  - richer selection stats and logging (incl. NaN/Inf sanitization)
  - missing Prometheus metric registrations + latest-provider-block metric fixes
  - selection-via-header support and related endpoint/header plumbing
- Improve rpcprovider test-mode behavior for deterministic latest_block/head-gap and availability failure simulation; preserve test LatestBlock behavior.
- Add/extend scripts and local tooling for WRS analysis and reproducible test scenarios:
  - WRS analysis helpers + e2e scripts/test data
  - `wrs_tests/` local framework (stake/latency/availability/sync) and analyzers
- Misc hardening/cleanup:
  - avoid nil ParsedInput panic in parser flow
  - log timestamp precision tweaks, gofmt, and assorted test/config updates

- remove comments
- refactor: remove provider optimizer exploration feature
- wrs_tests: add local WRS test framework and static stake support
- feat(analyze): add log analysis script for provider selection metrics
- feat(setup): add init script for static and backup provider configuration
- refactor(provideroptimizer): add context parameter to provider selection methods
- consumer: add probe-update-weight CLI flag
- refactor(weighted_selector): enhance total stake calculation for consistent normalization
- Enable nanosecond precision in log timestamps
- feat(wrs): Fix Test 3 sync testing with deterministic baseline approach
- provideroptimizer: remove block-availability penalty
- feat: Add support for provider selection via header in session management
- fix: simplify consumer startup message in init script
- fix: lava_consumer_latest_provider_block metric showing 0
- fix: Register missing metrics (latestBlockMetric, qosMetric, providerReputationMetric) with Prometheus
- feat: Enable QoS optimizer improvements in init script
- feat(provider_setup): enhance ETH RPC configuration and validation
- refactor(provider_optimizer): update provider selection metrics logging
- feat(metrics): improve validation and handling of adaptive bounds
- test: Optimize Test 3 startup by using tendermintrpc-only provider config
- feat: add Test 3 init script and metrics analysis tool
- feat: enhance WRS logging and metrics with parameter contributions
- feat(metrics): enhance provider selection logging and validation
- feat(metrics): add sanitizeFloat function to handle NaN/Inf values
- feat(metrics): enhance provider selection metrics and tracking
- chore: upgrade T-Digest library to caio/go-tdigest v5.0.0
- chore: add tdigest dependency for Phase 2 adaptive normalization
- feat: enable Phase 2 adaptive normalization (P10-P90 with global T-Digest)
- chore: lower availability threshold from 90% to 80%
- feat: implement square root scaling for stake normalization
- feat: implement Phase 2 P10-P90 adaptive normalization for sync parameter
- refactor: improve adaptive normalization - constants, bounds, and logging
- feat: implement Phase 2 P10-P90 hybrid adaptive normalization for latency
- e2e optimizer: per-provider test inputs + preserve test LatestBlock under DR
- feat(metrics): enhance provider selection metrics tracking
- rpcprovider test_mode: availability probability with grpc failure
- rpcprovider test_mode: deterministic head/gap latest_block + delay controls
- chore: gofmt
- feat(provideroptimizer): add selection statistics for provider selection
- test(provideroptimizer): add weighted selector edge-case + concurrency tests
- fixes after rebase
- test(provideroptimizer): stabilize availability selection test
- test(provideroptimizer): cover NaN/Inf weight configs
- fix(provideroptimizer): harden weighted selector weight validation
- fix: prevent divide-by-zero panic in WeightedSelector initialization
- tune(provideroptimizer): lower default MinSelectionChance
- fix(provideroptimizer): align selector normalization with clamp
- fix(provideroptimizer): correct requestedBlock Poisson gating
- feat: Implement block availability calculation for provider selection
- Updated tests
- Updated default weights
- Removed dead code
- Enhance tests with deterministic behavior and error handling improvements
- Refactor provider optimizer to support deterministic seed for testing
- Enhance WeightedSelector with customizable random number generation
- Refactor provider optimizer initialization to remove unused parameter
- Refactor provider selection mechanism to remove tier-based logic and enhance weighted selection
- test: Enhance provider optimizer tests for statistical validation
- test: Refine provider optimizer tests for deterministic behavior
- test: Enhance provider optimizer tests for extreme latency scenarios
- test: Update provider optimizer tests for weighted selection logic
- refactor: Remove legacy tier-based selection and streamline provider optimization
- feat: Implement weighted provider selection system
- protocol/parser: avoid nil ParsedInput panic in generic parser flow
- chore: Update lava_consumer_static_with_backup.yml for provider configuration

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant

Comments