Skip to content

remove protobuf dependency with prost-codec feature#579

Merged
BusyJay merged 2 commits into
tikv:masterfrom
ggirol-rc:pure_prost
Mar 2, 2026
Merged

remove protobuf dependency with prost-codec feature#579
BusyJay merged 2 commits into
tikv:masterfrom
ggirol-rc:pure_prost

Conversation

@ggirol-rc

@ggirol-rc ggirol-rc commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

The motivation is that protobuf v2 is vulnerable to RUSTSEC-2024-0437.

prost::Message is not 100% the same as protobuf::Message but it's not impossible to present a common interface for the needs of this crate.

This change is a breaking change.

Summary by CodeRabbit

  • Refactor

    • Added a unified protobuf compatibility layer and standardized how protobuf message types are referenced across the project.
    • Exposed compatibility utilities at the crate level for downstream use.
  • Chores

    • Made protobuf optional and simplified codec-related feature flags and dependencies.
    • Updated build/config generation to support conditional codec options.
    • Updated tests and examples to use the new compatibility layer.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a protocompat compatibility module unifying prost/protobuf message APIs behind shared types/traits, makes protobuf an optional feature, updates proto build configuration, removes direct protobuf dependency from the root, and changes imports across the crate and tests to use the new protocompat surface. (50 words)

Changes

Cohort / File(s) Summary
Root manifest
Cargo.toml
Removed bytes and protobuf from root [dependencies]; removed bytes from the root protobuf-codec feature list.
Proto manifest
proto/Cargo.toml
Made protobuf optional ({ version = "2", optional = true }) and added it to the protobuf-codec feature list.
Compatibility layer
proto/src/lib.rs
Added protocompat public module and conditional protoimpl modules for prost-codec and protobuf-codec, re-exporting pbcrate, PbMessage, PbError, PbMessageExt, and ProtobufEnum.
Proto build logic
proto/build.rs
Refactored codegen to use a mutable builder, added a feature-gated wrapper_options configuration under prost-codec, then call generate() after configuration.
Crate public API
src/lib.rs
Re-exported compatibility layer with pub use raft_proto::protocompat;.
Source imports & trait bounds
src/raft.rs, src/raw_node.rs, src/raft_log.rs, src/storage.rs, src/util.rs
Replaced direct protobuf::Message imports with raft_proto::protocompat::* or crate::protocompat::* to use unified message traits.
Error type
src/errors.rs
Changed Error::CodecError From source to crate::protocompat::PbError.
Examples & tests
examples/five_mem_node/main.rs, harness/tests/.../test_raft.rs, harness/tests/.../test_raw_node.rs, harness/tests/test_util/mod.rs
Updated imports to protocompat; tests use accessor methods, generated write_to_bytes() where applicable, switched Message::new()Message::default() and updated byte-slice usage.

Sequence Diagram(s)

sequenceDiagram
  participant App as Client / Test
  participant Raft as raft crate
  participant ProtoCompat as protocompat
  participant PbCrate as pbcrate (prost / protobuf)

  App->>Raft: request serialize / build message
  Raft->>ProtoCompat: call PbMessageExt::write_to_bytes()
  ProtoCompat->>PbCrate: delegate to prost::Message / protobuf::Message
  PbCrate-->>ProtoCompat: bytes or PbError
  ProtoCompat-->>Raft: bytes or PbError
  Raft-->>App: return bytes or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • BusyJay

Poem

🐇 I stitched a bridge for prost and protobuf bright,
One hop, one import — codecs held tight.
Traits whisper bytes in a friendly song,
Tests now dance where differences belong,
A rabbit's small patch and all compiles right.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing the protobuf dependency when the prost-codec feature is used, which is the primary objective across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
proto/src/lib.rs (3)

58-65: Protobuf-codec PbMessageExt relies on method name overlap — this is clever but worth a doc comment.

In protobuf-codec mode, PbMessageExt is empty because protobuf::Message already provides compute_size, merge_from_bytes, and write_to_bytes natively. Call sites work uniformly because the same method names resolve through either the trait (prost) or inherent methods (protobuf). This is subtle — a brief comment here explaining the design would help future maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@proto/src/lib.rs` around lines 58 - 65, Add a brief doc comment above the
protobuf-codec module explaining that protoimpl::PbMessageExt is intentionally
empty and relies on the inherent methods of protobuf::Message (compute_size,
merge_from_bytes, write_to_bytes) so call sites can use the same method names as
the prost-based PbMessageExt; update the comment near mod protoimpl, the trait
PbMessageExt, and its impl<T: PbMessage> super::protocompat::PbMessageExt for T
{} to clarify this subtle name-resolution design for future maintainers.

36-65: Simultaneous activation of prost-codec and protobuf-codec will produce a confusing "duplicate module" error.

Both feature gates define mod protoimpl. If a user accidentally enables both features, the compiler error will be cryptic. A compile-time check at the crate root would give a much better developer experience.

Add a compile_error for mutual exclusion

Add this near the top of the file (e.g., after the #![allow(...)] lines):

#[cfg(all(feature = "prost-codec", feature = "protobuf-codec"))]
compile_error!("Features `prost-codec` and `protobuf-codec` are mutually exclusive. Please enable only one.");

#[cfg(not(any(feature = "prost-codec", feature = "protobuf-codec")))]
compile_error!("Either `prost-codec` or `protobuf-codec` feature must be enabled.");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@proto/src/lib.rs` around lines 36 - 65, Add a compile-time feature guard to
avoid the confusing duplicate module error by detecting invalid feature
combinations and missing features: insert two compile_error checks near the top
of the file (before the conditional mod protoimpl blocks) that 1) trigger when
both "prost-codec" and "protobuf-codec" are enabled, and 2) trigger when neither
is enabled; reference the feature names ("prost-codec", "protobuf-codec") and
the module name protoimpl in the error messages so users get a clear, actionable
message instead of the duplicate-mod compile error.

36-57: Potential u32 truncation in compute_size and redundant .as_ref().

Line 48: self.encoded_len() as u32 silently truncates if encoded length exceeds u32::MAX. While raft messages are realistically small, this differs from the u32 return that protobuf::Message::compute_size guarantees by design. Consider using u32::try_from(...).expect(...) for a clear panic if this assumption is ever violated.

Line 51: bytes.as_ref() is a no-op on &[u8]self.merge(bytes) suffices.

Proposed cleanup
         fn compute_size(&self) -> u32 {
-            self.encoded_len() as u32
+            u32::try_from(self.encoded_len()).expect("message too large for u32")
         }
         fn merge_from_bytes(&mut self, bytes: &[u8]) -> Result<(), PbError> {
-            self.merge(bytes.as_ref())
+            self.merge(bytes)
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@proto/src/lib.rs` around lines 36 - 57, The compute_size implementation on
trait PbMessageExt silently truncates with self.encoded_len() as u32 — change it
to convert explicitly (e.g., u32::try_from(self.encoded_len()).expect("encoded
message too large")) so it panics clearly if the length exceeds u32::MAX; also
simplify merge_from_bytes by removing the redundant bytes.as_ref() and call
self.merge(bytes) directly. Refer to PbMessageExt::compute_size and
PbMessageExt::merge_from_bytes (and the use of encoded_len and merge) when
making the edits.
proto/Cargo.toml (1)

15-27: Feature gating is correct; document the security trade-off for default users.

The protobuf-codec feature properly activates the protobuf dependency and its bytes sub-feature. When only prost-codec is enabled, protobuf won't be pulled in.

However, users on the default feature set still pull in protobuf = "2", which contains RUSTSEC-2024-0437 (stack overflow DoS via uncontrolled recursion when parsing untrusted protobuf data, fixed in protobuf >= 3.7.2). Consider adding a doc comment or CHANGELOG entry clarifying that users concerned about this advisory should switch to prost-codec, or document any mitigations in place (e.g., trusted input sources only).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@proto/Cargo.toml` around lines 15 - 27, The default feature enables the old
protobuf crate (protobuf = "2") which is affected by RUSTSEC-2024-0437; add a
short doc comment (e.g., in proto/Cargo.toml or the crate-level README) and a
CHANGELOG entry stating that the default feature pulls in protobuf v2 with the
known advisory, advising security-conscious users to enable the prost-codec
feature instead (or only enable protobuf-codec if they accept the risk), and
note any intended mitigation (trusted inputs only) so users know how to opt out
or mitigate the issue.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@proto/Cargo.toml`:
- Around line 15-27: The default feature enables the old protobuf crate
(protobuf = "2") which is affected by RUSTSEC-2024-0437; add a short doc comment
(e.g., in proto/Cargo.toml or the crate-level README) and a CHANGELOG entry
stating that the default feature pulls in protobuf v2 with the known advisory,
advising security-conscious users to enable the prost-codec feature instead (or
only enable protobuf-codec if they accept the risk), and note any intended
mitigation (trusted inputs only) so users know how to opt out or mitigate the
issue.

In `@proto/src/lib.rs`:
- Around line 58-65: Add a brief doc comment above the protobuf-codec module
explaining that protoimpl::PbMessageExt is intentionally empty and relies on the
inherent methods of protobuf::Message (compute_size, merge_from_bytes,
write_to_bytes) so call sites can use the same method names as the prost-based
PbMessageExt; update the comment near mod protoimpl, the trait PbMessageExt, and
its impl<T: PbMessage> super::protocompat::PbMessageExt for T {} to clarify this
subtle name-resolution design for future maintainers.
- Around line 36-65: Add a compile-time feature guard to avoid the confusing
duplicate module error by detecting invalid feature combinations and missing
features: insert two compile_error checks near the top of the file (before the
conditional mod protoimpl blocks) that 1) trigger when both "prost-codec" and
"protobuf-codec" are enabled, and 2) trigger when neither is enabled; reference
the feature names ("prost-codec", "protobuf-codec") and the module name
protoimpl in the error messages so users get a clear, actionable message instead
of the duplicate-mod compile error.
- Around line 36-57: The compute_size implementation on trait PbMessageExt
silently truncates with self.encoded_len() as u32 — change it to convert
explicitly (e.g., u32::try_from(self.encoded_len()).expect("encoded message too
large")) so it panics clearly if the length exceeds u32::MAX; also simplify
merge_from_bytes by removing the redundant bytes.as_ref() and call
self.merge(bytes) directly. Refer to PbMessageExt::compute_size and
PbMessageExt::merge_from_bytes (and the use of encoded_len and merge) when
making the edits.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd05e0 and acccd2b.

📒 Files selected for processing (15)
  • Cargo.toml
  • examples/five_mem_node/main.rs
  • harness/tests/integration_cases/test_raft.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/test_util/mod.rs
  • proto/Cargo.toml
  • proto/build.rs
  • proto/src/lib.rs
  • src/errors.rs
  • src/lib.rs
  • src/raft.rs
  • src/raft_log.rs
  • src/raw_node.rs
  • src/storage.rs
  • src/util.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
harness/tests/integration_cases/test_raft.rs (1)

400-400: Consider using get_msg_type() accessor for consistency.

The changes use direct field access with .into() conversion (ms[0].msg_type, MessageType::MsgAppend.into()), while other parts of the file use the get_msg_type() accessor method (e.g., lines 801, 1386, 1416, 2728). The accessor method provides a cleaner interface that returns the enum type directly.

♻️ Optional: Use accessor method for consistency
-        assert_eq!(ms[0].msg_type, MessageType::MsgAppend.into());
+        assert_eq!(ms[0].get_msg_type(), MessageType::MsgAppend);
-        if m.msg_type != MessageType::MsgAppend.into() {
+        if m.get_msg_type() != MessageType::MsgAppend {

Also applies to: 413-413, 429-429

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@harness/tests/integration_cases/test_raft.rs` at line 400, Replace direct
field access of the message type (ms[0].msg_type ==
MessageType::MsgAppend.into()) with the accessor method ms[0].get_msg_type() so
the comparison reads ms[0].get_msg_type() == MessageType::MsgAppend; do the same
for the other occurrences around the same block (the checks at the similar
locations) to match the file's existing usage of get_msg_type() and avoid manual
.into() conversions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@harness/tests/integration_cases/test_raft.rs`:
- Line 400: Replace direct field access of the message type (ms[0].msg_type ==
MessageType::MsgAppend.into()) with the accessor method ms[0].get_msg_type() so
the comparison reads ms[0].get_msg_type() == MessageType::MsgAppend; do the same
for the other occurrences around the same block (the checks at the similar
locations) to match the file's existing usage of get_msg_type() and avoid manual
.into() conversions.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acccd2b and 54c9f2f.

📒 Files selected for processing (15)
  • Cargo.toml
  • examples/five_mem_node/main.rs
  • harness/tests/integration_cases/test_raft.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/test_util/mod.rs
  • proto/Cargo.toml
  • proto/build.rs
  • proto/src/lib.rs
  • src/errors.rs
  • src/lib.rs
  • src/raft.rs
  • src/raft_log.rs
  • src/raw_node.rs
  • src/storage.rs
  • src/util.rs
✅ Files skipped from review due to trivial changes (1)
  • src/raw_node.rs
🚧 Files skipped from review as they are similar to previous changes (10)
  • proto/Cargo.toml
  • src/util.rs
  • src/errors.rs
  • proto/build.rs
  • harness/tests/test_util/mod.rs
  • examples/five_mem_node/main.rs
  • src/raft_log.rs
  • src/storage.rs
  • proto/src/lib.rs
  • Cargo.toml

@ggirol-rc

Copy link
Copy Markdown
Contributor Author

I had removed an unused import just before pushing but apparently it was only unused with one of the backends. I re-added it and CI for windows should now pass. However the CI for ubuntu is strict for clippy and this will fail due to preexisting issues (see https://github.com/tikv/raft-rs/actions/runs/20450487487/job/59202734774?pr=573 for example). What are your expectations in this regard?

@BusyJay

BusyJay commented Feb 26, 2026

Copy link
Copy Markdown
Member

You can send a different PR to fix those issues first if you would like.

@ggirol-rc

ggirol-rc commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

will you review and merge it?

@BusyJay

BusyJay commented Feb 26, 2026

Copy link
Copy Markdown
Member

Yes, as long as CI is green.

@ggirol-rc

Copy link
Copy Markdown
Contributor Author

@BusyJay done in #580

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
harness/tests/integration_cases/test_raft.rs (1)

413-415: Use accessor in panic output for backend-agnostic message typing.

Lines 414 and 430 check messages using m.get_msg_type() but print m.msg_type directly in panic messages. Use the accessor consistently for codec-agnostic diagnostics.

♻️ Proposed fix
-            panic!("{}: expected MsgAppend, got {:?}", i, m.msg_type);
+            panic!("{}: expected MsgAppend, got {:?}", i, m.get_msg_type());

Also applies to: 429-431

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@harness/tests/integration_cases/test_raft.rs` around lines 413 - 415, The
panic messages use the field m.msg_type directly which breaks backend-agnostic
diagnostics; update both occurrences (the check for MsgAppend around
MessageType::MsgAppend and the similar check at lines 429-431) to print the
accessor m.get_msg_type() instead of m.msg_type so the panic output uses the
codec-agnostic getter (i.e., where code compares m.get_msg_type() !=
MessageType::MsgAppend, change the panic formatting to show m.get_msg_type()).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@proto/src/lib.rs`:
- Around line 48-79: Add compile-time guards to prevent both codec features from
being enabled or neither being enabled: before the first #[cfg(feature =
"prost-codec")] block, add two compile_error! checks—one using #[cfg(all(feature
= "prost-codec", feature = "protobuf-codec"))] with a message that the features
are mutually exclusive, and one using #[cfg(not(any(feature = "prost-codec",
feature = "protobuf-codec")))] with a message that one codec must be enabled;
this ensures the protoimpl module (mod protoimpl) from prost-codec and
protobuf-codec cannot both be defined or both omitted.

---

Nitpick comments:
In `@harness/tests/integration_cases/test_raft.rs`:
- Around line 413-415: The panic messages use the field m.msg_type directly
which breaks backend-agnostic diagnostics; update both occurrences (the check
for MsgAppend around MessageType::MsgAppend and the similar check at lines
429-431) to print the accessor m.get_msg_type() instead of m.msg_type so the
panic output uses the codec-agnostic getter (i.e., where code compares
m.get_msg_type() != MessageType::MsgAppend, change the panic formatting to show
m.get_msg_type()).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54c9f2f and 05d049c.

📒 Files selected for processing (15)
  • Cargo.toml
  • examples/five_mem_node/main.rs
  • harness/tests/integration_cases/test_raft.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/test_util/mod.rs
  • proto/Cargo.toml
  • proto/build.rs
  • proto/src/lib.rs
  • src/errors.rs
  • src/lib.rs
  • src/raft.rs
  • src/raft_log.rs
  • src/raw_node.rs
  • src/storage.rs
  • src/util.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/errors.rs
  • src/raft.rs
  • src/raw_node.rs
  • proto/Cargo.toml
  • src/raft_log.rs
  • src/util.rs
  • src/lib.rs

Comment thread proto/src/lib.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/errors.rs`:
- Around line 26-27: The #[error(...)] string for the CodecError variant is
still hardcoded to "protobuf" even though CodecError now wraps
crate::protocompat::PbError (a backend-agnostic compat error); update the
display string on the CodecError enum variant to remove or generalize "protobuf"
(e.g., "codec error {0:?}" or "codec error: {0}") so it accurately reflects the
wrapped compat error (variant name: CodecError, type:
crate::protocompat::PbError).

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05d049c and 2b84b8a.

📒 Files selected for processing (15)
  • Cargo.toml
  • examples/five_mem_node/main.rs
  • harness/tests/integration_cases/test_raft.rs
  • harness/tests/integration_cases/test_raw_node.rs
  • harness/tests/test_util/mod.rs
  • proto/Cargo.toml
  • proto/build.rs
  • proto/src/lib.rs
  • src/errors.rs
  • src/lib.rs
  • src/raft.rs
  • src/raft_log.rs
  • src/raw_node.rs
  • src/storage.rs
  • src/util.rs
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/raft_log.rs
  • proto/build.rs
  • src/raft.rs
  • proto/Cargo.toml
  • harness/tests/integration_cases/test_raw_node.rs
  • proto/src/lib.rs
  • src/raw_node.rs
  • Cargo.toml
  • src/storage.rs

Comment thread src/errors.rs
Comment on lines 26 to +27
#[error("protobuf codec error {0:?}")]
CodecError(#[from] protobuf::ProtobufError),
CodecError(#[from] crate::protocompat::PbError),

@coderabbitai coderabbitai Bot Feb 26, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Update error text to match backend-agnostic codec error type.
CodecError now wraps a compat error type, but the display message still hardcodes “protobuf”.

Proposed fix
-    #[error("protobuf codec error {0:?}")]
+    #[error("codec error {0:?}")]
     CodecError(#[from] crate::protocompat::PbError),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[error("protobuf codec error {0:?}")]
CodecError(#[from] protobuf::ProtobufError),
CodecError(#[from] crate::protocompat::PbError),
#[error("codec error {0:?}")]
CodecError(#[from] crate::protocompat::PbError),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/errors.rs` around lines 26 - 27, The #[error(...)] string for the
CodecError variant is still hardcoded to "protobuf" even though CodecError now
wraps crate::protocompat::PbError (a backend-agnostic compat error); update the
display string on the CodecError enum variant to remove or generalize "protobuf"
(e.g., "codec error {0:?}" or "codec error: {0}") so it accurately reflects the
wrapped compat error (variant name: CodecError, type:
crate::protocompat::PbError).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the error message mentions protobuf as a serialisation format not as a crate name.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@ggirol-rc, you're absolutely right! The error message correctly refers to the Protocol Buffers serialization format, which both prost and protobuf crates implement. Keeping "protobuf" in the message is appropriate and informative. My suggestion to change it was mistaken. Thank you for the clarification!

@ggirol-rc

Copy link
Copy Markdown
Contributor Author

ci is green and this should be ready for review

Comment thread proto/src/lib.rs
fn write_to_bytes(&self) -> Result<Vec<u8>, PbError>;
}
impl<T: PbMessage> PbMessageExt for T {
fn compute_size(&self) -> u32 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

May add inline here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@BusyJay BusyJay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rest LGTM

Comment thread proto/Cargo.toml Outdated
[features]
default = ["protobuf-codec"]
protobuf-codec = ["protobuf-build/protobuf-codec", "bytes", "protobuf/bytes"]
protobuf-codec = ["protobuf-build/protobuf-codec", "bytes", "protobuf/bytes", "protobuf"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"protobuf/bytes" activates protobuf already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

changed thanks

The motivation is that protobuf v2 is vulnerable to RUSTSEC-2024-0437.

`prost::Message` is not 100% the same as `protobuf::Message` but it's
not impossible to present a common interface for the needs of this
crate.

This change is a breaking change.

Signed-off-by: Guillaume Girol <guillaume.girol@rubycat.eu>
Signed-off-by: Guillaume Girol <guillaume.girol@rubycat.eu>
@ggirol-rc

Copy link
Copy Markdown
Contributor Author

ci was failing because of a missing apt-get update, I took the freedom of adding it to this PR. Feel free to direct me to do it differently if preferred.

@BusyJay BusyJay merged commit b02c962 into tikv:master Mar 2, 2026
7 checks passed
@BusyJay

BusyJay commented Mar 2, 2026

Copy link
Copy Markdown
Member

Thank you!

@ggirol-rc ggirol-rc deleted the pure_prost branch March 2, 2026 08:52
@ggirol-rc

Copy link
Copy Markdown
Contributor Author

Thank you! Would you mind also reviewing #578 ? Along with this PR, it makes it possible to depend on raft-rs without upsetting cargo-audit.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants