Skip to content

Commit

Permalink
Merge branch 'verify-artifacts' of github.com:hyperledger/besu into v…
Browse files Browse the repository at this point in the history
…erify-artifacts
  • Loading branch information
joshuafernandes committed Jan 6, 2025
2 parents 48001a9 + 493e9ab commit b80b078
Show file tree
Hide file tree
Showing 33 changed files with 909 additions and 175 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
### Additions and Improvements
- Add RPC HTTP options to specify custom truststore and its password [#7978](https://github.com/hyperledger/besu/pull/7978)
- Retrieve all transaction receipts for a block in one request [#6646](https://github.com/hyperledger/besu/pull/6646)
- Implement EIP-7840: Add blob schedule to config files [#8042](https://github.com/hyperledger/besu/pull/8042)


### Bug fixes
- Fix serialization of state overrides when `movePrecompileToAddress` is present [#8204](https://github.com/hyperledger/besu/pull/8024)
- Revise the approach for setting level_compaction_dynamic_level_bytes RocksDB configuration option [#8037](https://github.com/hyperledger/besu/pull/8037)
- Fix possible incomplete txpool restore from dump file [#7991](https://github.com/hyperledger/besu/pull/7991)

## 24.12.2 Hotfix

Expand Down
14 changes: 14 additions & 0 deletions acceptance-tests/tests/src/test/resources/dev/dev_prague.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
"terminalTotalDifficulty":0,
"cancunTime":0,
"pragueTime":0,
"blobSchedule": {
"cancun": {
"target": 3,
"max": 6
},
"prague": {
"target": 6,
"max": 9
},
"osaka": {
"target": 9,
"max": 12
}
},
"clique": {
"period": 5,
"epoch": 30000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceBlock.ChainUpdater;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.chain.Blockchain;
Expand Down Expand Up @@ -155,14 +156,14 @@ public void trace(
blocks.get(0).getHash(),
traceableState -> {
final WorldUpdater worldStateUpdater = traceableState.updater();
final ChainUpdater chainUpdater = new ChainUpdater(traceableState, worldStateUpdater);
beforeTracing.accept(worldStateUpdater);
final List<TransactionProcessingResult> results = new ArrayList<>();
blocks.forEach(
block -> {
results.addAll(trace(blockchain, block, worldStateUpdater, tracer));
worldStateUpdater.commit();
results.addAll(trace(blockchain, block, chainUpdater, tracer));
});
afterTracing.accept(worldStateUpdater);
afterTracing.accept(chainUpdater.getNextUpdater());
return Optional.of(results);
});
}
Expand All @@ -177,15 +178,15 @@ private Optional<List<TransactionProcessingResult>> trace(
blockchainQueries,
block.getHash(),
traceableState ->
Optional.of(trace(blockchain, block, traceableState.updater(), tracer)));
Optional.of(trace(blockchain, block, new ChainUpdater(traceableState), tracer)));

return results;
}

private List<TransactionProcessingResult> trace(
final Blockchain blockchain,
final Block block,
final WorldUpdater worldUpdater,
final ChainUpdater chainUpdater,
final BlockAwareOperationTracer tracer) {
final List<TransactionProcessingResult> results = new ArrayList<>();
final ProtocolSpec protocolSpec = protocolSchedule.getByBlockHeader(block.getHeader());
Expand All @@ -208,6 +209,7 @@ private List<TransactionProcessingResult> trace(
.map(parent -> calculateExcessBlobGasForParent(protocolSpec, parent))
.orElse(BlobGas.ZERO));

final WorldUpdater worldUpdater = chainUpdater.getNextUpdater();
final TransactionProcessingResult result =
transactionProcessor.processTransaction(
worldUpdater,
Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -546,4 +546,11 @@ default boolean isConsensusMigration() {
* @return the consolidation request contract address
*/
Optional<Address> getConsolidationRequestContractAddress();

/**
* The blob schedule is a list of hardfork names and their associated target and max blob values.
*
* @return the blob schedule
*/
Optional<BlobScheduleOptions> getBlobScheduleOptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
private static final String TRANSITIONS_CONFIG_KEY = "transitions";
private static final String DISCOVERY_CONFIG_KEY = "discovery";
private static final String CHECKPOINT_CONFIG_KEY = "checkpoint";
private static final String BLOB_SCHEDULE_CONFIG_KEY = "blobschedule";
private static final String ZERO_BASE_FEE_KEY = "zerobasefee";
private static final String FIXED_BASE_FEE_KEY = "fixedbasefee";
private static final String WITHDRAWAL_REQUEST_CONTRACT_ADDRESS_KEY =
Expand Down Expand Up @@ -199,6 +200,12 @@ public EthashConfigOptions getEthashConfigOptions() {
.orElse(EthashConfigOptions.DEFAULT);
}

@Override
public Optional<BlobScheduleOptions> getBlobScheduleOptions() {
return JsonUtil.getObjectNode(configRoot, BLOB_SCHEDULE_CONFIG_KEY)
.map(BlobScheduleOptions::new);
}

@Override
public TransitionsConfigOptions getTransitions() {
return transitions;
Expand Down Expand Up @@ -537,6 +544,10 @@ public Map<String, Object> asMap() {
builder.put("fixedBaseFee", true);
}

if (getBlobScheduleOptions().isPresent()) {
builder.put("blobSchedule", getBlobScheduleOptions().get().asMap());
}

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ public Optional<Address> getConsolidationRequestContractAddress() {
return Optional.empty();
}

@Override
public Optional<BlobScheduleOptions> getBlobScheduleOptions() {
return Optional.empty();
}

/**
* Homestead block stub genesis config options.
*
Expand Down
10 changes: 10 additions & 0 deletions config/src/main/resources/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
"terminalTotalDifficulty": 58750000000000000000000,
"shanghaiTime": 1681338455,
"cancunTime": 1710338135,
"blobSchedule": {
"cancun": {
"target": 3,
"max": 6
},
"prague": {
"target": 6,
"max": 9
}
},
"ethash": {
},
"discovery": {
Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,46 @@ void asMapIncludesConsolidationRequestContractAddress() {
.containsValue(Address.ZERO);
}

@SuppressWarnings("unchecked")
@Test
void asMapIncludesBlobFeeSchedule() {
final GenesisConfigOptions config =
GenesisConfig.fromConfig(
"{\n"
+ " \"config\": {\n"
+ " \"blobSchedule\": {\n"
+ " \"cancun\": {\n"
+ " \"target\": 1,\n"
+ " \"max\": 2\n"
+ " },\n"
+ " \"prague\": {\n"
+ " \"target\": 3,\n"
+ " \"max\": 4\n"
+ " },\n"
+ " \"osaka\": {\n"
+ " \"target\": 4,\n"
+ " \"max\": 5\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}")
.getConfigOptions();

final Map<String, Object> map = config.asMap();
assertThat(map).containsOnlyKeys("blobSchedule");
final Map<String, Object> blobSchedule = (Map<String, Object>) map.get("blobSchedule");
assertThat(blobSchedule).containsOnlyKeys("cancun", "prague", "osaka");
assertThat((Map<String, Object>) blobSchedule.get("cancun"))
.containsOnlyKeys("target", "max")
.containsValues(1, 2);
assertThat((Map<String, Object>) blobSchedule.get("prague"))
.containsOnlyKeys("target", "max")
.containsValues(3, 4);
assertThat((Map<String, Object>) blobSchedule.get("osaka"))
.containsOnlyKeys("target", "max")
.containsValues(4, 5);
}

private GenesisConfigOptions fromConfigOptions(final Map<String, Object> configOptions) {
final ObjectNode rootNode = JsonUtil.createEmptyObjectNode();
final ObjectNode options = JsonUtil.objectNodeFromMap(configOptions);
Expand Down
Loading

0 comments on commit b80b078

Please sign in to comment.