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

feat!: remove namespace and share version from MsgPayForBlobs #2930

Closed
Closed
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
2 changes: 1 addition & 1 deletion app/test/check_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestCheckTx(t *testing.T) {
require.NoError(t, err)
return bbtx
},
expectedABCICode: blobtypes.ErrNamespaceMismatch.ABCICode(),
expectedABCICode: blobtypes.ErrInvalidShareCommitment.ABCICode(),
},
{
name: "PFB with no blob, CheckTxType_New",
Expand Down
21 changes: 0 additions & 21 deletions app/test/process_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
appns "github.com/celestiaorg/celestia-app/pkg/namespace"
"github.com/celestiaorg/celestia-app/pkg/shares"
"github.com/celestiaorg/celestia-app/pkg/square"
"github.com/celestiaorg/celestia-app/pkg/user"
testutil "github.com/celestiaorg/celestia-app/test/util"
"github.com/celestiaorg/celestia-app/test/util/blobfactory"
"github.com/celestiaorg/celestia-app/test/util/testfactory"
Expand All @@ -32,9 +31,6 @@ func TestProcessProposal(t *testing.T) {
accounts := testfactory.GenerateAccounts(6)
testApp, kr := testutil.SetupTestAppWithGenesisValSet(app.DefaultConsensusParams(), accounts...)
infos := queryAccountInfo(testApp, accounts, kr)
addr := testfactory.GetAddress(kr, accounts[0])
signer, err := user.NewSigner(kr, nil, addr, enc, testutil.ChainID, infos[0].AccountNum, infos[0].Sequence)
require.NoError(t, err)

// create 4 single blob blobTxs that are signed with valid account numbers
// and sequences
Expand Down Expand Up @@ -201,23 +197,6 @@ func TestProcessProposal(t *testing.T) {
},
expectedResult: abci.ResponseProcessProposal_REJECT,
},
{
name: "invalid namespace in index wrapper tx",
input: validData(),
mutator: func(d *tmproto.Data) {
index := 4
tx, b := blobfactory.IndexWrappedTxWithInvalidNamespace(t, tmrand.NewRand(), signer, uint32(index))
blobTx, err := blob.MarshalBlobTx(tx, &b)
require.NoError(t, err)

// Replace the data with new contents
d.Txs = [][]byte{blobTx}

// Erasure code the data to update the data root so this doesn't doesn't fail on an incorrect data root.
d.Hash = calculateNewDataHash(t, d.Txs)
},
expectedResult: abci.ResponseProcessProposal_REJECT,
},
{
name: "swap blobTxs",
input: validData(),
Expand Down
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,6 @@ google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpX
google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ=
10 changes: 5 additions & 5 deletions pkg/proof/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,21 @@ func TestNewShareInclusionProof(t *testing.T) {
{
name: "shares from PFB namespace",
startingShare: 53,
endingShare: 56,
endingShare: 55,
namespaceID: appns.PayForBlobNamespace,
expectErr: false,
},
{
name: "blob shares for first namespace",
startingShare: 56,
endingShare: 58,
startingShare: 55,
endingShare: 57,
namespaceID: ns1,
expectErr: false,
},
{
name: "blob shares for third namespace",
startingShare: 60,
endingShare: 62,
startingShare: 59,
endingShare: 61,
namespaceID: ns3,
expectErr: false,
},
Expand Down
13 changes: 7 additions & 6 deletions pkg/square/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,12 @@ func TestBuilderRejectsBlobTransactions(t *testing.T) {
added: true,
},
{
// fun fact: three blobs increases the size of the PFB to two shares, hence this fails
// fun fact: four blobs increases the size of the PFB to two shares, hence this fails
blobSize: []int{
shares.AvailableBytesFromSparseShares(1),
shares.AvailableBytesFromSparseShares(1),
shares.AvailableBytesFromSparseShares(1),
shares.AvailableBytesFromSparseShares(1),
},
added: false,
},
Expand Down Expand Up @@ -300,7 +301,7 @@ func TestSquareBlobPostions(t *testing.T) {
[]ns.Namespace{ns1, ns1, ns1, ns1, ns1, ns1, ns1, ns1, ns1},
blobfactory.Repeat([]int{100}, 9),
),
expectedIndexes: [][]uint32{{7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}},
expectedIndexes: [][]uint32{{6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}},
},
{
squareSize: 4,
Expand All @@ -318,7 +319,7 @@ func TestSquareBlobPostions(t *testing.T) {
[]ns.Namespace{ns1, ns1, ns1},
[][]int{{1000}, {10000}, {10000}},
),
expectedIndexes: [][]uint32{{3}, {6}, {27}},
expectedIndexes: [][]uint32{{2}, {5}, {26}},
},
{
squareSize: 32,
Expand All @@ -327,7 +328,7 @@ func TestSquareBlobPostions(t *testing.T) {
[]ns.Namespace{ns2, ns1, ns1},
[][]int{{100}, {100}, {100}},
),
expectedIndexes: [][]uint32{{5}, {3}, {4}},
expectedIndexes: [][]uint32{{4}, {2}, {3}},
},
{
squareSize: 16,
Expand All @@ -336,7 +337,7 @@ func TestSquareBlobPostions(t *testing.T) {
[]ns.Namespace{ns1, ns2, ns1},
[][]int{{100}, {900}, {900}}, // 1, 2, 2 shares respectively
),
expectedIndexes: [][]uint32{{3}, {6}, {4}},
expectedIndexes: [][]uint32{{2}, {5}, {3}},
},
{
squareSize: 4,
Expand Down Expand Up @@ -432,7 +433,7 @@ func TestSquareBlobPostions(t *testing.T) {
for j, tx := range txs {
wrappedPFB, isWrappedPFB := coretypes.UnmarshalIndexWrapper(tx)
require.True(t, isWrappedPFB)
require.Equal(t, tt.expectedIndexes[j], wrappedPFB.ShareIndexes, j)
require.Equal(t, tt.expectedIndexes[j], wrappedPFB.ShareIndexes, fmt.Sprintf("expected index %v, got %v", tt.expectedIndexes[j], wrappedPFB.ShareIndexes))
}
})
}
Expand Down
8 changes: 3 additions & 5 deletions proto/celestia/blob/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package celestia.blob.v1;

option go_package = "github.com/celestiaorg/celestia-app/x/blob/types";

// EventPayForBlobs defines an event that is emitted after a pay for blob has
// EventPayForBlobs defines an event that is emitted after a PayForBlobs has
// been processed.
message EventPayForBlobs {
string signer = 1;
repeated uint32 blob_sizes = 2;
// namespaces is a list of namespaces that the blobs in blob_sizes belong to.
// A namespace has length of 29 bytes where the first byte is the
// namespaceVersion and the subsequent 28 bytes are the namespaceID.
repeated bytes namespaces = 3;
// 3 was previously used for namespaces
reserved 3;
}
13 changes: 4 additions & 9 deletions proto/celestia/blob/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ message MsgPayForBlobs {
// signer is the bech32 encoded signer address. See
// https://en.bitcoin.it/wiki/Bech32.
string signer = 1;
// namespaces is a list of namespaces that the blobs are associated with. A
// namespace is a byte slice of length 29 where the first byte is the
// namespaceVersion and the subsequent 28 bytes are the namespaceId.
repeated bytes namespaces = 2;
// 2 was previously used for namespaces.
reserved 2;
// blob_sizes is a list of blob sizes (one per blob). Each size is in bytes.
repeated uint32 blob_sizes = 3;
// share_commitments is a list of share commitments (one per blob).
repeated bytes share_commitments = 4;
// share_versions are the versions of the share format that the blobs
// associated with this message should use when included in a block. The
// share_versions specified must match the share_versions used to generate the
// share_commitment in this message.
repeated uint32 share_versions = 8;
// 8 was previously used for share_versions;
reserved 8;
}
Comment on lines 20 to 29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking

since this is breaking, do we need to create a v2 of the proto msg?

I think #2932 (comment) makes sense, and we might have to add an intermediate type to convert between v1 and v2 so that we don't have to have an extra copy of the logic to execute the msg.


// MsgPayForBlobsResponse describes the response returned after the submission
Expand Down
25 changes: 0 additions & 25 deletions test/util/blobfactory/payforblob_factory.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package blobfactory

import (
"bytes"
"context"
"testing"

Expand Down Expand Up @@ -234,30 +233,6 @@ func ManyMultiBlobTx(
return txs
}

// IndexWrappedTxWithInvalidNamespace returns an index wrapped PFB tx with an
// invalid namespace and a blob associated with that index wrapped PFB tx.
func IndexWrappedTxWithInvalidNamespace(
t *testing.T,
rand *tmrand.Rand,
signer *user.Signer,
index uint32,
) (coretypes.Tx, blob.Blob) {
t.Helper()
addr := signer.Address()
blob := ManyRandBlobs(rand, 100)[0]
msg, err := blobtypes.NewMsgPayForBlobs(addr.String(), blob)
require.NoError(t, err)
msg.Namespaces[0] = bytes.Repeat([]byte{1}, 33) // invalid namespace

rawTx, err := signer.CreateTx([]sdk.Msg{msg}, DefaultTxOpts()...)
require.NoError(t, err)

cTx, err := coretypes.MarshalIndexWrapper(rawTx, index)
require.NoError(t, err)

return cTx, *blob
}

func RandBlobTxsWithNamespacesAndSigner(
signer *user.Signer,
namespaces []appns.Namespace,
Expand Down
2 changes: 1 addition & 1 deletion x/blob/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (k Keeper) PayForBlobs(goCtx context.Context, msg *types.MsgPayForBlobs) (*
ctx.GasMeter().ConsumeGas(gasToConsume, payForBlobGasDescriptor)

err := ctx.EventManager().EmitTypedEvent(
types.NewPayForBlobsEvent(msg.Signer, msg.BlobSizes, msg.Namespaces),
types.NewPayForBlobsEvent(msg.Signer, msg.BlobSizes),
)
if err != nil {
return &types.MsgPayForBlobsResponse{}, err
Expand Down
2 changes: 0 additions & 2 deletions x/blob/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestPayForBlobs(t *testing.T) {
k, _, ctx := CreateKeeper(t)
signer := "celestia15drmhzw5kwgenvemy30rqqqgq52axf5wwrruf7"
namespace := appns.MustNewV0(bytes.Repeat([]byte{1}, appns.NamespaceVersionZeroIDSize))
namespaces := [][]byte{namespace.Bytes()}
blobData := []byte("blob")
blobSizes := []uint32{uint32(len(blobData))}

Expand All @@ -54,7 +53,6 @@ func TestPayForBlobs(t *testing.T) {

// verify the attributes of the event
assert.Equal(t, signer, event.Signer)
assert.Equal(t, namespaces, event.Namespaces)
assert.Equal(t, blobSizes, event.BlobSizes)
}

Expand Down
18 changes: 0 additions & 18 deletions x/blob/types/blob_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,6 @@ func ValidateBlobTx(txcfg client.TxEncodingConfig, bTx blob.BlobTx) error {
return ErrBlobSizeMismatch.Wrapf("actual %v declared %v", sizes, msgPFB.BlobSizes)
}

for i, ns := range msgPFB.Namespaces {
msgPFBNamespace, err := appns.From(ns)
if err != nil {
return err
}

// this not only checks that the pfb namespaces match the ones in the blobs
// but that the namespace version and namespace id are valid
blobNamespace, err := appns.New(uint8(bTx.Blobs[i].NamespaceVersion), bTx.Blobs[i].NamespaceId)
if err != nil {
return err
}

if !bytes.Equal(blobNamespace.Bytes(), msgPFBNamespace.Bytes()) {
return ErrNamespaceMismatch.Wrapf("%v %v", blobNamespace.Bytes(), msgPFB.Namespaces[i])
}
}

// verify that the commitment of the blob matches that of the msgPFB
for i, commitment := range msgPFB.ShareCommitments {
calculatedCommit, err := inclusion.CreateCommitment(bTx.Blobs[i])
Expand Down
2 changes: 1 addition & 1 deletion x/blob/types/blob_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestValidateBlobTx(t *testing.T) {
btx.Blobs[0].NamespaceId = namespace.RandomBlobNamespace().ID
return btx
},
expectedErr: types.ErrNamespaceMismatch,
expectedErr: types.ErrInvalidShareCommitment,
},
{
name: "invalid transaction, no pfb",
Expand Down
Loading
Loading