Skip to content

fix[oz-retainer-07-n-06]: update reward cache before oracle call - #64

Open
md0x wants to merge 1 commit into
pablo/oz-retainer-07-l-05-request-reward-getterfrom
pablo/oz-retainer-07-n-06-reward-cache-cei
Open

fix[oz-retainer-07-n-06]: update reward cache before oracle call#64
md0x wants to merge 1 commit into
pablo/oz-retainer-07-l-05-request-reward-getterfrom
pablo/oz-retainer-07-n-06-reward-cache-cei

Conversation

@md0x

@md0x md0x commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Audit finding

OpenZeppelin Retainer 07 identified the following issue:

N-06 — Reward Cache in setRequestReward Is Updated After External Oracle Call

  • Severity: Notes
  • Status: Open

OOReporter.setRequestReward updates its cached reward only after calling oracle.setReward. A callback during that external call can therefore observe stale reporter state, making checks-effects-interactions safety depend on the oracle's lock and the reward token's behavior.

This PR is stacked on #63, which replaces the full-request assembly decode used by the same reward-update path.

References: OpenZeppelin audit finding · FRO-114 · audited scope tag

Resolution

  • Write the reporter's cached reward before calling oracle.setReward, so callbacks observe the new value.
  • Retain Managed OO as the authoritative source for the old reward and preserve delta funding behavior.
  • Rely on transaction atomicity to restore the previous cache if the oracle rejects the update.
  • Update the reward-flow documentation to describe the CEI ordering and rollback behavior.
  • Extend the existing reward-update regression so the mock oracle verifies the cache during the external call.
  • Preserve access control, lifecycle behavior, ABI, storage layout, and production runtime size.

Validation

  • Pre-fix regression — fails with reporter reward not updated
  • cd pm-v2-oo-reporter && forge test --match-path test/OOReporter.t.sol — 45 tests passed
  • forge test --match-contract 'ManagedOptimisticOracleV2Test|DeferredPayoutTest' — 73 tests passed
  • cd pm-v2-oo-reporter && forge build --sizes --optimize falseOOReporter 24,463 B (113 B margin, unchanged)
  • forge build --sizesManagedOptimisticOracleV2 24,378 B (198 B margin, unchanged)
  • cd pm-v2-oo-reporter && forge fmt --check
  • git diff --check

@md0x
md0x marked this pull request as ready for review August 3, 2026 10:46
@linear

linear Bot commented Aug 3, 2026

Copy link
Copy Markdown

FRO-114

@md0x
md0x requested review from Reinis-FRP and chrismaree August 3, 2026 10:46

@chrismaree chrismaree left a comment

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.

Reviewed at . The cache write now precedes the Managed OO interaction, transaction rollback preserves the prior cache on failure, and the regression checks in-call visibility. No remaining issues.\n\n---\nSent from Chris Codex Agent 🤖

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.

3 participants