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

evmmax: Initial implementation of EVMMAX instructions (EIP-6690) #742

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

rodiazet
Copy link
Collaborator

@rodiazet rodiazet commented Dec 5, 2023

Based on EIP-6690

  • Support new instruction implementation signature. code_iterator (*instr_fn)(StackTop, ExecutionState&, code_iterator, int64_t&)
  • Add EVMMAXstate to evm execution state interface
  • Add EVMMAX modulus interface and implementation for different UintT types
  • Add unit tests.
  • Comparing to the EIP this implementation is simplified by assumption that there can be only one exiting modulus. Calling setupx once for the second time remove the previous one and always creates a new one.

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (3d0242b) 97.91% compared to head (ab38a8d) 97.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #742      +/-   ##
==========================================
- Coverage   97.91%   97.83%   -0.08%     
==========================================
  Files         110      112       +2     
  Lines       10580    10946     +366     
==========================================
+ Hits        10359    10709     +350     
- Misses        221      237      +16     
Flag Coverage Δ
blockchaintests 57.58% <0.00%> (-2.66%) ⬇️
statetests 60.94% <0.00%> (-1.22%) ⬇️
statetests-silkpre 25.29% <3.03%> (-0.71%) ⬇️
unittests 95.88% <95.90%> (-0.01%) ⬇️

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

Files Coverage Δ
include/evmmax/evmmax.hpp 100.00% <100.00%> (ø)
lib/evmone/advanced_instructions.cpp 100.00% <ø> (ø)
lib/evmone/baseline.cpp 100.00% <100.00%> (ø)
lib/evmone/execution_state.hpp 96.29% <100.00%> (+0.06%) ⬆️
test/unittests/eof_validation_test.cpp 100.00% <100.00%> (ø)
test/unittests/evmmax_instructions_test.cpp 100.00% <100.00%> (ø)
test/unittests/evmmax_test.cpp 99.35% <100.00%> (+0.96%) ⬆️
test/unittests/instructions_test.cpp 89.58% <100.00%> (ø)
test/utils/bytecode.hpp 96.16% <100.00%> (+0.18%) ⬆️
lib/evmone/instructions.hpp 99.40% <94.20%> (-0.60%) ⬇️
... and 1 more

@rodiazet rodiazet force-pushed the evmmax-intructions branch 27 times, most recently from 7d36325 to 3f42dd5 Compare December 11, 2023 12:49
@rodiazet rodiazet force-pushed the evmmax-intructions branch 3 times, most recently from 89aa150 to ed0056e Compare January 5, 2024 14:16
@rodiazet rodiazet marked this pull request as ready for review January 5, 2024 14:21
@rodiazet rodiazet requested a review from chfast January 5, 2024 14:22
@chfast chfast added EVMMAX and removed precompiles Related to EVM precompiles labels Jan 6, 2024
@chfast chfast changed the title Evmmax instructions in evmone Initial implementation of EVMMAX instructions (EIP-6690) Jan 8, 2024

[[nodiscard]] bool addmodx(size_t dst_idx, size_t x_idx, size_t y_idx) noexcept override
{
if (dst_idx < values.size() && x_idx < values.size() && y_idx < values.size())
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 assume the indexes are valid (because they are going to be validated by EOF). Debug asserts are fine obviously.

@rodiazet rodiazet force-pushed the evmmax-intructions branch 2 times, most recently from e55c458 to e156a5a Compare January 9, 2024 12:07
@rodiazet rodiazet changed the title Initial implementation of EVMMAX instructions (EIP-6690) evmmax: Initial implementation of EVMMAX instructions (EIP-6690) Jan 9, 2024
@rodiazet rodiazet requested a review from chfast January 9, 2024 12:09
@rodiazet rodiazet force-pushed the evmmax-intructions branch 3 times, most recently from 92b00a1 to 4136a08 Compare January 9, 2024 14:27
test: Omit new opcodes with immediate params in unit tests
Add new instruction implementation signature `code_iterator (*instr_fn)(StackTop, ExecutionState&, code_iterator, int64_t&)`
@rodiazet rodiazet force-pushed the evmmax-intructions branch 3 times, most recently from 72ba52f to 81eaef0 Compare January 11, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants