Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: incorrect gas accounting for GAS opcode #36

Closed
Tracked by #28
greged93 opened this issue Aug 29, 2023 · 1 comment
Closed
Tracked by #28

bug: incorrect gas accounting for GAS opcode #36

greged93 opened this issue Aug 29, 2023 · 1 comment
Labels
evm bug Something related to normal EVM execution isn't working

Comments

@greged93
Copy link
Contributor

greged93 commented Aug 29, 2023

Bug Report

Kakarot version: ee6458a

Current behavior:
The gas accounting for the following suite of opcodes is incorrect:

PUSH5 0xffffffffff
PUSH1 0x00
MSTORE
PUSH2 0xeeee
PUSH1 0x5a
MSTORE
GAS
PUSH1 0x00
SSTORE
STOP

Expected behavior:
Expected gas output should be 0x4b1457b, the current implementation calculates 0x1310bb. Main difference comes from the fact that we do not apply the gas cap calculation for a call opcode.

Steps to reproduce:

make setup
make fetch-dump
make target=gas_d0g0v0_Shanghai ef-test

Failing output should be:

[!] Case ~/code/rust/ef-tests/crates/ef-testing/ethereum-tests/BlockchainTests/GeneralStateTests/VMTests/vmIOandFlowOperations/gas.json failed (description: gas): Test failed: failed test gas_d0g0v0_Shanghai: expected storage value 0x0000000000000000000000000000000000000000000000000000000004b1457b, got 0x00000000000000000000000000000000000000000000000000000000001310bb
@greged93 greged93 added the bug Something isn't working label Aug 29, 2023
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Aug 29, 2023
@Eikix
Copy link
Member

Eikix commented Aug 29, 2023

After reading the specification, I see the GAS opcode returns:

Get the amount of available gas, including the corresponding reduction for the cost of this instruction

I'm not sure how we can do this in Cairo without gas accounting, unless we can access gas_used or gas_left in a specific transaction

@Eikix Eikix added this to the Official Ethereum Conformance milestone Aug 29, 2023
@greged93 greged93 added evm bug Something related to normal EVM execution isn't working and removed bug Something isn't working labels Sep 2, 2023
@github-project-automation github-project-automation bot moved this from 🆕 Backlog to ✅ Done in Kakarot on Starknet Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evm bug Something related to normal EVM execution isn't working
Projects
No open projects
Archived in project
Development

No branches or pull requests

3 participants