Skip to content

Commit

Permalink
Remove code differences with Besu upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 committed Jul 31, 2024
1 parent a127045 commit c0029e6
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
import org.hyperledger.besu.metrics.MetricsService;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;

Expand Down Expand Up @@ -259,7 +258,6 @@ private BesuController createController() {
// set to mainnet genesis block so validation rules won't reject it.
.clock(Clock.fixed(Instant.ofEpochSecond(startTime), ZoneOffset.UTC))
.miningParameters(getMiningParameters())
.dataStorageConfiguration(DataStorageConfiguration.DEFAULT_CONFIG)
.build();
} catch (final Exception e) {
throw new ExecutionException(parentCommand.spec.commandLine(), e.getMessage(), e);
Expand Down Expand Up @@ -378,7 +376,6 @@ private BesuController createBesuController() {
.parentCommand
.getControllerBuilder()
.miningParameters(MiningParameters.newDefault())
.dataStorageConfiguration(DataStorageConfiguration.DEFAULT_CONFIG)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@

/** The Merge besu controller builder. */
public class MergeBesuControllerBuilder extends BesuControllerBuilder {
private static final Logger LOG = LoggerFactory.getLogger(MergeBesuControllerBuilder.class);
private final AtomicReference<SyncState> syncState = new AtomicReference<>();
private static final Logger LOG = LoggerFactory.getLogger(MergeBesuControllerBuilder.class);

/** Default constructor. */
public MergeBesuControllerBuilder() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@

/** A concrete implementation of BesuEvents used in Besu plugin framework. */
public class BesuEventsImpl implements BesuEvents {
private Blockchain blockchain;
private BlockBroadcaster blockBroadcaster;
private TransactionPool transactionPool;
private SyncState syncState;
private BadBlockManager badBlockManager;

/** Default constructor */
public BesuEventsImpl() {}
private final Blockchain blockchain;
private final BlockBroadcaster blockBroadcaster;
private final TransactionPool transactionPool;
private final SyncState syncState;
private final BadBlockManager badBlockManager;

/**
* Constructor for BesuEventsImpl
Expand All @@ -59,7 +56,7 @@ public BesuEventsImpl() {}
* @param syncState An instance of SyncState
* @param badBlockManager A cache of bad blocks encountered on the network
*/
public void init(
public BesuEventsImpl(
final Blockchain blockchain,
final BlockBroadcaster blockBroadcaster,
final TransactionPool transactionPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
import org.hyperledger.besu.plugin.services.storage.PrivacyKeyValueStorageFactory;
import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier;
import org.hyperledger.besu.services.BesuConfigurationImpl;
import org.hyperledger.besu.services.BesuEventsImpl;
import org.hyperledger.besu.services.BesuPluginContextImpl;
import org.hyperledger.besu.services.BlockchainServiceImpl;
import org.hyperledger.besu.services.PermissioningServiceImpl;
Expand Down Expand Up @@ -565,8 +564,7 @@ public static class TestBesuCommand extends BesuCommand {
new TransactionSelectionServiceImpl(),
new TransactionPoolValidatorServiceImpl(),
new TransactionSimulationServiceImpl(),
new BlockchainServiceImpl(),
new BesuEventsImpl());
new BlockchainServiceImpl());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ public void setUp() {
new BlobCache(),
MiningParameters.newDefault());

serviceImpl = new BesuEventsImpl();
serviceImpl.init(blockchain, blockBroadcaster, transactionPool, syncState, badBlockManager);
serviceImpl =
new BesuEventsImpl(
blockchain, blockBroadcaster, transactionPool, syncState, badBlockManager);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class TransactionValidatorFactory {

protected volatile Supplier<TransactionValidator> transactionValidatorSupplier;
private volatile Supplier<TransactionValidator> transactionValidatorSupplier;

public TransactionValidatorFactory(
final GasCalculator gasCalculator,
Expand Down Expand Up @@ -69,29 +69,28 @@ public TransactionValidatorFactory(
final Set<TransactionType> acceptedTransactionTypes,
final int maxInitcodeSize) {

cacheValidator(
new MainnetTransactionValidator(
gasCalculator,
gasLimitCalculator,
feeMarket,
checkSignatureMalleability,
chainId,
acceptedTransactionTypes,
maxInitcodeSize));
this.transactionValidatorSupplier =
Suppliers.memoize(
() ->
new MainnetTransactionValidator(
gasCalculator,
gasLimitCalculator,
feeMarket,
checkSignatureMalleability,
chainId,
acceptedTransactionTypes,
maxInitcodeSize));
}

public void setPermissionTransactionFilter(
final PermissionTransactionFilter permissionTransactionFilter) {
final TransactionValidator baseTxValidator = transactionValidatorSupplier.get();
cacheValidator(
new PermissionTransactionValidator(baseTxValidator, permissionTransactionFilter));
transactionValidatorSupplier =
Suppliers.memoize(
() -> new PermissionTransactionValidator(baseTxValidator, permissionTransactionFilter));
}

public TransactionValidator get() {
return transactionValidatorSupplier.get();
}

protected void cacheValidator(final TransactionValidator transactionValidator) {
transactionValidatorSupplier = Suppliers.memoize(() -> transactionValidator);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public String toString() {
public static CallParameter fromTransaction(final Transaction tx) {
return new CallParameter(
tx.getSender(),
tx.getTo().orElseGet(() -> null),
tx.getTo().orElse(null),
tx.getGasLimit(),
tx.getGasPrice().orElse(Wei.ZERO),
tx.getMaxPriorityFeePerGas(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public void toURI_WithHostnameShouldWorkWhenDnsEnabledAndUpdateEnabled()
"enode://"
+ VALID_NODE_ID
+ "@"
+ InetAddress.getLocalHost().getHostName()
+ InetAddress.getLocalHost().getCanonicalHostName()
+ ":"
+ P2P_PORT;
final URI expectedURI = URI.create(enodeURLString);
Expand Down
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = 'ycZ8d+jgooJiJDc5mwpNqk0+mx79IG5QO4GVDtgIbeY='
knownHash = 'I851CCOs00yYpW10qIGIak1bKbYhKFQkV2wyCYELHKY='
}
check.dependsOn('checkAPIChanges')

Expand Down

0 comments on commit c0029e6

Please sign in to comment.