use of org.hyperledger.besu.evm.internal.EvmConfiguration in project besu by hyperledger.
the class BaseBftProtocolSchedule method createProtocolSchedule.
public ProtocolSchedule createProtocolSchedule(final GenesisConfigOptions config, final ForksSchedule<? extends BftConfigOptions> forksSchedule, final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration) {
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();
forksSchedule.getForks().forEach(forkSpec -> specMap.put(forkSpec.getBlock(), builder -> applyBftChanges(builder, forkSpec.getValue(), config.isQuorum(), bftExtraDataCodec)));
final ProtocolSpecAdapters specAdapters = new ProtocolSpecAdapters(specMap);
return new ProtocolScheduleBuilder(config, DEFAULT_CHAIN_ID, specAdapters, privacyParameters, isRevertReasonEnabled, config.isQuorum(), evmConfiguration).createProtocolSchedule();
}
use of org.hyperledger.besu.evm.internal.EvmConfiguration in project besu by hyperledger.
the class MainnetProtocolSpecs method londonDefinition.
static ProtocolSpecBuilder londonDefinition(final Optional<BigInteger> chainId, final OptionalInt configContractSizeLimit, final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final boolean quorumCompatibilityMode, final EvmConfiguration evmConfiguration) {
final int contractSizeLimit = configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(Long.MAX_VALUE);
final BaseFeeMarket londonFeeMarket = FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
return berlinDefinition(chainId, configContractSizeLimit, configStackSizeLimit, enableRevertReason, quorumCompatibilityMode, evmConfiguration).gasCalculator(LondonGasCalculator::new).gasLimitCalculator(new LondonTargetingGasLimitCalculator(londonForkBlockNumber, londonFeeMarket)).transactionValidatorBuilder(gasCalculator -> new MainnetTransactionValidator(gasCalculator, londonFeeMarket, true, chainId, Set.of(TransactionType.FRONTIER, TransactionType.ACCESS_LIST, TransactionType.EIP1559), quorumCompatibilityMode)).transactionProcessorBuilder((gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor) -> new MainnetTransactionProcessor(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, true, stackSizeLimit, londonFeeMarket, CoinbaseFeePriceCalculator.eip1559())).contractCreationProcessorBuilder((gasCalculator, evm) -> new ContractCreationProcessor(gasCalculator, evm, true, List.of(MaxCodeSizeRule.of(contractSizeLimit), PrefixCodeRule.of()), 1, SPURIOUS_DRAGON_FORCE_DELETE_WHEN_EMPTY_ADDRESSES)).evmBuilder((gasCalculator, jdCacheConfig) -> MainnetEVMs.london(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration)).feeMarket(londonFeeMarket).difficultyCalculator(MainnetDifficultyCalculators.LONDON).blockHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.createBaseFeeMarketValidator(londonFeeMarket)).ommerHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.createBaseFeeMarketOmmerValidator(londonFeeMarket)).blockBodyValidatorBuilder(BaseFeeBlockBodyValidator::new).name(LONDON_FORK_NAME);
}
use of org.hyperledger.besu.evm.internal.EvmConfiguration in project besu by hyperledger.
the class ThreadBesuNodeRunner method startNode.
@Override
public void startNode(final BesuNode node) {
if (MDC.get("node") != null) {
LOG.error("ThreadContext node is already set to {}", MDC.get("node"));
}
MDC.put("node", node.getName());
if (!node.getRunCommand().isEmpty()) {
throw new UnsupportedOperationException("commands are not supported with thread runner");
}
final StorageServiceImpl storageService = new StorageServiceImpl();
final SecurityModuleServiceImpl securityModuleService = new SecurityModuleServiceImpl();
final Path dataDir = node.homeDirectory();
final BesuConfiguration commonPluginConfiguration = new BesuConfigurationImpl(dataDir, dataDir.resolve(DATABASE_PATH));
final BesuPluginContextImpl besuPluginContext = besuPluginContextMap.computeIfAbsent(node, n -> buildPluginContext(node, storageService, securityModuleService, commonPluginConfiguration));
final ObservableMetricsSystem metricsSystem = MetricsSystemFactory.create(node.getMetricsConfiguration());
final List<EnodeURL> bootnodes = node.getConfiguration().getBootnodes().stream().map(EnodeURLImpl::fromURI).collect(Collectors.toList());
final NetworkName network = node.getNetwork() == null ? NetworkName.DEV : node.getNetwork();
final EthNetworkConfig.Builder networkConfigBuilder = new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(network)).setBootNodes(bootnodes);
node.getConfiguration().getGenesisConfig().ifPresent(networkConfigBuilder::setGenesisConfig);
final EthNetworkConfig ethNetworkConfig = networkConfigBuilder.build();
final BesuControllerBuilder builder = new BesuController.Builder().fromEthNetworkConfig(ethNetworkConfig);
final KeyValueStorageProvider storageProvider = new KeyValueStorageProviderBuilder().withStorageFactory(storageService.getByName("rocksdb").get()).withCommonConfiguration(commonPluginConfiguration).withMetricsSystem(metricsSystem).build();
final TransactionPoolConfiguration txPoolConfig = ImmutableTransactionPoolConfiguration.builder().strictTransactionReplayProtectionEnabled(node.isStrictTxReplayProtectionEnabled()).build();
final int maxPeers = 25;
builder.synchronizerConfiguration(new SynchronizerConfiguration.Builder().build()).dataDirectory(node.homeDirectory()).miningParameters(node.getMiningParameters()).privacyParameters(node.getPrivacyParameters()).nodeKey(new NodeKey(new KeyPairSecurityModule(KeyPairUtil.loadKeyPair(dataDir)))).metricsSystem(metricsSystem).transactionPoolConfiguration(txPoolConfig).ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()).clock(Clock.systemUTC()).isRevertReasonEnabled(node.isRevertReasonEnabled()).storageProvider(storageProvider).gasLimitCalculator(GasLimitCalculator.constant()).pkiBlockCreationConfiguration(node.getPkiKeyStoreConfiguration().map(pkiConfig -> new PkiBlockCreationConfigurationProvider().load(pkiConfig))).evmConfiguration(EvmConfiguration.DEFAULT).maxPeers(maxPeers);
node.getGenesisConfig().map(GenesisConfigFile::fromConfig).ifPresent(builder::genesisConfigFile);
final BesuController besuController = builder.build();
final RunnerBuilder runnerBuilder = new RunnerBuilder();
runnerBuilder.permissioningConfiguration(node.getPermissioningConfiguration());
final Runner runner = runnerBuilder.vertx(Vertx.vertx()).besuController(besuController).ethNetworkConfig(ethNetworkConfig).discovery(node.isDiscoveryEnabled()).p2pAdvertisedHost(node.getHostName()).p2pListenPort(0).maxPeers(maxPeers).networkingConfiguration(node.getNetworkingConfiguration()).jsonRpcConfiguration(node.jsonRpcConfiguration()).webSocketConfiguration(node.webSocketConfiguration()).jsonRpcIpcConfiguration(node.jsonRpcIpcConfiguration()).dataDir(node.homeDirectory()).metricsSystem(metricsSystem).permissioningService(new PermissioningServiceImpl()).metricsConfiguration(node.getMetricsConfiguration()).p2pEnabled(node.isP2pEnabled()).p2pTLSConfiguration(node.getTLSConfiguration()).graphQLConfiguration(GraphQLConfiguration.createDefault()).staticNodes(node.getStaticNodes().stream().map(EnodeURLImpl::fromString).collect(Collectors.toList())).besuPluginContext(new BesuPluginContextImpl()).autoLogBloomCaching(false).storageProvider(storageProvider).forkIdSupplier(() -> besuController.getProtocolManager().getForkIdAsBytesList()).rpcEndpointService(new RpcEndpointServiceImpl()).build();
besuPluginContext.beforeExternalServices();
runner.startExternalServices();
besuPluginContext.addService(BesuEvents.class, new BesuEventsImpl(besuController.getProtocolContext().getBlockchain(), besuController.getProtocolManager().getBlockBroadcaster(), besuController.getTransactionPool(), besuController.getSyncState()));
besuPluginContext.startPlugins();
runner.startEthereumMainLoop();
besuRunners.put(node.getName(), runner);
MDC.remove("node");
}
use of org.hyperledger.besu.evm.internal.EvmConfiguration in project besu by hyperledger.
the class MainnetProtocolSpecs method frontierDefinition.
public static ProtocolSpecBuilder frontierDefinition(final OptionalInt configContractSizeLimit, final OptionalInt configStackSizeLimit, final boolean goQuorumMode, final EvmConfiguration evmConfiguration) {
final int contractSizeLimit = configContractSizeLimit.orElse(FRONTIER_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return new ProtocolSpecBuilder().gasCalculator(FrontierGasCalculator::new).gasLimitCalculator(new FrontierTargetingGasLimitCalculator()).evmBuilder(MainnetEVMs::frontier).precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::frontier).messageCallProcessorBuilder(MessageCallProcessor::new).contractCreationProcessorBuilder((gasCalculator, evm) -> new ContractCreationProcessor(gasCalculator, evm, false, Collections.singletonList(MaxCodeSizeRule.of(contractSizeLimit)), 0)).transactionValidatorBuilder(gasCalculator -> new MainnetTransactionValidator(gasCalculator, false, Optional.empty(), goQuorumMode)).transactionProcessorBuilder((gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor) -> new MainnetTransactionProcessor(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, false, stackSizeLimit, FeeMarket.legacy(), CoinbaseFeePriceCalculator.frontier())).privateTransactionProcessorBuilder((gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, privateTransactionValidator) -> new PrivateTransactionProcessor(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, false, stackSizeLimit, new PrivateTransactionValidator(Optional.empty()))).difficultyCalculator(MainnetDifficultyCalculators.FRONTIER).blockHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.create()).ommerHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.createLegacyFeeMarketOmmerValidator()).blockBodyValidatorBuilder(MainnetBlockBodyValidator::new).transactionReceiptFactory(MainnetProtocolSpecs::frontierTransactionReceiptFactory).blockReward(FRONTIER_BLOCK_REWARD).skipZeroBlockRewards(false).blockProcessorBuilder(MainnetProtocolSpecs.blockProcessorBuilder(goQuorumMode)).blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder(goQuorumMode)).blockImporterBuilder(MainnetBlockImporter::new).blockHeaderFunctions(new MainnetBlockHeaderFunctions()).miningBeneficiaryCalculator(BlockHeader::getCoinbase).evmConfiguration(evmConfiguration).name("Frontier");
}
use of org.hyperledger.besu.evm.internal.EvmConfiguration in project besu by hyperledger.
the class MainnetProtocolSpecs method spuriousDragonDefinition.
public static ProtocolSpecBuilder spuriousDragonDefinition(final Optional<BigInteger> chainId, final OptionalInt configContractSizeLimit, final OptionalInt configStackSizeLimit, final boolean quorumCompatibilityMode, final EvmConfiguration evmConfiguration) {
final int contractSizeLimit = configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return tangerineWhistleDefinition(OptionalInt.empty(), configStackSizeLimit, quorumCompatibilityMode, evmConfiguration).gasCalculator(SpuriousDragonGasCalculator::new).skipZeroBlockRewards(true).messageCallProcessorBuilder((evm, precompileContractRegistry) -> new MessageCallProcessor(evm, precompileContractRegistry, SPURIOUS_DRAGON_FORCE_DELETE_WHEN_EMPTY_ADDRESSES)).contractCreationProcessorBuilder((gasCalculator, evm) -> new ContractCreationProcessor(gasCalculator, evm, true, Collections.singletonList(MaxCodeSizeRule.of(contractSizeLimit)), 1, SPURIOUS_DRAGON_FORCE_DELETE_WHEN_EMPTY_ADDRESSES)).transactionValidatorBuilder(gasCalculator -> new MainnetTransactionValidator(gasCalculator, true, chainId, quorumCompatibilityMode)).transactionProcessorBuilder((gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor) -> new MainnetTransactionProcessor(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, true, stackSizeLimit, FeeMarket.legacy(), CoinbaseFeePriceCalculator.frontier())).name("SpuriousDragon");
}
Aggregations