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

EIP-7623 #8093

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

daniellehrner
Copy link
Contributor

PR description

Implements EIP-7623 (calldata cost increase)

Fixed Issue(s)

fixes #7994

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:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

@daniellehrner daniellehrner force-pushed the feat/issue-7994/eip-7623 branch from 348ad34 to 2d2cfaf Compare January 9, 2025 22:15
Signed-off-by: Daniel Lehrner <[email protected]>
Signed-off-by: Daniel Lehrner <[email protected]>
Copy link
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

I think there's a bug in when the floor gets applied for tx processing, see comments.

I like the way you structured the refactor 👍

Perhaps not a functional issue, but I'm a little confused by the Long boundary checks:

  • Their use appears inconsistent which makes me wonder if one or more of them were left in by accident?
  • I understand checking MAX_VALUE before an add (although doesn't clampedAdd already handle this?) but I don't understand why we return early if the intermediate cost == MIN_VALUE. In the intermediate calculations, won't the subsequent addition usually mean cost > MIN_VALUE?

*
* @param payload the call data payload
* @param isContractCreation whether the transaction is a contract creation
* @param baselineGas how much gas is used by access lists and code delegations
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: baselineGas isn't the most descriptive name but this is a hard one to name. IMO we should try to match the spec with our names (which is still in flux so good luck 😆)

cc. @jflo as just noticed you had the opposite opinion 😅 #7997 (comment)

Comment on lines +157 to +159
if (cost == Long.MIN_VALUE || cost == Long.MAX_VALUE) {
return cost;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we do check MIN_VALUE and return here, potentially bypassing adding more to the cost below?

To me, this doesn't appear to be equivalent behaviour to https://github.com/hyperledger/besu/blob/2aadbfcb0a6c22734ef3ae8cc2ae3823512c5419/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java

final long totalCostFloor =
tokensInCallData(payload.size(), zeroBytes(payload)) * TOTAL_COST_FLOOR_PER_TOKEN;

return clampedAdd(TX_BASE_COST, Math.max(dynamicIntrinsicGasCost, totalCostFloor));
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is a bug because we shouldn't consider the totalCostFloor as part of the intrinsic gas, rather apply the floor after tx execution.

Note, this code does still work for validating the tx (where the floor is only compared against the intrinsic gas).

According to the latest spec correction, the floor should also be applied after the refund: https://github.com/ethereum/execution-specs/pull/1076/files

In short:

gas_used -= refund
gas_used = max(gas_used, floor_cost)

where gas_used is the post-execution value rather than intrinsic gas.

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.

Pectra devnet-5: EIP-7623: Increase calldata cost
2 participants