Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change transaction value fields from u128 to a wrapper-type of U256 #4439

Merged
merged 4 commits into from
Oct 4, 2023

Conversation

roberto-bayardo
Copy link
Contributor

@roberto-bayardo roberto-bayardo commented Aug 31, 2023

Chains like OP stack can use the entire range of "value" (256 bits) in a transaction, so we are changing the type to a 256-bit capable representation. The field is still treated as u128 within to/from_compact for backwards DB compatibility with Ethereum & other chains where 128 bits is sufficient. A "value-256" feature is introduced that enables 256-bit DB encoding for value.

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #4439 (ac462ff) into main (6f4febc) will increase coverage by 0.03%.
Report is 1 commits behind head on main.
The diff coverage is 77.65%.

Impacted file tree graph

Files Coverage Δ
bin/reth/src/main.rs 14.28% <ø> (ø)
crates/consensus/common/src/validation.rs 71.73% <100.00%> (ø)
crates/interfaces/src/test_utils/generators.rs 98.23% <100.00%> (ø)
crates/primitives/src/transaction/legacy.rs 100.00% <100.00%> (ø)
crates/storage/codecs/derive/src/compact/mod.rs 94.84% <100.00%> (+0.02%) ⬆️
crates/primitives/src/transaction/eip1559.rs 83.94% <50.00%> (ø)
crates/primitives/src/transaction/eip2930.rs 92.59% <66.66%> (ø)
crates/primitives/src/transaction/eip4844.rs 38.73% <0.00%> (ø)
crates/primitives/src/transaction/tx_value.rs 98.24% <98.24%> (ø)
crates/rpc/rpc-types-compat/src/transaction/mod.rs 0.00% <0.00%> (ø)
... and 6 more

... and 11 files with indirect coverage changes

Flag Coverage Δ
integration-tests 15.56% <27.65%> (+0.01%) ⬆️
unit-tests 62.60% <77.65%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 32.63% <ø> (ø)
blockchain tree 80.44% <ø> (ø)
pipeline 88.45% <ø> (ø)
storage (db) 73.32% <100.00%> (+<0.01%) ⬆️
trie 94.52% <ø> (+0.03%) ⬆️
txpool 49.62% <12.50%> (+0.44%) ⬆️
networking 76.08% <ø> (-0.04%) ⬇️
rpc 57.72% <0.00%> (-0.01%) ⬇️
consensus 61.06% <100.00%> (ø)
revm 28.54% <25.00%> (ø)
payload builder 8.16% <ø> (ø)
primitives 85.31% <91.89%> (+0.04%) ⬆️

@rkrasiuk
Copy link
Member

@mattsse ptal

@roberto-bayardo
Copy link
Contributor Author

this is just a draft, no need to review just yet. we need to figure out how to best implement the to/from_compact methods to preserve the current ethereum DB format.

@roberto-bayardo roberto-bayardo changed the title change transaction value fields from u128 to U256 change transaction value fields from u128 to a wrapper-type of U256 Sep 3, 2023
@roberto-bayardo roberto-bayardo force-pushed the roberto/value-to-U256 branch 6 times, most recently from 988f15a to 0bc6340 Compare September 3, 2023 19:26
@roberto-bayardo roberto-bayardo marked this pull request as ready for review September 3, 2023 19:41
@roberto-bayardo roberto-bayardo force-pushed the roberto/value-to-U256 branch 5 times, most recently from 252effb to 492e77d Compare September 3, 2023 21:25
crates/storage/codecs/derive/src/compact/mod.rs Outdated Show resolved Hide resolved
crates/primitives/src/transaction/mod.rs Outdated Show resolved Hide resolved
crates/primitives/src/transaction/mod.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@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.

I understand why we need this and this fix makes sense to me.

One problem is, that we're running CI with --all-features, which should be fine for testing but I think we should take extra precautions so that it does not slip into the reth binary.

maybe with a mutually exclusive feature (ethereum) or another compile check in the reth binary

crates/primitives/src/transaction/mod.rs Outdated Show resolved Hide resolved
crates/primitives/src/transaction/mod.rs Outdated Show resolved Hide resolved
crates/primitives/src/transaction/mod.rs Outdated Show resolved Hide resolved
crates/primitives/src/transaction/mod.rs Outdated Show resolved Hide resolved
@roberto-bayardo roberto-bayardo force-pushed the roberto/value-to-U256 branch 5 times, most recently from 8634aae to e42f6f4 Compare September 28, 2023 17:01
@mattsse
Copy link
Collaborator

mattsse commented Sep 28, 2023

@roberto-bayardo we just merge the big alloy transition, hence the conflicts.

feature-wise this PR lgtm and I'm supportive, I will make some feature changes so we guarantee that the reth binary never ships with this.

we can phase this out once we're breaking the database format.

And I'm actually not sure if this would even effect existing dbs on ethereum since we're always <u128, wdyt @joshieDo ?

…ike OP where this value might take on the full range
@roberto-bayardo
Copy link
Contributor Author

I have resolved the conflicts.

@mattsse mattsse requested a review from onbjerg as a code owner October 3, 2023 12:47
Copy link
Collaborator

@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.

lgtm.

I've added some macros that act as compile check to ensure the feature is enabled/disabled.

This is only needed for existing databases and can all be phased out when we decide to break the format

@mattsse mattsse added C-enhancement New feature or request A-db Related to the database labels Oct 3, 2023
@mattsse mattsse enabled auto-merge October 3, 2023 13:30
@mattsse mattsse requested a review from joshieDo October 3, 2023 13:33
@mattsse mattsse added this pull request to the merge queue Oct 4, 2023
Merged via the queue into paradigmxyz:main with commit 081d71e Oct 4, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants