Search in sources :

Example 1 with PrecompileContractRegistry

use of org.hyperledger.besu.evm.precompile.PrecompileContractRegistry in project besu by hyperledger.

the class MainnetPrecompiledContractRegistries method frontier.

public static PrecompileContractRegistry frontier(final PrecompiledContractConfiguration precompiledContractConfiguration) {
    final PrecompileContractRegistry registry = new PrecompileContractRegistry();
    populateForFrontier(registry, precompiledContractConfiguration.getGasCalculator());
    return registry;
}
Also used : PrecompileContractRegistry(org.hyperledger.besu.evm.precompile.PrecompileContractRegistry)

Example 2 with PrecompileContractRegistry

use of org.hyperledger.besu.evm.precompile.PrecompileContractRegistry in project besu by hyperledger.

the class MainnetPrecompiledContractRegistries method byzantium.

public static PrecompileContractRegistry byzantium(final PrecompiledContractConfiguration precompiledContractConfiguration) {
    final PrecompileContractRegistry registry = new PrecompileContractRegistry();
    populateForByzantium(registry, precompiledContractConfiguration.getGasCalculator());
    return registry;
}
Also used : PrecompileContractRegistry(org.hyperledger.besu.evm.precompile.PrecompileContractRegistry)

Example 3 with PrecompileContractRegistry

use of org.hyperledger.besu.evm.precompile.PrecompileContractRegistry in project besu by hyperledger.

the class MainnetPrecompiledContractRegistries method istanbul.

public static PrecompileContractRegistry istanbul(final PrecompiledContractConfiguration precompiledContractConfiguration) {
    final PrecompileContractRegistry registry = new PrecompileContractRegistry();
    populateForIstanbul(registry, precompiledContractConfiguration.getGasCalculator());
    return registry;
}
Also used : PrecompileContractRegistry(org.hyperledger.besu.evm.precompile.PrecompileContractRegistry)

Example 4 with PrecompileContractRegistry

use of org.hyperledger.besu.evm.precompile.PrecompileContractRegistry in project besu by hyperledger.

the class MainnetPrecompiledContractRegistries method bls12.

public static PrecompileContractRegistry bls12(final PrecompiledContractConfiguration precompiledContractConfiguration) {
    final PrecompileContractRegistry registry = new PrecompileContractRegistry();
    populateForBLS12(registry, precompiledContractConfiguration.getGasCalculator());
    return registry;
}
Also used : PrecompileContractRegistry(org.hyperledger.besu.evm.precompile.PrecompileContractRegistry)

Example 5 with PrecompileContractRegistry

use of org.hyperledger.besu.evm.precompile.PrecompileContractRegistry in project besu by hyperledger.

the class ProtocolSpecBuilder method build.

public ProtocolSpec build(final ProtocolSchedule protocolSchedule) {
    checkNotNull(gasCalculatorBuilder, "Missing gasCalculator");
    checkNotNull(gasLimitCalculator, "Missing gasLimitCalculator");
    checkNotNull(evmBuilder, "Missing operation registry");
    checkNotNull(evmConfiguration, "Missing evm configuration");
    checkNotNull(transactionValidatorBuilder, "Missing transaction validator");
    checkNotNull(privateTransactionValidatorBuilder, "Missing private transaction validator");
    checkNotNull(contractCreationProcessorBuilder, "Missing contract creation processor");
    checkNotNull(precompileContractRegistryBuilder, "Missing precompile contract registry");
    checkNotNull(messageCallProcessorBuilder, "Missing message call processor");
    checkNotNull(transactionProcessorBuilder, "Missing transaction processor");
    checkNotNull(privateTransactionProcessorBuilder, "Missing private transaction processor");
    checkNotNull(blockHeaderValidatorBuilder, "Missing block header validator");
    checkNotNull(blockBodyValidatorBuilder, "Missing block body validator");
    checkNotNull(blockProcessorBuilder, "Missing block processor");
    checkNotNull(blockImporterBuilder, "Missing block importer");
    checkNotNull(blockValidatorBuilder, "Missing block validator");
    checkNotNull(blockHeaderFunctions, "Missing block hash function");
    checkNotNull(blockReward, "Missing block reward");
    checkNotNull(difficultyCalculator, "Missing difficulty calculator");
    checkNotNull(transactionReceiptFactory, "Missing transaction receipt factory");
    checkNotNull(name, "Missing name");
    checkNotNull(miningBeneficiaryCalculator, "Missing Mining Beneficiary Calculator");
    checkNotNull(protocolSchedule, "Missing protocol schedule");
    checkNotNull(privacyParameters, "Missing privacy parameters");
    checkNotNull(feeMarket, "Missing fee market");
    checkNotNull(badBlockManager, "Missing bad blocks manager");
    final GasCalculator gasCalculator = gasCalculatorBuilder.get();
    final EVM evm = evmBuilder.apply(gasCalculator, evmConfiguration);
    final PrecompiledContractConfiguration precompiledContractConfiguration = new PrecompiledContractConfiguration(gasCalculator, privacyParameters);
    final MainnetTransactionValidator transactionValidator = transactionValidatorBuilder.apply(gasCalculator);
    final AbstractMessageProcessor contractCreationProcessor = contractCreationProcessorBuilder.apply(gasCalculator, evm);
    final PrecompileContractRegistry precompileContractRegistry = precompileContractRegistryBuilder.apply(precompiledContractConfiguration);
    final AbstractMessageProcessor messageCallProcessor = messageCallProcessorBuilder.apply(evm, precompileContractRegistry);
    final MainnetTransactionProcessor transactionProcessor = transactionProcessorBuilder.apply(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor);
    final BlockHeaderValidator blockHeaderValidator = blockHeaderValidatorBuilder.apply(feeMarket).difficultyCalculator(difficultyCalculator).build();
    final BlockHeaderValidator ommerHeaderValidator = ommerHeaderValidatorBuilder.apply(feeMarket).difficultyCalculator(difficultyCalculator).build();
    final BlockBodyValidator blockBodyValidator = blockBodyValidatorBuilder.apply(protocolSchedule);
    BlockProcessor blockProcessor = blockProcessorBuilder.apply(transactionProcessor, transactionReceiptFactory, blockReward, miningBeneficiaryCalculator, skipZeroBlockRewards, privacyParameters.getGoQuorumPrivacyParameters());
    // Set private Tx Processor
    PrivateTransactionProcessor privateTransactionProcessor = null;
    if (privacyParameters.isEnabled()) {
        final PrivateTransactionValidator privateTransactionValidator = privateTransactionValidatorBuilder.apply();
        privateTransactionProcessor = privateTransactionProcessorBuilder.apply(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, privateTransactionValidator);
        if (privacyParameters.isPrivacyPluginEnabled()) {
            final PrivacyPluginPrecompiledContract privacyPluginPrecompiledContract = (PrivacyPluginPrecompiledContract) precompileContractRegistry.get(PLUGIN_PRIVACY);
            privacyPluginPrecompiledContract.setPrivateTransactionProcessor(privateTransactionProcessor);
        } else if (privacyParameters.isFlexiblePrivacyGroupsEnabled()) {
            final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract = (FlexiblePrivacyPrecompiledContract) precompileContractRegistry.get(FLEXIBLE_PRIVACY);
            flexiblePrivacyPrecompiledContract.setPrivateTransactionProcessor(privateTransactionProcessor);
        } else {
            final PrivacyPrecompiledContract privacyPrecompiledContract = (PrivacyPrecompiledContract) precompileContractRegistry.get(DEFAULT_PRIVACY);
            privacyPrecompiledContract.setPrivateTransactionProcessor(privateTransactionProcessor);
        }
        blockProcessor = new PrivacyBlockProcessor(blockProcessor, protocolSchedule, privacyParameters.getEnclave(), privacyParameters.getPrivateStateStorage(), privacyParameters.getPrivateWorldStateArchive(), privacyParameters.getPrivateStateRootResolver(), privacyParameters.getPrivateStateGenesisAllocator());
    }
    final BlockValidator blockValidator = blockValidatorBuilder.apply(blockHeaderValidator, blockBodyValidator, blockProcessor, badBlockManager, privacyParameters.getGoQuorumPrivacyParameters());
    final BlockImporter blockImporter = blockImporterBuilder.apply(blockValidator);
    return new ProtocolSpec(name, evm, transactionValidator, transactionProcessor, privateTransactionProcessor, blockHeaderValidator, ommerHeaderValidator, blockBodyValidator, blockProcessor, blockImporter, blockValidator, blockHeaderFunctions, transactionReceiptFactory, difficultyCalculator, blockReward, miningBeneficiaryCalculator, precompileContractRegistry, skipZeroBlockRewards, gasCalculator, gasLimitCalculator, feeMarket, badBlockManager, Optional.ofNullable(powHasher));
}
Also used : GasCalculator(org.hyperledger.besu.evm.gascalculator.GasCalculator) PrivateTransactionProcessor(org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor) PrivacyPluginPrecompiledContract(org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract) FlexiblePrivacyPrecompiledContract(org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract) PrecompileContractRegistry(org.hyperledger.besu.evm.precompile.PrecompileContractRegistry) BlockValidator(org.hyperledger.besu.ethereum.BlockValidator) BlockImporter(org.hyperledger.besu.ethereum.core.BlockImporter) AbstractMessageProcessor(org.hyperledger.besu.evm.processor.AbstractMessageProcessor) PrivateTransactionValidator(org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator) EVM(org.hyperledger.besu.evm.EVM) PrivacyPrecompiledContract(org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract) FlexiblePrivacyPrecompiledContract(org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract)

Aggregations

PrecompileContractRegistry (org.hyperledger.besu.evm.precompile.PrecompileContractRegistry)8 EVM (org.hyperledger.besu.evm.EVM)4 ArrayDeque (java.util.ArrayDeque)3 Code (org.hyperledger.besu.evm.Code)3 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)3 MessageCallProcessor (org.hyperledger.besu.evm.processor.MessageCallProcessor)3 Stopwatch (com.google.common.base.Stopwatch)2 Bytes (org.apache.tuweni.bytes.Bytes)2 ProtocolSpec (org.hyperledger.besu.ethereum.mainnet.ProtocolSpec)2 StandardJsonTracer (org.hyperledger.besu.evm.tracing.StandardJsonTracer)2 WorldUpdater (org.hyperledger.besu.evm.worldstate.WorldUpdater)2 JsonObject (io.vertx.core.json.JsonObject)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Instant (java.time.Instant)1 Deque (java.util.Deque)1 List (java.util.List)1 Optional (java.util.Optional)1