Search in sources :

Example 1 with LondonGasCalculator

use of org.hyperledger.besu.evm.gascalculator.LondonGasCalculator in project besu by hyperledger.

the class PrevRanDaoOperationTest method pushesPrevRandaoWhenDifficultyZero.

@Test
public void pushesPrevRandaoWhenDifficultyZero() {
    PrevRanDaoOperation op = new PrevRanDaoOperation(new LondonGasCalculator());
    MessageFrame messageFrame = mock(MessageFrame.class);
    BlockValues blockHeader = mock(BlockValues.class);
    Bytes32 prevRandao = Bytes32.fromHexString("0xb0b0face");
    when(blockHeader.getDifficultyBytes()).thenReturn(UInt256.ZERO);
    when(blockHeader.getMixHashOrPrevRandao()).thenReturn(prevRandao);
    when(messageFrame.getBlockValues()).thenReturn(blockHeader);
    EVM evm = mock(EVM.class);
    Operation.OperationResult r = op.executeFixedCostOperation(messageFrame, evm);
    assertThat(r.getHaltReason()).isNotPresent();
    verify(messageFrame).pushStackItem(prevRandao);
}
Also used : PrevRanDaoOperation(org.hyperledger.besu.evm.operation.PrevRanDaoOperation) LondonGasCalculator(org.hyperledger.besu.evm.gascalculator.LondonGasCalculator) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) BlockValues(org.hyperledger.besu.evm.frame.BlockValues) Operation(org.hyperledger.besu.evm.operation.Operation) PrevRanDaoOperation(org.hyperledger.besu.evm.operation.PrevRanDaoOperation) Bytes32(org.apache.tuweni.bytes.Bytes32) EVM(org.hyperledger.besu.evm.EVM) Test(org.junit.Test)

Example 2 with LondonGasCalculator

use of org.hyperledger.besu.evm.gascalculator.LondonGasCalculator 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);
}
Also used : BaseFeeMarket(org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket) WorldUpdater(org.hyperledger.besu.evm.worldstate.WorldUpdater) GoQuorumBlockProcessor(org.hyperledger.besu.ethereum.goquorum.GoQuorumBlockProcessor) PowAlgorithm(org.hyperledger.besu.config.PowAlgorithm) FeeMarket(org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket) GenesisConfigOptions(org.hyperledger.besu.config.GenesisConfigOptions) ByzantiumGasCalculator(org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator) BlockValidatorBuilder(org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockValidatorBuilder) BlockProcessorBuilder(org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockProcessorBuilder) TransactionReceipt(org.hyperledger.besu.ethereum.core.TransactionReceipt) MainnetEVMs(org.hyperledger.besu.evm.MainnetEVMs) TangerineWhistleGasCalculator(org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator) BigInteger(java.math.BigInteger) HomesteadGasCalculator(org.hyperledger.besu.evm.gascalculator.HomesteadGasCalculator) ImmutableSet(com.google.common.collect.ImmutableSet) Blockchain(org.hyperledger.besu.ethereum.chain.Blockchain) CoinbaseFeePriceCalculator(org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator) Set(java.util.Set) EvmConfiguration(org.hyperledger.besu.evm.internal.EvmConfiguration) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) TransactionProcessingResult(org.hyperledger.besu.ethereum.processing.TransactionProcessingResult) List(java.util.List) IstanbulGasCalculator(org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator) MutableAccount(org.hyperledger.besu.evm.account.MutableAccount) Optional(java.util.Optional) ContractCreationProcessor(org.hyperledger.besu.evm.processor.ContractCreationProcessor) TransactionType(org.hyperledger.besu.plugin.data.TransactionType) PrefixCodeRule(org.hyperledger.besu.evm.contractvalidation.PrefixCodeRule) IntStream(java.util.stream.IntStream) MessageCallProcessor(org.hyperledger.besu.evm.processor.MessageCallProcessor) PrivateTransactionValidator(org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator) Address(org.hyperledger.besu.datatypes.Address) OptionalInt(java.util.OptionalInt) MaxCodeSizeRule(org.hyperledger.besu.evm.contractvalidation.MaxCodeSizeRule) FrontierGasCalculator(org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator) BaseFeeMarket(org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket) Wei(org.hyperledger.besu.datatypes.Wei) LondonGasCalculator(org.hyperledger.besu.evm.gascalculator.LondonGasCalculator) PetersburgGasCalculator(org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator) PrivateMetadataUpdater(org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater) WorldState(org.hyperledger.besu.evm.worldstate.WorldState) GoQuorumBlockValidator(org.hyperledger.besu.ethereum.goquorum.GoQuorumBlockValidator) Resources(com.google.common.io.Resources) BlockHeader(org.hyperledger.besu.ethereum.core.BlockHeader) MutableWorldState(org.hyperledger.besu.ethereum.core.MutableWorldState) IOException(java.io.IOException) PrivateTransactionProcessor(org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor) JsonArray(io.vertx.core.json.JsonArray) MainnetBlockValidator(org.hyperledger.besu.ethereum.MainnetBlockValidator) SpuriousDragonGasCalculator(org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator) BerlinGasCalculator(org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator) ConstantinopleGasCalculator(org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) Transaction(org.hyperledger.besu.ethereum.core.Transaction) Collections(java.util.Collections) ContractCreationProcessor(org.hyperledger.besu.evm.processor.ContractCreationProcessor)

Example 3 with LondonGasCalculator

use of org.hyperledger.besu.evm.gascalculator.LondonGasCalculator in project besu by hyperledger.

the class PrevRanDaoOperationTest method pushesDifficultyWhenPresent.

@Test
public void pushesDifficultyWhenPresent() {
    PrevRanDaoOperation op = new PrevRanDaoOperation(new LondonGasCalculator());
    MessageFrame messageFrame = mock(MessageFrame.class);
    BlockValues blockHeader = mock(BlockValues.class);
    Bytes32 prevRandao = Bytes32.fromHexString("0xb0b0face");
    Bytes difficulty = Bytes.random(32);
    when(blockHeader.getDifficultyBytes()).thenReturn(difficulty);
    when(blockHeader.getMixHashOrPrevRandao()).thenReturn(prevRandao);
    when(messageFrame.getBlockValues()).thenReturn(blockHeader);
    EVM evm = mock(EVM.class);
    Operation.OperationResult r = op.executeFixedCostOperation(messageFrame, evm);
    assertThat(r.getHaltReason()).isNotPresent();
    verify(messageFrame).pushStackItem(difficulty);
}
Also used : PrevRanDaoOperation(org.hyperledger.besu.evm.operation.PrevRanDaoOperation) Bytes(org.apache.tuweni.bytes.Bytes) LondonGasCalculator(org.hyperledger.besu.evm.gascalculator.LondonGasCalculator) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) BlockValues(org.hyperledger.besu.evm.frame.BlockValues) Operation(org.hyperledger.besu.evm.operation.Operation) PrevRanDaoOperation(org.hyperledger.besu.evm.operation.PrevRanDaoOperation) Bytes32(org.apache.tuweni.bytes.Bytes32) EVM(org.hyperledger.besu.evm.EVM) Test(org.junit.Test)

Aggregations

MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)3 LondonGasCalculator (org.hyperledger.besu.evm.gascalculator.LondonGasCalculator)3 Bytes32 (org.apache.tuweni.bytes.Bytes32)2 EVM (org.hyperledger.besu.evm.EVM)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Resources (com.google.common.io.Resources)1 JsonArray (io.vertx.core.json.JsonArray)1 IOException (java.io.IOException)1 BigInteger (java.math.BigInteger)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 OptionalInt (java.util.OptionalInt)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Bytes (org.apache.tuweni.bytes.Bytes)1 GenesisConfigOptions (org.hyperledger.besu.config.GenesisConfigOptions)1 PowAlgorithm (org.hyperledger.besu.config.PowAlgorithm)1