-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Dudley <[email protected]>
- Loading branch information
Showing
22 changed files
with
552 additions
and
88 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
110 changes: 110 additions & 0 deletions
110
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,110 @@ | ||
/* | ||
* 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 com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
/** The Checkpoint config options. */ | ||
public class BlobScheduleOptions { | ||
|
||
/** The constant DEFAULT. */ | ||
public static final BlobScheduleOptions DEFAULT = | ||
new BlobScheduleOptions(JsonUtil.createEmptyObjectNode()); | ||
|
||
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 BlobSchedule getCancun() { | ||
return JsonUtil.getObjectNode(blobScheduleOptionsConfigRoot, CANCUN_KEY) | ||
.map(BlobSchedule::new) | ||
.orElse(BlobSchedule.DEFAULT); | ||
} | ||
|
||
/** | ||
* Gets prague blob schedule. | ||
* | ||
* @return the prague blob schedule | ||
*/ | ||
public BlobSchedule getPrague() { | ||
return JsonUtil.getObjectNode(blobScheduleOptionsConfigRoot, PRAGUE_KEY) | ||
.map(BlobSchedule::new) | ||
.orElse(BlobSchedule.DEFAULT); | ||
} | ||
|
||
/** | ||
* Gets osaka blob schedule. | ||
* | ||
* @return the osaka blob schedule | ||
*/ | ||
public BlobSchedule getOsaka() { | ||
return JsonUtil.getObjectNode(blobScheduleOptionsConfigRoot, OSAKA_KEY) | ||
.map(BlobSchedule::new) | ||
.orElse(BlobSchedule.DEFAULT); | ||
} | ||
|
||
/** The Blob schedule for a particular fork. */ | ||
public static class BlobSchedule { | ||
private final ObjectNode blobScheduleConfigRoot; | ||
|
||
/** The constant DEFAULT. */ | ||
public static final BlobSchedule DEFAULT = new BlobSchedule(JsonUtil.createEmptyObjectNode()); | ||
|
||
/** | ||
* Instantiates a new Blob schedule. | ||
* | ||
* @param blobScheduleItemConfigRoot the blob schedule item config root | ||
*/ | ||
public BlobSchedule(final ObjectNode blobScheduleItemConfigRoot) { | ||
this.blobScheduleConfigRoot = blobScheduleItemConfigRoot; | ||
} | ||
|
||
/** | ||
* Gets target. | ||
* | ||
* @return the target | ||
*/ | ||
public int getTarget() { | ||
// TODO SLD EIP-7840 - reasonable default? | ||
return JsonUtil.getInt(blobScheduleConfigRoot, "target").orElse(3); | ||
} | ||
|
||
/** | ||
* Gets max. | ||
* | ||
* @return the max | ||
*/ | ||
public int getMax() { | ||
// TODO SLD EIP-7840 - reasonable default? | ||
return JsonUtil.getInt(blobScheduleConfigRoot, "max").orElse(6); | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
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,36 @@ | ||
/* | ||
* 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 GenesisConfigFile genesisConfigFile = | ||
GenesisConfigFile.fromResource("/mainnet_with_blob_schedule.json"); | ||
final GenesisConfigOptions configOptions = genesisConfigFile.getConfigOptions(); | ||
|
||
assertThat(configOptions.getBlobScheduleOptions().getCancun().getTarget()).isEqualTo(3); | ||
assertThat(configOptions.getBlobScheduleOptions().getCancun().getMax()).isEqualTo(6); | ||
assertThat(configOptions.getBlobScheduleOptions().getPrague().getTarget()).isEqualTo(6); | ||
assertThat(configOptions.getBlobScheduleOptions().getPrague().getMax()).isEqualTo(9); | ||
assertThat(configOptions.getBlobScheduleOptions().getOsaka().getTarget()).isEqualTo(9); | ||
assertThat(configOptions.getBlobScheduleOptions().getOsaka().getMax()).isEqualTo(12); | ||
} | ||
} |
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": 3, | ||
"max": 6 | ||
}, | ||
"prague": { | ||
"target": 6, | ||
"max": 9 | ||
}, | ||
"osaka": { | ||
"target": 9, | ||
"max": 12 | ||
} | ||
}, | ||
"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.