mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
fix: exclude L1 message from block payload size validation (#476)
* fix: exclude L1 message from block payload size validation * fix the bug when calculating l2TxCount. (#479) * fix bug when calculate l2 tx count * Update version * bump version --------- Co-authored-by: maskpp <maskpp266@gmail.com>
This commit is contained in:
parent
b65f42b41a
commit
727f88bc5f
5 changed files with 24 additions and 10 deletions
|
|
@ -3353,6 +3353,8 @@ func TestL1MessageValidationFailure(t *testing.T) {
|
||||||
// initialize genesis
|
// initialize genesis
|
||||||
config := params.AllEthashProtocolChanges
|
config := params.AllEthashProtocolChanges
|
||||||
config.Scroll.L1Config.NumL1MessagesPerBlock = 1
|
config.Scroll.L1Config.NumL1MessagesPerBlock = 1
|
||||||
|
maxPayload := 1024
|
||||||
|
config.Scroll.MaxTxPayloadBytesPerBlock = &maxPayload
|
||||||
|
|
||||||
genspec := &Genesis{
|
genspec := &Genesis{
|
||||||
Config: config,
|
Config: config,
|
||||||
|
|
@ -3365,7 +3367,10 @@ func TestL1MessageValidationFailure(t *testing.T) {
|
||||||
|
|
||||||
// initialize L1 message DB
|
// initialize L1 message DB
|
||||||
msgs := []types.L1MessageTx{
|
msgs := []types.L1MessageTx{
|
||||||
{QueueIndex: 0, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{2}},
|
// large L1 message, should not count against block payload limit
|
||||||
|
{QueueIndex: 0, Gas: 25100, To: &common.Address{1}, Data: make([]byte, 1025), Sender: common.Address{2}},
|
||||||
|
|
||||||
|
// normal L1 messages
|
||||||
{QueueIndex: 1, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{2}},
|
{QueueIndex: 1, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{2}},
|
||||||
{QueueIndex: 2, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{2}},
|
{QueueIndex: 2, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{2}},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,9 @@ func (b *Block) PayloadSize() common.StorageSize {
|
||||||
// add up all txs sizes
|
// add up all txs sizes
|
||||||
var totalSize common.StorageSize
|
var totalSize common.StorageSize
|
||||||
for _, tx := range b.transactions {
|
for _, tx := range b.transactions {
|
||||||
totalSize += tx.Size()
|
if !tx.IsL1MessageTx() {
|
||||||
|
totalSize += tx.Size()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return totalSize
|
return totalSize
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1003,7 +1003,7 @@ loop:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Error may be ignored here. The error has already been checked
|
// Error may be ignored here. The error has already been checked
|
||||||
// during transaction acceptance is the transaction pool.
|
// during transaction acceptance in the transaction pool.
|
||||||
//
|
//
|
||||||
// We use the eip155 signer regardless of the current hf.
|
// We use the eip155 signer regardless of the current hf.
|
||||||
from, _ := types.Sender(w.current.signer, tx)
|
from, _ := types.Sender(w.current.signer, tx)
|
||||||
|
|
@ -1050,15 +1050,18 @@ loop:
|
||||||
case errors.Is(err, nil):
|
case errors.Is(err, nil):
|
||||||
// Everything ok, collect the logs and shift in the next transaction from the same account
|
// Everything ok, collect the logs and shift in the next transaction from the same account
|
||||||
coalescedLogs = append(coalescedLogs, logs...)
|
coalescedLogs = append(coalescedLogs, logs...)
|
||||||
|
w.current.tcount++
|
||||||
|
txs.Shift()
|
||||||
|
|
||||||
if tx.IsL1MessageTx() {
|
if tx.IsL1MessageTx() {
|
||||||
queueIndex := tx.AsL1MessageTx().QueueIndex
|
queueIndex := tx.AsL1MessageTx().QueueIndex
|
||||||
log.Debug("Including L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String())
|
log.Debug("Including L1 message", "queueIndex", queueIndex, "tx", tx.Hash().String())
|
||||||
w.current.l1TxCount++
|
w.current.l1TxCount++
|
||||||
w.current.nextL1MsgIndex = queueIndex + 1
|
w.current.nextL1MsgIndex = queueIndex + 1
|
||||||
|
} else {
|
||||||
|
// only consider block size limit for L2 transactions
|
||||||
|
w.current.blockSize += tx.Size()
|
||||||
}
|
}
|
||||||
w.current.tcount++
|
|
||||||
w.current.blockSize += tx.Size()
|
|
||||||
txs.Shift()
|
|
||||||
|
|
||||||
case errors.Is(err, core.ErrTxTypeNotSupported):
|
case errors.Is(err, core.ErrTxTypeNotSupported):
|
||||||
// Pop the unsupported transaction without shifting in the next from the account
|
// Pop the unsupported transaction without shifting in the next from the account
|
||||||
|
|
|
||||||
|
|
@ -895,13 +895,13 @@ func TestLargeL1MessageSkipPayloadCheck(t *testing.T) {
|
||||||
{QueueIndex: 2, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{3}}, // different sender
|
{QueueIndex: 2, Gas: 21016, To: &common.Address{1}, Data: []byte{0x01}, Sender: common.Address{3}}, // different sender
|
||||||
}
|
}
|
||||||
|
|
||||||
l1MessageTest(t, msgs, false, func(blockNum int, block *types.Block, db ethdb.Database, w *worker) bool {
|
l1MessageTest(t, msgs, true, func(blockNum int, block *types.Block, db ethdb.Database, w *worker) bool {
|
||||||
switch blockNum {
|
switch blockNum {
|
||||||
case 0:
|
case 0:
|
||||||
return false
|
return false
|
||||||
case 1:
|
case 1:
|
||||||
// include #0, #1 and #2
|
// include #0, #1 and #2 + one L2 tx
|
||||||
assert.Equal(3, len(block.Transactions()))
|
assert.Equal(4, len(block.Transactions()))
|
||||||
|
|
||||||
assert.True(block.Transactions()[0].IsL1MessageTx())
|
assert.True(block.Transactions()[0].IsL1MessageTx())
|
||||||
assert.Equal(uint64(0), block.Transactions()[0].AsL1MessageTx().QueueIndex)
|
assert.Equal(uint64(0), block.Transactions()[0].AsL1MessageTx().QueueIndex)
|
||||||
|
|
@ -910,6 +910,10 @@ func TestLargeL1MessageSkipPayloadCheck(t *testing.T) {
|
||||||
assert.True(block.Transactions()[2].IsL1MessageTx())
|
assert.True(block.Transactions()[2].IsL1MessageTx())
|
||||||
assert.Equal(uint64(2), block.Transactions()[2].AsL1MessageTx().QueueIndex)
|
assert.Equal(uint64(2), block.Transactions()[2].AsL1MessageTx().QueueIndex)
|
||||||
|
|
||||||
|
// since L1 messages do not count against the block size limit,
|
||||||
|
// we can include additional L2 transaction
|
||||||
|
assert.False(block.Transactions()[3].IsL1MessageTx())
|
||||||
|
|
||||||
// db is updated correctly
|
// db is updated correctly
|
||||||
queueIndex := rawdb.ReadFirstQueueIndexNotInL2Block(db, block.Hash())
|
queueIndex := rawdb.ReadFirstQueueIndexNotInL2Block(db, block.Hash())
|
||||||
assert.NotNil(queueIndex)
|
assert.NotNil(queueIndex)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 4 // Major version component of the current release
|
VersionMajor = 4 // Major version component of the current release
|
||||||
VersionMinor = 3 // Minor version component of the current release
|
VersionMinor = 3 // Minor version component of the current release
|
||||||
VersionPatch = 46 // Patch version component of the current release
|
VersionPatch = 47 // Patch version component of the current release
|
||||||
VersionMeta = "sepolia" // Version metadata to append to the version string
|
VersionMeta = "sepolia" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue