CRE Price Snapshot
A Chainlink Runtime Environment workflow that reads a Data Feed price on Sepolia and writes it on-chain in a single HTTP-triggered run.
- Exact answer-block resolution by matching the AnswerUpdated round id, not an estimate
- Reads pinned to the last finalized block so every DON node observes identical state
- Forwarder check as the trust boundary: a single write path, address(0) rejected, ERC-165 implemented, replay rejected via StaleSnapshot
- 48 tests across Foundry and Bun, pinning the report byte layout from both sides so encode and decode cannot drift
- Documents the Sepolia gas discrepancy (deployment 7.6x local, delivery 4.8x) that silently reverts onReport at a locally-derived gas limit
One HTTP trigger, one execution: the workflow takes a token name, reads that token's USD price from a Chainlink Data Feed through the EVM Read capability, and writes the answer to a PriceSnapshot contract through EVM Write, delivered as a DON-signed report the KeystoneForwarder verifies before calling onReport.
The hard requirement was storing the block at which the feed answer was last updated — and no view function on the aggregator returns it. latestRoundData gives timestamps; latestConfigDetails().blockNumber is the block the config was set, not the answer. The block lives only in the AnswerUpdated event, so the workflow masks the proxy round id down to the aggregator's own (phaseId << 64 | aggregatorRoundId), searches a window sized from how stale the answer is, and matches on the round id topic — which makes the result exact rather than approximate. If no matching log turns up it retries at the full cap and then fails loudly instead of storing a guess.