Skip to content

Commit

Permalink
message frame buider will create AuthorizedCodeService by itsef if it…
Browse files Browse the repository at this point in the history
… isn't set

Signed-off-by: Daniel Lehrner <[email protected]>
  • Loading branch information
daniellehrner committed Jul 16, 2024
1 parent 017319f commit 9c610ec
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBMetricsFactory;
Expand Down Expand Up @@ -125,8 +124,7 @@ public MessageFrame.Builder createMessageFrameBuilder() {
.apparentValue(messageFrame.getApparentValue())
.code(messageFrame.getCode())
.isStatic(messageFrame.isStatic())
.completer(frame -> {})
.authorizedCodeService(new AuthorizedCodeService());
.completer(frame -> {});
}

public void cleanUp() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.hyperledger.besu.evm.operation.BlockHashOperation;
import org.hyperledger.besu.evm.processor.AbstractMessageProcessor;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Deque;
Expand Down Expand Up @@ -137,7 +136,6 @@ private MessageFrame createCallFrame(
maybeContract
.map(c -> processor.getCodeFromEVM(c.getCodeHash(), c.getCode()))
.orElse(CodeV0.EMPTY_CODE))
.authorizedCodeService(new AuthorizedCodeService())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.processor.AbstractMessageProcessor;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Deque;
Expand Down Expand Up @@ -148,7 +147,6 @@ public TransactionProcessingResult processTransaction(
.contract(privateContractAddress)
.inputData(initCodeBytes.slice(code.getSize()))
.code(code)
.authorizedCodeService(new AuthorizedCodeService())
.build();
} else {
final Address to = transaction.getTo().get();
Expand All @@ -164,7 +162,6 @@ public TransactionProcessingResult processTransaction(
maybeContract
.map(c -> messageCallProcessor.getCodeFromEVM(c.getCodeHash(), c.getCode()))
.orElse(CodeV0.EMPTY_CODE))
.authorizedCodeService(new AuthorizedCodeService())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.code.CodeV0;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.ArrayList;
Expand Down Expand Up @@ -181,7 +180,6 @@ public MessageFrame build() {
blockHashLookup.orElseGet(
() -> new CachingBlockHashLookup(localBlockHeader, localBlockchain)))
.maxStackSize(maxStackSize)
.authorizedCodeService(new AuthorizedCodeService())
.build();
stackItems.forEach(frame::pushStackItem);
return frame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ShanghaiGasCalculator;
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;

import java.io.PrintStream;
import java.util.Locale;
Expand Down Expand Up @@ -71,7 +70,6 @@ public abstract class BenchmarkExecutor {
.originator(Address.ZERO)
.initialGas(100_000L)
.worldUpdater(new SimpleWorld())
.authorizedCodeService(new AuthorizedCodeService())
.build();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.math.BigInteger;
Expand Down Expand Up @@ -745,7 +744,6 @@ public Bytes execute() {
.accessListWarmStorage(accessListWarmStorage)
.versionedHashes(versionedHashes)
.completer(c -> {})
.authorizedCodeService(new AuthorizedCodeService())
.build();

final Deque<MessageFrame> messageFrameStack = initialMessageFrame.getMessageFrameStack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,6 @@ private void validate() {
checkState(apparentValue != null, "Missing message frame apparent value");
checkState(code != null, "Missing message frame code");
checkState(completer != null, "Missing message frame completer");
checkState(authorizedCodeService != null, "Missing authorized account service");
}

/**
Expand All @@ -1690,6 +1689,11 @@ public MessageFrame build() {
WorldUpdater updater;
boolean newStatic;
TxValues newTxValues;

if (authorizedCodeService == null) {
authorizedCodeService = new AuthorizedCodeService();
}

if (parentMessageFrame == null) {
newTxValues =
new TxValues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.operation.JumpOperation;
import org.hyperledger.besu.evm.operation.Operation.OperationResult;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -91,7 +90,6 @@ private MessageFrame createJumpFrame(final CodeV0 getsCached) {
.completer(f -> {})
.miningBeneficiary(Address.ZERO)
.blockHashLookup(l -> Hash.EMPTY)
.authorizedCodeService(new AuthorizedCodeService())
.build();

frame.setPC(CURRENT_PC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.hyperledger.besu.evm.code.CodeV0;
import org.hyperledger.besu.evm.toy.ToyBlockValues;
import org.hyperledger.besu.evm.toy.ToyWorld;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;

import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
Expand Down Expand Up @@ -59,8 +58,7 @@ void setUp() {
.value(Wei.ZERO)
.apparentValue(Wei.ZERO)
.code(CodeV0.EMPTY_CODE)
.completer(messageFrame -> {})
.authorizedCodeService(new AuthorizedCodeService());
.completer(messageFrame -> {});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.hyperledger.besu.evm.internal.Words;
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Deque;
Expand Down Expand Up @@ -176,7 +175,6 @@ private void executeOperation(final Bytes contract, final EVM evm) {
.originator(Address.ZERO)
.initialGas(100000L)
.worldUpdater(worldUpdater)
.authorizedCodeService(new AuthorizedCodeService())
.build();
final Deque<MessageFrame> messageFrameStack = messageFrame.getMessageFrameStack();
messageFrame.pushStackItem(Bytes.ofUnsignedLong(contract.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.testutils.TestMessageFrameBuilder;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Deque;
Expand Down Expand Up @@ -164,7 +163,6 @@ public void setUp(final String sender, final String salt, final String code) {
.originator(Address.ZERO)
.initialGas(100_000L)
.worldUpdater(worldUpdater)
.authorizedCodeService(new AuthorizedCodeService())
.build();
messageFrame.pushStackItem(UInt256.fromHexString(salt));
messageFrame.pushStackItem(memoryLength);
Expand Down Expand Up @@ -277,7 +275,6 @@ private MessageFrame testMemoryFrame(final UInt256 memoryOffset, final UInt256 m
.originator(Address.ZERO)
.initialGas(100000L)
.worldUpdater(worldUpdater)
.authorizedCodeService(new AuthorizedCodeService())
.build();
messageFrame.pushStackItem(Bytes.EMPTY);
messageFrame.pushStackItem(memoryLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.testutils.TestMessageFrameBuilder;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Deque;
Expand Down Expand Up @@ -272,7 +271,6 @@ private MessageFrame testMemoryFrame(
.originator(Address.ZERO)
.initialGas(100000L)
.worldUpdater(worldUpdater)
.authorizedCodeService(new AuthorizedCodeService())
.build();
messageFrame.pushStackItem(memoryLength);
messageFrame.pushStackItem(memoryOffset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.List;
Expand Down Expand Up @@ -155,7 +154,6 @@ private MessageFrame testMemoryFrame(final Code code, final Bytes initData) {
.originator(Address.ZERO)
.initialGas(100000L)
.worldUpdater(worldUpdater)
.authorizedCodeService(new AuthorizedCodeService())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.hyperledger.besu.evm.internal.Words;
import org.hyperledger.besu.evm.operation.Operation;
import org.hyperledger.besu.evm.operation.SelfDestructOperation;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -92,7 +91,6 @@ void checkContractDeletionCommon(
.originator(Address.ZERO)
.initialGas(100_000L)
.worldUpdater(worldUpdater)
.authorizedCodeService(new AuthorizedCodeService())
.build();
messageFrame.pushStackItem(Bytes.fromHexString(beneficiary));
if (newContract) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator;
import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;

import java.math.BigInteger;
import java.util.Map;
Expand Down Expand Up @@ -73,7 +72,6 @@ public class Benchmarks {
.originator(Address.ZERO)
.initialGas(100_000L)
.worldUpdater(new SimpleWorld())
.authorizedCodeService(new AuthorizedCodeService())
.build();

private static void benchSecp256k1Recover() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.hyperledger.besu.evm.internal.Words;
import org.hyperledger.besu.evm.operation.BlockHashOperation.BlockHashLookup;
import org.hyperledger.besu.evm.toy.ToyWorld;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.ArrayList;
Expand Down Expand Up @@ -171,7 +170,6 @@ public MessageFrame build() {
.blockHashLookup(blockHashLookup.orElse(number -> Hash.hash(Words.longBytes(number))))
.maxStackSize(maxStackSize)
.isStatic(isStatic)
.authorizedCodeService(new AuthorizedCodeService())
.build();
frame.setPC(pc);
frame.setSection(section);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.tracing.StandardJsonTracer;
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.io.PrintStream;
Expand Down Expand Up @@ -192,7 +191,6 @@ public void run() {
.completer(c -> {})
.miningBeneficiary(Address.ZERO)
.blockHashLookup(n -> null)
.authorizedCodeService(new AuthorizedCodeService())
.build();

final MessageCallProcessor mcp = new MessageCallProcessor(evm, precompileContractRegistry);
Expand Down

0 comments on commit 9c610ec

Please sign in to comment.