From 370af2ed0626f722e9c5dfc14596d92d0b233baa Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 10 Jun 2025 16:10:26 +0200 Subject: [PATCH] core/vm: fix condition --- core/vm/common.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/vm/common.go b/core/vm/common.go index cddeb7d94c..f2732c7b19 100644 --- a/core/vm/common.go +++ b/core/vm/common.go @@ -27,14 +27,16 @@ import ( // CheckInitCodeSize checks the size of contract initcode against the protocol-defined limit. func CheckInitCodeSize(rules *params.Rules, size uint64) error { - switch { - case rules.IsOsaka && size > params.MaxInitCodeSizeOsaka: - return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, size, params.MaxInitCodeSizeOsaka) - case rules.IsShanghai && size > params.MaxInitCodeSize: - return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, size, params.MaxInitCodeSize) - default: - return nil + if rules.IsOsaka { + if size > params.MaxInitCodeSizeOsaka { + return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, size, params.MaxInitCodeSizeOsaka) + } + } else if rules.IsShanghai { + if size > params.MaxInitCodeSize { + return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, size, params.MaxInitCodeSize) + } } + return nil } // calcMemSize64 calculates the required memory size, and returns