Skip to content

Commit

Permalink
check initcode size earlier (hyperledger#7233)
Browse files Browse the repository at this point in the history
Fail earlier with the initcode size check

Signed-off-by: Danno Ferrin <danno@numisight.com>
  • Loading branch information
shemnon authored Jun 16, 2024
1 parent 529bd33 commit db9710b
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {

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
Expand All @@ -113,14 +118,9 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) {
} 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);
Expand Down

0 comments on commit db9710b

Please sign in to comment.