Skip to content

Replace JrpcConv by custom EthJson flavor#237

Merged
nitely merged 5 commits into
status-im:masterfrom
nitely:jrpc_flavor
May 1, 2026
Merged

Replace JrpcConv by custom EthJson flavor#237
nitely merged 5 commits into
status-im:masterfrom
nitely:jrpc_flavor

Conversation

@nitely
Copy link
Copy Markdown
Contributor

@nitely nitely commented Jan 13, 2026

Changes:

  • Add EthJson (replaces JrpcConv).
  • Add web3/eth_json_marshal (replaces json_rpc/jsonmarshal).
  • Remove JrpcConv usage and json_rpc/jsonmarshal exports.
  • Pending: nim-json-rpc release

Should EthJson live here or in nim-eth?

Note: rpc context adds an indentation level; if reviewing in github, turn on "Hide whitespace" config in the tool bar.

Comment thread tests/helpers/handlers.nim Outdated
proc eth_syncing(x: JsonString): SyncingStatus =
return SyncingStatus(syncing: false)

proc eth_sendRawTransaction(x: JsonString, data: seq[byte]): Hash32 =
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.

hm - this actually looks pretty good, ie having the flavor up in the rpc part.

Not really for this PR, but one thing that has always put me off a bit with json_rpc is the fact that these functions are implicitly async without this being visible in the signature or anywhere really .. it has crossed my mind that it should be made explicit somewhere, ie either server.asyncRpc(EthJson) so that there's "async" in the name, or server.rpc(async = true, Format = EthJson), or variations thereof ..

the point being of course that a lot of these functions are not async, so we would need a way to override the default per-function.

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.

Well, you can add {.async.} to the signatures, it produces the same code. We could add support to specify the return as Future[T] too.

the point being of course that a lot of these functions are not async, so we would need a way to override the default per-function.

Maybe we should enforce the async pragma. Later we can do a different transformation if the async pragma is not specified (i.e: the proc is synchronous).

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.

Maybe we should enforce the async pragma.

mmh, but if we do this, we should copy the entire pragma section into the generated async proc. So async: (raises: [MyException]) is applied.

Copy link
Copy Markdown
Contributor Author

@nitely nitely Feb 25, 2026

Choose a reason for hiding this comment

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

I implemented support for async and non-async RPC functions status-im/nim-json-rpc#264 and I updated this PR to use raises.

@arnetheduck
Copy link
Copy Markdown
Member

Should EthJson live here or in nim-eth?

Here - at least for now - though there's maybe room for moving it in the future depending on how we define the role of nim-eth - specially since the encoding has gotten a lot more standardised in recent years there might be a case for putting it in eth..

The other reason we use json_ser is logging which uses the default flavor - something that would be nice for chronicles is if it used its own logging flavor that automatically inherited the default flavor but could be overridden (for example to log more compact representations of things, hide passwords and omit parts).

Copy link
Copy Markdown
Member

@arnetheduck arnetheduck left a comment

Choose a reason for hiding this comment

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

very nice! let's get everything released and merged

@jangko
Copy link
Copy Markdown
Contributor

jangko commented Apr 26, 2026

Please rebase, it's time to merge this PR and apply changes to nimbus-eth1. Before complexity in nimbus-eth1 increase because we shifted our attention to improve nimbus-eth1 RPC condition.

@nitely nitely marked this pull request as ready for review April 30, 2026 14:53
@nitely
Copy link
Copy Markdown
Contributor Author

nitely commented Apr 30, 2026

@jangko is nimbus-eth1 kurtosis test flaky? I ran them 3 times (status-im/nimbus-eth1#3914), 1st it failed one test, 2nd it sigsev (the golang binary it seems), 3rd passed. But I've also seen them fail for a harmless change here status-im/nimbus-eth1#4181

@jangko
Copy link
Copy Markdown
Contributor

jangko commented Apr 30, 2026

Probably fixed by status-im/nimbus-eth1#4186

@nitely nitely merged commit 288f1ee into status-im:master May 1, 2026
15 checks passed
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.

4 participants