Search in sources :

Example 1 with PrevRanDaoOperation

use of org.hyperledger.besu.evm.operation.PrevRanDaoOperation in project besu by hyperledger.

the class MainnetEVMs method registerPreMergeForkOperations.

public static void registerPreMergeForkOperations(final OperationRegistry registry, final GasCalculator gasCalculator, final BigInteger chainID) {
    registerLondonOperations(registry, gasCalculator, chainID);
    registry.put(new PrevRanDaoOperation(gasCalculator));
}
Also used : PrevRanDaoOperation(org.hyperledger.besu.evm.operation.PrevRanDaoOperation)

Example 2 with PrevRanDaoOperation

use of org.hyperledger.besu.evm.operation.PrevRanDaoOperation 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 3 with PrevRanDaoOperation

use of org.hyperledger.besu.evm.operation.PrevRanDaoOperation in project besu by hyperledger.

the class MainnetEVMs method registerParisOperations.

public static void registerParisOperations(final OperationRegistry registry, final GasCalculator gasCalculator, final BigInteger chainID) {
    registerLondonOperations(registry, gasCalculator, chainID);
    registry.put(new PrevRanDaoOperation(gasCalculator));
}
Also used : PrevRanDaoOperation(org.hyperledger.besu.evm.operation.PrevRanDaoOperation)

Example 4 with PrevRanDaoOperation

use of org.hyperledger.besu.evm.operation.PrevRanDaoOperation 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

PrevRanDaoOperation (org.hyperledger.besu.evm.operation.PrevRanDaoOperation)4 Bytes32 (org.apache.tuweni.bytes.Bytes32)2 EVM (org.hyperledger.besu.evm.EVM)2 BlockValues (org.hyperledger.besu.evm.frame.BlockValues)2 MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)2 LondonGasCalculator (org.hyperledger.besu.evm.gascalculator.LondonGasCalculator)2 Operation (org.hyperledger.besu.evm.operation.Operation)2 Test (org.junit.Test)2 Bytes (org.apache.tuweni.bytes.Bytes)1