Skip to content

Conversation

@manuelmauro
Copy link
Contributor

@manuelmauro manuelmauro commented Aug 29, 2025

Description

Adds support for EIP-7623

@manuelmauro manuelmauro changed the base branch from master to v0.x August 29, 2025 14:52
@sorpaas
Copy link
Member

sorpaas commented Aug 31, 2025

Thanks! I'll also try to cherry-pick this changes once you finished to v1.0 branch.

@manuelmauro manuelmauro marked this pull request as ready for review September 2, 2025 16:00
used_gas: 0,
refunded_gas: 0,
config,
metrics: GasMetrics::new(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Metrics is probably a bad name. Could we do something similar to bluealloy/revm#1744?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better solution! Addressed in dc1f984

@RomarQ
Copy link
Contributor

RomarQ commented Sep 5, 2025

Thanks! I'll also try to cherry-pick this changes once you finished to v1.0 branch.

Since v1.0 branch has access to execution layer vector tests for pectra, I would prefer that we do the first implementation there. @manuelmauro Could you give it a try?

@RomarQ RomarQ mentioned this pull request Sep 5, 2025
12 tasks
gas_per_empty_account_cost: u64,
has_eip_7623: bool,
gas_calldata_zero_floor: u64,
gas_calldata_non_zero_floor: u64,
Copy link
Contributor

@RomarQ RomarQ Sep 5, 2025

Choose a reason for hiding this comment

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

To avoid having many fields in DerivedConfigInputs, we could have a single field, which is specify to eip-7623

pub struct EIP7623Config {
 enabled: bool,
 standard_token_cost: u64,
 total_cost_floor_per_token: u64
}
Suggested change
gas_calldata_non_zero_floor: u64,
eip_7623: EIP7623Config

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, we already 2 constants that are used for this.

gas_transaction_zero_data: 4,
gas_transaction_non_zero_data: 16,

Copy link
Contributor

@RomarQ RomarQ Sep 5, 2025

Choose a reason for hiding this comment

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

eip-7623 changes gas_transaction_non_zero_data from 16 to 40 and gas_transaction_zero_data from 4 to 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need to keep both, because the 10/40 is applied only in the case the 4/16 plus execution costs do not reach the floor.

tx.gasUsed = (
    21000
    +
    max(
        STANDARD_TOKEN_COST * tokens_in_calldata
        + execution_gas_used
        + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)),
        TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
    )
)

The STANDARD_TOKEN_COST stays 4, while we add TOTAL_COST_FLOOR_PER_TOKEN which is 10.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid having many fields in DerivedConfigInputs, we could have a single field, which is specify to eip-7623

I like this, but maybe better to evaluate it as a refactoring in another PR?

@manuelmauro
Copy link
Contributor Author

Thanks! I'll also try to cherry-pick this changes once you finished to v1.0 branch.

Since v1.0 branch has access to execution layer vector tests for pectra, I would prefer that we do the first implementation there. @manuelmauro Could you give it a try?

Draft PR here: #391

@sorpaas sorpaas merged commit 6917b13 into rust-ethereum:v0.x Sep 8, 2025
2 checks passed
manuelmauro added a commit to moonbeam-foundation/evm that referenced this pull request Sep 8, 2025
* feat: ✨ add support for EIP-7623

* feat: ✨ add post_execution method to gasometer

* fix: 🐛 check for invalid gas limit

* feat: ✨ add gas tracker

* style: 🎨 fmt

* fix: 🐛 add check for recorded transaction

* Revert "fix: 🐛 add check for recorded transaction"

This reverts commit e129161.

* fix: 🐛 use saturanting arithmetic in execution gas calculation

* refactor: 🔥 remove apply_eip_7623_adjustment function

* fix: 🐛 fix computation of EIP-7623 cost

* fix: 🐛 fix execution cost computation

* refactor: ♻️ move cost computation inside GasTracker

* perf: ⚡ add caching to GasTracker

* test: ✅ add proper testing

* refactor: 🚨 clippy

* refactor: ♻️ rename GasTracker to GasMetrics and move it to a new module

* refactor: ♻️ rename execution_cost to non_intrinsic_cost

* refactor: ♻️ rename tracker to metrics

* docs: 📝 improve docs

* fix: 🐛 add instrinsic gas cost metric

* docs: 📝 document intrinsic_cost_metrics method

* refactor: ♻️ add init method to GasMetrics

* refactor: ♻️ reduce code duplication

* refactor: ♻️ improve if condition

* fix: 🐛 add contract creation component to intrinsic gas calculation

* fix: 🐛 remove duplicated init_code_cost component

* refactor: 🔥 remove intrinsic cost metrics

* test: ✅ test invalid transaction with gas lower than floor/intrinsic cost

* refactor: ♻️ wildly simplify the solution

* revert: ⏪ remove refactoring
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