Skip to content

Conversation

@gumb0
Copy link
Member

@gumb0 gumb0 commented Dec 9, 2024

https://eips.ethereum.org/EIPS/eip-7685

  • Introduce Requests type.
  • Calculate hash of the list of requests after transactions execution.
  • Read expected hash from blockchain test files and compare with result of calculation.
  • Use requests hash calculation function in t8n.

(EIP-7685 tests are not enabled yet, because they require all of EIP-6110, 7002 and 7251 to be implemented.)

@gumb0 gumb0 changed the title Implement EIP-7685: General purpose execution layer requests EIP-7685: General purpose execution layer requests Dec 9, 2024
@gumb0 gumb0 force-pushed the eip-7685 branch 3 times, most recently from c696b91 to 2a1cfaf Compare December 9, 2024 17:27
// if (requests.data.empty())
// continue;

const bytes requests_bytes = requests.type + requests.data;
Copy link
Member Author

Choose a reason for hiding this comment

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

This can be optimized to get rid of copying, if we represent Requests as just struct Requests { bytes data; } and put type as the first byte of data right away when collecting requests.

Let me know if it's worth it. I think not really, as it only affects blockchain test runner performance.

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 this is worth it when all EIPs are implemented. So let's make an issue to track it.

Copy link
Member

Choose a reason for hiding this comment

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

This can be also handled by init-update-final API for sha256.

BTW, is there rationale for this double-hashing?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is worth it when all EIPs are implemented. So let's make an issue to track it.

#1086

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW, is there rationale for this double-hashing?

Good question, I couldn't find any in the EIP, other than previously it was a root of MPT and now is hash of flat list of hashes.
Asked on magicians https://ethereum-magicians.org/t/eip-7685-general-purpose-execution-layer-requests/19668/20

@codecov
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.29%. Comparing base (94582ff) to head (b72a12a).

Files with missing lines Patch % Lines
test/state/requests.hpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1083   +/-   ##
=======================================
  Coverage   94.29%   94.29%           
=======================================
  Files         157      159    +2     
  Lines       17080    17102   +22     
=======================================
+ Hits        16105    16127   +22     
  Misses        975      975           
Flag Coverage Δ
eof_execution_spec_tests 23.65% <100.00%> (+0.12%) ⬆️
ethereum_tests 26.49% <26.08%> (-0.01%) ⬇️
ethereum_tests_silkpre 19.08% <0.00%> (-0.02%) ⬇️
execution_spec_tests 20.35% <100.00%> (+0.12%) ⬆️
unittests 89.24% <4.34%> (-0.11%) ⬇️

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.73% <100.00%> (+0.01%) ⬆️
test/blockchaintest/blockchaintest_runner.cpp 79.20% <100.00%> (+2.12%) ⬆️
test/state/requests.cpp 100.00% <100.00%> (ø)
test/state/requests.hpp 0.00% <0.00%> (ø)

@gumb0 gumb0 marked this pull request as ready for review December 9, 2024 20:43
@gumb0 gumb0 requested review from chfast and pdobacz December 9, 2024 20:43
@gumb0 gumb0 self-assigned this Dec 9, 2024
Copy link
Member

@pdobacz pdobacz left a comment

Choose a reason for hiding this comment

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

LGTM overall, I left some minor comments. Also, maybe we're ready to undo the workarounds from https://github.com/ethereum/evmone/pull/1064/files ?

struct Requests
{
/// Request type.
uint8_t type = 0;
Copy link
Member

Choose a reason for hiding this comment

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

is having a default good here?

Copy link
Member

Choose a reason for hiding this comment

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

also, maybe introduce a Request::Type enum like for tx?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was meaning to just introduce constants for types in respective later PRs, but enum is a better idea, I'll add it in the next PR.

Having a default in general is good, otherwise it may be left uninitialized.

Copy link
Member

Choose a reason for hiding this comment

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

Having a default in general is good, otherwise it may be left uninitialized.

ah right, that would not error out :(. OK then

Copy link
Member Author

Choose a reason for hiding this comment

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

added enum here

@gumb0
Copy link
Member Author

gumb0 commented Dec 10, 2024

Also, maybe we're ready to undo the workarounds from https://github.com/ethereum/evmone/pull/1064/files ?

Ah I forgot about t8n, thanks for the reminder. I'll look into it, it probably will go to a separate PR, too.

@chfast chfast added the Prague Changes for Prague upgrade label Dec 10, 2024
@pdobacz
Copy link
Member

pdobacz commented Dec 10, 2024

Ah I forgot about t8n, thanks for the reminder. I'll look into it, it probably will go to a separate PR, too.

OK, but also maybe this in particular is better off here to make the change more atomic? Also, t8n has an integration test, so your code would also get automatically covered by that for extra assurance.

using RequestsList = std::vector<Requests>;

/// Calculate commitment value of block requests list
hash256 calculate_requests_hash(std::span<const Requests> block_requests_list);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
hash256 calculate_requests_hash(std::span<const Requests> block_requests_list);
hash256 calculate_requests_hash(std::span<const Requests> requests_list);

};

/// Block requests list - container of `requests` objects, ordered by request type.
using RequestsList = std::vector<Requests>;
Copy link
Member

Choose a reason for hiding this comment

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

I'd skip this alias because we also use std::span<Requests>.

hash256 calculate_requests_hash(std::span<const Requests> block_requests_list)
{
bytes requests_hash_list;
requests_hash_list.reserve(sizeof(bytes32) * block_requests_list.size());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
requests_hash_list.reserve(sizeof(bytes32) * block_requests_list.size());
requests_hash_list.reserve(sizeof(hash256) * block_requests_list.size());

// if (requests.data.empty())
// continue;

const bytes requests_bytes = requests.type + requests.data;
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 this is worth it when all EIPs are implemented. So let's make an issue to track it.

Introduce Requests and RequestsList types.
Calculate hash of the list of requests after transactions execution.
Read expected hash from blockchain test files and compare with result of calculation.
@gumb0 gumb0 force-pushed the eip-7685 branch 2 times, most recently from 229cdf7 to b991667 Compare December 10, 2024 18:29
@gumb0 gumb0 requested review from chfast and pdobacz December 10, 2024 18:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 9 changed files in this pull request and generated no suggestions.

Files not reviewed (8)
  • 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/CMakeLists.txt: Language not supported
  • test/state/requests.cpp: Language not supported
  • test/state/requests.hpp: Language not supported
  • test/t8n/CMakeLists.txt: Language not supported
  • test/t8n/t8n.cpp: Language not supported

@gumb0 gumb0 merged commit 2939b9f into master Dec 11, 2024
23 checks passed
@gumb0 gumb0 deleted the eip-7685 branch December 11, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Prague Changes for Prague upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants