-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drive Cancun, Prague and Osaka target and max blobs per block from genesis config. If blobSchedule is missing, use the mainnet default values. Target is wired into appropriate *GasCalculator implementations. Max is wired into appropriate *TargetingGasLimitCalculator implementations. --------- Signed-off-by: Simon Dudley <simon.dudley@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
- Loading branch information
Showing
29 changed files
with
701 additions
and
106 deletions.
There are no files selected for viewing
This file contains 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 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
137 changes: 137 additions & 0 deletions
137
config/src/main/java/org/hyperledger/besu/config/BlobScheduleOptions.java
This file contains 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,137 @@ | ||
/* | ||
* Copyright contributors to Hyperledger 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.config; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
/** The Blob Schedule config options. */ | ||
public class BlobScheduleOptions { | ||
|
||
private final ObjectNode blobScheduleOptionsConfigRoot; | ||
|
||
private static final String CANCUN_KEY = "cancun"; | ||
private static final String PRAGUE_KEY = "prague"; | ||
private static final String OSAKA_KEY = "osaka"; | ||
|
||
/** | ||
* Instantiates a new Blob Schedule config options. | ||
* | ||
* @param blobScheduleConfigRoot the blob schedule config root | ||
*/ | ||
public BlobScheduleOptions(final ObjectNode blobScheduleConfigRoot) { | ||
this.blobScheduleOptionsConfigRoot = blobScheduleConfigRoot; | ||
} | ||
|
||
/** | ||
* Gets cancun blob schedule. | ||
* | ||
* @return the cancun blob schedule | ||
*/ | ||
public Optional<BlobSchedule> getCancun() { | ||
return JsonUtil.getObjectNode(blobScheduleOptionsConfigRoot, CANCUN_KEY).map(BlobSchedule::new); | ||
} | ||
|
||
/** | ||
* Gets prague blob schedule. | ||
* | ||
* @return the prague blob schedule | ||
*/ | ||
public Optional<BlobSchedule> getPrague() { | ||
return JsonUtil.getObjectNode(blobScheduleOptionsConfigRoot, PRAGUE_KEY).map(BlobSchedule::new); | ||
} | ||
|
||
/** | ||
* Gets osaka blob schedule. | ||
* | ||
* @return the osaka blob schedule | ||
*/ | ||
public Optional<BlobSchedule> getOsaka() { | ||
return JsonUtil.getObjectNode(blobScheduleOptionsConfigRoot, OSAKA_KEY).map(BlobSchedule::new); | ||
} | ||
|
||
/** | ||
* As map. | ||
* | ||
* @return the map | ||
*/ | ||
public Map<String, Object> asMap() { | ||
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); | ||
getCancun().ifPresent(bs -> builder.put(CANCUN_KEY, bs.asMap())); | ||
getPrague().ifPresent(bs -> builder.put(PRAGUE_KEY, bs.asMap())); | ||
getOsaka().ifPresent(bs -> builder.put(OSAKA_KEY, bs.asMap())); | ||
return builder.build(); | ||
} | ||
|
||
/** The Blob schedule for a particular fork. */ | ||
public static class BlobSchedule { | ||
private final int target; | ||
private final int max; | ||
|
||
/** The constant CANCUN_DEFAULT. */ | ||
public static final BlobSchedule CANCUN_DEFAULT = new BlobSchedule(3, 6); | ||
|
||
/** The constant PRAGUE_DEFAULT. */ | ||
public static final BlobSchedule PRAGUE_DEFAULT = new BlobSchedule(6, 9); | ||
|
||
/** The constant OSAKA_DEFAULT. */ | ||
public static final BlobSchedule OSAKA_DEFAULT = new BlobSchedule(9, 12); | ||
|
||
/** | ||
* Instantiates a new Blob schedule. | ||
* | ||
* @param blobScheduleConfigRoot the blob schedule config root | ||
*/ | ||
public BlobSchedule(final ObjectNode blobScheduleConfigRoot) { | ||
this.target = JsonUtil.getInt(blobScheduleConfigRoot, "target").orElseThrow(); | ||
this.max = JsonUtil.getInt(blobScheduleConfigRoot, "max").orElseThrow(); | ||
} | ||
|
||
private BlobSchedule(final int target, final int max) { | ||
this.target = target; | ||
this.max = max; | ||
} | ||
|
||
/** | ||
* Gets target. | ||
* | ||
* @return the target | ||
*/ | ||
public int getTarget() { | ||
return target; | ||
} | ||
|
||
/** | ||
* Gets max. | ||
* | ||
* @return the max | ||
*/ | ||
public int getMax() { | ||
return max; | ||
} | ||
|
||
/** | ||
* As map. | ||
* | ||
* @return the map | ||
*/ | ||
Map<String, Object> asMap() { | ||
return Map.of("target", target, "max", max); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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
41 changes: 41 additions & 0 deletions
41
config/src/test/java/org/hyperledger/besu/config/BlobScheduleOptionsTest.java
This file contains 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,41 @@ | ||
/* | ||
* Copyright contributors to Hyperledger 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.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class BlobScheduleOptionsTest { | ||
|
||
@Test | ||
public void blobScheduleIsParsed() { | ||
final GenesisConfig genesisConfigFile = | ||
GenesisConfig.fromResource("/mainnet_with_blob_schedule.json"); | ||
final GenesisConfigOptions configOptions = genesisConfigFile.getConfigOptions(); | ||
|
||
assertThat(configOptions.getBlobScheduleOptions()).isNotEmpty(); | ||
final BlobScheduleOptions blobScheduleOptions = configOptions.getBlobScheduleOptions().get(); | ||
assertThat(blobScheduleOptions.getCancun()).isNotEmpty(); | ||
assertThat(blobScheduleOptions.getCancun().get().getTarget()).isEqualTo(4); | ||
assertThat(blobScheduleOptions.getCancun().get().getMax()).isEqualTo(7); | ||
assertThat(blobScheduleOptions.getPrague()).isNotEmpty(); | ||
assertThat(blobScheduleOptions.getPrague().get().getTarget()).isEqualTo(7); | ||
assertThat(blobScheduleOptions.getPrague().get().getMax()).isEqualTo(10); | ||
assertThat(blobScheduleOptions.getOsaka()).isNotEmpty(); | ||
assertThat(blobScheduleOptions.getOsaka().get().getTarget()).isEqualTo(10); | ||
assertThat(blobScheduleOptions.getOsaka().get().getMax()).isEqualTo(13); | ||
} | ||
} |
This file contains 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 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,37 @@ | ||
{ | ||
"config": { | ||
"chainId": 3151908, | ||
"homesteadBlock": 0, | ||
"eip150Block": 0, | ||
"eip155Block": 0, | ||
"eip158Block": 0, | ||
"byzantiumBlock": 0, | ||
"constantinopleBlock": 0, | ||
"petersburgBlock": 0, | ||
"istanbulBlock": 0, | ||
"berlinBlock": 0, | ||
"londonBlock": 0, | ||
"preMergeForkBlock": 0, | ||
"terminalTotalDifficulty": 0, | ||
"ethash": {}, | ||
"shanghaiTime": 0, | ||
"cancunTime": 0, | ||
"blobSchedule": { | ||
"cancun": { | ||
"target": 4, | ||
"max": 7 | ||
}, | ||
"prague": { | ||
"target": 7, | ||
"max": 10 | ||
}, | ||
"osaka": { | ||
"target": 10, | ||
"max": 13 | ||
} | ||
}, | ||
"depositContractAddress": "0x4242424242424242424242424242424242424242", | ||
"pragueTime": 1734106711, | ||
"osakaTime": 1734107095 | ||
} | ||
} |
This file contains 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 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
Oops, something went wrong.