Description
Multi-oracle resolution currently fetches sources sequentially and applies an unweighted majority vote. In contracts/predictify-hybrid/src/oracles.rs, OracleIntegrationManager::fetch_and_verify_oracle_result iterates oracle_sources and feeds successful results into determine_consensus_outcome, which counts "yes"/"no" equally and compares against DEFAULT_CONSENSUS_THRESHOLD = 66. Every whitelisted oracle therefore has identical influence regardless of trust. This issue adds optional per-oracle weighting so consensus can reflect oracle reliability.
Requirements and context
- Relevant code:
OracleIntegrationManager::fetch_and_verify_oracle_result, determine_consensus_outcome, and calculate_confidence_score in contracts/predictify-hybrid/src/oracles.rs; the DEFAULT_CONSENSUS_THRESHOLD constant on OracleIntegrationManager.
- Per-oracle metadata already exists via
OracleMetadata and OracleWhitelist (oracles.rs), giving a natural place to store a weight field.
- Weighted tally should fall back to the current unweighted behavior when no weights are configured, preserving existing tests.
- Error semantics must remain:
Error::OracleNoConsensus when the weighted agreement is below threshold, Error::OracleUnavailable when no source returns data.
- Non-functional: keep arithmetic checked/bounded (weights and counts are small
u32/i128); do not introduce unbounded loops beyond the existing source set.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/weighted-oracle-consensus.
2. Implement changes — contracts/predictify-hybrid/src/oracles.rs (consensus + metadata); admin setter in contracts/predictify-hybrid/src/lib.rs if a new config knob is added.
3. Write/extend tests — add cases to the oracle test suites (e.g. contracts/predictify-hybrid/src/tests/oracle_validation_tests.rs once re-enabled, or oracle_fallback_timeout_tests.rs).
4. Test and commit
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test -p predictify-hybrid
stellar contract build --verbose
Example commit message
feat: support weighted multi-oracle consensus in OracleIntegrationManager
Guidelines
≥90% coverage on the consensus paths. Document weighting in doc-comments, API_DOCUMENTATION.md (Oracle Management), and docs/contracts/ORACLE_RESOLUTION.md. Timeframe: 96 hours.
Description
Multi-oracle resolution currently fetches sources sequentially and applies an unweighted majority vote. In
contracts/predictify-hybrid/src/oracles.rs,OracleIntegrationManager::fetch_and_verify_oracle_resultiteratesoracle_sourcesand feeds successful results intodetermine_consensus_outcome, which counts "yes"/"no" equally and compares againstDEFAULT_CONSENSUS_THRESHOLD = 66. Every whitelisted oracle therefore has identical influence regardless of trust. This issue adds optional per-oracle weighting so consensus can reflect oracle reliability.Requirements and context
OracleIntegrationManager::fetch_and_verify_oracle_result,determine_consensus_outcome, andcalculate_confidence_scoreincontracts/predictify-hybrid/src/oracles.rs; theDEFAULT_CONSENSUS_THRESHOLDconstant onOracleIntegrationManager.OracleMetadataandOracleWhitelist(oracles.rs), giving a natural place to store a weight field.Error::OracleNoConsensuswhen the weighted agreement is below threshold,Error::OracleUnavailablewhen no source returns data.u32/i128); do not introduce unbounded loops beyond the existing source set.Acceptance criteria
OracleMetadataor whitelist config) with a sensible default.determine_consensus_outcome(or a new weighted variant) tallies by weight and still respects the configurable threshold.OracleNoConsensusis returned when weighted agreement is below threshold; confidence score reflects weighting.cargo fmt,cargo clippy, andcargo testpass.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/weighted-oracle-consensus.2. Implement changes —
contracts/predictify-hybrid/src/oracles.rs(consensus + metadata); admin setter incontracts/predictify-hybrid/src/lib.rsif a new config knob is added.3. Write/extend tests — add cases to the oracle test suites (e.g.
contracts/predictify-hybrid/src/tests/oracle_validation_tests.rsonce re-enabled, ororacle_fallback_timeout_tests.rs).4. Test and commit
cargo fmt --all -- --check cargo clippy --all-targets --all-features -- -D warnings cargo test -p predictify-hybrid stellar contract build --verboseExample commit message
Guidelines
≥90% coverage on the consensus paths. Document weighting in doc-comments,
API_DOCUMENTATION.md(Oracle Management), anddocs/contracts/ORACLE_RESOLUTION.md. Timeframe: 96 hours.