Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove 2315 #1983

Merged
merged 10 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public MessageFrame.Builder createMessageFrameBuilder() {
.completer(messageFrame -> {})
.miningBeneficiary(messageFrame.getMiningBeneficiary())
.maxStackSize(messageFrame.getMaxStackSize())
.blockHashLookup(messageFrame.getBlockHashLookup())
.returnStack(messageFrame.getReturnStack());
.blockHashLookup(messageFrame.getBlockHashLookup());
}

public void cleanUp() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,6 @@ public Gas getSelfDestructRefundAmount() {
return SELF_DESTRUCT_REFUND_AMOUNT;
}

@Override
public Gas getBeginSubGasCost() {
throw new UnsupportedOperationException(
"BEGINSUB operation not supported by " + getClass().getSimpleName());
}

protected Gas copyWordsToMemoryGasCost(
final MessageFrame frame,
final Gas baseGasCost,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.hyperledger.besu.ethereum.vm.operations.AddressOperation;
import org.hyperledger.besu.ethereum.vm.operations.AndOperation;
import org.hyperledger.besu.ethereum.vm.operations.BalanceOperation;
import org.hyperledger.besu.ethereum.vm.operations.BeginSubOperation;
import org.hyperledger.besu.ethereum.vm.operations.BlockHashOperation;
import org.hyperledger.besu.ethereum.vm.operations.ByteOperation;
import org.hyperledger.besu.ethereum.vm.operations.CallCodeOperation;
Expand Down Expand Up @@ -56,7 +55,6 @@
import org.hyperledger.besu.ethereum.vm.operations.IsZeroOperation;
import org.hyperledger.besu.ethereum.vm.operations.JumpDestOperation;
import org.hyperledger.besu.ethereum.vm.operations.JumpOperation;
import org.hyperledger.besu.ethereum.vm.operations.JumpSubOperation;
import org.hyperledger.besu.ethereum.vm.operations.JumpiOperation;
import org.hyperledger.besu.ethereum.vm.operations.LogOperation;
import org.hyperledger.besu.ethereum.vm.operations.LtOperation;
Expand All @@ -77,7 +75,6 @@
import org.hyperledger.besu.ethereum.vm.operations.ReturnDataCopyOperation;
import org.hyperledger.besu.ethereum.vm.operations.ReturnDataSizeOperation;
import org.hyperledger.besu.ethereum.vm.operations.ReturnOperation;
import org.hyperledger.besu.ethereum.vm.operations.ReturnSubOperation;
import org.hyperledger.besu.ethereum.vm.operations.RevertOperation;
import org.hyperledger.besu.ethereum.vm.operations.SDivOperation;
import org.hyperledger.besu.ethereum.vm.operations.SGtOperation;
Expand Down Expand Up @@ -147,14 +144,6 @@ static EVM istanbul(final GasCalculator gasCalculator, final BigInteger chainId)
return new EVM(registry, gasCalculator);
}

static EVM berlin(final GasCalculator gasCalculator, final BigInteger chainId) {
final OperationRegistry registry = new OperationRegistry();

registerBerlinOpcodes(registry, gasCalculator, Account.DEFAULT_VERSION, chainId);

return new EVM(registry, gasCalculator);
}

private static void registerFrontierOpcodes(
final OperationRegistry registry,
final GasCalculator gasCalculator,
Expand Down Expand Up @@ -289,15 +278,4 @@ private static void registerIstanbulOpcodes(
new SStoreOperation(gasCalculator, SStoreOperation.EIP_1706_MINIMUM),
Account.DEFAULT_VERSION);
}

private static void registerBerlinOpcodes(
final OperationRegistry registry,
final GasCalculator gasCalculator,
final int accountVersion,
final BigInteger chainId) {
registerIstanbulOpcodes(registry, gasCalculator, accountVersion, chainId);
registry.put(new BeginSubOperation(gasCalculator), accountVersion);
registry.put(new JumpSubOperation(gasCalculator), accountVersion);
registry.put(new ReturnSubOperation(gasCalculator), accountVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,6 @@ static ProtocolSpecBuilder berlinDefinition(
chainId,
Set.of(TransactionType.FRONTIER, TransactionType.ACCESS_LIST),
quorumCompatibilityMode))
.evmBuilder(
gasCalculator ->
MainnetEvmRegistries.berlin(gasCalculator, chainId.orElse(BigInteger.ZERO)))
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::berlin)
.transactionReceiptFactory(
enableRevertReason
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.hyperledger.besu.ethereum.vm.GasCalculator;
import org.hyperledger.besu.ethereum.vm.MessageFrame;
import org.hyperledger.besu.ethereum.vm.OperationTracer;
import org.hyperledger.besu.ethereum.vm.operations.ReturnStack;
import org.hyperledger.besu.ethereum.worldstate.GoQuorumMutablePrivateWorldStateUpdater;
import org.hyperledger.besu.plugin.data.TransactionType;

Expand Down Expand Up @@ -311,7 +310,6 @@ public TransactionProcessingResult processTransaction(
MessageFrame.builder()
.messageFrameStack(messageFrameStack)
.maxStackSize(maxStackSize)
.returnStack(new ReturnStack())
.blockchain(blockchain)
.worldState(worldUpdater.updater())
.initialGas(gasAvailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.hyperledger.besu.ethereum.vm.GasCalculator;
import org.hyperledger.besu.ethereum.vm.MessageFrame;
import org.hyperledger.besu.ethereum.vm.OperationTracer;
import org.hyperledger.besu.ethereum.vm.operations.ReturnStack;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateUpdater;

import java.util.ArrayDeque;
Expand Down Expand Up @@ -131,7 +130,6 @@ public TransactionProcessingResult processTransaction(
MessageFrame.builder()
.messageFrameStack(messageFrameStack)
.maxStackSize(maxStackSize)
.returnStack(new ReturnStack())
.blockchain(blockchain)
.worldState(mutablePrivateWorldStateUpdater)
.initialGas(Gas.MAX_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
.miningBeneficiary(frame.getMiningBeneficiary())
.blockHashLookup(frame.getBlockHashLookup())
.maxStackSize(frame.getMaxStackSize())
.returnStack(frame.getReturnStack())
.build();
frame.incrementRemainingGas(cost);
childFrame.copyWarmedUpFields(frame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.ethereum.vm;

import org.hyperledger.besu.ethereum.vm.operations.BeginSubOperation;
import org.hyperledger.besu.ethereum.vm.operations.JumpDestOperation;

import java.util.BitSet;
Expand All @@ -32,9 +31,6 @@ public class Code {
/** Used to cache valid jump destinations. */
private BitSet validJumpDestinations;

/** Used to cache valid jump sub destinations. */
private BitSet validJumpSubDestinations;

/**
* Public constructor.
*
Expand Down Expand Up @@ -108,35 +104,6 @@ public boolean isValidJumpDestination(
return validJumpDestinations.get(jumpDestination);
}

/**
* Determine whether a specified destination is a valid jump sub target.
*
* @param evm the EVM executing this code
* @param frame The current message frame
* @param destination The destination we're checking for validity.
* @return Whether or not this location is a valid jump sub destination.
*/
public boolean isValidJumpSubDestination(
final EVM evm, final MessageFrame frame, final UInt256 destination) {
if (!destination.fitsInt()) return false;
final int jumpDestination = destination.intValue();
if (jumpDestination >= getSize()) return false;

if (validJumpSubDestinations == null) {
// Calculate valid jump destinations
validJumpSubDestinations = new BitSet(getSize());
evm.forEachOperation(
this,
frame.getContractAccountVersion(),
(final Operation op, final Integer offset) -> {
if (op.getOpcode() == BeginSubOperation.OPCODE) {
validJumpSubDestinations.set(offset);
}
});
}
return validJumpSubDestinations.get(jumpDestination);
}

public Bytes getBytes() {
return bytes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public enum ExceptionalHaltReason {
INVALID_OPERATION("Bad instruction"),
INVALID_RETURN_DATA_BUFFER_ACCESS("Out of bounds"),
TOO_MANY_STACK_ITEMS("Out of stack"),
ILLEGAL_STATE_CHANGE("Illegal state change"),
INVALID_RETSUB("Invalid retsub"),
INVALID_SUB_ROUTINE_ENTRY("Invalid subroutine entry");
ILLEGAL_STATE_CHANGE("Illegal state change");

String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.hyperledger.besu.ethereum.mainnet.precompiles.RIPEMD160PrecompiledContract;
import org.hyperledger.besu.ethereum.mainnet.precompiles.SHA256PrecompiledContract;
import org.hyperledger.besu.ethereum.vm.operations.BalanceOperation;
import org.hyperledger.besu.ethereum.vm.operations.BeginSubOperation;
import org.hyperledger.besu.ethereum.vm.operations.BlockHashOperation;
import org.hyperledger.besu.ethereum.vm.operations.ExpOperation;
import org.hyperledger.besu.ethereum.vm.operations.ExtCodeCopyOperation;
Expand Down Expand Up @@ -386,13 +385,6 @@ Gas logOperationGasCost(
*/
Gas getSelfDestructRefundAmount();

/**
* Returns the cost for executing a {@link BeginSubOperation}.
*
* @return the cost for executing begin sub operation
*/
Gas getBeginSubGasCost();

/**
* Returns the cost of a SLOAD to a storage slot not previously loaded in the TX context.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.hyperledger.besu.ethereum.mainnet.AbstractMessageProcessor;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
import org.hyperledger.besu.ethereum.vm.internal.MemoryEntry;
import org.hyperledger.besu.ethereum.vm.operations.ReturnStack;

import java.util.ArrayList;
import java.util.Deque;
Expand Down Expand Up @@ -237,9 +236,6 @@ public enum Type {
private final PrivateMetadataUpdater privateMetadataUpdater;
private Optional<Bytes> revertReason;

// as defined on https://eips.ethereum.org/EIPS/eip-2315
private final ReturnStack returnStack;

// Privacy Execution Environment fields.
private final Hash transactionHash;

Expand All @@ -259,7 +255,6 @@ private MessageFrame(
final Type type,
final Blockchain blockchain,
final Deque<MessageFrame> messageFrameStack,
final ReturnStack returnStack,
final WorldUpdater worldState,
final Gas initialGas,
final Address recipient,
Expand Down Expand Up @@ -288,7 +283,6 @@ private MessageFrame(
this.type = type;
this.blockchain = blockchain;
this.messageFrameStack = messageFrameStack;
this.returnStack = returnStack;
this.worldState = worldState;
this.gasRemaining = initialGas;
this.blockHashLookup = blockHashLookup;
Expand Down Expand Up @@ -510,53 +504,6 @@ public int stackSize() {
return stack.size();
}

/**
* Tests if the return stack is full
*
* @return true is the return stack is full, else false
*/
public boolean isReturnStackFull() {
return returnStack.isFull();
}

/**
* Tests if the return stack is empty
*
* @return true is the return stack is empty, else false
*/
public boolean isReturnStackEmpty() {
return returnStack.isEmpty();
}

/**
* Removes the item at the top of the return stack.
*
* @return the item at the top of the return stack
* @throws IllegalStateException if the return stack is empty
*/
public int popReturnStackItem() {
return returnStack.pop();
}

/**
* Return the return stack.
*
* @return the return stack
*/
public ReturnStack getReturnStack() {
return returnStack;
}

/**
* Pushes the corresponding item onto the top of the return stack
*
* @param value The value to push onto the return stack.
* @throws IllegalStateException if the stack is full
*/
public void pushReturnStackItem(final int value) {
returnStack.push(value);
}

/**
* Returns whether or not the message frame is static or not.
*
Expand Down Expand Up @@ -1162,7 +1109,6 @@ public static class Builder {
private PrivateMetadataUpdater privateMetadataUpdater = null;
private Hash transactionHash;
private Optional<Bytes> reason = Optional.empty();
private ReturnStack returnStack = new ReturnStack();
private Set<Address> accessListWarmAddresses = emptySet();
private Multimap<Address, Bytes32> accessListWarmStorage = HashMultimap.create();

Expand All @@ -1171,11 +1117,6 @@ public Builder type(final Type type) {
return this;
}

public Builder returnStack(final ReturnStack returnStack) {
this.returnStack = returnStack;
return this;
}

public Builder messageFrameStack(final Deque<MessageFrame> messageFrameStack) {
this.messageFrameStack = messageFrameStack;
return this;
Expand Down Expand Up @@ -1316,7 +1257,6 @@ private void validate() {
checkState(type != null, "Missing message frame type");
checkState(blockchain != null, "Missing message frame blockchain");
checkState(messageFrameStack != null, "Missing message frame message frame stack");
checkState(returnStack != null, "Missing return stack");
checkState(worldState != null, "Missing message frame world state");
checkState(initialGas != null, "Missing message frame initial getGasRemaining");
checkState(address != null, "Missing message frame recipient");
Expand Down Expand Up @@ -1344,7 +1284,6 @@ public MessageFrame build() {
type,
blockchain,
messageFrameStack,
returnStack,
worldState,
initialGas,
address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.vm.Operation.OperationResult;
import org.hyperledger.besu.ethereum.vm.operations.ReturnStack;

import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -80,11 +79,6 @@ public void traceExecution(
for (int i = messageFrame.stackSize() - 1; i >= 0; i--) {
stack.add(shortBytes(messageFrame.getStackItem(i)));
}
final ArrayNode returnStack = traceLine.putArray("returnStack");
final ReturnStack rs = messageFrame.getReturnStack();
for (int i = rs.size() - 1; i >= 0; i--) {
returnStack.add("0x" + Integer.toHexString(rs.get(i) - 1));
}
Bytes returnData = messageFrame.getReturnData();
traceLine.put("returnData", returnData.size() > 0 ? returnData.toHexString() : null);
traceLine.put("depth", messageFrame.getMessageStackDepth() + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ private void spawnChildMessage(final MessageFrame frame) {
.miningBeneficiary(frame.getMiningBeneficiary())
.blockHashLookup(frame.getBlockHashLookup())
.maxStackSize(frame.getMaxStackSize())
.returnStack(frame.getReturnStack())
.build();

frame.incrementRemainingGas(cost);
Expand Down
Loading