From db9710b2aafde17ea850cde88c97779f66102eec Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Sun, 16 Jun 2024 01:43:51 -0600 Subject: [PATCH] check initcode size earlier (#7233) Fail earlier with the initcode size check Signed-off-by: Danno Ferrin --- .../besu/evm/operation/AbstractCreateOperation.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java index a484f28ceb..180eac2799 100644 --- a/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java +++ b/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);