Skip to content

About

CCIP and CRE libraries in Vyper

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

Repository files navigation

Chainlink Vyper Module

Vyper interfaces and modules for integrating with Chainlink's CRE (Chainlink Runtime Environment) and CCIP (Cross-Chain Interoperability Protocol), built as a standalone package. Curve's Blockhash Oracle is powered by this module (https://github.com/curvefi/blockhash-oracle).

Overview

The module provides:

  • CCIP — sending and receiving cross-chain messages via a CCIP router (fee quoting, peer management, message transmission/receipt).
  • CREReceiver — an abstract, permissioned receiver for Chainlink CRE workflow reports (onReport), with optional checks on forwarder, workflow author, name, and ID.
  • IReceiver — the onReport interface implemented by CRE report receivers.
  • IWorkflowRegistry — a read-only interface for the CRE WorkflowRegistry (always deployed on Ethereum mainnet) used to resolve a workflow's ID on-chain.

Security

Always ensure proper peer/forwarder setup and ownership management when deploying. Code has not been audited yet and probably contains bugs.

Integrating

  • Call CCIP._ccipReceive / CREReceiver._on_report first in your ccipReceive / onReport, before decoding or acting on the payload.
  • CCIP._transmit calls the router; enable # pragma nonreentrancy on in the consuming contract so entry points that reach it cannot be re-entered mid-update. Mark only deliberate ETH receivers @reentrant, plus any supportsInterface you define yourself: routers ask it before delivering, and an answer the lock reverts reads as no receiver.
  • CCIP._try_transmit gives each router call router_call_gas (500k by default) and reverts if the caller's gas cannot cover it. Export set_router_call_gas to retune it without a redeploy; whoever sizes the caller's gas limit must follow the change.
  • The modules authenticate the source only. Payload validity, freshness, replay protection and ordering (CCIP out-of-order execution is always on) are the consumer's job.
  • Keep _on_report's default strict mode in production. strict_mode=False is for testing only: with no workflow identity configured it accepts any workflow the forwarder delivers.
  • IWorkflowRegistry lookups return an empty struct, not a revert, for unknown workflows. Assert workflow_id != empty(bytes32) before passing it to set_expected_workflow_id: zero there disables the check rather than rejecting everything.

Development

Requirements:

  • Python 3.12+
  • Vyper 0.4.3

Testing:

# Setup virtual environment
uv venv
uv sync
source .venv/bin/activate

# Run all tests
pytest tests/

Some tests (@pytest.mark.mainnet) fork Ethereum mainnet against a real CCIP router and require a DRPC_API_KEY environment variable.

Example Use

examples/ReactorConsumer.vy shows how to build a CRE report consumer on top of the CREReceiver module: it validates the report via CREReceiver._on_report, then decodes and acts on the payload (flagging an address). Use it as a template for wiring up your own onReport handler.

About

CCIP and CRE libraries in Vyper

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages