Skip to content

Fakes should support workflows with generated bindings#1584

Draft
ernest-nowacki wants to merge 2 commits into
developfrom
fix/simulate-with-bindings
Draft

Fakes should support workflows with generated bindings#1584
ernest-nowacki wants to merge 2 commits into
developfrom
fix/simulate-with-bindings

Conversation

@ernest-nowacki

Copy link
Copy Markdown

Description

cre workflow simulate (cre-cli) writes Solana reports through the mock forwarder fake in contracts/capabilities/fakes. Workflows built with SDK-generated bindings (Go cre-sdk-go, TS @chainlink/cre-sdk) construct reports for production:

  • remainingAccounts layout: index 0 = forwarder state, index 1 = forwarder authority PDA, index 2+ = receiver accounts — taken from workflow config, i.e. the real keystone forwarder;
  • report embeds account_hash = sha256(concat(remainingAccount pubkeys)), which the forwarder recomputes on-chain over [state, authority, ...remaining] and rejects on mismatch (Custom:6002 InvalidAccountHash).

Since the fake substitutes the mock forwarder's state/authority, the workflow-computed hash never matches and every simulated write fails with InvalidAccountHash.

This PR makes FakeSolanaChain.WriteReport accept unmodified production reports:

  1. strips remainingAccounts[0..1] (forwarder state + authority), mirroring the real transmitter's forwarder_client.go, which maps them onto named instruction accounts;
  2. rewrites account_hash in place over the account list the mock forwarder will actually see: [mock state, mock authority, ...receiver accounts] (patchReportAccountHash). Safe because the mock forwarder verifies no DON signatures and the transaction is signed by the fake's transmitter afterwards;
  3. logs info whenever the hash is rewritten.

Net effect: workflows keep their production config — no simulation-specific forwarder addresses, no binding changes, cre workflow simulate and deploy use identical workflow code.

Also adds contracts/capabilities/fakes/README.md documenting the mock-forwarder write path and what receiver authors still need (receiver's own caller validation must accept the mock forwarder).

Testing: TestPatchReportAccountHash covers hash rewrite, idempotent no-op on second patch, and too-short raw report error. Verified end-to-end via cre workflow simulate on solana-devnet against a bindings-based workflow (sol_cap-canary equivalent).

Requires Dependencies

Resolves Dependencies

  • I will create cre-cli PR that would bumps github.com/smartcontractkit/chainlink-solana/contracts to this commit; once it lands indevelop.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-solana/contracts

View full report

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.

1 participant