Skip to content

Support marking RPC methods as #[deprecated]#59

Open
jsdanielh wants to merge 1 commit into
masterfrom
deprecated-rpc-methods
Open

Support marking RPC methods as #[deprecated]#59
jsdanielh wants to merge 1 commit into
masterfrom
deprecated-rpc-methods

Conversation

@jsdanielh

Copy link
Copy Markdown
Member

Compile-time warnings for proxy callers, server-side logging on dispatch, and an rpc.deprecatedMethods introspection endpoint.

@jsdanielh
jsdanielh requested a review from Eligioo June 17, 2026 19:39
Compile-time warnings for proxy callers, server-side logging on
dispatch, and an rpc.deprecatedMethods introspection endpoint.
@jsdanielh
jsdanielh force-pushed the deprecated-rpc-methods branch from 5637420 to 8f68ef1 Compare June 26, 2026 14:07

#[nimiq_jsonrpc_derive::service(rename_all = "camelCase")]
#[allow(dead_code)]
impl TestService {

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.

Your deprecation implementation only works for inherent impls:

impl TestService {}

But not for trait impls

impl ConsensusInterface for ConsensusDispatcher {} (an example we use downstream for core-rs-ablatross). This is because Rust rejects #[deprecated] on trait-method impls I believe.

Comment thread derive/src/lib.rs

/// Extracts the optional `note` from a `#[deprecated]` attribute in any of its supported forms:
/// `#[deprecated]`, `#[deprecated = "..."]`, or `#[deprecated(note = "...", since = "...")]`.
fn parse_deprecation(attr: &Attribute) -> Deprecation {

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.

#[deprecated(since = "1.0", note = "use foo")] would create a server log without the actual note. Because the since key is not consumed, a syn error is swallowed by the let _ = and the loop never reaches the note.

So now it would depend on the order you write note and since.

Comment thread derive/src/proxy.rs
}

#[::async_trait::async_trait]
#[allow(deprecated)]

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.

A downstream crate with #![deny(deprecated)] or deny(warnings)) now would suddenly fail to compile?

Comment thread server/src/lib.rs
// Built-in introspection methods (the `rpc.` prefix is reserved by the JSON-RPC spec for
// these kinds of system extensions). They let any client discover which methods exist and,
// in particular, which ones are deprecated, so the client can report deprecated usage.
if request.method == "rpc.methods" || request.method == "rpc.deprecatedMethods" {

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.

Could be a match?

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.

2 participants