Skip to content

Commit

Permalink
Updates to address PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Born <codyborn@outlook.com>
  • Loading branch information
codyborn committed Jul 31, 2022
1 parent 75d74aa commit b6bf7fc
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
/*
* Copyright Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core;

import kotlin.UInt;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
import org.hyperledger.besu.datatypes.Address;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ default long getMaxRefundQuotient() {
*
* @return the cost of a TLOAD from a storage slot
*/
default long getTloadOperationGasCost() {
default long getTransientLoadOperationGasCost() {
return 0L;
}

Expand All @@ -488,7 +488,7 @@ default long getTloadOperationGasCost() {
*
* @return the cost of a TSTORE to a storage slot
*/
default long getTstoreOperationGasCost() {
default long getTransientStoreOperationGasCost() {
return 0L;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -23,12 +23,12 @@ public ShanghaiGasCalculator() {}

// EIP-1153
@Override
public long getTloadOperationGasCost() {
public long getTransientLoadOperationGasCost() {
return TLOAD_GAS;
}

@Override
public long getTstoreOperationGasCost() {
public long getTransientStoreOperationGasCost() {
return TSTORE_GAS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
*/
package org.hyperledger.besu.evm.operation;

import org.hyperledger.besu.evm.frame.ExceptionalHaltReason;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;

import java.util.Optional;
import java.util.OptionalLong;

/**
* All {@link Operation} implementations should inherit from this class to get the setting of some
* members for free.
Expand All @@ -29,6 +33,10 @@ public abstract class AbstractOperation implements Operation {
private final int opSize;
private final GasCalculator gasCalculator;

protected static final OperationResult ILLEGAL_STATE_CHANGE =
new OperationResult(
OptionalLong.of(0L), Optional.of(ExceptionalHaltReason.ILLEGAL_STATE_CHANGE));

protected AbstractOperation(
final int opcode,
final String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ public class SStoreOperation extends AbstractOperation {
public static final long FRONTIER_MINIMUM = 0L;
public static final long EIP_1706_MINIMUM = 2300L;

protected static final OperationResult ILLEGAL_STATE_CHANGE =
new OperationResult(
OptionalLong.of(0L), Optional.of(ExceptionalHaltReason.ILLEGAL_STATE_CHANGE));

private final long minimumGasRemaining;

public SStoreOperation(final GasCalculator gasCalculator, final long minimumGasRemaining) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -37,7 +37,7 @@ public TLoadOperation(final GasCalculator gasCalculator) {

@Override
public OperationResult execute(final MessageFrame frame, final EVM evm) {
final long cost = gasCalculator().getTloadOperationGasCost();
final long cost = gasCalculator().getTransientLoadOperationGasCost();
try {
final Account account = frame.getWorldUpdater().get(frame.getRecipientAddress());
final Bytes32 key = UInt256.fromBytes(frame.popStackItem());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -27,14 +27,6 @@

public class TStoreOperation extends AbstractOperation {

public static final long FRONTIER_MINIMUM = 0L;
public static final long EIP_1706_MINIMUM = 2300L;

protected static final OperationResult ILLEGAL_STATE_CHANGE =
new OperationResult(
OptionalLong.of(0L), Optional.of(ExceptionalHaltReason.ILLEGAL_STATE_CHANGE));


public TStoreOperation(final GasCalculator gasCalculator) {
super(0xb4, "TSTORE", 2, 0, 1, gasCalculator);
}
Expand All @@ -51,7 +43,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
return ILLEGAL_STATE_CHANGE;
}

final long cost = gasCalculator().getTstoreOperationGasCost();
final long cost = gasCalculator().getTransientStoreOperationGasCost();

final long remainingGas = frame.getRemainingGas();
if (frame.isStatic()) {
Expand Down

0 comments on commit b6bf7fc

Please sign in to comment.