smartcontractkit / smartcontractkit/cre-cli

Auto-deploy MockKeystoneForwarder for experimental chains during simulation

Open
#393 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
24
Forks
25
Avg merge
10h 10m
Merged PRs (30d)
13

Description

Description

When using experimental-chains in project.yaml, users must manually deploy a MockKeystoneForwarder contract and provide its address in the forwarder field. This adds friction to the local development workflow, especially when using tools like Anvil for local testing.

Current behavior
experimental-chains:
  - chain-selector: 31337
    rpc-url: http://127.0.0.1:8545
    forwarder: "0x..."  # User must deploy and provide this manually

If the forwarder field is missing or incorrect, the simulation silently fails — the forwarder can't deliver reports to the receiver contract, and there's no clear error message indicating the issue.

Proposed behavior

When cre workflow simulate runs with an experimental chain that has no forwarder specified:

  1. Compute a deterministic address for the MockKeystoneForwarder
  2. Check if code already exists at that address (eth_getCode) — if found, reuse it
  3. If no code found, auto-deploy it using the private key from CRE_ETH_PRIVATE_KEY
  4. Use the deployed/existing address for the simulation
  5. Log the address so the user is aware

This avoids redeploying on every simulation run while keeping the forwarder field optional, matching the seamless experience of official chains where the simulator handles this automatically.

Context

While setting up CRE workflow simulation against a local Anvil instance, we initially deployed the KeystoneForwarder contract instead of the MockKeystoneForwarder. The simulation appeared to succeed (returned a tx hash), but the forwarder's report delivery silently failed. There was no error indicating we needed the mock version. It took significant debugging — tracing transactions, checking ERC165 interface IDs, and inspecting ReportProcessed events — to discover the issue.

Auto-deploying the correct MockKeystoneForwarder during simulation would eliminate this confusion entirely and save developers from a non-obvious debugging path.

###Proposed implementation
The change would be in cmd/workflow/simulate/simulate.go around line 175, where it currently errors on missing forwarder:

return Inputs{}, fmt.Errorf("experimental chain %d missing forwarder", ec.ChainSelector)

Instead of erroring:

  • Compute a deterministic address for the MockKeystoneForwarder (e.g., using CREATE2 or a fixed nonce)
  • Call eth_getCode at that address — if bytecode exists, reuse it without redeploying
  • If no code found, deploy using the user's private key from CRE_ETH_PRIVATE_KEY
  • Log: "No forwarder specified for experimental chain %d — using MockKeystoneForwarder at %s"

The compiled artifact already exists in the repo at test/MockKeystoneForwarder.json. If forwarder is provided, behavior remains unchanged.

Happy to submit a PR if the team is open to this approach.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cmd/workflow/simulate/simulate.go around the missing-forwarder error near line 175, then inspect test/MockKeystoneForwarder.json and the simulation RPC flow. Verify how eth_getCode, CRE_ETH_PRIVATE_KEY, and deployment are handled. Done means an omitted forwarder reuses or deploys the mock, logs its address, and preserves the existing behavior when one is provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
blockchain, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.