EOF Spec Updates (#6431)

Update a few EOF features based on updated spec
* Add a prague reference test target
* Run evmtool from prestate when no code specified
* RETF and dangling immediate arg fixes

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
pull/6433/head
Danno Ferrin 9 months ago committed by GitHub
parent 94d86afb40
commit e76bcf0bab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java
  2. 2
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
  3. 5
      evm/src/main/java/org/hyperledger/besu/evm/code/CodeV1Validation.java
  4. 4
      evm/src/main/java/org/hyperledger/besu/evm/code/EOFLayout.java
  5. 1
      evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java
  6. 2
      evm/src/main/java/org/hyperledger/besu/evm/operation/RetFOperation.java
  7. 1
      evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java
  8. 7
      evm/src/main/java/org/hyperledger/besu/evm/tracing/StandardJsonTracer.java
  9. 8
      evm/src/test/java/org/hyperledger/besu/evm/code/EOFLayoutTest.java

@ -371,6 +371,9 @@ public class EvmToolCommand implements Runnable {
long txGas = gas - intrinsicGasCost - accessListCost;
final EVM evm = protocolSpec.getEvm();
if (codeBytes.isEmpty()) {
codeBytes = component.getWorldState().get(receiver).getCode();
}
Code code = evm.getCode(Hash.hash(codeBytes), codeBytes);
if (!code.isValid()) {
out.println(((CodeInvalid) code).getInvalidReason());

@ -79,7 +79,7 @@ public class ReferenceTestProtocolSchedules {
createSchedule(genesisStub.clone().shanghaiTime(0).cancunTime(15000)));
builder.put("Cancun", createSchedule(genesisStub.clone().cancunTime(0)));
// TODO remove this after execution-test-specs finalize
builder.put("Shanghai+6780", createSchedule(genesisStub.clone().cancunTime(0)));
builder.put("Prague", createSchedule(genesisStub.clone().futureEipsTime(0)));
builder.put("Future_EIPs", createSchedule(genesisStub.clone().futureEipsTime(0)));
builder.put("Experimental_EIPs", createSchedule(genesisStub.clone().experimentalEipsTime(0)));
return new ReferenceTestProtocolSchedules(builder.build());

@ -779,6 +779,11 @@ public final class CodeV1Validation {
}
currentPC += pcAdvance;
if (currentPC >= stackHeights.length) {
return String.format(
"Dangling immediate argument for opcode 0x%x at PC %d in code section %d.",
currentStackHeight, codeLength - pcAdvance, codeSectionToValidate);
}
stackHeights[currentPC] = currentStackHeight;
unusedBytes -= pcAdvance;
}

@ -158,7 +158,7 @@ public class EOFLayout {
if (typeData[codeSectionCount - 1][2] == -1) {
return invalidLayout(container, version, "Incomplete type section");
}
if (typeData[0][0] != 0 || typeData[0][1] != 0) {
if (typeData[0][0] != 0 || (typeData[0][1] & 0x7f) != 0) {
return invalidLayout(
container, version, "Code section does not have zero inputs and outputs");
}
@ -182,7 +182,7 @@ public class EOFLayout {
version,
"Type data input stack too large - 0x" + Integer.toHexString(typeData[i][0]));
}
if (typeData[i][1] > 0x7f) {
if (typeData[i][1] > 0x80) {
return invalidLayout(
container,
version,

@ -141,7 +141,6 @@ public abstract class AbstractCreateOperation extends AbstractOperation {
final Wei value = Wei.wrap(parent.getStackItem(0));
final Address contractAddress = targetContractAddress(parent);
parent.addCreate(contractAddress);
final long childGasStipend =
gasCalculator().gasAvailableForChildCreate(parent.getRemainingGas());

@ -24,7 +24,7 @@ public class RetFOperation extends AbstractOperation {
/** The Opcode. */
public static final int OPCODE = 0xe4;
/** The Ret F success. */
static final OperationResult retfSuccess = new OperationResult(4, null);
static final OperationResult retfSuccess = new OperationResult(3, null);
/**
* Instantiates a new Ret F operation.

@ -122,6 +122,7 @@ public class ContractCreationProcessor extends AbstractMessageProcessor {
operationTracer.traceAccountCreationResult(
frame, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
} else {
frame.addCreate(contractAddress);
contract.incrementBalance(frame.getValue());
contract.setNonce(initialContractNonce);
contract.clearStorage();

@ -126,9 +126,7 @@ public class StandardJsonTracer implements OperationTracer {
for (int i = messageFrame.stackSize() - 1; i >= 0; i--) {
stack.add("\"" + shortBytes(messageFrame.getStackItem(i)) + "\"");
}
pc =
messageFrame.getPC()
- messageFrame.getCode().getCodeSection(messageFrame.getSection()).getEntryPoint();
pc = messageFrame.getPC() - messageFrame.getCode().getCodeSection(0).getEntryPoint();
section = messageFrame.getSection();
gas = shortNumber(messageFrame.getRemainingGas());
memorySize = messageFrame.memoryWordSize() * 32;
@ -171,6 +169,9 @@ public class StandardJsonTracer implements OperationTracer {
public void tracePostExecution(
final MessageFrame messageFrame, final Operation.OperationResult executeResult) {
final Operation currentOp = messageFrame.getCurrentOperation();
if (currentOp.isVirtualOperation()) {
return;
}
final int opcode = currentOp.getOpcode();
final Bytes returnData = messageFrame.getReturnData();

@ -276,15 +276,15 @@ public class EOFLayoutTest {
1
},
{
"EF0001 010010 0200040001000200020002 030000 00 00000000 80000000 00010000 02030000 FE 5000 3000 8000",
"EF0001 010010 0200040001000200020002 030000 00 00000000 F0000000 00010000 02030000 FE 5000 3000 8000",
"inputs too large",
"Type data input stack too large - 0x80",
"Type data input stack too large - 0xf0",
1
},
{
"EF0001 010010 0200040001000200020002 030000 00 00000000 01000000 00800000 02030000 FE 5000 3000 8000",
"EF0001 010010 0200040001000200020002 030000 00 00000000 01000000 00F00000 02030000 FE 5000 3000 8000",
"outputs too large",
"Type data output stack too large - 0x80",
"Type data output stack too large - 0xf0",
1
},
{

Loading…
Cancel
Save