Skip to content

num-audit: extension#474

Merged
mattsse merged 13 commits intoalloy-rs:mainfrom
yash-atreya:num_audit_ext
Apr 8, 2024
Merged

num-audit: extension#474
mattsse merged 13 commits intoalloy-rs:mainfrom
yash-atreya:num_audit_ext

Conversation

@yash-atreya
Copy link
Contributor

@yash-atreya yash-atreya commented Apr 6, 2024

Motivation

Extension of #454

Solution

  • gas related fields to u128
  • nonce and number to u64 in Header from B64 and U256 respectively

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

* gas related field to `u128`
* `nonce` and `number` to `u64` in `Header` from `B64` and `U256` respectively
@klkvr
Copy link
Member

klkvr commented Apr 6, 2024

rpc_types::TransactionReceipt also has several u64 gas price fields

@klkvr
Copy link
Member

klkvr commented Apr 6, 2024

I am experiencing serde-rs/json#625 on latest alloy while deserializing WithOtherFields<TransactionRequest>, so I think we should ensure that all u128 fields have a with = u128_hex_or_decimal or similar alternative even if we only serialize/deserialize it as a decimal

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

very supportive
unifying all of them is necessary, just need to ensure we keep hex support

@yash-atreya yash-atreya requested review from mattsse and prestwich April 8, 2024 18:21
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

last pedantic serde nits

@yash-atreya yash-atreya requested review from mattsse and prestwich April 8, 2024 20:31
@prestwich
Copy link
Member

#465 actually somewhat superseded by the newer issue wrt serde helpers redundant code

@yash-atreya
Copy link
Contributor Author

#465 actually somewhat superseded by the newer issue wrt serde helpers redundant code

Yes, the PR that addresses #479 will close #465

@yash-atreya yash-atreya requested review from klkvr and mattsse April 8, 2024 20:55
@prestwich
Copy link
Member

#465 actually somewhat superseded by the newer issue wrt serde helpers redundant code

Yes, the PR that addresses #479 will close #465

not exactly because moving to via_ruint canonizes the tolerant behavior, where #465 would require significant changes to reject the invalid-but-tolerated objects

Given how much surface area its add, my current preference is to leave everything tolerant

@mattsse
Copy link
Member

mattsse commented Apr 8, 2024

Given how much surface area its add, my current preference is to leave everything tolerant

hmm, for response types, being tolerant is actually beneficial because the user doesn't really care how the server formats it

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

per above,
also, supporting decimals on deserialize is okay and perhaps even preferable, in case servers don't follow QUANTITY

@mattsse mattsse merged commit cd5a2c7 into alloy-rs:main Apr 8, 2024
ben186 pushed a commit to ben186/alloy that referenced this pull request Jul 27, 2024
* num-audit: extension
* gas related field to `u128`
* `nonce` and `number` to `u64` in `Header` from `B64` and `U256` respectively

* num-audit: gas fields to `u128` in Genesis

* num-audit: use primitive types in rpc-types: common, optimism, receipt, request

* fix(rpc-types): request tests

* fix(rpc-types): optimism tests

* add serde attr and fix rpc-types tests

* timestamp -> `u64` in rpc-types `block`

* nit

* serde attr nits

* skip_serializing nits

* rpc-types: make `gas_used` required in receipt

* fix: gas filler tests
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