use of org.hyperledger.besu.evm.processor.MessageCallProcessor 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.processor.MessageCallProcessor 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.processor.MessageCallProcessor 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");
}
use of org.hyperledger.besu.evm.processor.MessageCallProcessor in project besu by hyperledger.
the class ClassicProtocolSpecs method atlantisDefinition.
public static ProtocolSpecBuilder atlantisDefinition(final Optional<BigInteger> chainId, final OptionalInt configContractSizeLimit, final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final OptionalLong ecip1017EraRounds, final boolean quorumCompatibilityMode, final EvmConfiguration evmConfiguration) {
final int contractSizeLimit = configContractSizeLimit.orElse(MainnetProtocolSpecs.SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return gothamDefinition(chainId, configContractSizeLimit, configStackSizeLimit, ecip1017EraRounds, quorumCompatibilityMode, evmConfiguration).evmBuilder(MainnetEVMs::byzantium).evmConfiguration(evmConfiguration).gasCalculator(SpuriousDragonGasCalculator::new).skipZeroBlockRewards(true).messageCallProcessorBuilder(MessageCallProcessor::new).precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium).difficultyCalculator(ClassicDifficultyCalculators.EIP100).transactionReceiptFactory(enableRevertReason ? ClassicProtocolSpecs::byzantiumTransactionReceiptFactoryWithReasonEnabled : ClassicProtocolSpecs::byzantiumTransactionReceiptFactory).contractCreationProcessorBuilder((gasCalculator, evm) -> new ContractCreationProcessor(gasCalculator, evm, true, Collections.singletonList(MaxCodeSizeRule.of(contractSizeLimit)), 1)).transactionProcessorBuilder((gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor) -> new MainnetTransactionProcessor(gasCalculator, transactionValidator, contractCreationProcessor, messageCallProcessor, true, stackSizeLimit, FeeMarket.legacy(), CoinbaseFeePriceCalculator.frontier())).name("Atlantis");
}
use of org.hyperledger.besu.evm.processor.MessageCallProcessor in project besu by hyperledger.
the class TestCodeExecutor method executeCode.
public MessageFrame executeCode(final String codeHexString, final long gasLimit, final Consumer<MutableAccount> accountSetup) {
final ProtocolSpec protocolSpec = fixture.getProtocolSchedule().getByBlockNumber(0);
final WorldUpdater worldUpdater = createInitialWorldState(accountSetup, fixture.getStateArchive());
final Deque<MessageFrame> messageFrameStack = new ArrayDeque<>();
final EVM evm = protocolSpec.getEvm();
final MessageCallProcessor messageCallProcessor = new MessageCallProcessor(evm, new PrecompileContractRegistry());
final Bytes codeBytes = Bytes.fromHexString(codeHexString);
final Code code = evm.getCode(Hash.hash(codeBytes), codeBytes);
final Transaction transaction = Transaction.builder().type(TransactionType.FRONTIER).value(Wei.ZERO).sender(SENDER_ADDRESS).signature(SignatureAlgorithmFactory.getInstance().createSignature(BigInteger.ONE, BigInteger.TEN, (byte) 1)).gasLimit(gasLimit).to(SENDER_ADDRESS).payload(Bytes.EMPTY).gasPrice(Wei.ZERO).nonce(0).build();
final MessageFrame initialFrame = new MessageFrameTestFixture().messageFrameStack(messageFrameStack).blockchain(fixture.getBlockchain()).worldUpdater(worldUpdater).initialGas(gasLimit).address(SENDER_ADDRESS).originator(SENDER_ADDRESS).contract(SENDER_ADDRESS).gasPrice(transaction.getGasPrice().get()).inputData(transaction.getPayload()).sender(SENDER_ADDRESS).value(transaction.getValue()).code(code).blockHeader(blockHeader).depth(0).build();
messageFrameStack.addFirst(initialFrame);
while (!messageFrameStack.isEmpty()) {
messageCallProcessor.process(messageFrameStack.peekFirst(), OperationTracer.NO_TRACING);
}
return initialFrame;
}
Aggregations