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();
}
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);
}
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));
}
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));
}
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));
}
Aggregations