Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
Signed-off-by: Karim Taam <[email protected]>
  • Loading branch information
matkt committed Jun 12, 2024
1 parent 0cfcf98 commit 9d88191
Show file tree
Hide file tree
Showing 23 changed files with 108 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.encoding.EncodingContext;
import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder;
import org.hyperledger.besu.ethereum.core.witness.ExecutionWitness;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
Expand All @@ -67,7 +68,6 @@
import org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil;
import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.core.witness.ExecutionWitness;
import org.hyperledger.besu.plugin.services.exception.StorageException;

import java.security.InvalidParameterException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public VerkleProofParameter(
this.ipaProof = ipaProof;
}

public static VerkleProofParameter fromVerkleProof(
final VerkleProof verkleProof) {
public static VerkleProofParameter fromVerkleProof(final VerkleProof verkleProof) {
return new VerkleProofParameter(
verkleProof.otherStems().stream().map(Bytes::toHexString).toList(),
verkleProof.depthExtensionPresent(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ private Block createFakeBlock(
null,
null,
null,
null,
null),
new BlockBody(
IntStream.range(0, txsNum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.ExecutionWitnessValidator;
import org.hyperledger.besu.ethereum.mainnet.PoWHasher;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
Expand Down Expand Up @@ -151,7 +152,8 @@ public class EthGetTransactionReceiptTest {
Optional.empty(),
new FrontierBlockHashProcessor(),
true,
true);
true,
new ExecutionWitnessValidator.ProhibitedExecutionWitness());
private final ProtocolSpec statusTransactionTypeSpec =
new ProtocolSpec(
"status",
Expand Down Expand Up @@ -182,7 +184,8 @@ public class EthGetTransactionReceiptTest {
Optional.empty(),
new FrontierBlockHashProcessor(),
true,
true);
true,
new ExecutionWitnessValidator.ProhibitedExecutionWitness());

@SuppressWarnings("unchecked")
private final ProtocolSchedule protocolSchedule = mock(ProtocolSchedule.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,9 @@ protected EnginePayloadParameter mockEnginePayload(
final BlockHeader header,
final List<String> txs,
final List<WithdrawalParameter> withdrawals,
final List<DepositRequestParameter> depositRequests,
final List<DepositRequestParameter> depositRequests,
final List<WithdrawalRequestParameter> withdrawalRequests,
final ExecutionWitnessParameter executionWitness) {
final ExecutionWitnessParameter executionWitness) {
return new EnginePayloadParameter(
header.getHash(),
header.getParentHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ private BlockHeader createBlockHeader(final Hash blockHash, final long blockNumb
null,
null,
null,
null,
new BlockHeaderFunctions() {
@Override
public Hash hash(final BlockHeader header) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public void shouldReturnValidIfWithdrawalsIsNotNull_WhenWithdrawalsAllowed() {
.when(blockchain.getBlockHeader(mockHeader.getParentHash()))
.thenReturn(Optional.of(mock(BlockHeader.class)));
var resp =
resp(mockEnginePayload(mockHeader, Collections.emptyList(), withdrawalsParam, null, null, null));
resp(
mockEnginePayload(
mockHeader, Collections.emptyList(), withdrawalsParam, null, null, null));

assertValidResponse(mockHeader, resp);
}
Expand Down Expand Up @@ -127,7 +129,8 @@ public void shouldReturnInvalidIfWithdrawalsIsNotNull_WhenWithdrawalsProhibited(
Collections.emptyList(),
withdrawals,
null,
null, null));
null,
null));

final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
Expand All @@ -143,7 +146,8 @@ public void shouldValidateBlobGasUsedCorrectly() {
.blobGasUsed(100L)
.buildHeader();

var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));
var resp =
resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));
final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
assertThat(jsonRpcError.getData()).isEqualTo("non-null BlobGasUsed pre-cancun");
Expand All @@ -159,7 +163,8 @@ public void shouldValidateExcessBlobGasCorrectly() {
.excessBlobGas(BlobGas.MAX_BLOB_GAS)
.buildHeader();

var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));
var resp =
resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));

final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
Expand All @@ -180,7 +185,8 @@ public void shouldReturnInvalidIfWithdrawalsIsNull_WhenWithdrawalsAllowed() {
Collections.emptyList(),
withdrawals,
null,
null, null));
null,
null));

assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode());
verify(engineCallListener, times(1)).executionEngineCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public void shouldValidateBlobGasUsedCorrectly() {
.blobGasUsed(null)
.buildHeader();

var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));
var resp =
resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));

final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
Expand All @@ -212,7 +213,8 @@ public void shouldValidateExcessBlobGasCorrectly() {
.blobGasUsed(100L)
.buildHeader();

var resp = resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));
var resp =
resp(mockEnginePayload(blockHeader, Collections.emptyList(), List.of(), null, null, null));

final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public void shouldReturnValidIfDepositRequestsIsNull_WhenDepositRequestsProhibit
.thenReturn(Optional.of(mockHeader.getHash()));

var resp =
resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositRequests, null, null));
resp(
mockEnginePayload(
mockHeader, Collections.emptyList(), null, depositRequests, null, null));

assertValidResponse(mockHeader, resp);
}
Expand All @@ -125,7 +127,8 @@ public void shouldReturnInvalidIfDepositRequestsIsNull_WhenDepositRequestsAllowe
Collections.emptyList(),
null,
depositRequests,
null, null));
null,
null));

assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode());
verify(engineCallListener, times(1)).executionEngineCalled();
Expand Down Expand Up @@ -172,7 +175,8 @@ public void shouldReturnInvalidIfDepositRequestsIsNotNull_WhenDepositRequestsPro
Collections.emptyList(),
null,
depositRequests,
null, null));
null,
null));

final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
Expand Down Expand Up @@ -211,7 +215,8 @@ public void shouldReturnInvalidIfWithdrawalRequestsIsNull_WhenWithdrawalRequests
Collections.emptyList(),
null,
null,
null, null));
null,
null));

assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode());
verify(engineCallListener, times(1)).executionEngineCalled();
Expand Down Expand Up @@ -258,7 +263,8 @@ public void shouldReturnValidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequest
Collections.emptyList(),
null,
null,
withdrawalRequests, null));
withdrawalRequests,
null));

final JsonRpcError jsonRpcError = fromErrorResp(resp);
assertThat(jsonRpcError.getCode()).isEqualTo(INVALID_PARAMS.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void setup() {
null,
null,
null,
null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
final BlockBody fakeBody = new BlockBody(Collections.emptyList(), Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void setup() throws IOException {
null,
null,
null,
null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
when(blockchain.getBlockHeader(anyLong())).thenReturn(Optional.of(fakeHeader));
Expand Down Expand Up @@ -283,6 +284,7 @@ private BlockHeader createBlock(final long number, final Optional<String> messag
null,
null,
null,
null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
when(blockchain.getBlockHeader(number)).thenReturn(Optional.of(fakeHeader));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.witness.ExecutionWitness;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.evm.log.LogsBloomFilter;

import java.time.Instant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.NoOpTrieLogManager;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldStateConfig;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.cache.VerkleNoOpCachedWorldStorageManager;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.storage.VerkleWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.worldview.VerkleWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldStateConfig;
import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.forest.worldview.ForestMutableWorldState;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
Expand Down Expand Up @@ -95,7 +95,8 @@ private static MutableWorldState createGenesisVerkleWorldState() {
verkleWorldStateKeyValueStorage,
new VerkleNoOpCachedWorldStorageManager(verkleWorldStateKeyValueStorage),
new NoOpTrieLogManager(),
EvmConfiguration.DEFAULT);
EvmConfiguration.DEFAULT,
new DiffBasedWorldStateConfig());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.common.DiffBasedWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.diffbased.common.trielog.TrieLogManager;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldStateConfig;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
Expand Down Expand Up @@ -153,8 +152,4 @@ public void prepareStateHealing(final Address address, final Bytes location) {

getBonsaiWorldStateKeyValueStorage().downgradeToPartialFlatDbMode();
}

private DiffBasedWorldStateConfig cloneBonsaiWorldStateConfig() {
return new DiffBasedWorldStateConfig(defaultWorldStateConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,8 @@ public void close() {
// no op
}
}

protected DiffBasedWorldStateConfig cloneBonsaiWorldStateConfig() {
return new DiffBasedWorldStateConfig(defaultWorldStateConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ public synchronized void unsubscribe(final long id) {
trieLogObservers.unsubscribe(id);
}

private TrieLogFactory setupTrieLogFactory(final DataStorageFormat dataStorageFormat,final BesuContext pluginContext) {
private TrieLogFactory setupTrieLogFactory(
final DataStorageFormat dataStorageFormat, final BesuContext pluginContext) {
// if we have a TrieLogService from pluginContext, use it.
var trieLogServicez =
Optional.ofNullable(pluginContext)
.flatMap(context -> context.getService(TrieLogService.class));
Optional.ofNullable(pluginContext)
.flatMap(context -> context.getService(TrieLogService.class));

if (trieLogServicez.isPresent()) {
var trieLogService = trieLogServicez.get();
Expand All @@ -158,7 +159,7 @@ private TrieLogFactory setupTrieLogFactory(final DataStorageFormat dataStorageFo
if (dataStorageFormat.equals(DataStorageFormat.VERKLE)) {
return new TrieLogFactoryImpl();
}
//or default to BONSAI TrieLogFactoryImpl
// or default to BONSAI TrieLogFactoryImpl
return new org.hyperledger.besu.ethereum.trie.diffbased.bonsai.trielog.TrieLogFactoryImpl();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ public VerkleWorldStateProvider(
maxLayersToLoad,
pluginContext);
provideCachedWorldStorageManager(
new VerkleCachedWorldStorageManager(this, worldStateKeyValueStorage));
loadPersistedState(new VerkleWorldState(this, worldStateKeyValueStorage, evmConfiguration));
new VerkleCachedWorldStorageManager(
this, worldStateKeyValueStorage, this::cloneBonsaiWorldStateConfig));
loadPersistedState(
new VerkleWorldState(
this, worldStateKeyValueStorage, evmConfiguration, defaultWorldStateConfig));
}

@VisibleForTesting
Expand All @@ -56,6 +59,8 @@ public VerkleWorldStateProvider(
final EvmConfiguration evmConfiguration) {
super(worldStateKeyValueStorage, blockchain, trieLogManager);
provideCachedWorldStorageManager(cachedWorldStorageManager);
loadPersistedState(new VerkleWorldState(this, worldStateKeyValueStorage, evmConfiguration));
loadPersistedState(
new VerkleWorldState(
this, worldStateKeyValueStorage, evmConfiguration, defaultWorldStateConfig));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@
import org.hyperledger.besu.ethereum.trie.diffbased.common.cache.DiffBasedCachedWorldStorageManager;
import org.hyperledger.besu.ethereum.trie.diffbased.common.storage.DiffBasedWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldStateConfig;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.VerkleWorldStateProvider;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.storage.VerkleLayeredWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.storage.VerkleSnapshotWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.storage.VerkleWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.worldview.VerkleWorldState;
import org.hyperledger.besu.evm.internal.EvmConfiguration;

import java.util.function.Supplier;

public class VerkleCachedWorldStorageManager extends DiffBasedCachedWorldStorageManager {

public VerkleCachedWorldStorageManager(
final DiffBasedWorldStateProvider archive,
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage) {
super(archive, worldStateKeyValueStorage);
final DiffBasedWorldStateKeyValueStorage worldStateKeyValueStorage,
final Supplier<DiffBasedWorldStateConfig> defaultBonsaiWorldStateConfigSupplier) {
super(archive, worldStateKeyValueStorage, defaultBonsaiWorldStateConfigSupplier);
}

@Override
Expand All @@ -41,7 +45,8 @@ public DiffBasedWorldState createWorldState(
return new VerkleWorldState(
(VerkleWorldStateProvider) archive,
(VerkleWorldStateKeyValueStorage) worldStateKeyValueStorage,
evmConfiguration);
evmConfiguration,
defaultBonsaiWorldStateConfigSupplier.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldState;
import org.hyperledger.besu.ethereum.trie.diffbased.common.worldview.DiffBasedWorldStateConfig;
import org.hyperledger.besu.ethereum.trie.diffbased.verkle.storage.VerkleWorldStateKeyValueStorage;

import java.util.Optional;
Expand All @@ -26,7 +27,7 @@ public class VerkleNoOpCachedWorldStorageManager extends VerkleCachedWorldStorag

public VerkleNoOpCachedWorldStorageManager(
final VerkleWorldStateKeyValueStorage verkleWorldStateKeyValueStorage) {
super(null, verkleWorldStateKeyValueStorage);
super(null, verkleWorldStateKeyValueStorage, DiffBasedWorldStateConfig::new);
}

@Override
Expand Down
Loading

0 comments on commit 9d88191

Please sign in to comment.