Search in sources :

Example 1 with TransactionPoolConfiguration

use of org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration in project besu by hyperledger.

the class TransactionPoolOptionsTest method eth65TrxAnnouncedBufferingPeriod.

@Test
public void eth65TrxAnnouncedBufferingPeriod() {
    final long eth65TrxAnnouncedBufferingPeriod = 999;
    final TestBesuCommand cmd = parseCommand("--Xeth65-tx-announced-buffering-period-milliseconds", String.valueOf(eth65TrxAnnouncedBufferingPeriod));
    final TransactionPoolOptions options = getOptionsFromBesuCommand(cmd);
    final TransactionPoolConfiguration config = options.toDomainObject().build();
    assertThat(config.getEth65TrxAnnouncedBufferingPeriod()).hasMillis(eth65TrxAnnouncedBufferingPeriod);
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : ImmutableTransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) TransactionPoolOptions(org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions) Test(org.junit.Test)

Example 2 with TransactionPoolConfiguration

use of org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration in project besu by hyperledger.

the class TransactionPoolOptionsTest method strictTxReplayProtection_disabled.

@Test
public void strictTxReplayProtection_disabled() {
    final TestBesuCommand cmd = parseCommand("--strict-tx-replay-protection-enabled=false");
    final TransactionPoolOptions options = getOptionsFromBesuCommand(cmd);
    final TransactionPoolConfiguration config = options.toDomainObject().build();
    assertThat(config.getStrictTransactionReplayProtectionEnabled()).isFalse();
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : ImmutableTransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) TransactionPoolOptions(org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions) Test(org.junit.Test)

Example 3 with TransactionPoolConfiguration

use of org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration in project besu by hyperledger.

the class TransactionPoolOptionsTest method strictTxReplayProtection_enabled.

@Test
public void strictTxReplayProtection_enabled() {
    final TestBesuCommand cmd = parseCommand("--strict-tx-replay-protection-enabled");
    final TransactionPoolOptions options = getOptionsFromBesuCommand(cmd);
    final TransactionPoolConfiguration config = options.toDomainObject().build();
    assertThat(config.getStrictTransactionReplayProtectionEnabled()).isTrue();
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : ImmutableTransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) TransactionPoolOptions(org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions) Test(org.junit.Test)

Example 4 with TransactionPoolConfiguration

use of org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration in project besu by hyperledger.

the class TransactionPoolOptionsTest method strictTxReplayProtection_enabledWithBooleanArg.

@Test
public void strictTxReplayProtection_enabledWithBooleanArg() {
    final TestBesuCommand cmd = parseCommand("--strict-tx-replay-protection-enabled=true");
    final TransactionPoolOptions options = getOptionsFromBesuCommand(cmd);
    final TransactionPoolConfiguration config = options.toDomainObject().build();
    assertThat(config.getStrictTransactionReplayProtectionEnabled()).isTrue();
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : ImmutableTransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) TransactionPoolOptions(org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions) Test(org.junit.Test)

Example 5 with TransactionPoolConfiguration

use of org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration in project besu by hyperledger.

the class RetestethContext method buildContext.

private boolean buildContext(final String genesisConfigString, final String sealEngine, final Optional<Long> clockTime) {
    final ObjectNode genesisConfig = normalizeKeys(JsonUtil.objectNodeFromString(genesisConfigString));
    retestethClock = new RetestethClock();
    clockTime.ifPresent(retestethClock::resetTime);
    final MetricsSystem metricsSystem = new NoOpMetricsSystem();
    final JsonGenesisConfigOptions jsonGenesisConfigOptions = JsonGenesisConfigOptions.fromJsonObject(JsonUtil.getObjectNode(genesisConfig, "config").get());
    protocolSchedule = MainnetProtocolSchedule.fromConfig(jsonGenesisConfigOptions, EvmConfiguration.DEFAULT);
    if ("NoReward".equalsIgnoreCase(sealEngine)) {
        protocolSchedule = new NoRewardProtocolScheduleWrapper(protocolSchedule);
    }
    blockHeaderFunctions = ScheduleBasedBlockHeaderFunctions.create(protocolSchedule);
    final GenesisState genesisState = GenesisState.fromJson(genesisConfigString, protocolSchedule);
    coinbase = genesisState.getBlock().getHeader().getCoinbase();
    extraData = genesisState.getBlock().getHeader().getExtraData();
    final WorldStateArchive worldStateArchive = new DefaultWorldStateArchive(new WorldStateKeyValueStorage(new InMemoryKeyValueStorage()), new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()));
    final MutableWorldState worldState = worldStateArchive.getMutable();
    genesisState.writeStateTo(worldState);
    blockchain = createInMemoryBlockchain(genesisState.getBlock());
    protocolContext = new ProtocolContext(blockchain, worldStateArchive, null);
    blockchainQueries = new BlockchainQueries(blockchain, worldStateArchive, ethScheduler);
    final String sealengine = JsonUtil.getString(genesisConfig, "sealengine", "");
    headerValidationMode = "NoProof".equals(sealengine) || "NoReward".equals(sealEngine) ? HeaderValidationMode.LIGHT : HeaderValidationMode.FULL;
    final Iterable<Long> nonceGenerator = new IncrementingNonceGenerator(0);
    poWSolver = ("NoProof".equals(sealengine) || "NoReward".equals(sealEngine)) ? new PoWSolver(nonceGenerator, NO_WORK_HASHER, false, Subscribers.none(), new EpochCalculator.DefaultEpochCalculator(), 1000, 8) : new PoWSolver(nonceGenerator, PoWHasher.ETHASH_LIGHT, false, Subscribers.none(), new EpochCalculator.DefaultEpochCalculator(), 1000, 8);
    blockReplay = new BlockReplay(protocolSchedule, blockchainQueries.getBlockchain(), blockchainQueries.getWorldStateArchive());
    // mining support
    final EthPeers ethPeers = new EthPeers("reteseth", retestethClock, metricsSystem, 0);
    final SyncState syncState = new SyncState(blockchain, ethPeers);
    ethScheduler = new EthScheduler(1, 1, 1, 1, metricsSystem);
    final EthContext ethContext = new EthContext(ethPeers, new EthMessages(), ethScheduler);
    final TransactionPoolConfiguration transactionPoolConfiguration = ImmutableTransactionPoolConfiguration.builder().build();
    transactionPool = TransactionPoolFactory.createTransactionPool(protocolSchedule, protocolContext, ethContext, retestethClock, metricsSystem, syncState, new MiningParameters.Builder().minTransactionGasPrice(Wei.ZERO).build(), transactionPoolConfiguration);
    if (LOG.isTraceEnabled()) {
        LOG.trace("Genesis Block {} ", genesisState.getBlock());
    }
    return true;
}
Also used : GenesisState(org.hyperledger.besu.ethereum.chain.GenesisState) EthContext(org.hyperledger.besu.ethereum.eth.manager.EthContext) MutableWorldState(org.hyperledger.besu.ethereum.core.MutableWorldState) TransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration) ImmutableTransactionPoolConfiguration(org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration) EpochCalculator(org.hyperledger.besu.ethereum.mainnet.EpochCalculator) EthPeers(org.hyperledger.besu.ethereum.eth.manager.EthPeers) WorldStatePreimageKeyValueStorage(org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage) WorldStateKeyValueStorage(org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage) BlockchainQueries(org.hyperledger.besu.ethereum.api.query.BlockchainQueries) SyncState(org.hyperledger.besu.ethereum.eth.sync.state.SyncState) ProtocolContext(org.hyperledger.besu.ethereum.ProtocolContext) MetricsSystem(org.hyperledger.besu.plugin.services.MetricsSystem) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) EthMessages(org.hyperledger.besu.ethereum.eth.manager.EthMessages) DefaultWorldStateArchive(org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) InMemoryKeyValueStorage(org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage) BlockReplay(org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay) EthScheduler(org.hyperledger.besu.ethereum.eth.manager.EthScheduler) JsonGenesisConfigOptions(org.hyperledger.besu.config.JsonGenesisConfigOptions) DefaultWorldStateArchive(org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive) WorldStateArchive(org.hyperledger.besu.ethereum.worldstate.WorldStateArchive) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) IncrementingNonceGenerator(org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator) PoWSolver(org.hyperledger.besu.ethereum.mainnet.PoWSolver)

Aggregations

ImmutableTransactionPoolConfiguration (org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration)9 TransactionPoolConfiguration (org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration)9 TransactionPoolOptions (org.hyperledger.besu.cli.options.unstable.TransactionPoolOptions)6 Test (org.junit.Test)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Vertx (io.vertx.core.Vertx)1 File (java.io.File)1 Path (java.nio.file.Path)1 Clock (java.time.Clock)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 Runner (org.hyperledger.besu.Runner)1 RunnerBuilder (org.hyperledger.besu.RunnerBuilder)1 EthNetworkConfig (org.hyperledger.besu.cli.config.EthNetworkConfig)1 NetworkName (org.hyperledger.besu.cli.config.NetworkName)1