Skip to content

On JSON-RPC, authorization serializes v as yParity#209

Merged
jangko merged 7 commits intomasterfrom
dev/etan/ff-yparity
Jul 30, 2025
Merged

On JSON-RPC, authorization serializes v as yParity#209
jangko merged 7 commits intomasterfrom
dev/etan/ff-yparity

Conversation

@etan-status
Copy link
Copy Markdown
Contributor

JSON uses yParity for authorization instead of v like in transaction, because v for transaction has additional information mixed in in legacy case (chain ID and magic value); this legacy case is not relevant for authorizations. Existing logic ignored yParity value from JSON and uses default initialized v = 0 value. Create our own web3 type, same as how we do it for transactions and receipts, and use correct yParity key.

@arnetheduck
Copy link
Copy Markdown
Member

this passes hive and everything? ie feels like we should have nimbus-eth1/2 PR:s that include this change so their CI's run

minLen: static[int] = 0,
maxLen: static[int] = high(int)] = distinct seq[byte]

U8Quantity* = distinct uint8
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need a new U8Quantity, only readValue/writeValue for uint8. n-j-s is smart enough today.

proc writeValue*(w: var JsonWriter[JrpcConv], v: uint64)
shows we can even get rid of Quantity if needed.

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.

shows we can even get rid of Quantity if needed.

about that, we still lack the "flavor" option to disable the automatic serialization of integers and other primitives, so it's actually risky to rely on uint64

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

okay, I think we need to implement status-im/nim-json-serialization#121 first. looks not too difficult

JSON uses yParity for authorization instead of v like in transaction,
because v for transaction has additional information mixed in in legacy
case (chain ID and magic value); this legacy case is not relevant for
authorizations. Existing logic ignored yParity value from JSON and uses
default initialized v = 0 value. Create our own web3 type, same as how
we do it for transactions and receipts, and use correct yParity key.
@jangko jangko force-pushed the dev/etan/ff-yparity branch from 50d7ef4 to 7421228 Compare July 29, 2025 06:12

# Disable automatic primitive serialization, especially uint64 and uint8
# We don't want they are serialized into ordinary number, but hex.
JrpcConv.automaticSerialization(SomeInteger, false)
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.

I think this is what I meant by the feature feeling messy .. ie it feels like it would be easier to start from a point where JrpcConv has no automatic conversions at all and then add them, rather than disabling some conversions here - this approach feels quite weird and risky, also because of status-im/nim-json-rpc#239..

what would happen here? if I (or some dependency) imports this file, automatic serialization will be disabled where exactly? in this module? in all modules due to macrocache? in some modules, ie those that were imported after this one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right it feels weird

# JrpcConv configuration
#------------------------------------------------------------------------------

JrpcConv.automaticSerialization(string, true)
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.

remove the true here? ie is false meaningful?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, that can be done later.

Co-authored-by: Jacek Sieka <jacek@status.im>
@jangko
Copy link
Copy Markdown
Contributor

jangko commented Jul 30, 2025

one more step left. the new hardhat expect one of input or data field of TransactionArgs and not both. even if one of them is null will error.

@jangko jangko force-pushed the dev/etan/ff-yparity branch from a3aa6c8 to 633b8fd Compare July 30, 2025 10:39
@jangko jangko merged commit 304afd1 into master Jul 30, 2025
20 checks passed
@jangko jangko deleted the dev/etan/ff-yparity branch July 30, 2025 15:10
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