Skip to content

Charge gas for illegal memory access instruction - #497

Merged
0xjunha merged 1 commit into
gavofyork:mainfrom
davxy:consume-gas-on-bad-memory-access
Nov 19, 2025
Merged

0xjunha merged 1 commit into
gavofyork:mainfrom
davxy:consume-gas-on-bad-memory-access

Conversation

@davxy

@davxy davxy commented Sep 17, 2025

Copy link
Copy Markdown
Collaborator

Charging for the instruction that triggered the trap makes sense also according to this statement at the begin of section A.1

Assuming the program blob is valid (which can be validated statically), some gas is always charged whenever execution
is attempted. This is the case even if no instruction is effectively executed and machine state is unchanged (i.e. the result
state is equal to the parameter).

Otherwise no gas is charged if the very first instruction is one that triggers a trap for memory access.


Furthermore this is consistent and equivalent to an explicit trap instruction, which is charged 1 gas unit.

@davxy
davxy requested a review from zdave-parity September 17, 2025 14:41
@davxy
davxy marked this pull request as ready for review September 17, 2025 14:41
@davxy davxy changed the title Account gas for memory access Account gas for illegal memory access Sep 17, 2025
@davxy davxy changed the title Account gas for illegal memory access Account gas for illegal memory access instruction Sep 17, 2025
@davxy

davxy commented Sep 17, 2025 •

Copy link
Copy Markdown
Collaborator Author

Before

Screenshot from 2025-09-17 16-47-58

After

Screenshot from 2025-09-17 16-46-57

@zdave-parity zdave-parity left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agree that gas should always be charged.

@davxy davxy changed the title Account gas for illegal memory access instruction Charge gas for illegal memory access instruction Sep 17, 2025
@davxy
davxy requested a review from 0xjunha November 19, 2025 06:38
@0xjunha
0xjunha merged commit b318d1e into gavofyork:main Nov 19, 2025
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