diff --git a/cmd/devp2p/internal/ethtest/suite.go b/cmd/devp2p/internal/ethtest/suite.go index aa56dc1085..52baa41969 100644 --- a/cmd/devp2p/internal/ethtest/suite.go +++ b/cmd/devp2p/internal/ethtest/suite.go @@ -1048,7 +1048,9 @@ func (s *Suite) makeBlobTxs(txCount, blobCount int, discriminator byte) (txs typ panic("blob tx signing failed") } blobs = append(blobs, sidecar.Blobs) - txs = append(txs, tx.WithoutBlob()) + scNoBlob := sidecar.Copy() + scNoBlob.Blobs = nil + txs = append(txs, tx.WithBlobTxSidecar(scNoBlob)) } return txs, blobs } @@ -1360,7 +1362,7 @@ partial fetch GetCells should never arrive. Any GetCells that does arrive must b for i, tx := range txs { hashes[i] = tx.Hash() txTypes[i] = types.BlobTxType - sizes[i] = uint32(tx.WithoutBlob().Size()) + sizes[i] = uint32(tx.Size()) } ann := eth.NewPooledTransactionHashesPacket72{ Types: txTypes, diff --git a/core/txpool/blobpool/blobpool_test.go b/core/txpool/blobpool/blobpool_test.go index 6c6b9638ca..71810bb659 100644 --- a/core/txpool/blobpool/blobpool_test.go +++ b/core/txpool/blobpool/blobpool_test.go @@ -279,6 +279,15 @@ func makeMultiBlobTx(nonce uint64, gasTipCap uint64, gasFeeCap uint64, blobFeeCa return types.MustSignNewTx(key, types.LatestSigner(params.MainnetChainConfig), blobtx) } +// removeBlobs returns a copy of tx with the blob payload removed from the +// sidecar, keeping commitments, proofs and cells intact (simulating what +// ETH/72 peers send). +func removeBlobs(tx *types.Transaction) *types.Transaction { + sidecar := tx.BlobTxSidecar().Copy() + sidecar.Blobs = nil + return tx.WithBlobTxSidecar(sidecar) +} + // makeUnsignedTx is a utility method to construct a random blob transaction // without signing it. func makeUnsignedTx(nonce uint64, gasTipCap uint64, gasFeeCap uint64, blobFeeCap uint64) *types.BlobTx { @@ -2354,7 +2363,7 @@ func TestGetCells(t *testing.T) { // TestEncodeForNetwork verifies that encodeForNetwork produces the correct wire // encoding for each (sidecar version, eth protocol version) combination. // - eth/69, eth/70: blobs recovered from cells, output matches the original tx -// - eth/72: blob payload omitted, output matches tx.WithoutBlob() +// - eth/72: blob payload omitted, output matches removeBlobs(tx) func TestEncodeForNetwork(t *testing.T) { cases := []struct { name string @@ -2379,7 +2388,7 @@ func testEncodeForNetwork(t *testing.T, sidecarVer byte, ethVer uint) { wantTx := tx if ethVer >= 72 { - wantTx = tx.WithoutBlob() + wantTx = removeBlobs(tx) } wantRLP, err := rlp.EncodeToBytes(wantTx) if err != nil { diff --git a/core/txpool/blobpool/buffer_test.go b/core/txpool/blobpool/buffer_test.go index a9465b25e2..ba2e74bd2e 100644 --- a/core/txpool/blobpool/buffer_test.go +++ b/core/txpool/blobpool/buffer_test.go @@ -14,7 +14,7 @@ import ( func makeV1Tx(t *testing.T, nonce uint64, blobCount int, blobOffset int, key *ecdsa.PrivateKey) *types.Transaction { t.Helper() tx := makeMultiBlobTx(nonce, 1, 1, 1, blobCount, blobOffset, key, types.BlobSidecarVersion1) - return tx.WithoutBlob() + return removeBlobs(tx) } // makePeerDelivery creates a PeerDelivery for given cell indices from a set of blobs. diff --git a/core/types/transaction.go b/core/types/transaction.go index 2ab6d14b87..e9bf08daef 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -510,19 +510,6 @@ func (tx *Transaction) WithoutBlobTxSidecar() *Transaction { return cpy } -// todo: remove -// WithoutBlob returns a copy of tx with the blob data removed from the sidecar, -// keeping commitments, proofs and other metadata intact. -func (tx *Transaction) WithoutBlob() *Transaction { - blobtx, ok := tx.inner.(*BlobTx) - if !ok || blobtx.Sidecar == nil { - return tx - } - sidecarWithoutBlob := blobtx.Sidecar.Copy() - sidecarWithoutBlob.Blobs = nil - return tx.WithBlobTxSidecar(sidecarWithoutBlob) -} - // WithBlobTxSidecar returns a copy of tx with the blob sidecar added. func (tx *Transaction) WithBlobTxSidecar(sideCar *BlobTxSidecar) *Transaction { blobtx, ok := tx.inner.(*BlobTx)