Skip to content

feat: introduce tycho-protobuf crate#996

Open
kayibal wants to merge 1 commit into
mainfrom
feat/tycho-protobuf-crate
Open

feat: introduce tycho-protobuf crate#996
kayibal wants to merge 1 commit into
mainfrom
feat/tycho-protobuf-crate

Conversation

@kayibal
Copy link
Copy Markdown
Contributor

@kayibal kayibal commented May 7, 2026

Summary

  • Introduces a new crates/tycho-protobuf workspace crate that owns the protobuf type definitions and conversions previously scattered across tycho-substreams (external) and tycho-indexer
  • Moves BlockChanges and TxWithContractChanges from tycho-indexer::extractor::models to tycho-common::models::blockchain
  • tycho-indexer drops its tycho-substreams dependency

crates/tycho-protobuf

Module Purpose
src/pb/ Generated protobuf types from proto/tycho/evm/v1/common.proto
src/convert.rs TryFromMessage trait + all protobuf → domain type conversions
src/error.rs DecodeError (no dependency on indexer-internal error types)
buf.gen.yaml Regeneration config — identical plugin/attribute setup to tycho-substreams
build.rs Runs buf generate when PROTO_BUILD=1 is set

Regenerate with PROTO_BUILD=1 cargo build -p tycho-protobuf or buf generate from the crate directory.

tycho-common

BlockChanges and TxWithContractChanges are now in tycho-common::models::blockchain (and re-exported from tycho-common::models). BlockChanges::into_aggregated() returns MergeError instead of the indexer-internal ExtractionError.

tycho-indexer

  • tycho-substreams = "0.6.0" replaced by tycho-protobuf.workspace
  • protobuf_deserialisation.rs reduced to pub use tycho_protobuf::convert::TryFromMessage
  • ExtractionError gets a manual From<tycho_protobuf::error::DecodeError> impl so DecodeError::Empty maps to ExtractionError::Empty

Test plan

  • cargo check --workspace passes
  • cargo test -p tycho-common --lib passes (67 tests)
  • cargo test -p tycho-indexer --lib passes (327 tests; 5 serial_db tests require a live Postgres connection and are expected to fail locally)

🤖 Generated with Claude Code

Factors out a new `tycho-protobuf` crate from `protocols/substreams/crates/tycho-substreams`.
The crate lives at `crates/tycho-protobuf` inside the main workspace.

- `src/pb/` holds the generated protobuf types (from `proto/tycho/evm/v1/common.proto`);
  regenerate with `PROTO_BUILD=1 cargo build -p tycho-protobuf` or `buf generate` from the
  crate directory (uses the same `buf.gen.yaml` plugin/attribute config as tycho-substreams).
- `src/convert.rs` exposes the `TryFromMessage` trait and all implementations converting
  protobuf messages to `tycho-common` domain types.
- `src/error.rs` defines `DecodeError` with `Decode(String)` and `Empty` variants so the
  crate has no dependency on the indexer-internal `ExtractionError`.

`BlockChanges` and `TxWithContractChanges` are moved from `tycho-indexer::extractor::models`
to `tycho-common::models::blockchain` and re-exported from there. `into_aggregated()` now
returns `MergeError` instead of `ExtractionError`.

`tycho-indexer` drops the `tycho-substreams` dependency and uses `tycho-protobuf` instead.
`protobuf_deserialisation.rs` is reduced to a single re-export of `TryFromMessage`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant