check initcode size earlier (#7233)

Fail earlier with the initcode size check

Signed-off-by: Danno Ferrin <danno@numisight.com>
pull/7234/head
Danno Ferrin 5 months ago committed by GitHub
parent 529bd336fc
commit db9710b2aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java

@ -104,6 +104,11 @@ public abstract class AbstractCreateOperation extends AbstractOperation {
Code code = codeSupplier.get();
if (code != null && code.getSize() > maxInitcodeSize) {
frame.popStackItems(getStackItemsConsumed());
return new OperationResult(cost, ExceptionalHaltReason.CODE_TOO_LARGE);
}
if (value.compareTo(account.getBalance()) > 0
|| frame.getDepth() >= 1024
|| account.getNonce() == -1
@ -113,14 +118,9 @@ public abstract class AbstractCreateOperation extends AbstractOperation {
} else {
account.incrementNonce();
if (code.getSize() > maxInitcodeSize) {
frame.popStackItems(getStackItemsConsumed());
return new OperationResult(cost, ExceptionalHaltReason.CODE_TOO_LARGE);
}
if (!code.isValid()) {
fail(frame);
} else {
frame.decrementRemainingGas(cost);
spawnChildMessage(frame, code, evm);
frame.incrementRemainingGas(cost);

Loading…
Cancel
Save