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

EIP-4844 - pass blockchain tests #1077

Merged
merged 6 commits into from
Jan 15, 2025
Merged

EIP-4844 - pass blockchain tests #1077

merged 6 commits into from
Jan 15, 2025

Conversation

pdobacz
Copy link
Contributor

@pdobacz pdobacz commented Dec 3, 2024

build/bin/evmone-blockchaintest ~/Downloads/fixtures_test_prague_devnet_5/blockchain_tests/cancun/eip4844_blobs/
...
[==========] 43 tests from 7 test suites ran. (4250 ms total)
[  PASSED  ] 43 tests.

🍏

NOTE: I'll squash the commits before merging.

NOTE2: opening as draft to work through CI issues. Not reviewable yet, but if I'm completely off the scent somewhere, please let know

Ready for review

Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.30%. Comparing base (7a96b8e) to head (49b2258).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1077      +/-   ##
==========================================
+ Coverage   94.28%   94.30%   +0.02%     
==========================================
  Files         159      159              
  Lines       17229    17273      +44     
==========================================
+ Hits        16245    16290      +45     
+ Misses        984      983       -1     
Flag Coverage Δ
eof_execution_spec_tests 23.82% <55.38%> (+0.21%) ⬆️
ethereum_tests 26.90% <69.23%> (+0.27%) ⬆️
ethereum_tests_silkpre 18.94% <22.64%> (+<0.01%) ⬆️
execution_spec_tests 21.30% <69.23%> (+0.33%) ⬆️
unittests 88.97% <69.23%> (-0.08%) ⬇️

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

Files with missing lines Coverage Δ
test/blockchaintest/blockchaintest.hpp 0.00% <ø> (ø)
test/blockchaintest/blockchaintest_loader.cpp 98.90% <100.00%> (+0.12%) ⬆️
test/blockchaintest/blockchaintest_runner.cpp 80.62% <100.00%> (+2.39%) ⬆️
test/state/block.cpp 100.00% <100.00%> (ø)
test/state/block.hpp 100.00% <ø> (ø)
test/state/host.cpp 100.00% <100.00%> (ø)
test/state/state.cpp 98.41% <100.00%> (+0.01%) ⬆️
test/state/transaction.hpp 100.00% <100.00%> (ø)
test/statetest/statetest_loader.cpp 97.81% <100.00%> (ø)
test/t8n/t8n.cpp 88.16% <100.00%> (+0.07%) ⬆️
... and 4 more

@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch 2 times, most recently from c6d64a1 to 8b251ca Compare December 9, 2024 12:09
@pdobacz pdobacz marked this pull request as ready for review December 9, 2024 12:10
@pdobacz pdobacz requested a review from chfast December 9, 2024 12:10
@pdobacz pdobacz added the Cancun Changes for Cancun Ethereum spec revision label Dec 9, 2024
@pdobacz pdobacz self-assigned this Dec 9, 2024
@@ -493,7 +493,7 @@ evmc_tx_context Host::get_tx_context() const noexcept
m_block.prev_randao,
0x01_bytes32, // Chain ID is expected to be 1.
uint256be{m_block.base_fee},
intx::be::store<uint256be>(m_block.blob_base_fee),
intx::be::store<uint256be>(compute_blob_gas_price(m_block.excess_blob_gas.value_or(0))),
Copy link
Member

Choose a reason for hiding this comment

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

I think we should not compute this each access. Maybe we need two sets of fields in BlockInfo: official/header fields and computed values.

If big deal, we can handle this by separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, get_tx_context() is called within the instruction, yeah, better to fix right away :(. Alternatively this can be kept in Host? WDYT? if we can avoid mixing header/computed values, maybe it's better? or is Host just inappropriate for this?

Copy link
Member

Choose a reason for hiding this comment

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

Better to put it back to BlockInfo because this is also used in transaction validation and transition. These are also important cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

argh, I've done it and only after I recalled from previous week, that I have already been there. The problem which arises is that it makes compute_blob_gas_price come before block validation, making problematic inputs (excess_blob_gas) come through, which previously wasn't the case. fake_exponential seems to go into infinite loop for such inputs.

I'll need to revisit this and look more closely at what exactly is happening

Copy link
Member

Choose a reason for hiding this comment

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

I imagine we keep the newly added field and also have blob_base_fee "after" them computed as some point...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I explored this idea, but I'm struggling to find a good point to compute that. It would sacrifice some consts and make a mess, or force us to introduce more complexity to manage that.

I have a counter-proposal. I dug deeper into fake_exponential, and it seems to me like not only it infinite loops but also easily overflows over 256 bits. If I cap the result at uint256::max on mul overflow (I can post code in a moment), things work OK. I think the tacit assumption in fake_exponential spec is that it should use arbitrary precision, and I peeked at some impls and they actually do that.

So I'd rather fix fake_exponential to not loop/overflow, and rely on current block validation, which would reject the block properly.

I see three options here:

  1. switch from uint256 to big int of some sort
  2. detect overflow and cap compute_blob_gas_price to uint256::max
  3. detect overflow and return nullopt from compute_blob_gas_price

2 is the easiest (will push in a sec), but has the disadvantage of there being a block with potentially incorrect blob_base_fee field, hanging around until we reject it (on validation of excess/used blob gas fields).

3 seems better but not sure if the opts won't proliferate around the code base excessively. Maybe not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying (2.) first

@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch 2 times, most recently from 781660c to 672e4d8 Compare December 11, 2024 13:37
@chfast chfast requested a review from Copilot December 11, 2024 14:21

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

Files not reviewed (14)
  • test/blockchaintest/blockchaintest.hpp: Language not supported
  • test/blockchaintest/blockchaintest_loader.cpp: Language not supported
  • test/blockchaintest/blockchaintest_runner.cpp: Language not supported
  • test/state/block.cpp: Language not supported
  • test/state/block.hpp: Language not supported
  • test/state/host.cpp: Language not supported
  • test/state/state.cpp: Language not supported
  • test/state/transaction.hpp: Language not supported
  • test/statetest/statetest_loader.cpp: Language not supported
  • test/t8n/t8n.cpp: Language not supported
  • test/unittests/state_transition.cpp: Language not supported
  • test/unittests/state_transition_block_test.cpp: Language not supported
  • test/unittests/state_transition_tx_test.cpp: Language not supported
  • test/unittests/state_tx_test.cpp: Language not supported
@pdobacz pdobacz requested a review from chfast December 11, 2024 14:38
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch 2 times, most recently from 2c04d7d to fff2f4f Compare December 17, 2024 13:50
@pdobacz pdobacz changed the base branch from master to enable-inv-bloack December 17, 2024 13:50
@pdobacz pdobacz marked this pull request as draft December 17, 2024 13:55
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from fff2f4f to 3224eb4 Compare December 17, 2024 15:44
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch 2 times, most recently from fcfbac4 to 4557052 Compare December 17, 2024 17:49
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from 4557052 to 8dbd8c6 Compare December 18, 2024 16:44
Base automatically changed from enable-inv-bloack to master December 18, 2024 19:24
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from 8dbd8c6 to cc76590 Compare January 8, 2025 14:51
@pdobacz pdobacz marked this pull request as ready for review January 8, 2025 16:01
@pdobacz
Copy link
Contributor Author

pdobacz commented Jan 8, 2025

@chfast I've almost forgotten about this one 😅 . Rebased and tests seem to pass, ready to review

Copy link
Contributor

@rodiazet rodiazet left a comment

Choose a reason for hiding this comment

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

OK in general. Some nitpicks added. Most important ones with not throwing access to optional already mentioned by @chfast

@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from ddc3296 to 55328e6 Compare January 15, 2025 08:38
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from 55328e6 to b87fcf3 Compare January 15, 2025 08:55
Copy link
Contributor

@rodiazet rodiazet left a comment

Choose a reason for hiding this comment

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

One last nit.

@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from b87fcf3 to 87b8bca Compare January 15, 2025 09:21
@pdobacz pdobacz requested a review from chfast January 15, 2025 09:26
@pdobacz pdobacz force-pushed the eip4844-blockchain-tests branch from 87b8bca to 49b2258 Compare January 15, 2025 10:28
@pdobacz pdobacz merged commit c49bc0a into master Jan 15, 2025
25 checks passed
@pdobacz pdobacz deleted the eip4844-blockchain-tests branch January 15, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cancun Changes for Cancun Ethereum spec revision
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants