Skip to content

Implement BaseFee, blobBaseFee, CallValue, GasPrice, Balance and SelfBalance for EVM v2#10229

Draft
ahamlat wants to merge 3 commits intobesu-eth:mainfrom
ahamlat:wei-opcodes-on-evm-v2
Draft

Implement BaseFee, blobBaseFee, CallValue, GasPrice, Balance and SelfBalance for EVM v2#10229
ahamlat wants to merge 3 commits intobesu-eth:mainfrom
ahamlat:wei-opcodes-on-evm-v2

Conversation

@ahamlat
Copy link
Copy Markdown
Contributor

@ahamlat ahamlat commented Apr 13, 2026

PR description

Continues the EVM v2 implementation started in #10105.

Implement V2 versions of five Wei-related opcodes operating directly on the long[] stack: BALANCE (0x31), SELFBALANCE (0x47), BASEFEE (0x48), BLOBBASEFEE (0x4a), CALLVALUE (0x34), and GASPRICE (0x3a).

The stack long[] array is not exposed beyond the operation boundary. Each operation is solely responsible for manipulating the stack: reading inputs, writing results, and updating the stack top pointer. The shared helper methods (pushWei, pushZero, toAddressAt) are deliberately simple write/read primitives that operate on a given slot index -- they have no knowledge of the stack top and do not return or update it. The caller (the operation's execute method) is responsible for computing the correct slot indices and deciding whether/how to update the stack top based on its own pop/push semantics.

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

ahamlat added 3 commits April 13, 2026 15:00
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
// significant)
private final long[] stackDataV2;
private int stackTopV2;
private final int stackMaxSize;
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.

Wonder if there's any advantage to this field over referring to txValues.maxStackSize in line?

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.

Suggested change
private final int stackMaxSize;
private final int stackMaxSizeV2;

@@ -29,6 +35,19 @@
*/
public abstract class AbstractOperation implements Operation {
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.

I thought we discussed and agreed to introduce AbstractOperationV2 as duplicate of AbstractOperation - has your thinking changed on that?

If we prefer mixing V1 and V2 code together, then perhaps we should mix AbstractFixCostOperationV2 as well so we're sticking to a single convention for V2.

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.

Do changes here impact V1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants