Skip to content

set_oracle and add_oracle/remove_oracle are duplicate, conflicting APIs; set_oracle silently drops all existing oracles #43

Description

@cybermax4200

Labels: type: bug, type: api-design, difficulty: intermediate, area: reward-engine

Why this matters now

The README documents set_oracle as "Replace the entire oracle roster with a single oracle" and also lists it under the function table for reward-engine twice (both as an admin function and under the oracle management section). In the contract, set_oracle (verification.rs line ~149) overwrites Oracles with a single-element Vec, silently dropping every oracle added via add_oracle. A multi-oracle operator who calls set_oracle to rotate one oracle accidentally removes all others with no warning and no event. This is a liveness risk — if set_oracle is called by mistake in a production multi-oracle setup, all but one oracle lose their ability to submit proofs with no on-chain record of the removal.

Key Challenges

  • set_oracle emits no OracleRemovedEvent for the oracles it silently drops; this is inconsistent with remove_oracle which always emits one.
  • Two competing mental models exist: set_oracle (replace roster) vs add_oracle/remove_oracle (roster management). One must be canonical. The recommended fix is to either: (a) remove set_oracle and require callers to use add_oracle/remove_oracle, or (b) make set_oracle emit OracleRemovedEvent for every evicted oracle and OracleAddedEvent for the new one.
  • The README lists set_oracle twice — the docs must be corrected to match whichever model is chosen.

Acceptance Criteria

  • Either set_oracle is removed (breaking) and the docs updated, OR set_oracle emits OracleRemovedEvent for every oracle it evicts.
  • A test test_set_oracle_evicts_existing_oracles_with_events asserts the eviction events fire.
  • No oracle can be silently removed without an on-chain event record.
  • README function table corrected (remove duplicate set_oracle entry).
  • All existing oracle tests pass.

Relevant files / functions

File Symbol
contracts/reward-engine/src/verification.rs set_oracle, add_oracle, remove_oracle

Out of scope

  • Multi-oracle consensus logic
  • Changes to add_oracle / remove_oracle behaviour

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions