Skip to content

Conversation

@yperbasis
Copy link
Member

@yperbasis yperbasis commented Aug 7, 2025

Make sure that lengths of the form 2^64*n, n>=1 are not accepted (that would be a violation of EIP-7823).

N.B. EIP-7823 restricts the range of expLen even in the special case baseLen == 0 && modLen == 0.

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.

In evmone, I handle EIP-7823 in the "gas" function by returning the MAX_GAS in case the lengths are above the limits. May this potentially improve code structure?

@yperbasis
Copy link
Member Author

In evmone, I handle EIP-7823 in the "gas" function by returning the MAX_GAS in case the lengths are above the limits. May this potentially improve code structure?

To my mind relying on the gas function is a bit brittle because it disperses EIP-7823 checks among two functions.

@yperbasis yperbasis enabled auto-merge (squash) August 8, 2025 07:18
@chfast
Copy link
Member

chfast commented Aug 11, 2025

In evmone, I handle EIP-7823 in the "gas" function by returning the MAX_GAS in case the lengths are above the limits. May this potentially improve code structure?

To my mind relying on the gas function is a bit brittle because it disperses EIP-7823 checks among two functions.

I think this would keep the EIP-7823 in the gas function only. But I'm not pushing here.

// 32 - 8 bytes are truncated in the Uint64 conversion above
baseLenHighBitsAreZero = allZero(header[0 : 32-8])
expLenHighBitsAreZero = allZero(header[32 : 64-8])
modLenHighBitsAreZero = allZero(header[64 : 96-8])
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 baseLenHighBitsAreZero and modLenHighBitsAreZero are always true in practice because otherwise we would get huge gas cost because of the "mult complexity" calculation. I.e. these will not be testable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I'd like to have them here for consistency and robustness so that Run is self-explanatory w/o a hidden dependency on the behaviour of RequiredGas.

}

// Handle a special case when both the base and mod length is zero
if baseLen == 0 && modLen == 0 && baseLenHighBitsAreZero && modLenHighBitsAreZero {
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 the original check was overspecified. This is true for only the modLen being 0 (you can skip the base check).

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right. I've amended the special case.

@yperbasis yperbasis merged commit aaf47b3 into main Aug 12, 2025
13 of 15 checks passed
@yperbasis yperbasis deleted the yperbasis/more_eip7823 branch August 12, 2025 09:30
yperbasis added a commit that referenced this pull request Aug 12, 2025
Make sure that lengths of the form 2^64*_n_, _n_>=1 are not accepted
(that would be a violation of
[EIP-7823](https://eips.ethereum.org/EIPS/eip-7823)).

N.B. EIP-7823 restricts the range of `expLen` even in the special case
`baseLen == 0 && modLen == 0`.
NazariiDenha pushed a commit that referenced this pull request Oct 24, 2025
Make sure that lengths of the form 2^64*_n_, _n_>=1 are not accepted
(that would be a violation of
[EIP-7823](https://eips.ethereum.org/EIPS/eip-7823)).

N.B. EIP-7823 restricts the range of `expLen` even in the special case
`baseLen == 0 && modLen == 0`.
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.

4 participants