Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
Signed-off-by: Karim Taam <[email protected]>
  • Loading branch information
matkt committed Feb 13, 2025
1 parent d95c009 commit ce557c7
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.debug.TraceFrame;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.code.Bytecode;
import org.hyperledger.besu.evm.code.FullBytecode;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Collections;
import java.util.Optional;
import java.util.function.Function;

import org.apache.tuweni.bytes.Bytes;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -211,7 +212,7 @@ void shouldBeSuccessfulWhenTransactionsAndAccountArePresent() {

final String codeString =
"0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063b27b880414610030575b";
final Bytes code = Bytes.fromHexString(codeString);
final Bytecode code = FullBytecode.fromHexString(codeString);
final long nonce = MAX_NONCE - 1;
final String balanceString = "0xffff";
final Wei balance = Wei.fromHexString(balanceString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.EvmSpecVersion;
import org.hyperledger.besu.evm.code.Bytecode;
import org.hyperledger.besu.evm.code.CodeInvalid;
import org.hyperledger.besu.evm.code.EOFLayout;
import org.hyperledger.besu.evm.code.FullBytecode;
import org.hyperledger.besu.util.LogConfigurator;

import java.io.BufferedReader;
Expand All @@ -42,7 +44,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.tuweni.bytes.Bytes;
import picocli.CommandLine;

/** A PicoCli annotated command for running EOF validation reference tests. */
Expand Down Expand Up @@ -215,10 +216,10 @@ private void executeEOFTest(final String fileName, final Map<String, EOFTestCase
* @return The result of the EOF validation test.
*/
public TestResult considerCode(final String hexCode) {
Bytes codeBytes;
Bytecode codeBytes;
try {
codeBytes =
Bytes.fromHexString(
FullBytecode.fromHexString(
hexCode.replaceAll("(^|\n)#[^\n]*($|\n)", "").replaceAll("[^0-9A-Za-z]", ""));
} catch (RuntimeException re) {
return failed(re.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.EvmSpecVersion;
import org.hyperledger.besu.evm.code.Bytecode;
import org.hyperledger.besu.evm.code.CodeInvalid;
import org.hyperledger.besu.evm.code.EOFLayout;
import org.hyperledger.besu.evm.code.FullBytecode;
import org.hyperledger.besu.util.LogConfigurator;

import java.util.ArrayList;
import java.util.List;

import org.apache.tuweni.bytes.Bytes;
import picocli.CommandLine;

/**
Expand Down Expand Up @@ -89,9 +90,9 @@ public void run() {
LogConfigurator.setLevel("", "OFF");

for (var hexCode : codeList) {
Bytes container;
Bytecode container;
try {
container = Bytes.fromHexString(hexCode);
container = FullBytecode.fromHexString(hexCode);
} catch (IllegalArgumentException e) {
parentCommand.out.println("Invalid hex string: " + e.getMessage());
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.code.Bytecode;
import org.hyperledger.besu.evm.code.CodeInvalid;
import org.hyperledger.besu.evm.code.CodeV1;
import org.hyperledger.besu.evm.code.EOFLayout;
import org.hyperledger.besu.evm.code.FullBytecode;
import org.hyperledger.besu.testutil.JsonTestParameters;

public class EOFReferenceTestTools {
Expand All @@ -59,7 +61,7 @@ public class EOFReferenceTestTools {
for (final Map.Entry<String, EOFTestCaseSpec.TestVector> entry :
eofSpec.getVector().entrySet()) {
final String name = entry.getKey();
final Bytes code = Bytes.fromHexString(entry.getValue().code());
final Bytecode code = FullBytecode.fromHexString(entry.getValue().code());
final String containerKind = entry.getValue().containerKind();
for (final Entry<String, TestResult> result :
entry.getValue().results().entrySet()) {
Expand Down Expand Up @@ -100,7 +102,7 @@ public static Collection<Object[]> generateTestParametersForConfig(final String[
public static void executeTest(
final String name,
final String fork,
final Bytes code,
final Bytecode code,
final String containerKind,
final EOFTestCaseSpec.TestResult expected) {
EVM evm = ReferenceTestProtocolSchedules.getInstance().geSpecByName(fork).getEvm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.hyperledger.besu.ethereum.referencetests.EOFTestCaseSpec;
import java.util.stream.Stream;

import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.evm.code.Bytecode;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -35,6 +36,6 @@ public class %%TESTS_NAME%% {
final EOFTestCaseSpec.TestResult results,
final boolean runTest) {
assumeTrue(runTest, "Test " + name + " was ignored");
executeTest(name, fork, code, containerKind, results);
executeTest(name, fork, (Bytecode) code, containerKind, results);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public Bytecode slice(final int i) {
public abstract RawByteArray getRawByteArray();

@Override
public Bytecode copy() {
throw new UnsupportedOperationException("cannot create a copy of bytecode");
}
public abstract Bytecode copy();

@Override
public MutableBytes mutableCopy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public byte get(final int i) {
return bytes.get(i);
}

@Override
public Bytecode copy() {
return new FullBytecode(bytes.copy());
}

@Override
public Bytecode slice(final int i, final int length) {
return new SlicedBytecode(this, i, length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public byte get(final int index) {
return parent.get(sliceOffset + index);
}

@Override
public Bytecode copy() {
return new SlicedBytecode(parent.copy(), sliceOffset, sliceLength);
}

@Override
public Bytecode slice(final int offset, final int length) {
// Just compose the offset again relative to the parent
Expand Down

0 comments on commit ce557c7

Please sign in to comment.