Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/68: always announce tx sizes with envelopes #8502

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion erigon-lib/types/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type TxSlot struct {
Traced bool // Whether transaction needs to be traced throughout transaction pool code and generate debug printing
Creation bool // Set to true if "To" field of the transaction is not set
Type byte // Transaction type
Size uint32 // Size of the payload
Size uint32 // Size of the payload, always including the envelope for typed transactions

// EIP-4844: Shard Blob Transactions
BlobFeeCap uint256.Int // max_fee_per_blob_gas
Expand Down Expand Up @@ -287,6 +287,12 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int, slot *TxSlo
}

slot.Size = uint32(p - pos)
if !legacy && !hasEnvelope {
// Normalize the size so that it accounts for the envelope bytes
// See https://github.com/ledgerwatch/erigon/issues/8456
slot.Size = uint32(rlp.ListPrefixLen(int(slot.Size))) + slot.Size
}

return p, err
}

Expand Down
4 changes: 3 additions & 1 deletion erigon-lib/types/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/ledgerwatch/erigon-lib/common/fixedgas"
"github.com/ledgerwatch/erigon-lib/common/hexutility"
"github.com/ledgerwatch/erigon-lib/rlp"
)

func TestParseTransactionRLP(t *testing.T) {
Expand Down Expand Up @@ -261,7 +262,8 @@ func TestBlobTxParsing(t *testing.T) {
p, err = ctx.ParseTransaction(wrapperRlp, 0, &fatTx, nil, hasEnvelope, wrappedWithBlobs, nil)
require.NoError(t, err)
assert.Equal(t, len(wrapperRlp), p)
assert.Equal(t, len(wrapperRlp), int(fatTx.Size))
wrapperLenWithEnvelope := rlp.ListPrefixLen(len(wrapperRlp)) + len(wrapperRlp)
assert.Equal(t, wrapperLenWithEnvelope, int(fatTx.Size))
assert.Equal(t, wrapperRlp, fatTx.Rlp)
assert.Equal(t, BlobTxType, fatTx.Type)

Expand Down