Skip to content

Implement EIP-7883 #1226

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

Open
wants to merge 1 commit into
base: forks/osaka
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ethereum/osaka/vm/precompiled_contracts/modexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def complexity(base_length: U256, modulus_length: U256) -> Uint:
"""
max_length = max(Uint(base_length), Uint(modulus_length))
words = (max_length + Uint(7)) // Uint(8)
return words ** Uint(2)
complexity = words ** Uint(2)
if max_length <= Uint(32):
return complexity
else:
return Uint(2) * complexity


def iterations(exponent_length: U256, exponent_head: Uint) -> Uint:
Expand Down Expand Up @@ -120,7 +124,7 @@ def iterations(exponent_length: U256, exponent_head: Uint) -> Uint:

count = bit_length
else:
length_part = Uint(8) * (Uint(exponent_length) - Uint(32))
length_part = Uint(16) * (Uint(exponent_length) - Uint(32))
bits_part = Uint(exponent_head.bit_length())

if bits_part > Uint(0):
Expand Down Expand Up @@ -166,4 +170,4 @@ def gas_cost(
iteration_count = iterations(exponent_length, exponent_head)
cost = multiplication_complexity * iteration_count
cost //= GQUADDIVISOR
return max(Uint(200), cost)
return max(Uint(500), cost)
Loading