Skip to content

feat(levm): opcodes gas consumption#584

Merged
jrchatruc merged 29 commits into
mainfrom
levm/feat/gas-opcode
Oct 2, 2024
Merged

feat(levm): opcodes gas consumption#584
jrchatruc merged 29 commits into
mainfrom
levm/feat/gas-opcode

Conversation

@juanimedone

@juanimedone juanimedone commented Sep 27, 2024

Copy link
Copy Markdown
Contributor

Motivation
Implement GAS opcode, which requires a first global handling of gas consumption.

Description

  • Uses VM::gas_limit and VM::consumed_gas for handling all opcodes static and dynamic gas consumption.
  • Check if gas is enough before executing each one of them.
  • Save warm_addresses in VM.
  • Fixes a jump bug and a CALL test.
  • Adds gas checks to the tests.
  • CALL's code_execution_cost is still to be implemented (Implement CALL's code_execution_cost #605).

Closes #493 and #587.

@juanimedone juanimedone linked an issue Sep 27, 2024 that may be closed by this pull request
@juanimedone juanimedone linked an issue Sep 30, 2024 that may be closed by this pull request
- Add new `is_empty` function for `Account`.
- Save `warm_addresses` in `VM`.
- `code_execution_cost` for `CALL` is still missing.
- Fix a `CALL` test.
@juanimedone juanimedone self-assigned this Sep 30, 2024
@juanimedone juanimedone marked this pull request as ready for review September 30, 2024 20:25
@juanimedone juanimedone requested a review from a team as a code owner September 30, 2024 20:25
Comment thread crates/levm/src/vm.rs Outdated
Comment thread crates/levm/src/memory.rs Outdated
Comment thread crates/levm/src/vm.rs Outdated
Comment thread crates/levm/tests/tests.rs Outdated

@belfortep belfortep left a comment

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.

Great work! everything looks nice, just asked for some minor changes

@belfortep belfortep left a comment

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.

LGTM! 🚀

@jrchatruc jrchatruc added this pull request to the merge queue Oct 2, 2024
Merged via the queue into main with commit 8a1cb85 Oct 2, 2024
@jrchatruc jrchatruc deleted the levm/feat/gas-opcode branch October 2, 2024 21:24
emirongrr pushed a commit to emirongrr/ethrex that referenced this pull request Nov 10, 2024
**Motivation**
Implement `GAS` opcode, which requires a first global handling of gas
consumption.
<!-- Why does this pull request exist? What are its goals? -->

**Description**
- Uses `VM::gas_limit` and `VM::consumed_gas` for handling all opcodes
static and dynamic gas consumption.
- Check if gas is enough before executing each one of them.
- Save `warm_addresses` in `VM`.
- Fixes a `jump` bug and a `CALL` test.
- Adds gas checks to the tests. 
- `CALL`'s `code_execution_cost` is still to be implemented (lambdaclass#605). 
<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves lambdaclass#111, Resolves lambdaclass#222 -->

Closes lambdaclass#493 and lambdaclass#587.

---------

Co-authored-by: Paolo Belforte <75280184+belfortep@users.noreply.github.com>
Co-authored-by: iinaki <llorensinaki22@gmail.com>
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.

Handle opcodes gas consumption Opcode: GAS

4 participants