use of org.hyperledger.besu.evm.operation.SStoreOperation in project besu by hyperledger.
the class SStoreOperationTest method storeOperation.
@Test
public void storeOperation() {
final SStoreOperation operation = new SStoreOperation(gasCalculator, minimumGasAvailable);
final MessageFrame frame = createMessageFrame(Address.fromHexString("0x18675309"), initialGas, remainingGas);
frame.pushStackItem(UInt256.ZERO);
frame.pushStackItem(UInt256.fromHexString("0x01"));
final OperationResult result = operation.execute(frame, null);
assertThat(result.getHaltReason()).isEqualTo(expectedHalt);
}
use of org.hyperledger.besu.evm.operation.SStoreOperation in project besu by hyperledger.
the class MainnetEVMs method registerIstanbulOperations.
public static void registerIstanbulOperations(final OperationRegistry registry, final GasCalculator gasCalculator, final BigInteger chainId) {
registerConstantinopleOperations(registry, gasCalculator);
registry.put(new ChainIdOperation(gasCalculator, Bytes32.leftPad(Bytes.of(chainId.toByteArray()))));
registry.put(new SelfBalanceOperation(gasCalculator));
registry.put(new SStoreOperation(gasCalculator, SStoreOperation.EIP_1706_MINIMUM));
}
use of org.hyperledger.besu.evm.operation.SStoreOperation in project besu by hyperledger.
the class MainnetEVMs method registerFrontierOperations.
public static void registerFrontierOperations(final OperationRegistry registry, final GasCalculator gasCalculator) {
registry.put(new AddOperation(gasCalculator));
registry.put(new MulOperation(gasCalculator));
registry.put(new SubOperation(gasCalculator));
registry.put(new DivOperation(gasCalculator));
registry.put(new SDivOperation(gasCalculator));
registry.put(new ModOperation(gasCalculator));
registry.put(new SModOperation(gasCalculator));
registry.put(new ExpOperation(gasCalculator));
registry.put(new AddModOperation(gasCalculator));
registry.put(new MulModOperation(gasCalculator));
registry.put(new SignExtendOperation(gasCalculator));
registry.put(new LtOperation(gasCalculator));
registry.put(new GtOperation(gasCalculator));
registry.put(new SLtOperation(gasCalculator));
registry.put(new SGtOperation(gasCalculator));
registry.put(new EqOperation(gasCalculator));
registry.put(new IsZeroOperation(gasCalculator));
registry.put(new AndOperation(gasCalculator));
registry.put(new OrOperation(gasCalculator));
registry.put(new XorOperation(gasCalculator));
registry.put(new NotOperation(gasCalculator));
registry.put(new ByteOperation(gasCalculator));
registry.put(new Keccak256Operation(gasCalculator));
registry.put(new AddressOperation(gasCalculator));
registry.put(new BalanceOperation(gasCalculator));
registry.put(new OriginOperation(gasCalculator));
registry.put(new CallerOperation(gasCalculator));
registry.put(new CallValueOperation(gasCalculator));
registry.put(new CallDataLoadOperation(gasCalculator));
registry.put(new CallDataSizeOperation(gasCalculator));
registry.put(new CallDataCopyOperation(gasCalculator));
registry.put(new CodeSizeOperation(gasCalculator));
registry.put(new CodeCopyOperation(gasCalculator));
registry.put(new GasPriceOperation(gasCalculator));
registry.put(new ExtCodeCopyOperation(gasCalculator));
registry.put(new ExtCodeSizeOperation(gasCalculator));
registry.put(new BlockHashOperation(gasCalculator));
registry.put(new CoinbaseOperation(gasCalculator));
registry.put(new TimestampOperation(gasCalculator));
registry.put(new NumberOperation(gasCalculator));
registry.put(new DifficultyOperation(gasCalculator));
registry.put(new GasLimitOperation(gasCalculator));
registry.put(new PopOperation(gasCalculator));
registry.put(new MLoadOperation(gasCalculator));
registry.put(new MStoreOperation(gasCalculator));
registry.put(new MStore8Operation(gasCalculator));
registry.put(new SLoadOperation(gasCalculator));
registry.put(new SStoreOperation(gasCalculator, SStoreOperation.FRONTIER_MINIMUM));
registry.put(new JumpOperation(gasCalculator));
registry.put(new JumpiOperation(gasCalculator));
registry.put(new PCOperation(gasCalculator));
registry.put(new MSizeOperation(gasCalculator));
registry.put(new GasOperation(gasCalculator));
registry.put(new JumpDestOperation(gasCalculator));
registry.put(new ReturnOperation(gasCalculator));
registry.put(new InvalidOperation(gasCalculator));
registry.put(new StopOperation(gasCalculator));
registry.put(new SelfDestructOperation(gasCalculator));
registry.put(new CreateOperation(gasCalculator));
registry.put(new CallOperation(gasCalculator));
registry.put(new CallCodeOperation(gasCalculator));
// Register the PUSH1, PUSH2, ..., PUSH32 operations.
for (int i = 1; i <= 32; ++i) {
registry.put(new PushOperation(i, gasCalculator));
}
// Register the DUP1, DUP2, ..., DUP16 operations.
for (int i = 1; i <= 16; ++i) {
registry.put(new DupOperation(i, gasCalculator));
}
// Register the SWAP1, SWAP2, ..., SWAP16 operations.
for (int i = 1; i <= 16; ++i) {
registry.put(new SwapOperation(i, gasCalculator));
}
// Register the LOG0, LOG1, ..., LOG4 operations.
for (int i = 0; i < 5; ++i) {
registry.put(new LogOperation(i, gasCalculator));
}
}
use of org.hyperledger.besu.evm.operation.SStoreOperation in project besu by hyperledger.
the class EstimateGasOperationTracerTest method shouldDetectMinimumGasRemainingForSStoreOperation.
@Test
public void shouldDetectMinimumGasRemainingForSStoreOperation() {
final ExecuteOperation noExecutionOperation = mock(ExecuteOperation.class);
final long minimumGasRemaining = 2300L;
assertThat(operationTracer.getStipendNeeded()).isZero();
final MessageFrame firstFrame = messageFrameTestFixture.build();
firstFrame.setCurrentOperation(mock(CallCodeOperation.class));
operationTracer.traceExecution(firstFrame, noExecutionOperation);
assertThat(operationTracer.getStipendNeeded()).isZero();
final MessageFrame secondFrame = messageFrameTestFixture.build();
secondFrame.setCurrentOperation(new SStoreOperation(mock(GasCalculator.class), minimumGasRemaining));
operationTracer.traceExecution(secondFrame, noExecutionOperation);
assertThat(operationTracer.getStipendNeeded()).isEqualTo(minimumGasRemaining);
operationTracer.traceExecution(secondFrame, noExecutionOperation);
assertThat(operationTracer.getStipendNeeded()).isEqualTo(minimumGasRemaining);
}
Aggregations