Skip to content

Commit

Permalink
Remove EIP-3074 code (#7208)
Browse files Browse the repository at this point in the history
Remove all EIP-3074 code from Besu. Since EIP-3074 has been replaced
with EIP-7702 in Pectra, and there is no intent to schedule it for a
future fork there is no need to retain the code.

Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon authored Jun 12, 2024
1 parent 8a8f1ce commit 365737c
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 703 deletions.
6 changes: 1 addition & 5 deletions evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import org.hyperledger.besu.evm.operation.AddOperation;
import org.hyperledger.besu.evm.operation.AddressOperation;
import org.hyperledger.besu.evm.operation.AndOperation;
import org.hyperledger.besu.evm.operation.AuthCallOperation;
import org.hyperledger.besu.evm.operation.AuthOperation;
import org.hyperledger.besu.evm.operation.BalanceOperation;
import org.hyperledger.besu.evm.operation.BaseFeeOperation;
import org.hyperledger.besu.evm.operation.BlobBaseFeeOperation;
Expand Down Expand Up @@ -951,9 +949,7 @@ public static void registerPragueOperations(
final BigInteger chainID) {
registerCancunOperations(registry, gasCalculator, chainID);

// EIP-3074 AUTH and AUTHCALL
registry.put(new AuthOperation(gasCalculator));
registry.put(new AuthCallOperation(gasCalculator));
// TODO add EOF operations here once PragueEOF is collapsed into Prague
}

/**
Expand Down
25 changes: 3 additions & 22 deletions evm/src/main/java/org/hyperledger/besu/evm/frame/MessageFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ public enum Type {
/** The mark of the undoable collections at the creation of this message frame */
private final long undoMark;

/** mutated by AUTH operation */
private Address authorizedBy = null;

/**
* Builder builder.
*
Expand Down Expand Up @@ -1373,24 +1370,6 @@ public Optional<List<VersionedHash>> getVersionedHashes() {
return txValues.versionedHashes();
}

/**
* Accessor for address that authorized future AUTHCALLs.
*
* @return the revert reason
*/
public Address getAuthorizedBy() {
return authorizedBy;
}

/**
* Mutator for address that authorizes future AUTHCALLs, set by AUTH opcode
*
* @param authorizedBy the address that authorizes future AUTHCALLs
*/
public void setAuthorizedBy(final Address authorizedBy) {
this.authorizedBy = authorizedBy;
}

/** Reset. */
public void reset() {
maybeUpdatedMemory = Optional.empty();
Expand Down Expand Up @@ -1428,7 +1407,9 @@ public static class Builder {
private Optional<List<VersionedHash>> versionedHashes = Optional.empty();

/** Instantiates a new Builder. */
public Builder() {}
public Builder() {
// constructor added to deal with JavaDoc linting rules.
}

/**
* The "parent" message frame. When present some fields will be populated from the parent and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,35 +210,6 @@ long callOperationGasCost(
Address contract,
boolean accountIsWarm);

/**
* Returns the gas cost for AUTHCALL.
*
* @param frame The current frame
* @param stipend The gas stipend being provided by the CALL caller
* @param inputDataOffset The offset in memory to retrieve the CALL input data
* @param inputDataLength The CALL input data length
* @param outputDataOffset The offset in memory to place the CALL output data
* @param outputDataLength The CALL output data length
* @param transferValue The wei being transferred
* @param invoker The contract calling out on behalf of the authority
* @param invokee The address of the recipient (never null)
* @param accountIsWarm The address of the contract is "warm" as per EIP-2929
* @return The gas cost for the CALL operation
*/
default long authCallOperationGasCost(
final MessageFrame frame,
final long stipend,
final long inputDataOffset,
final long inputDataLength,
final long outputDataOffset,
final long outputDataLength,
final Wei transferValue,
final Account invoker,
final Address invokee,
final boolean accountIsWarm) {
return 0L;
}

/**
* Gets additional call stipend.
*
Expand Down Expand Up @@ -646,18 +617,4 @@ default long computeExcessBlobGas(final long parentExcessBlobGas, final int newB
default long computeExcessBlobGas(final long parentExcessBlobGas, final long blobGasUsed) {
return 0L;
}

/**
* Returns the gas cost of validating an auth commitment for an AUTHCALL
*
* @param frame the current frame, with memory to be read from
* @param offset start of memory read
* @param length amount of memory read
* @param authority address to check for warmup
* @return total gas cost for the operation
*/
default long authOperationGasCost(
final MessageFrame frame, final long offset, final long length, final Address authority) {
return 0L;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

import static org.hyperledger.besu.datatypes.Address.BLS12_MAP_FP2_TO_G2;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.frame.MessageFrame;

/**
* Gas Calculator for Prague
*
Expand All @@ -32,8 +27,6 @@
* </UL>
*/
public class PragueGasCalculator extends CancunGasCalculator {
private static final int AUTH_OP_FIXED_FEE = 3100;
private static final long AUTH_CALL_VALUE_TRANSFER_GAS_COST = 6700;

/** Instantiates a new Prague Gas Calculator. */
public PragueGasCalculator() {
Expand All @@ -48,55 +41,4 @@ public PragueGasCalculator() {
protected PragueGasCalculator(final int maxPrecompile) {
super(maxPrecompile);
}

@Override
public long authOperationGasCost(
final MessageFrame frame, final long offset, final long length, final Address authority) {
final long memoryExpansionGasCost = memoryExpansionGasCost(frame, offset, length);
final long accessFee = frame.isAddressWarm(authority) ? 100 : 2600;
final long gasCost = AUTH_OP_FIXED_FEE + memoryExpansionGasCost + accessFee;
return gasCost;
}

/**
* Returns the gas cost to call another contract on behalf of an authority
*
* @return the gas cost to call another contract on behalf of an authority
*/
@Override
public long authCallOperationGasCost(
final MessageFrame frame,
final long stipend,
final long inputDataOffset,
final long inputDataLength,
final long outputDataOffset,
final long outputDataLength,
final Wei transferValue,
final Account invoker,
final Address invokee,
final boolean accountIsWarm) {

final long inputDataMemoryExpansionCost =
memoryExpansionGasCost(frame, inputDataOffset, inputDataLength);
final long outputDataMemoryExpansionCost =
memoryExpansionGasCost(frame, outputDataOffset, outputDataLength);
final long memoryExpansionCost =
Math.max(inputDataMemoryExpansionCost, outputDataMemoryExpansionCost);

final long staticGasCost = getWarmStorageReadCost();

long dynamicGasCost = accountIsWarm ? 0 : getColdAccountAccessCost() - getWarmStorageReadCost();

if (!transferValue.isZero()) {
dynamicGasCost += AUTH_CALL_VALUE_TRANSFER_GAS_COST;
}

if ((invoker == null || invoker.isEmpty()) && !transferValue.isZero()) {
dynamicGasCost += newAccountGasCost();
}

long cost = staticGasCost + memoryExpansionCost + dynamicGasCost;

return cost;
}
}

This file was deleted.

Loading

0 comments on commit 365737c

Please sign in to comment.