Skip to content

Conversation

@minh-bq
Copy link
Contributor

@minh-bq minh-bq commented Mar 4, 2025

Currently, when answering GetPooledTransaction request, txpool.Get() is used. When the requested hash is blob transaction, blobpool.Get() is called. This function loads the RLP-encoded transaction from limbo then decodes and returns. Later, in answerGetPooledTransactions, we need to RLP encode again. This decode then encode is wasteful. This commit adds GetRLP to transaction pool interface so that answerGetPooledTransactions can use the RLP-encoded from limbo directly.

@rjl493456442 rjl493456442 self-assigned this Mar 4, 2025
Currently, when answering GetPooledTransaction request, txpool.Get() is used.
When the requested hash is blob transaction, blobpool.Get() is called. This
function loads the RLP-encoded transaction from limbo then decodes and returns.
Later, in answerGetPooledTransactions, we need to RLP encode again. This decode
then encode is wasteful. This commit adds GetRLP to transaction pool interface
so that answerGetPooledTransactions can use the RLP-encoded from limbo
directly.
@rjl493456442
Copy link
Member

func BenchmarkBlobTxEncodeDecode(b *testing.B) {
	key, _ := crypto.GenerateKey()
	tx := createEmptyBlobTx(key, true) // 1 blob
	b.ResetTimer()
	b.ReportAllocs()

	for i := 0; i < b.N; i++ {
		blob, _ := rlp.EncodeToBytes(tx)
		var dec Transaction
		rlp.DecodeBytes(blob, &dec)
	}
}
BenchmarkBlobTxEncodeDecode
BenchmarkBlobTxEncodeDecode-8   	   15196	     74555 ns/op	  680612 B/op	      30 allocs/op

The additional blobTx encode/decode is not trivial, I guess this optimization would be useful.

fjl
fjl previously approved these changes Mar 18, 2025
@fjl fjl removed the status:triage label Mar 18, 2025
@rjl493456442 rjl493456442 added this to the 1.15.6 milestone Mar 19, 2025
@rjl493456442 rjl493456442 merged commit 930836e into ethereum:master Mar 19, 2025
5 of 6 checks passed
@minh-bq minh-bq deleted the get-pooled-tx branch March 19, 2025 06:51
sivaratrisrinivas pushed a commit to sivaratrisrinivas/go-ethereum that referenced this pull request Apr 21, 2025
Currently, when answering GetPooledTransaction request, txpool.Get() is
used. When the requested hash is blob transaction, blobpool.Get() is
called. This function loads the RLP-encoded transaction from limbo then
decodes and returns. Later, in answerGetPooledTransactions, we need to
RLP encode again. This decode then encode is wasteful. This commit adds
GetRLP to transaction pool interface so that answerGetPooledTransactions
can use the RLP-encoded from limbo directly.

---------

Co-authored-by: Gary Rong <[email protected]>
jakub-freebit pushed a commit to fblch/go-ethereum that referenced this pull request Jul 3, 2025
Currently, when answering GetPooledTransaction request, txpool.Get() is
used. When the requested hash is blob transaction, blobpool.Get() is
called. This function loads the RLP-encoded transaction from limbo then
decodes and returns. Later, in answerGetPooledTransactions, we need to
RLP encode again. This decode then encode is wasteful. This commit adds
GetRLP to transaction pool interface so that answerGetPooledTransactions
can use the RLP-encoded from limbo directly.

---------

Co-authored-by: Gary Rong <[email protected]>
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
Currently, when answering GetPooledTransaction request, txpool.Get() is
used. When the requested hash is blob transaction, blobpool.Get() is
called. This function loads the RLP-encoded transaction from limbo then
decodes and returns. Later, in answerGetPooledTransactions, we need to
RLP encode again. This decode then encode is wasteful. This commit adds
GetRLP to transaction pool interface so that answerGetPooledTransactions
can use the RLP-encoded from limbo directly.

---------

Co-authored-by: Gary Rong <[email protected]>
gballet pushed a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
Currently, when answering GetPooledTransaction request, txpool.Get() is
used. When the requested hash is blob transaction, blobpool.Get() is
called. This function loads the RLP-encoded transaction from limbo then
decodes and returns. Later, in answerGetPooledTransactions, we need to
RLP encode again. This decode then encode is wasteful. This commit adds
GetRLP to transaction pool interface so that answerGetPooledTransactions
can use the RLP-encoded from limbo directly.

---------

Co-authored-by: Gary Rong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants