Skip to content

Off-Chain Report Validation template - #85

Open
ejacquier wants to merge 4 commits into
mainfrom
report-validation-template
Open

ejacquier wants to merge 4 commits into
mainfrom
report-validation-template

Conversation

@ejacquier

Copy link
Copy Markdown
Contributor

Off-Chain Report Validation template

Adds starter-templates/offchain-report-validation — a TypeScript starter template that demonstrates the full off-chain report flow, end to end:

  • Workflow (cre/offchain-report-write/): cron-triggered, writes a uint256 to a Storage consumer via the chain writer (writeReport), and emits the DON-signed report in its logs (REPORT_JSON_BEGIN/END markers, one field per line to avoid truncation) in a copy-pasteable JSON format. The HTTP hand-off point (push report to your backend) is marked with a comment but intentionally not implemented.
  • Contracts (cre/contracts/): Storage.sol on ReceiverTemplate, checked-in ABI, and TypeScript bindings generated with cre generate-bindings (+ newStorageMock used in unit tests).
  • Web app (template root): a minimal Vite + viem browser app that validates a report entirely client-side — parses the report header, computes the report hash, reads the DON config (f + signer addresses) from the capabilities registry via plain eth_call over RPC, and checks f + 1 unique DON signatures. Ships a real production-DON sample report that validates out of the box (npm run dev / npm run verify:sample). First template with a small web UI — included because off-chain validation is something end users do outside the DON.

@github-actions

Copy link
Copy Markdown

👋 ejacquier, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Comment on lines +33 to +36
// getDON(uint32)
const GET_DON_SELECTOR = new Uint8Array([0x23, 0x53, 0x74, 0x05])
// getNodesByP2PIds(bytes32[])
const GET_NODES_BY_P2P_IDS_SELECTOR = new Uint8Array([0x05, 0xa5, 0x19, 0x66])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be generated by something in the ABI?

@@ -0,0 +1,451 @@
/**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot to ask a customer to do. Should we refactor the code that verifies reports in our existing SDKs to do most of the heavy lifting that's here?

Namely, we could ask them to fetch from the contract themselves (since that's different than how the SDK would do it) then do the rest.

OTOH; it would only work for TS and Go that way, so it's kind of nice to have this isolated in case someone wants to verify in a Java server etc...

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.

2 participants