Skip to content

core/vm: add read only protection for opcodes#33637

Merged
rjl493456442 merged 2 commits into
ethereum:masterfrom
rjl493456442:add-readonly-protect
Jan 19, 2026
Merged

core/vm: add read only protection for opcodes#33637
rjl493456442 merged 2 commits into
ethereum:masterfrom
rjl493456442:add-readonly-protect

Conversation

@rjl493456442

Copy link
Copy Markdown
Member

This PR reverts a part of changes brought by https://github.com/ethereum/go-ethereum/pull/33281/changes

Specifically, read-only protection should always be enforced at the opcode level,
regardless of whether the check has already been performed during gas metering.

It should act as a gatekeeper, otherwise, it is easy to introduce errors by adding
new gas measurement logic without consistently applying the read-only protection.

lightclient
lightclient previously approved these changes Jan 19, 2026

@lightclient lightclient left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems nice to have this additional safeguard.

Comment thread core/vm/operations_acl.go
// it can effectively prevent accessing the states in the following steps
if contract.Gas < gas {
return gas, nil
return 0, ErrOutOfGas

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's effectively a no-op change, because either way, it will be caught in the interpreter loop. It's fine though, and the comment is nice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, two approaches are equivalent. We use error in some other places and it's better to keep them consistent.

@rjl493456442 rjl493456442 added this to the 1.17.0 milestone Jan 19, 2026
@rjl493456442 rjl493456442 merged commit 500931b into ethereum:master Jan 19, 2026
11 of 13 checks passed
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 23, 2026
AnilChinchawale pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Feb 5, 2026
gballet pushed a commit to BZO95/go-ethereum that referenced this pull request May 21, 2026
This PR reverts a part of changes brought by https://github.com/ethereum/go-ethereum/pull/33281/changes

Specifically, read-only protection should always be enforced at the opcode level, 
regardless of whether the check has already been performed during gas metering.

It should act as a gatekeeper, otherwise, it is easy to introduce errors by adding
new gas measurement logic without consistently applying the read-only protection.
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