From cc9a1dd82de72497b954e0b86804813f1f28f373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Thu, 26 Jun 2025 13:08:59 +0200 Subject: [PATCH] feat(block-validation): remove block size and tx count checks (#1215) * feat(block-validation): remove block size and tx count checks * remove tests --- core/block_validator.go | 9 --- core/blockchain_test.go | 127 ---------------------------------------- params/version.go | 2 +- 3 files changed, 1 insertion(+), 137 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index fab1c4060b..e46a2bc12c 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -70,13 +70,6 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { if v.bc.HasBlockAndState(block.Hash(), block.NumberU64()) { return ErrKnownBlock } - if !v.config.Scroll.IsValidTxCount(len(block.Transactions())) { - return consensus.ErrInvalidTxCount - } - // Check if block payload size is smaller than the max size - if !v.config.Scroll.IsValidBlockSize(block.PayloadSize()) { - return ErrInvalidBlockPayloadSize - } // Header validity is known at this point, check the uncles and transactions header := block.Header() if err := v.engine.VerifyUncles(v.bc, block); err != nil { @@ -127,7 +120,6 @@ func (v *BlockValidator) ValidateL1Messages(block *types.Block) error { blockHash := block.Hash() if v.config.Scroll.L1Config == nil { - // TODO: should we allow follower nodes to skip L1 message verification? panic("Running on L1Message-enabled network but no l1Config was provided") } @@ -204,7 +196,6 @@ func (v *BlockValidator) ValidateL1Messages(block *types.Block) error { } // skipped messages - // TODO: consider verifying that skipped messages overflow for index := queueIndex; index < txQueueIndex; index++ { if exists := it.Next(); !exists { if err := it.Error(); err != nil { diff --git a/core/blockchain_test.go b/core/blockchain_test.go index febdb032ac..8a64a9ef03 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -3186,70 +3186,6 @@ func TestFeeVault(t *testing.T) { } } -// TestTransactionCountLimit tests that the chain reject blocks with too many transactions. -func TestTransactionCountLimit(t *testing.T) { - // Create config that allows at most 1 transaction per block - config := params.TestChainConfig - config.Scroll.MaxTxPerBlock = new(int) - *config.Scroll.MaxTxPerBlock = 1 - defer func() { - config.Scroll.MaxTxPerBlock = nil - }() - - var ( - engine = ethash.NewFaker() - db = rawdb.NewMemoryDatabase() - key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - address = crypto.PubkeyToAddress(key.PublicKey) - funds = big.NewInt(1000000000000000) - gspec = &Genesis{Config: config, Alloc: GenesisAlloc{address: {Balance: funds}}} - genesis = gspec.MustCommit(db) - ) - - addTx := func(b *BlockGen) { - tx := types.NewTransaction(b.TxNonce(address), address, big.NewInt(0), 50000, b.header.BaseFee, nil) - signed, _ := types.SignTx(tx, types.HomesteadSigner{}, key) - b.AddTx(signed) - } - - // Initialize blockchain - blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil) - if err != nil { - t.Fatalf("failed to create new chain manager: %v", err) - } - defer blockchain.Stop() - - // Insert empty block - block1, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) { - // empty - }) - - if _, err := blockchain.InsertChain(block1); err != nil { - t.Fatalf("failed to insert chain: %v", err) - } - - // Insert block with 1 transaction - block2, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) { - addTx(b) - }) - - if _, err := blockchain.InsertChain(block2); err != nil { - t.Fatalf("failed to insert chain: %v", err) - } - - // Insert block with 2 transactions - block3, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) { - addTx(b) - addTx(b) - }) - - _, err = blockchain.InsertChain(block3) - - if !errors.Is(err, consensus.ErrInvalidTxCount) { - t.Fatalf("error mismatch: have: %v, want: %v", err, consensus.ErrInvalidTxCount) - } -} - // TestInsertBlocksWithL1Messages tests that the chain accepts blocks with L1MessageTx transactions. func TestInsertBlocksWithL1Messages(t *testing.T) { var ( @@ -3443,69 +3379,6 @@ func TestL1MessageValidationFailure(t *testing.T) { assert.Equal(t, uint64(4), *queueIndex) } -func TestBlockPayloadSizeLimit(t *testing.T) { - // Create config that allows at most 150 bytes per block payload - config := params.TestChainConfig - config.Scroll.MaxTxPayloadBytesPerBlock = new(int) - *config.Scroll.MaxTxPayloadBytesPerBlock = 150 - defer func() { - config.Scroll.MaxTxPayloadBytesPerBlock = nil - }() - - var ( - engine = ethash.NewFaker() - db = rawdb.NewMemoryDatabase() - key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - address = crypto.PubkeyToAddress(key.PublicKey) - funds = big.NewInt(1000000000000000) - gspec = &Genesis{Config: config, Alloc: GenesisAlloc{address: {Balance: funds}}} - genesis = gspec.MustCommit(db) - ) - - addTx := func(b *BlockGen) { - tx := types.NewTransaction(b.TxNonce(address), address, big.NewInt(0), 50000, b.header.BaseFee, nil) - signed, _ := types.SignTx(tx, types.HomesteadSigner{}, key) - b.AddTx(signed) - } - - // Initialize blockchain - blockchain, err := NewBlockChain(db, nil, config, engine, vm.Config{}, nil, nil) - if err != nil { - t.Fatalf("failed to create new chain manager: %v", err) - } - defer blockchain.Stop() - - // Insert empty block - block1, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) { - // empty - }) - - if _, err := blockchain.InsertChain(block1); err != nil { - t.Fatalf("failed to insert chain: %v", err) - } - - // Insert block with 1 transaction - block2, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) { - addTx(b) - }) - - if _, err := blockchain.InsertChain(block2); err != nil { - t.Fatalf("failed to insert chain: %v", err) - } - - // Insert block with 2 transactions - block3, _ := GenerateChain(config, genesis, ethash.NewFaker(), db, 1, func(i int, b *BlockGen) { - addTx(b) - addTx(b) - }) - - _, err = blockchain.InsertChain(block3) - - if !errors.Is(err, ErrInvalidBlockPayloadSize) { - t.Fatalf("error mismatch: have: %v, want: %v", err, ErrInvalidBlockPayloadSize) - } -} - func TestEIP3651(t *testing.T) { var ( addraa = common.HexToAddress("0x000000000000000000000000000000000000aaaa") diff --git a/params/version.go b/params/version.go index 13fa655ad5..6b1ffd3c7b 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 8 // Minor version component of the current release - VersionPatch = 58 // Patch version component of the current release + VersionPatch = 59 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )