Skip to content

Commit de02bda

Browse files
authoredDec 9, 2022
chore!: rename malleatedTx -> indexWrapper (#905)
1 parent 74d234e commit de02bda

File tree

9 files changed

+165
-167
lines changed

9 files changed

+165
-167
lines changed
 

‎mempool/v0/clist_mempool_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ func TestRemoveBlobTx(t *testing.T) {
692692
defer cleanup()
693693

694694
originalTx := []byte{1, 2, 3, 4}
695-
malleatedTx, err := types.MarshalMalleatedTx(100, originalTx)
695+
indexWrapper, err := types.MarshalIndexWrapper(100, originalTx)
696696
require.NoError(t, err)
697697

698698
// create the blobTx
@@ -707,7 +707,7 @@ func TestRemoveBlobTx(t *testing.T) {
707707
err = mp.CheckTx(bTx, nil, mempool.TxInfo{})
708708
require.NoError(t, err)
709709

710-
err = mp.Update(1, []types.Tx{malleatedTx}, abciResponses(1, abci.CodeTypeOK), nil, nil)
710+
err = mp.Update(1, []types.Tx{indexWrapper}, abciResponses(1, abci.CodeTypeOK), nil, nil)
711711
require.NoError(t, err)
712712
assert.EqualValues(t, 0, mp.Size())
713713
assert.EqualValues(t, 0, mp.SizeBytes())

‎mempool/v1/mempool_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ func TestRemoveBlobTx(t *testing.T) {
659659
txmp := setup(t, 500)
660660

661661
originalTx := []byte{1, 2, 3, 4}
662-
malleatedTx, err := types.MarshalMalleatedTx(100, originalTx)
662+
indexWrapper, err := types.MarshalIndexWrapper(100, originalTx)
663663
require.NoError(t, err)
664664

665665
// create the blobTx
@@ -674,7 +674,7 @@ func TestRemoveBlobTx(t *testing.T) {
674674
err = txmp.CheckTx(bTx, nil, mempool.TxInfo{})
675675
require.NoError(t, err)
676676

677-
err = txmp.Update(1, []types.Tx{malleatedTx}, abciResponses(1, abci.CodeTypeOK), nil, nil)
677+
err = txmp.Update(1, []types.Tx{indexWrapper}, abciResponses(1, abci.CodeTypeOK), nil, nil)
678678
require.NoError(t, err)
679679
assert.EqualValues(t, 0, txmp.Size())
680680
assert.EqualValues(t, 0, txmp.SizeBytes())

‎pkg/consts/consts.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const (
1616
// decoding binaries that are not actually BlobTxs.
1717
ProtoBlobTxTypeID = "BLOB"
1818

19-
// ProtoMalleatedTxTypeID is included in each encoded MalleatedTx to help prevent
20-
// decoding binaries that are not actually MalleatedTxs.
21-
ProtoMalleatedTxTypeID = "MLTD"
19+
// ProtoIndexWrapperTypeID is included in each encoded IndexWrapper to help prevent
20+
// decoding binaries that are not actually IndexWrappers.
21+
ProtoIndexWrapperTypeID = "INDX"
2222
)
2323

2424
var (

‎proto/tendermint/types/types.pb.go

+124-125
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎proto/tendermint/types/types.proto

+3-4
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,9 @@ message TxProof {
189189
repeated NMTProof proofs = 3;
190190
}
191191

192-
// MalleatedTx wraps a transaction that was derived from a different original
193-
// transaction. This allows for tendermint to track malleated and original
194-
// transactions
195-
message MalleatedTx {
192+
// IndexWrapper adds index metadata to a transaction. This is used to track
193+
// transactions that pay for blobs, and where the blobs start in the square.
194+
message IndexWrapper {
196195
bytes tx = 1;
197196
uint32 share_index = 2;
198197
string type_id = 3;

‎state/txindex/kv/kv_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestWrappedTxIndex(t *testing.T) {
7070
indexer := NewTxIndex(db.NewMemDB())
7171

7272
tx := types.Tx("HELLO WORLD")
73-
wrappedTx, err := types.MarshalMalleatedTx(11, tx)
73+
wrappedTx, err := types.MarshalIndexWrapper(11, tx)
7474
require.NoError(t, err)
7575
txResult := &abci.TxResult{
7676
Height: 1,

‎types/event_bus_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestEventBusPublishEventTx(t *testing.T) {
6565
}
6666
}
6767

68-
func TestEventBusPublishEventMalleatedTx(t *testing.T) {
68+
func TestEventBusPublishEventIndexWrapper(t *testing.T) {
6969
eventBus := NewEventBus()
7070
err := eventBus.Start()
7171
require.NoError(t, err)

‎types/tx.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ type (
2929
)
3030

3131
// Hash computes the TMHASH hash of the wire encoded transaction. It attempts to
32-
// unwrap the transaction if it is a MalleatedTx or a BlobTx.
32+
// unwrap the transaction if it is a IndexWrapper or a BlobTx.
3333
func (tx Tx) Hash() []byte {
34-
if malleatedTx, isMalleated := UnmarshalMalleatedTx(tx); isMalleated {
35-
return tmhash.Sum(malleatedTx.Tx)
34+
if indexWrapper, isIndexWrapper := UnmarshalIndexWrapper(tx); isIndexWrapper {
35+
return tmhash.Sum(indexWrapper.Tx)
3636
}
3737
if blobTx, isBlobTx := UnmarshalBlobTx(tx); isBlobTx {
3838
return tmhash.Sum(blobTx.Tx)
@@ -41,13 +41,13 @@ func (tx Tx) Hash() []byte {
4141
}
4242

4343
// Key returns the sha256 hash of the wire encoded transaction. It attempts to
44-
// unwrap the transaction if it is a BlobTx or a MalleatedTx.
44+
// unwrap the transaction if it is a BlobTx or a IndexWrapper.
4545
func (tx Tx) Key() TxKey {
4646
if blobTx, isBlobTx := UnmarshalBlobTx(tx); isBlobTx {
4747
return sha256.Sum256(blobTx.Tx)
4848
}
49-
if malleatedTx, isMalleated := UnmarshalMalleatedTx(tx); isMalleated {
50-
return sha256.Sum256(malleatedTx.Tx)
49+
if indexWrapper, isIndexWrapper := UnmarshalIndexWrapper(tx); isIndexWrapper {
50+
return sha256.Sum256(indexWrapper.Tx)
5151
}
5252
return sha256.Sum256(tx)
5353
}
@@ -208,36 +208,36 @@ func ComputeProtoSizeForTxs(txs []Tx) int64 {
208208
return int64(pdData.Size())
209209
}
210210

211-
// UnmarshalMalleatedTx attempts to unmarshal the provided transaction into a
212-
// malleated transaction. It returns true if the provided transaction is a
213-
// malleated transaction. A malleated transaction is a transaction that contains
211+
// UnmarshalIndexWrapper attempts to unmarshal the provided transaction into an
212+
// IndexWrapper transaction. It returns true if the provided transaction is an
213+
// IndexWrapper transaction. An IndexWrapper transaction is a transaction that contains
214214
// a MsgPayForBlob that has been wrapped with a share index.
215215
//
216216
// NOTE: protobuf sometimes does not throw an error if the transaction passed is
217-
// not a tmproto.MalleatedTx, since the protobuf definition for MsgPayForBlob is
217+
// not a tmproto.IndexWrapper, since the protobuf definition for MsgPayForBlob is
218218
// kept in the app, we cannot perform further checks without creating an import
219219
// cycle.
220-
func UnmarshalMalleatedTx(tx Tx) (malleatedTx tmproto.MalleatedTx, isMalleated bool) {
221-
// attempt to unmarshal into a a malleated transaction
222-
err := proto.Unmarshal(tx, &malleatedTx)
220+
func UnmarshalIndexWrapper(tx Tx) (indexWrapper tmproto.IndexWrapper, isIndexWrapper bool) {
221+
// attempt to unmarshal into an IndexWrapper transaction
222+
err := proto.Unmarshal(tx, &indexWrapper)
223223
if err != nil {
224-
return malleatedTx, false
224+
return indexWrapper, false
225225
}
226-
if malleatedTx.TypeId != consts.ProtoMalleatedTxTypeID {
227-
return malleatedTx, false
226+
if indexWrapper.TypeId != consts.ProtoIndexWrapperTypeID {
227+
return indexWrapper, false
228228
}
229-
return malleatedTx, true
229+
return indexWrapper, true
230230
}
231231

232-
// MarshalMalleatedTx creates a wrapped Tx that includes the original transaction
232+
// MarshalIndexWrapper creates a wrapped Tx that includes the original transaction
233233
// and the share index of the start of its blob.
234234
//
235235
// NOTE: must be unwrapped to be a viable sdk.Tx
236-
func MarshalMalleatedTx(shareIndex uint32, tx Tx) (Tx, error) {
237-
wTx := tmproto.MalleatedTx{
236+
func MarshalIndexWrapper(shareIndex uint32, tx Tx) (Tx, error) {
237+
wTx := tmproto.IndexWrapper{
238238
Tx: tx,
239239
ShareIndex: shareIndex,
240-
TypeId: consts.ProtoMalleatedTxTypeID,
240+
TypeId: consts.ProtoIndexWrapperTypeID,
241241
}
242242
return proto.Marshal(&wTx)
243243
}

‎types/tx_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ func TestTxIndexByHash(t *testing.T) {
4444
}
4545
}
4646

47-
func TestUnmarshalMalleatedTx(t *testing.T) {
47+
func TestUnmarshalIndexWrapper(t *testing.T) {
4848
// perform a simple test for being unable to decode a non
49-
// malleated transaction
49+
// IndexWrapper transaction
5050
tx := Tx{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
51-
_, ok := UnmarshalMalleatedTx(tx)
51+
_, ok := UnmarshalIndexWrapper(tx)
5252
require.False(t, ok)
5353

5454
data := Data{
@@ -77,19 +77,19 @@ func TestUnmarshalMalleatedTx(t *testing.T) {
7777

7878
// due to protobuf not actually requiring type compatibility
7979
// we need to make sure that there is some check
80-
_, ok = UnmarshalMalleatedTx(rawBlock)
80+
_, ok = UnmarshalIndexWrapper(rawBlock)
8181
require.False(t, ok)
8282

83-
MalleatedTx, err := MarshalMalleatedTx(0, rawBlock)
83+
IndexWrapper, err := MarshalIndexWrapper(0, rawBlock)
8484
require.NoError(t, err)
8585

8686
// finally, ensure that the unwrapped bytes are identical to the input
87-
malleated, ok := UnmarshalMalleatedTx(MalleatedTx)
87+
indexWrapper, ok := UnmarshalIndexWrapper(IndexWrapper)
8888
require.True(t, ok)
89-
require.Equal(t, rawBlock, malleated.Tx)
89+
require.Equal(t, rawBlock, indexWrapper.Tx)
9090
}
9191

92-
func TestWrapUnmarshalBlobTx(t *testing.T) {
92+
func TestUnmarshalBlobTx(t *testing.T) {
9393
tx := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9}
9494
blob := tmproto.Blob{
9595
NamespaceId: []byte{1, 2, 3, 4, 5, 6, 7, 8},

0 commit comments

Comments
 (0)
Please sign in to comment.