Skip to content

rpcserver: Support named and null parameters, Review optionals on rpc internal methods, Stronger Response and Error codes#831

Merged
Davidson-Souza merged 3 commits into
getfloresta:masterfrom
jaoleal:some_fixes_rpcserver
Jun 2, 2026
Merged

rpcserver: Support named and null parameters, Review optionals on rpc internal methods, Stronger Response and Error codes#831
Davidson-Souza merged 3 commits into
getfloresta:masterfrom
jaoleal:some_fixes_rpcserver

Conversation

@jaoleal
Copy link
Copy Markdown
Member

@jaoleal jaoleal commented Feb 6, 2026

Description and Notes

Some time ago i was messing with the server trying to fix some pains that i had developing methods on it and i encountered some points to upgrade.

4839dc6 - fixes #827 by matching errors and returning constant values, i also mapped some custom error codes to internal errors as I understood that were allowed by the spec.

29220da- Adds named and null parameters support, I also reviewed some Options in internal rpc methods that actually had internal defaults, created a getter for that case.

fix #827
fix #704

How to verify the changes you have done?

Pushed some extensive tests regarding request and result parsing and behavior, checking that calls are accepted when expected and when refused we assert the error response.

Contributor Checklist

  • I've followed the contribution guidelines
  • I've verified one of the following:
    • Ran just pcc (recommended but slower)
    • Ran just lint-features '-- -D warnings' && cargo test --release
    • Confirmed CI passed on my fork
  • I've linked any related issue(s) in the sections above

Finally, you are encouraged to sign all your commits (it proves authorship and guards against tampering—see How (and why) to sign Git commits and GitHub's guide to signing commits).

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 6, 2026

cc @csgui

Why i cant alter the name of the PR 😭

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch from 766648c to 5cd9007 Compare February 6, 2026 23:25
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 6, 2026

Can someone with permission to alter the pr title fix it for me ?

rpcserver: Support named and null parameters, Review optionals on rpc internal methods, Stronger Response and Error codes.

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 6, 2026

5cd9007 Unrelated test fail

@Davidson-Souza Davidson-Souza added RPC Changes something with our JSON-RPC interface code quality Generally improves code readability and maintainability labels Feb 7, 2026
@Davidson-Souza Davidson-Souza changed the title rpcserver: Support named and null parameters, Review optionals on rpc internal methods, rpcserver: Support named and null parameters, Review optionals on rpc internal methods, Stronger Response and Error codes Feb 7, 2026
Comment thread crates/floresta-node/src/json_rpc/request.rs Outdated
Comment thread crates/floresta-node/src/json_rpc/request.rs Outdated
Comment thread crates/floresta-node/src/json_rpc/request.rs Outdated
Comment thread crates/floresta-node/src/json_rpc/request.rs Outdated
Comment thread crates/floresta-node/src/json_rpc/request.rs Outdated
@csgui
Copy link
Copy Markdown
Collaborator

csgui commented Feb 8, 2026

@jaoleal double check if you can use <T: DeserializeOwned> or <'de, T: Deserialize<'de>>. Not both, choose one.

That would makes more sense and allows the remove of clone in the code. When parsing RPC parameters clone can cause performance issues and increased memory pressure under heavy load. We do not have control on what Floresta user is passing to a RPC call.

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch 2 times, most recently from c13b68a to 0e160f5 Compare February 9, 2026 09:22
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 9, 2026

top commit: 0e160f5

  • Removed a clone from get_at, lifetime matching solved that.
  • Included back MempoolAccept, sorry conflict problems.
  • Fixed a bug matching against params in get_arr_at where it would result unwrapping in a malformed input.
  • Added extensive tests, they were written by claudiao but i reviewed it and found a bug.
  • Fixed a bug when an optional parameter is omitted when params are omitted as a whole.

Thanks for the suggestions @csgui

@moisesPompilio
Copy link
Copy Markdown
Collaborator

I think the commit descriptions are missing because they only have titles.

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch from 0e160f5 to 781ea91 Compare February 9, 2026 19:07
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 9, 2026

[781ea91 Rebased and extended commit message with descriptions.

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 9, 2026

Added formal fix statement for the issues that this pr fixes.

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch from 781ea91 to 994e4b7 Compare February 10, 2026 01:44
@jaoleal

This comment was marked as outdated.

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch 4 times, most recently from 2d230a8 to bd4d7a1 Compare February 10, 2026 15:45
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 10, 2026

gaddamit these conflicts

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch from bd4d7a1 to d18e6dd Compare February 10, 2026 20:32
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Feb 10, 2026

unrelated fail on functional tests d18e6dd

@jaoleal jaoleal requested a review from csgui February 11, 2026 18:07
Copy link
Copy Markdown
Contributor

@lorenzolfm lorenzolfm left a comment

Choose a reason for hiding this comment

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

ACK 784bf23

@jaoleal jaoleal force-pushed the some_fixes_rpcserver branch from 784bf23 to 0f040b6 Compare May 15, 2026 17:37
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 15, 2026

Rebased

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 18, 2026

Rebased 4dc5b8a

Comment thread crates/floresta-node/src/json_rpc/request.rs
Comment thread crates/floresta-node/src/json_rpc/server.rs
Comment thread crates/floresta-node/src/json_rpc/server.rs
Comment thread crates/floresta-node/src/json_rpc/request.rs Outdated
Comment thread crates/floresta-node/src/json_rpc/blockchain.rs
Comment thread tests/conftest.py
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 18, 2026

Ok, I remade the commit structure, theyre more concentrated now but i think its better.

Fixed the marked found by @moisesPompilio

@Davidson-Souza
Copy link
Copy Markdown
Member

Needs rebase.

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 25, 2026

Rebased

2 similar comments
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 26, 2026

Rebased

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 27, 2026

Rebased

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented May 27, 2026

Removed unwrap from getdifficulty

Comment thread tests/test_framework/rpc/base.py
Comment thread tests/florestad/rpcserver_request_parsing.py Outdated
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Jun 1, 2026

Done @moisesPompilio

Comment thread crates/floresta-node/src/json_rpc/server.rs
Copy link
Copy Markdown
Collaborator

@csgui csgui left a comment

Choose a reason for hiding this comment

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

@jaoleal left a comment regarding the gettxoutproof changes. Can you please check?

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Jun 1, 2026

@jaoleal left a comment regarding the gettxoutproof changes. Can you please check?

Yeah, it certainly changed because of the removal of .to_lower_hex_string().

I found another issues while trying to test it. I see this problem as something more focused on how gettxoutproof was implemented, this was a existing inconsistency problem that was raised because of the changes from this pr.

Given that, ill open a follow-up pr fixing gettxoutproof inconsistencies that rebases on top of this. Works for you @csgui ?

@csgui
Copy link
Copy Markdown
Collaborator

csgui commented Jun 1, 2026

Given that, ill open a follow-up pr fixing gettxoutproof inconsistencies that rebases on top of this. Works for you @csgui ?

Yes, it works @jaoleal . Please open an issue about what need to be tackled on gettxoutproof and mention that it should be covered with better testing. If we had better test coverage, issues like this would be caught much sooner. Tks!

Copy link
Copy Markdown
Collaborator

@csgui csgui left a comment

Choose a reason for hiding this comment

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

ACK 311485d

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Jun 1, 2026

If we had better test coverage, issues like this would be caught much sooner. Tks!

We could focus some time and work to test and assert on what we current have, to find a problem that way is literally a punch in the stomach.

@csgui
Copy link
Copy Markdown
Collaborator

csgui commented Jun 1, 2026

We could focus some time and work to test and assert on what we current have, to find a problem that way is literally a punch in the stomach.

Sure thing. Hardening the tests is on the table for the next plans. That might be our focus soon.

@Davidson-Souza
Copy link
Copy Markdown
Member

Needs more rebase 😢

jaoleal added 3 commits June 2, 2026 13:17
… calls

- Move JsonRpcError into a jsonrpc_interface submodule with structured
  RpcError/Response types, HTTP status code mapping, and named constants
  for floresta-specific RPC error codes (TX_NOT_FOUND, BLOCK_NOT_FOUND,
  PEER_NOT_FOUND, etc.)
- Add From<BlockchainError> for JsonRpcError conversion
- Rewrite arg_parser with generic get_at(), get_with_default(), and
  try_into_optional() functions supporting both positional (array) and
  named (object) parameters
- Change RpcRequest.params from Vec<Value> to Option<Value>
- Split method dispatch into no-param methods and param methods
- Replace all .unwrap() calls
- Apply #[deny(clippy::unwrap_used)] lint to the json_rpc module
- Change ScriptPubKeyJson.address to Option<String> for nonstandard
  scripts (matching Bitcoin Core behavior)
- Add module-level documentation for JSON-RPC 1.0/2.0 version support
- Add JSON-RPC error code (JSONRPC_ERRCODE_*) and message
  (JSONRPC_ERRMSG_*) constants to test_framework/constants.py
- Add make_raw_request, make_raw_data_request, make_request,
  assert_rpc_success, and assert_rpc_error to test_framework/rpc/base.py
- Extract _create_logger helper to deduplicate fixture logging setup
- Add class-scoped shared_florestad_node, shared_bitcoind_node, and
  shared_utreexod_node fixtures to conftest.py
- Switch xdist to loadscope distribution for class-scoped fixture safety
- Add comprehensive tests covering positional and named parameters,
  null/omitted params, optional defaults, error codes and messages, and
  response structure validation
- Add JSON-RPC 1.0 and 2.0 version acceptance tests (explicit version, omitted
  field, and response format verification)
- Add content-type handling tests (application/json, text/plain, and
  non-JSON body rejection)
@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Jun 2, 2026

Re based

@jaoleal
Copy link
Copy Markdown
Member Author

jaoleal commented Jun 2, 2026

last review round guys @csgui @Davidson-Souza @lorenzolfm @moisesPompilio

Copy link
Copy Markdown
Member

@Davidson-Souza Davidson-Souza left a comment

Choose a reason for hiding this comment

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

ACK b80de6a

Copy link
Copy Markdown
Member

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

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

ACK b80de6a

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

Labels

architecture reliability Related to runtime reliability, stability and production readiness RPC Changes something with our JSON-RPC interface

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Replace JSON-RPC error code literals with named constants [Bug] json-rpc server doesn't support named parameter

9 participants