Always validate deep

Don't give the option for shallow validation, it's always deep.

Signed-off-by: Danno Ferrin <danno@numisight.com>
mega-eof
Danno Ferrin 6 months ago
parent 97b9d4e972
commit 8032d0ba36
  1. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/CodeValidateSubCommand.java
  2. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EOFTestSubCommand.java
  3. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/PrettyPrintSubCommand.java
  4. 2
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/eof/EOFReferenceTestTools.java
  5. 2
      evm/src/main/java/org/hyperledger/besu/evm/code/CodeFactory.java
  6. 7
      evm/src/main/java/org/hyperledger/besu/evm/code/CodeV1Validation.java

@ -119,7 +119,7 @@ public class CodeValidateSubCommand implements Runnable {
return "err: layout - " + layout.invalidReason() + "\n";
}
String error = CodeV1Validation.validate(layout, true);
String error = CodeV1Validation.validate(layout);
if (error != null) {
return "err: " + error + "\n";
}

@ -215,7 +215,7 @@ public class EOFTestSubCommand implements Runnable {
return failed("validate " + ((CodeInvalid) code).getInvalidReason());
}
if (code instanceof CodeV1 codeV1) {
var result = CodeV1Validation.validate(codeV1.getEofLayout(), true);
var result = CodeV1Validation.validate(codeV1.getEofLayout());
if (result != null) {
return (failed("deep validate error: " + result));
}

@ -65,7 +65,7 @@ public class PrettyPrintSubCommand implements Runnable {
} else {
EOFLayout layout = EOFLayout.parseEOF(container);
if (layout.isValid()) {
String validation = CodeV1Validation.validate(layout, true);
String validation = CodeV1Validation.validate(layout);
if (validation == null || force) {
layout.prettyPrint(parentCommand.out);
}

@ -108,7 +108,7 @@ public class EOFReferenceTestTools {
: ((CodeInvalid) parsedCode).getInvalidReason()))
.isEqualTo(results.result());
if (parsedCode instanceof CodeV1 codeV1) {
var deepValidate = CodeV1Validation.validate(codeV1.getEofLayout(), true);
var deepValidate = CodeV1Validation.validate(codeV1.getEofLayout());
assertThat(deepValidate)
.withFailMessage(
() ->

@ -119,7 +119,7 @@ public final class CodeFactory {
return new CodeInvalid(layout.container(), "Invalid EOF Layout: " + layout.invalidReason());
}
final String validationError = CodeV1Validation.validate(layout, createTransaction);
final String validationError = CodeV1Validation.validate(layout);
if (validationError != null) {
return new CodeInvalid(layout.container(), "EOF Code Invalid : " + validationError);
}

@ -65,18 +65,15 @@ public final class CodeV1Validation {
* containers.
*
* @param layout The parsed EOFLayout of the code
* @param deep optional flag to see if we should validate deeply.
* @return either null, indicating no error, or a String describing the validation error.
*/
public static String validate(final EOFLayout layout, final boolean deep) {
public static String validate(final EOFLayout layout) {
Queue<EOFLayout> workList = new ArrayDeque<>(layout.getSubcontainerCount());
workList.add(layout);
while (!workList.isEmpty()) {
EOFLayout container = workList.poll();
if (deep) {
workList.addAll(List.of(container.subContainers()));
}
workList.addAll(List.of(container.subContainers()));
final String codeValidationError = CodeV1Validation.validateCode(container);
if (codeValidationError != null) {

Loading…
Cancel
Save