Skip to content

Conversation

spencer-tb
Copy link
Contributor

@spencer-tb spencer-tb commented Aug 20, 2025

🗒️ Description

Aims to update the modexp helpers to allow for length mismatch tests.

Length mismatch tests can be added with the following, copied over and refactored from #2044.

pytest.param(
    ModExpInput(
        base=b"",
        exponent=Bytes("80"),
        modulus=b"",
        declared_exponent_length=2**64,
    ),
    id="exp_2_pow_64_base_0_mod_0",
),

🔗 Related Issues or PRs

Fixes #2043 (attemps to).

✅ Checklist

  • All: Ran fast tox checks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:
    uvx --with=tox-uv tox -e lint,typecheck,spellcheck,markdownlint
  • All: PR title adheres to the repo standard - it will be used as the squash commit message and should start type(scope):.
  • All: Considered adding an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • All: Set appropriate labels for the changes (only maintainers can apply labels).

@spencer-tb spencer-tb added scope:tests Scope: Changes EL client test cases in `./tests` type:chore Type: Chore fork:osaka Osaka hardfork labels Aug 20, 2025
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.

This is still not fully consistent and I don't think you can reliably compute gas using this higher level structure. One reason is pointed out in the inline comment. Another reason is you can use raw_input= (and there are good reasons to do so) and then all the additional properties (e.g. length_base) are garbage. Same as the computed gas.

This precompile has ultimately complex input structure. If you want something reliable consider this: you can have reach set of constructors and/or constructor arguments for readability. But you should immediately build input bytes out of them. And the gas cost must be computed from bytes. EELS has it already so you can copy the code for start.

@@ -86,6 +128,26 @@ def from_bytes(cls, input_data: Bytes | str) -> "ModExpInput":

return cls(base=base, exponent=exponent, modulus=modulus, raw_input=input_data)

@classmethod
def create_mismatch(
Copy link
Member

Choose a reason for hiding this comment

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

This feels a bit too much for me. I generally struggle with some data types in EEST which have a lot of interconnected options and flags.

This could be a normal constructor. And you can fix the properties directly in the constructor like:

length_base = declared_base_length if  declared_base_length not None else len(base)

@spencer-tb spencer-tb force-pushed the modexp-length-override branch from 61c67db to d30b8ec Compare August 29, 2025 20:00
@spencer-tb
Copy link
Contributor Author

Updated regarding the comments using the EELS like approach..

Copy link
Collaborator

@LouisTsai-Csie LouisTsai-Csie left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fork:osaka Osaka hardfork scope:tests Scope: Changes EL client test cases in `./tests` type:chore Type: Chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ModExpInput prevents creating trimmed inputs
3 participants