feat: add firehose protobuf field annotations and fireproto package#157
feat: add firehose protobuf field annotations and fireproto package#157maoueh wants to merge 9 commits into
Conversation
Add replace directive pointing github.com/streamingfast/protox to the local branch at /Users/maoueh/work/sf/protox which contains the new WalkMessageInstanceFields function needed for tagging chain proto fields.
…c proto fields Adds the fireproto package with WalkNonDeterministicFields, ClearNonDeterministicFields, and FindTransactionsField utilities that use the firehose field option extensions to locate and manipulate annotated proto fields without chain-specific knowledge.
There was a problem hiding this comment.
Pull request overview
This PR introduces custom protobuf field annotations for Firehose block semantics and adds a fireproto helper package to discover and clear annotated fields generically (without chain-specific logic). It also pins github.com/streamingfast/protox to a commit that provides an instance-level message field walker used by the new utilities.
Changes:
- Add
pb/firehose/options.proto(+ generatedoptions.pb.go) defining(firehose.transactions)and(firehose.nondeterministic)FieldOptionsextensions. - Add new
fireprotopackage utilities:WalkNonDeterministicFields,ClearNonDeterministicFields, andFindTransactionsField(+ tests/docs). - Update dependencies (
protoxpin,zapbump) and document the feature inCHANGELOG.md.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pb/firehose/options.proto | Defines custom FieldOptions extensions for transactions and nondeterministic fields. |
| pb/firehose/options.pb.go | Generated Go bindings exporting the extension descriptors. |
| go.mod | Adds github.com/streamingfast/protox and bumps go.uber.org/zap. |
| go.sum | Adds checksums for protox and updates zap checksums. |
| fireproto/walker.go | Implements generic discovery/walk/clear utilities using protox and the new annotations. |
| fireproto/walker_test.go | Adds tests using dynamic descriptors to validate find/walk/clear behavior. |
| fireproto/log_test.go | Initializes package logger for tests (consistent with repo patterns). |
| fireproto/doc.go | Package documentation and usage examples for the new utilities. |
| CHANGELOG.md | Documents the new proto options and fireproto package under Unreleased. |
Files not reviewed (1)
- pb/firehose/options.pb.go: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| txFDP := &descriptorpb.FileDescriptorProto{ | ||
| Name: new("fireproto_test_tx.proto"), | ||
| Syntax: new("proto3"), | ||
| Package: new("fireproto.test"), | ||
| Options: &descriptorpb.FileOptions{GoPackage: new("fireproto/test;fireprototest")}, | ||
| MessageType: []*descriptorpb.DescriptorProto{ | ||
| { | ||
| Name: new("Tx"), | ||
| Field: []*descriptorpb.FieldDescriptorProto{ | ||
| { | ||
| Name: new("hash"), | ||
| Number: new(int32(1)), | ||
| Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), | ||
| Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), | ||
| JsonName: new("hash"), | ||
| }, | ||
| { | ||
| Name: new("fee"), | ||
| Number: new(int32(2)), | ||
| Type: descriptorpb.FieldDescriptorProto_TYPE_BYTES.Enum(), | ||
| Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), | ||
| JsonName: new("fee"), |
| Name: new("fireproto_test_block.proto"), | ||
| Syntax: new("proto3"), | ||
| Package: new("fireproto.test"), | ||
| Dependency: []string{"fireproto_test_tx.proto"}, | ||
| Options: &descriptorpb.FileOptions{GoPackage: new("fireproto/test;fireprototest")}, |
| { | ||
| Name: new("Block"), | ||
| Field: []*descriptorpb.FieldDescriptorProto{ | ||
| { | ||
| Name: new("transactions"), | ||
| Number: new(int32(1)), | ||
| Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), | ||
| Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), | ||
| TypeName: new(".fireproto.test.Tx"), | ||
| JsonName: new("transactions"), |
| { | ||
| Name: new("gas"), | ||
| Number: new(int32(2)), | ||
| Type: descriptorpb.FieldDescriptorProto_TYPE_BYTES.Enum(), | ||
| Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), | ||
| JsonName: new("gas"), |
There was a problem hiding this comment.
THis is a new Golang feature enabling creating pointer directly to literal types, added in Golang 1.26, aren't we compatible already?
|
cool, good idea.
|
Summary
pb/firehose/options.protodefining twoFieldOptionsextensions:(firehose.transactions)marks the repeated field holding block transactions,(firehose.nondeterministic)marks fields that may differ between nodes (e.g. gas used, fees)fireprotopackage withWalkNonDeterministicFields,ClearNonDeterministicFields, andFindTransactionsField— enables generic tooling to locate/clear tagged fields without chain-specific knowledgegithub.com/streamingfast/protoxto published commitcd8a8cfwhich addsWalkMessageInstanceFields(instance-level DFS walker with cycle prevention)How annotations look on a chain-specific Block proto
A chain team annotates their generated proto like this:
Generic consumer code (no chain knowledge required):
Test plan
go test ./fireproto/...— 5 tests covering find, walk, clear, and no-annotation pathsgo build ./...— no compilation errorspb/firehose/options.pb.goexportsE_TransactionsandE_Nondeterministicextension vars