Skip to content

Rust based sourceReader for EVM - #1362

Draft
RensR wants to merge 6 commits into
mainfrom
rust-reader
Draft

Rust based sourceReader for EVM#1362
RensR wants to merge 6 commits into
mainfrom
rust-reader

Conversation

@RensR

@RensR RensR commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

All requirements implemented and verified. What changed given the new constraints:

gRPC drop-in replacement

     - rust/proto/ccv/chainaccess/v1/source_reader.proto — ccv.chainaccess.v1.SourceReader service mirroring all five methods. Message travels in its canonical CCIP     LSPs are disabled                       
       v1.7 byte encoding, so the Go side decodes with its existing protocol.DecodeMessage — no fidelity loss.                                                                                                   
     - ccv-chainaccess-grpc (tonic): SourceReaderService<R: SourceReader> adapter, serve() with cooperative shutdown, and the ccv-chainaccess-grpc server binary (                                               
       env-configured, one chain per process, SIGINT → graceful drain, SIGKILL-safe since stateless).                                                                                                            
     - rust/grpc-client-go/ — generated pb code plus a hand-written grpcclient.Client implementing chainaccess.SourceReader (compile-time asserted), with the same                                               
       *big.Int conventions as the Go EVM reader. This is the actual drop-in glue on the Go side.          
                                                                                                      

Constraint compliance

     - No panics: both crates have #![forbid(unsafe_code)] + #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::indexing_slicing)] in non-test                                             
       code. Encoding became fallible (encode() -> Result), all slice access is checked, and code was restructured so error paths are genuinely reachable (no dead                                               
       defensive branches).                                                                                                                                                                                      
     - Chain family: EVM reader covers any chain with standard eth_* RPC; exceptions called out in docs (safe tag unsupported → Ok(None); finalized tag required).                                               
     - Stateless / no persistence below the interface: unchanged by design; the gRPC layer adds none.                                                                                                            
     - Shutdown without notice: tested — SIGKILL mid-serve leaves no bad state; SIGINT drains cleanly.              

Definition of done

    - Coverage: 100% line coverage per llvm-cov/lcov (including the binary's config/error paths, via process-spawn tests; a subtle one — tonic deadlocks graceful                                               
      shutdown if you hold the client open, the test drops it first).                                                                                                                                           
    - Historical backtest: 708 real CCIPMessageSent events from Sepolia's OnRamp v2.0.0 (blocks 10970571–11522733), all parsed and validated live (examples/                                                    
      backtest.rs).                                                                                                                                                                                             
    - Differential vs Go: rust/differential-go CLI exposes the Go pipeline; Rust tests compare per-case outcomes: 7500 codec fuzz cases + 708 historical + 600                                                  
      mutated logs — all agree byte-for-byte, including skip-reason codes.                                                                                                                                      
    - This caught two real divergences I fixed: Alloy's lenient decode masks uint32 overflow where geth rejects it (fixed with a raw-word range walk), and topic                                                
      handling is now masked exactly like Go (topic0 verification kept as documented hardening — unreachable through fetch since the RPC filter pins it).                      

@RensR RensR changed the title init Rust based sourceReader for EVM Aug 19, 2026
@github-actions

Copy link
Copy Markdown

Code coverage report:

Package main rust-reader Diff
github.com/smartcontractkit/chainlink-ccv/aggregator 50.86% 50.82% -0.04%
github.com/smartcontractkit/chainlink-ccv/bootstrap 70.72% 70.72% +0.00%
github.com/smartcontractkit/chainlink-ccv/cli 59.12% 59.12% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 36.93% 36.93% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 46.51% 46.51% +0.00%
github.com/smartcontractkit/chainlink-ccv/executor 42.80% 42.80% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 35.54% 35.55% +0.01%
github.com/smartcontractkit/chainlink-ccv/integration 56.56% 56.56% +0.00%
github.com/smartcontractkit/chainlink-ccv/internal 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/migration 77.66% 77.66% +0.00%
github.com/smartcontractkit/chainlink-ccv/pkg 100.00% 100.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 63.06% 63.06% +0.00%
github.com/smartcontractkit/chainlink-ccv/rust 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/tools 43.61% 43.61% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 34.37% 34.37% +0.00%
Total 49.00% 47.50% -1.50%

Files added (in rust-reader):

  • github.com/smartcontractkit/chainlink-ccv/rust/differential-go/main.go
  • github.com/smartcontractkit/chainlink-ccv/rust/grpc-client-go/client.go
  • github.com/smartcontractkit/chainlink-ccv/rust/grpc-client-go/pb/ccv/chainaccess/v1/source_reader.pb.go
  • github.com/smartcontractkit/chainlink-ccv/rust/grpc-client-go/pb/ccv/chainaccess/v1/source_reader_grpc.pb.go

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