Search in sources :

Example 11 with MessageFrame

use of org.hyperledger.besu.evm.frame.MessageFrame in project besu by hyperledger.

the class BlockHashOperationBenchmark method executeOperationWithEmptyHashCache.

@Benchmark
public Bytes executeOperationWithEmptyHashCache() {
    final MessageFrame cleanFrame = operationBenchmarkHelper.createMessageFrameBuilder().blockHashLookup(new BlockHashLookup((ProcessableBlockHeader) frame.getBlockValues(), operationBenchmarkHelper.getBlockchain())).build();
    cleanFrame.pushStackItem(UInt256.valueOf(blockNumber));
    operation.execute(cleanFrame, null);
    return cleanFrame.popStackItem();
}
Also used : BlockHashLookup(org.hyperledger.besu.ethereum.vm.BlockHashLookup) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 12 with MessageFrame

use of org.hyperledger.besu.evm.frame.MessageFrame in project besu by hyperledger.

the class OperationBenchmarkHelper method create.

public static OperationBenchmarkHelper create() throws IOException {
    final Path storageDirectory = Files.createTempDirectory("benchmark");
    final KeyValueStorage keyValueStorage = new RocksDBKeyValueStorage(new RocksDBConfigurationBuilder().databaseDir(storageDirectory).build(), new NoOpMetricsSystem(), RocksDBMetricsFactory.PUBLIC_ROCKS_DB_METRICS);
    final ExecutionContextTestFixture executionContext = ExecutionContextTestFixture.builder().keyValueStorage(keyValueStorage).build();
    final MutableBlockchain blockchain = executionContext.getBlockchain();
    for (int i = 1; i < 256; i++) {
        blockchain.appendBlock(new Block(new BlockHeaderTestFixture().parentHash(blockchain.getChainHeadHash()).number(i).difficulty(Difficulty.ONE).buildHeader(), new BlockBody(emptyList(), emptyList())), emptyList());
    }
    final MessageFrame messageFrame = new MessageFrameTestFixture().executionContextTestFixture(executionContext).blockHeader(new BlockHeaderTestFixture().parentHash(blockchain.getChainHeadHash()).number(blockchain.getChainHeadBlockNumber() + 1).difficulty(Difficulty.ONE).buildHeader()).build();
    return new OperationBenchmarkHelper(storageDirectory, keyValueStorage, messageFrame, blockchain);
}
Also used : Path(java.nio.file.Path) BlockBody(org.hyperledger.besu.ethereum.core.BlockBody) RocksDBKeyValueStorage(org.hyperledger.besu.plugin.services.storage.rocksdb.unsegmented.RocksDBKeyValueStorage) KeyValueStorage(org.hyperledger.besu.plugin.services.storage.KeyValueStorage) MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) MessageFrameTestFixture(org.hyperledger.besu.ethereum.core.MessageFrameTestFixture) BlockHeaderTestFixture(org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem) RocksDBKeyValueStorage(org.hyperledger.besu.plugin.services.storage.rocksdb.unsegmented.RocksDBKeyValueStorage) RocksDBConfigurationBuilder(org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBConfigurationBuilder) ExecutionContextTestFixture(org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture) Block(org.hyperledger.besu.ethereum.core.Block) MutableBlockchain(org.hyperledger.besu.ethereum.chain.MutableBlockchain)

Example 13 with MessageFrame

use of org.hyperledger.besu.evm.frame.MessageFrame in project besu by hyperledger.

the class SarOperationTest method shiftOperation.

@Test
public void shiftOperation() {
    final MessageFrame frame = mock(MessageFrame.class);
    when(frame.stackSize()).thenReturn(2);
    when(frame.getRemainingGas()).thenReturn(100L);
    when(frame.popStackItem()).thenReturn(UInt256.fromBytes(Bytes32.fromHexStringLenient(shift))).thenReturn(UInt256.fromHexString(number));
    operation.execute(frame, null);
    verify(frame).pushStackItem(UInt256.fromHexString(expectedResult));
}
Also used : MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) Test(org.junit.Test)

Example 14 with MessageFrame

use of org.hyperledger.besu.evm.frame.MessageFrame in project besu by hyperledger.

the class ShlOperationTest method shiftOperation.

@Test
public void shiftOperation() {
    final MessageFrame frame = mock(MessageFrame.class);
    when(frame.stackSize()).thenReturn(2);
    when(frame.getRemainingGas()).thenReturn(100L);
    when(frame.popStackItem()).thenReturn(UInt256.fromBytes(Bytes32.fromHexStringLenient(shift))).thenReturn(UInt256.fromHexString(number));
    operation.execute(frame, null);
    verify(frame).pushStackItem(UInt256.fromHexString(expectedResult));
}
Also used : MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) Test(org.junit.Test)

Example 15 with MessageFrame

use of org.hyperledger.besu.evm.frame.MessageFrame in project besu by hyperledger.

the class ShrOperationTest method shiftOperation.

@Test
public void shiftOperation() {
    final MessageFrame frame = mock(MessageFrame.class);
    when(frame.stackSize()).thenReturn(2);
    when(frame.getRemainingGas()).thenReturn(100L);
    when(frame.popStackItem()).thenReturn(UInt256.fromBytes(Bytes32.fromHexStringLenient(shift))).thenReturn(UInt256.fromHexString(number));
    operation.execute(frame, null);
    verify(frame).pushStackItem(UInt256.fromHexString(expectedResult));
}
Also used : MessageFrame(org.hyperledger.besu.evm.frame.MessageFrame) Test(org.junit.Test)

Aggregations

MessageFrame (org.hyperledger.besu.evm.frame.MessageFrame)73 Test (org.junit.Test)39 Bytes (org.apache.tuweni.bytes.Bytes)28 WorldUpdater (org.hyperledger.besu.evm.worldstate.WorldUpdater)15 ArrayDeque (java.util.ArrayDeque)13 Wei (org.hyperledger.besu.datatypes.Wei)12 Code (org.hyperledger.besu.evm.Code)12 MessageFrameTestFixture (org.hyperledger.besu.ethereum.core.MessageFrameTestFixture)11 OperationResult (org.hyperledger.besu.evm.operation.Operation.OperationResult)11 UInt256 (org.apache.tuweni.units.bigints.UInt256)10 Address (org.hyperledger.besu.datatypes.Address)10 EVM (org.hyperledger.besu.evm.EVM)10 TraceFrame (org.hyperledger.besu.ethereum.debug.TraceFrame)9 Bytes32 (org.apache.tuweni.bytes.Bytes32)8 ContractCreationProcessor (org.hyperledger.besu.evm.processor.ContractCreationProcessor)8 BlockHashLookup (org.hyperledger.besu.ethereum.vm.BlockHashLookup)7 MutableAccount (org.hyperledger.besu.evm.account.MutableAccount)7 Hash (org.hyperledger.besu.datatypes.Hash)6 Block (org.hyperledger.besu.ethereum.core.Block)6 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)6