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

feat(forks): Add gas costs functions #779

Merged
merged 12 commits into from
Nov 4, 2024

Conversation

marioevz
Copy link
Member

@marioevz marioevz commented Aug 30, 2024

🗒️ Description

Introduce gas-calculating functions in the fork object, which are updated for each fork:

  • memory_expansion_gas_calculator: Calculates the cost of expanding the memory from a starting memory length to a new memory length. Unchanged since Frontier fork.
  • calldata_gas_calculator: Calculates the intrinsic gas cost of a transaction calldata, given the amount of zero and non-zero bytes in it. Changed in Istanbul fork (not directly but due gas_costs().G_TX_DATA_NON_ZERO reduction).
  • transaction_intrinsic_cost_calculator: Calculates the intrinsic gas cost of a transaction given the calldata, whether the transaction is contract creating, the access list, and the number of authorizations. Updated for Homestead, Berlin and Prague forks.
  • gas_costs: returns an Enum containing all gas-related constants.

This PR should make the implementation of the TransactionTest spec type easier (#933).

🔗 Related Issues

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@marioevz marioevz force-pushed the update-to-gas-cost-functions-in-prep-for-eip-7623 branch from b933107 to 3e2ec92 Compare October 31, 2024 22:43
@marioevz marioevz marked this pull request as ready for review October 31, 2024 22:44
@marioevz marioevz requested a review from danceratopz October 31, 2024 22:50
@marioevz marioevz added scope:forks Scope: ethereum_test_forks package scope:tests Scope: Test cases type:refactor Type: Refactor type:feat type: Feature labels Oct 31, 2024
Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

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

Really impressive!

@marioevz marioevz merged commit 4ddc4f0 into main Nov 4, 2024
6 checks passed
@marioevz marioevz deleted the update-to-gas-cost-functions-in-prep-for-eip-7623 branch November 4, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:forks Scope: ethereum_test_forks package scope:tests Scope: Test cases type:feat type: Feature type:refactor Type: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants