-
Notifications
You must be signed in to change notification settings - Fork 1k
EIP-7918 blob base fee bounded by execution cost #8724
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
Merged
macfarla
merged 14 commits into
hyperledger:main
from
macfarla:7918-blob-base-fee-bound-by-execution-cost
Jun 6, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eb21c59
draft
macfarla 9511c66
fixed test and calculations; added a bunch of debug
macfarla 75cf3cb
cleanup
macfarla cc7ec1c
Merge branch 'main' of github.com:hyperledger/besu into 7918-blob-bas…
macfarla 941e694
Merge branch 'main' of github.com:hyperledger/besu into 7918-blob-bas…
macfarla 43d9fc8
pr review
macfarla 454ed58
Merge branch 'main' of github.com:hyperledger/besu into 7918-blob-bas…
macfarla 8612ccb
unencapsulate fields
macfarla 0f48dd1
Merge branch 'main' of github.com:hyperledger/besu into 7918-blob-bas…
macfarla 87217a6
return 0 if feeMarket doesn't implementBlobFee
macfarla 3c5f24f
Merge branch 'main' of github.com:hyperledger/besu into 7918-blob-bas…
macfarla e3381c9
remove redundant check
macfarla f4bb482
merge
macfarla 1c37142
Merge branch 'main' into 7918-blob-base-fee-bound-by-execution-cost
Gabriel-Trintinalia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...test/java/org/hyperledger/besu/ethereum/mainnet/OsakaTargetingGasLimitCalculatorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| /* | ||
| * Copyright contributors to Besu. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.hyperledger.besu.ethereum.mainnet; | ||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
|
||
| import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; | ||
| import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; | ||
| import org.hyperledger.besu.evm.gascalculator.OsakaGasCalculator; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.TestInstance; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| @TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
| class OsakaTargetingGasLimitCalculatorTest { | ||
| private static final long TARGET_BLOB_GAS_PER_BLOCK_OSAKA = 0x120000; | ||
|
|
||
| private final OsakaGasCalculator osakaGasCalculator = new OsakaGasCalculator(); | ||
| private final BaseFeeMarket feeMarket = FeeMarket.cancunDefault(0L, Optional.empty()); | ||
|
|
||
| @ParameterizedTest( | ||
| name = "{index} - parent gas {0}, used gas {1}, parent base fee per gas {2}, new excess {3}") | ||
| @MethodSource("osakaExcessBlobGasTestCases") | ||
| public void shouldCalculateOsakaExcessBlobGasCorrectly( | ||
| final long parentExcess, | ||
| final long used, | ||
| final long parentBaseFeePerGas, | ||
| final long expected) { | ||
| int maxBlobs = 10; | ||
| int targetBlobs = 9; | ||
| final OsakaTargetingGasLimitCalculator osakaTargetingGasLimitCalculator = | ||
| new OsakaTargetingGasLimitCalculator( | ||
| 0L, feeMarket, osakaGasCalculator, maxBlobs, targetBlobs); | ||
|
|
||
| final long usedBlobGas = osakaGasCalculator.blobGasCost(used); | ||
| assertThat( | ||
| osakaTargetingGasLimitCalculator.computeExcessBlobGas( | ||
| parentExcess, usedBlobGas, parentBaseFeePerGas)) | ||
| .isEqualTo(expected); | ||
| } | ||
|
|
||
| Iterable<Arguments> osakaExcessBlobGasTestCases() { | ||
| long targetGasPerBlock = TARGET_BLOB_GAS_PER_BLOCK_OSAKA; | ||
| return List.of( | ||
| // Case 1: Below target, should return 0 | ||
| Arguments.of(0L, 0L, 0L, 0L), | ||
| Arguments.of(targetGasPerBlock - 1, 0L, 0L, 0L), | ||
| Arguments.of(0L, 8, 0L, 0L), // 8 blobs is below target (9) | ||
|
|
||
| // Case 2: Above target, BLOB_BASE_COST * baseFee <= GAS_PER_BLOB * blobFee | ||
| // This should use the formula: parentExcess + parentBlobGasUsed - target | ||
| Arguments.of(targetGasPerBlock * 2, 10, 17L, 2490368L), | ||
|
|
||
| // Case 3: Above target, BLOB_BASE_COST * baseFee > GAS_PER_BLOB * blobFee | ||
| // This should use the formula: parentExcess + parentBlobGasUsed * (max - target) / max | ||
| Arguments.of(targetGasPerBlock, 1, 0L, osakaGasCalculator.getBlobGasPerBlob()), | ||
| Arguments.of(targetGasPerBlock, 10, 1L, 1310720L), | ||
| Arguments.of(targetGasPerBlock, 10, 16L, 1310720L)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldUseCorrectBlobGasPerBlob() { | ||
| // should use OsakaGasCalculator's blob gas per blob to calculate the gas limit | ||
| final long blobGasPerBlob = osakaGasCalculator.getBlobGasPerBlob(); | ||
| assertThat(blobGasPerBlob).isEqualTo(131072); // same as Cancun | ||
|
|
||
| int maxBlobs = 10; | ||
| int targetBlobs = 9; | ||
| var osakaTargetingGasLimitCalculator = | ||
| new OsakaTargetingGasLimitCalculator( | ||
| 0L, feeMarket, osakaGasCalculator, maxBlobs, targetBlobs); | ||
|
|
||
| // if maxBlobs = 10, then the gas limit would be 131072 * 10 = 1310720 | ||
| assertThat(osakaTargetingGasLimitCalculator.currentBlobGasLimit()) | ||
| .isEqualTo(blobGasPerBlob * maxBlobs); | ||
| assertThat(osakaTargetingGasLimitCalculator.currentBlobGasLimit()).isEqualTo(1310720); | ||
| assertThat(osakaTargetingGasLimitCalculator.getTargetBlobGasPerBlock()) | ||
| .isEqualTo(blobGasPerBlob * targetBlobs); | ||
| } | ||
|
|
||
| @Test | ||
| void testComputeExcessBlobGasWithDifferentConditions() { | ||
| // Create a test instance with specific parameters | ||
| int maxBlobs = 10; | ||
| int targetBlobs = 9; | ||
| var calculator = | ||
| new OsakaTargetingGasLimitCalculator( | ||
| 0L, feeMarket, osakaGasCalculator, maxBlobs, targetBlobs); | ||
| assertThat(calculator.maxBlobsPerBlock).isEqualTo(maxBlobs); | ||
| assertThat(calculator.targetBlobsPerBlock).isEqualTo(targetBlobs); | ||
|
|
||
| long parentExcessBlobGas = calculator.getTargetBlobGasPerBlock(); | ||
| long parentBlobGasUsed = osakaGasCalculator.getBlobGasPerBlob() * 2; | ||
|
|
||
| // Test the condition where BLOB_BASE_COST * baseFee > GAS_PER_BLOB * blobFee | ||
| // This should use the first formula | ||
| long result1 = calculator.computeExcessBlobGas(parentExcessBlobGas, parentBlobGasUsed, 0L); | ||
| // Expected value based on the test case | ||
| assertThat(result1).isEqualTo(262144L); | ||
|
|
||
| // Test with very high excess blob gas to trigger the second formula | ||
| // When excess is high, blob fee will be high, potentially making BLOB_BASE_COST * baseFee <= | ||
| // GAS_PER_BLOB * blobFee | ||
| long highExcess = calculator.getTargetBlobGasPerBlock() * 10; | ||
| long result2 = calculator.computeExcessBlobGas(highExcess, parentBlobGasUsed, 0L); | ||
| // Expected value based on the test case | ||
| assertThat(result2).isEqualTo(10878976L); | ||
| } | ||
|
|
||
| @Test | ||
| void dryRunDetector() { | ||
| Assertions.assertThat(true) | ||
| .withFailMessage("This test is here so gradle --dry-run executes this class") | ||
| .isTrue(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.