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

Initcode transaction (TXCREATE) support #702

Closed
wants to merge 2 commits into from
Closed

Initcode transaction (TXCREATE) support #702

wants to merge 2 commits into from

Conversation

gumb0
Copy link
Member

@gumb0 gumb0 commented Jan 11, 2024

Requires #681

@gumb0 gumb0 force-pushed the create3 branch 10 times, most recently from 234facf to 874a0a7 Compare February 29, 2024 19:44
Base automatically changed from create3 to master March 1, 2024 13:06
@gumb0 gumb0 changed the title CREATE4 support TXCREATE support Mar 4, 2024
@gumb0 gumb0 force-pushed the create4 branch 3 times, most recently from 762f323 to 2662288 Compare March 4, 2024 17:46
@gumb0 gumb0 changed the title TXCREATE support Initcode transaction (TXCREATE) support Mar 12, 2024
include/evmc/evmc.h Outdated Show resolved Hide resolved
@@ -4,6 +4,7 @@

/// @file
/// Example implementation of an EVMC Host.
/// TODO: Doesn't support TXCREATE transaction initcodes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure it makes sense to support it, example.c only sends EVMC_CALL message anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to drop the comment like this, if you feel like nothing needs to be done. I was very generous when adding them in

@gumb0 gumb0 self-assigned this Mar 13, 2024
@gumb0 gumb0 force-pushed the create4 branch 4 times, most recently from 9702dec to 3a6b2a3 Compare March 13, 2024 19:14
@gumb0 gumb0 force-pushed the create4 branch 4 times, most recently from 652c662 to 9bd690a Compare March 14, 2024 10:45
Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 5.88235% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 93.11%. Comparing base (f89284f) to head (7241cc5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #702      +/-   ##
==========================================
- Coverage   93.49%   93.11%   -0.39%     
==========================================
  Files          25       25              
  Lines        3861     3878      +17     
  Branches      396      397       +1     
==========================================
+ Hits         3610     3611       +1     
- Misses        139      155      +16     
  Partials      112      112              

@gumb0 gumb0 marked this pull request as ready for review March 14, 2024 11:40
@gumb0 gumb0 requested review from chfast and pdobacz March 14, 2024 11:45
@@ -4,6 +4,7 @@

/// @file
/// Example implementation of an EVMC Host.
/// TODO: Doesn't support TXCREATE transaction initcodes.
Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to drop the comment like this, if you feel like nothing needs to be done. I was very generous when adding them in

@gumb0 gumb0 requested a review from axic March 15, 2024 11:31
Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

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

I don't want to spoil the party, but I think the simpler API would be to extend the evmc_tx_context with

hashed_initcode* initcodes;
size_t initcodes_count;

where

struct hashed_initcode {
    evmc_bytes32 hash;
    const uint8_t* code;
    size_t code_size;
};

@pdobacz
Copy link
Contributor

pdobacz commented Mar 18, 2024

I don't want to spoil the party, but I think the simpler API would be to extend the evmc_tx_context with

Indeed simpler but makes problematic:

  1. Optimizing initcode lookup (unless we require the initcodes are sorted I suppose)
  2. Any usecases where the initcode is fetched not from the TX, for which the fetch-by-hash was introduced in the first place

Neither is maybe big deal but sth to keep in mind.

@gumb0
Copy link
Member Author

gumb0 commented Mar 18, 2024

Indeed simpler but makes problematic:

  1. Optimizing initcode lookup (unless we require the initcodes are sorted I suppose)

I don't think this variant changes much, it only changes where lookup by hash is happening.

  • With current API, Host gets initcodes array from transaction and hashes them and puts them into unordered_map to later serve get_tx_initcode_by_hash() requests.
  • With this new API, Host will get initcode array from transaction, hash them once and serve as array in tx_context, then EVM will get them and put into unordered_map on EVM side (in evmone it will be in ExecutionState).
  1. Any usecases where the initcode is fetched not from the TX, for which the fetch-by-hash was introduced in the first place

For something other than transaction, it will be some other different API? But I think fetch-by-hash is mainly for easier aggregating several transactions (or AA-transactions) into one batch transaction (merging their initcodes without changing TXCREATE instances). I don't think this usecase is in any way affected.

@gumb0
Copy link
Member Author

gumb0 commented Mar 18, 2024

Anyway I plan to try this in a different PR.

@pdobacz
Copy link
Contributor

pdobacz commented Mar 18, 2024

Makes sense!

@chfast
Copy link
Member

chfast commented Mar 18, 2024

The other approach can be implemented as a "flat map": vector of already sorted (hash, initcode) pairs. EVM only need to read it and can lookup values by binary search.

But I'm not insisting on sorting values right now. Linear search should be fine as the start.

@gumb0
Copy link
Member Author

gumb0 commented Mar 18, 2024

The other approach can be implemented as a "flat map": vector of already sorted (hash, initcode) pairs. EVM only need to read it and can lookup values by binary search.

ethereum/evmone@55a7102
EVM puts them into unordered_map.

@gumb0
Copy link
Member Author

gumb0 commented Mar 26, 2024

Replaced by #709

@gumb0 gumb0 closed this Mar 26, 2024
gumb0 added a commit that referenced this pull request Mar 26, 2024
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.

3 participants