remove WithoutBlobs()

This commit is contained in:
healthykim 2026-06-15 23:10:34 +02:00
parent ea7deacb76
commit 6ce938c2a4
4 changed files with 16 additions and 18 deletions

View file

@ -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,

View file

@ -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 {

View file

@ -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.

View file

@ -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)