From 1094569b5b4c243099982caed5be4a7850adf6d2 Mon Sep 17 00:00:00 2001 From: Nazarii Denha Date: Fri, 19 May 2023 15:41:58 +0200 Subject: [PATCH] feat: enable eip and update check (#335) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enable eip and update check * Update version.go --------- Co-authored-by: Péter Garamvölgyi Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- core/tx_pool.go | 5 +++++ core/vm/jump_table.go | 5 ++++- params/version.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index cfa86f988e..5fa2b5c479 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -18,6 +18,7 @@ package core import ( "errors" + "fmt" "math" "math/big" "sort" @@ -614,6 +615,10 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error { if uint64(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", 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 { diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index e7e98339d0..4112361b38 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -64,9 +64,12 @@ var ( // JumpTable contains the EVM opcodes supported at a given fork. type JumpTable [256]*operation +// newShanghaiInstructionSet returns the frontier, homestead, byzantium, +// contantinople, istanbul, petersburg, berlin, london and shanghai instructions. func newShanghaiInstructionSet() JumpTable { instructionSet := newLondonInstructionSet() - enable3860(&instructionSet) + enable3855(&instructionSet) // PUSH0 instruction https://eips.ethereum.org/EIPS/eip-3855 + enable3860(&instructionSet) // Limit and meter initcode https://eips.ethereum.org/EIPS/eip-3860 return instructionSet } diff --git a/params/version.go b/params/version.go index a26f0b46cb..b745a58bdc 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 3 // Major version component of the current release VersionMinor = 2 // Minor version component of the current release - VersionPatch = 1 // Patch version component of the current release + VersionPatch = 2 // Patch version component of the current release VersionMeta = "alpha" // Version metadata to append to the version string )