From a35b654f25fdac518d5775b55aa064025040b01a Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Wed, 18 Jan 2023 09:47:42 +0100 Subject: [PATCH] core/txpool: check if initcode size is exceeded (#26504) * core/txpool: check if initcode size is exceeded * core/txpool: move check --- core/txpool/txpool.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index dc6a71f07a..3e4eb21cfc 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -18,6 +18,7 @@ package txpool import ( "errors" + "fmt" "math" "math/big" "sort" @@ -599,6 +600,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if tx.Size() > txMaxSize { return ErrOversizedData } + // Check whether the init code size has been exceeded. + if pool.shanghai && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { + return fmt.Errorf("%w: code size %v limit %v", core.ErrMaxInitCodeSizeExceeded, len(tx.Data()), params.MaxInitCodeSize) + } // Transactions can't be negative. This may never happen using RLP decoded // transactions but may occur if you create a transaction using the RPC. if tx.Value().Sign() < 0 {