From 621858427c15b713bd72aa5a02df78a8d552f6a8 Mon Sep 17 00:00:00 2001 From: Rootul P Date: Mon, 3 Jul 2023 08:33:10 -0400 Subject: [PATCH] chore: enable stylecheck (#2005) Closes https://github.com/celestiaorg/celestia-app/issues/1989 --- .golangci.yml | 1 + app/test/integration_test.go | 3 +- app/test/process_proposal_test.go | 51 ++++++++++----------- app/validate_txs.go | 5 +- pkg/shares/share_sequence_test.go | 2 +- pkg/shares/split_compact_shares_test.go | 3 +- pkg/square/builder_test.go | 6 +-- pkg/square/square_test.go | 11 ++--- pkg/wrapper/nmt_wrapper_test.go | 3 +- test/txsim/run.go | 2 +- test/txsim/send.go | 2 +- test/txsim/sequence.go | 5 +- test/util/blobfactory/payforblob_factory.go | 13 ++---- test/util/blobfactory/test_util.go | 5 +- test/util/testnode/config.go | 5 +- test/util/testnode/node_interaction_api.go | 3 +- x/blob/client/testutil/integration_test.go | 5 +- x/blob/types/blob_tx_test.go | 7 ++- x/blob/types/builder.go | 3 +- x/blob/types/payforblob.go | 3 +- x/blob/types/test/blob_tx_test.go | 12 ++--- x/mint/keeper/genesis.go | 10 ++-- x/qgb/client/query.go | 3 +- x/qgb/types/genesis.go | 3 +- 24 files changed, 73 insertions(+), 93 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 371f88bc10..5d53602451 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,6 +10,7 @@ linters: - nakedret - revive - prealloc + - stylecheck linters-settings: nakedret: diff --git a/app/test/integration_test.go b/app/test/integration_test.go index 092668d031..b0137157d5 100644 --- a/app/test/integration_test.go +++ b/app/test/integration_test.go @@ -20,7 +20,6 @@ import ( appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/celestiaorg/celestia-app/pkg/square" "github.com/celestiaorg/celestia-app/x/blob" - "github.com/celestiaorg/celestia-app/x/blob/types" blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -227,7 +226,7 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() { { "large random typical", mustNewBlob(ns1, tmrand.Bytes(350000), appconsts.ShareVersionZero), - []types.TxBuilderOption{ + []blobtypes.TxBuilderOption{ blobtypes.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(10)))), blobtypes.SetGasLimit(1_000_000_000), }, diff --git a/app/test/process_proposal_test.go b/app/test/process_proposal_test.go index aaa69f2095..98c3419663 100644 --- a/app/test/process_proposal_test.go +++ b/app/test/process_proposal_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmrand "github.com/tendermint/tendermint/libs/rand" - core "github.com/tendermint/tendermint/proto/tendermint/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" coretypes "github.com/tendermint/tendermint/types" @@ -80,8 +79,8 @@ func TestProcessProposal(t *testing.T) { type test struct { name string - input *core.Data - mutator func(*core.Data) + input *tmproto.Data + mutator func(*tmproto.Data) expectedResult abci.ResponseProcessProposal_Result } @@ -89,13 +88,13 @@ func TestProcessProposal(t *testing.T) { { name: "valid untouched data", input: validData(), - mutator: func(d *core.Data) {}, + mutator: func(d *tmproto.Data) {}, expectedResult: abci.ResponseProcessProposal_ACCEPT, }, { name: "removed first blob tx", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { d.Txs = d.Txs[1:] }, expectedResult: abci.ResponseProcessProposal_REJECT, @@ -103,7 +102,7 @@ func TestProcessProposal(t *testing.T) { { name: "added an extra blob tx", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { d.Txs = append(d.Txs, blobTxs[3]) }, expectedResult: abci.ResponseProcessProposal_REJECT, @@ -111,9 +110,9 @@ func TestProcessProposal(t *testing.T) { { name: "modified a blobTx", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { blobTx, _ := coretypes.UnmarshalBlobTx(blobTxs[0]) - blobTx.Blobs[0] = &core.Blob{ + blobTx.Blobs[0] = &tmproto.Blob{ NamespaceId: ns1.ID, Data: data, NamespaceVersion: uint32(ns1.Version), @@ -127,9 +126,9 @@ func TestProcessProposal(t *testing.T) { { name: "invalid namespace TailPadding", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { blobTx, _ := coretypes.UnmarshalBlobTx(blobTxs[0]) - blobTx.Blobs[0] = &core.Blob{ + blobTx.Blobs[0] = &tmproto.Blob{ NamespaceId: appns.TailPaddingNamespace.ID, Data: data, NamespaceVersion: uint32(appns.TailPaddingNamespace.Version), @@ -143,9 +142,9 @@ func TestProcessProposal(t *testing.T) { { name: "invalid namespace TxNamespace", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { blobTx, _ := coretypes.UnmarshalBlobTx(blobTxs[0]) - blobTx.Blobs[0] = &core.Blob{ + blobTx.Blobs[0] = &tmproto.Blob{ NamespaceId: appns.TxNamespace.ID, Data: data, NamespaceVersion: uint32(appns.TxNamespace.Version), @@ -159,9 +158,9 @@ func TestProcessProposal(t *testing.T) { { name: "invalid namespace ParityShares", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { blobTx, _ := coretypes.UnmarshalBlobTx(blobTxs[0]) - blobTx.Blobs[0] = &core.Blob{ + blobTx.Blobs[0] = &tmproto.Blob{ NamespaceId: appns.ParitySharesNamespace.ID, Data: data, NamespaceVersion: uint32(appns.ParitySharesNamespace.Version), @@ -175,9 +174,9 @@ func TestProcessProposal(t *testing.T) { { name: "invalid blob namespace", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { blobTx, _ := coretypes.UnmarshalBlobTx(blobTxs[0]) - blobTx.Blobs[0] = &core.Blob{ + blobTx.Blobs[0] = &tmproto.Blob{ NamespaceId: invalidNamespace.ID, Data: data, ShareVersion: uint32(appconsts.ShareVersionZero), @@ -191,7 +190,7 @@ func TestProcessProposal(t *testing.T) { { name: "pfb namespace version does not match blob", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { blobTx, _ := coretypes.UnmarshalBlobTx(blobTxs[0]) blobTx.Blobs[0].NamespaceVersion = appns.NamespaceVersionMax blobTxBytes, _ := blobTx.Marshal() @@ -203,7 +202,7 @@ func TestProcessProposal(t *testing.T) { { name: "invalid namespace in index wrapper tx", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) index := 4 tx, blob := blobfactory.IndexWrappedTxWithInvalidNamespace(t, encCfg.TxConfig.TxEncoder(), tmrand.NewRand(), signer, 0, 0, uint32(index)) @@ -221,7 +220,7 @@ func TestProcessProposal(t *testing.T) { { name: "swap blobTxs", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { // swapping the order will cause the data root to be different d.Txs[0], d.Txs[1], d.Txs[2] = d.Txs[1], d.Txs[2], d.Txs[0] }, @@ -230,7 +229,7 @@ func TestProcessProposal(t *testing.T) { { name: "PFB without blobTx", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { btx, _ := coretypes.UnmarshalBlobTx(blobTxs[3]) d.Txs = append(d.Txs, btx.Tx) }, @@ -239,7 +238,7 @@ func TestProcessProposal(t *testing.T) { { name: "undecodable tx", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { d.Txs = append(d.Txs, tmrand.Bytes(300)) }, expectedResult: abci.ResponseProcessProposal_REJECT, @@ -247,7 +246,7 @@ func TestProcessProposal(t *testing.T) { { name: "incorrectly sorted; send tx after pfb", input: mixedData, - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { // swap txs at index 2 and 3 (essentially swapping a PFB with a normal tx) d.Txs[3], d.Txs[2] = d.Txs[2], d.Txs[3] }, @@ -256,7 +255,7 @@ func TestProcessProposal(t *testing.T) { { name: "included pfb with bad signature", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { d.Txs = append(d.Txs, badSigBlobTx) d.Hash = calculateNewDataHash(t, d.Txs) }, @@ -265,7 +264,7 @@ func TestProcessProposal(t *testing.T) { { name: "included pfb with incorrect nonce", input: validData(), - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { d.Txs = append(d.Txs, blobTxWithInvalidNonce) d.Hash = calculateNewDataHash(t, d.Txs) }, @@ -276,7 +275,7 @@ func TestProcessProposal(t *testing.T) { input: &tmproto.Data{ Txs: coretypes.Txs(sendTxs).ToSliceOfBytes(), }, - mutator: func(d *core.Data) { + mutator: func(d *tmproto.Data) { dataSquare, err := square.Construct(d.Txs, appconsts.LatestVersion, appconsts.DefaultSquareSizeUpperBound) require.NoError(t, err) @@ -307,7 +306,7 @@ func TestProcessProposal(t *testing.T) { tt.mutator(resp.BlockData) res := testApp.ProcessProposal(abci.RequestProcessProposal{ BlockData: resp.BlockData, - Header: core.Header{ + Header: tmproto.Header{ Height: 1, DataHash: resp.BlockData.Hash, }, diff --git a/app/validate_txs.go b/app/validate_txs.go index 28c54f2b08..9dd8c9949b 100644 --- a/app/validate_txs.go +++ b/app/validate_txs.go @@ -3,15 +3,14 @@ package app import ( "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" - core "github.com/tendermint/tendermint/proto/tendermint/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" coretypes "github.com/tendermint/tendermint/types" ) // separateTxs decodes raw tendermint txs into normal and blob txs. -func separateTxs(_ client.TxConfig, rawTxs [][]byte) ([][]byte, []core.BlobTx) { +func separateTxs(_ client.TxConfig, rawTxs [][]byte) ([][]byte, []tmproto.BlobTx) { normalTxs := make([][]byte, 0, len(rawTxs)) - blobTxs := make([]core.BlobTx, 0, len(rawTxs)) + blobTxs := make([]tmproto.BlobTx, 0, len(rawTxs)) for _, rawTx := range rawTxs { bTx, isBlob := coretypes.UnmarshalBlobTx(rawTx) if isBlob { diff --git a/pkg/shares/share_sequence_test.go b/pkg/shares/share_sequence_test.go index a32771d97f..31d790cdb4 100644 --- a/pkg/shares/share_sequence_test.go +++ b/pkg/shares/share_sequence_test.go @@ -231,7 +231,7 @@ func generateValidShareSequence(t *testing.T) ShareSequence { } } -func Fuzz_validSequenceLen(f *testing.F) { +func FuzzValidSequenceLen(f *testing.F) { f.Fuzz(func(t *testing.T, rawData []byte, rawNamespace []byte) { share, err := NewShare(rawData) if err != nil { diff --git a/pkg/shares/split_compact_shares_test.go b/pkg/shares/split_compact_shares_test.go index 8c4e4292cc..ca4bd7a05f 100644 --- a/pkg/shares/split_compact_shares_test.go +++ b/pkg/shares/split_compact_shares_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/celestiaorg/celestia-app/pkg/appconsts" - "github.com/celestiaorg/celestia-app/pkg/namespace" appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -39,7 +38,7 @@ func TestCount(t *testing.T) { } } - css := NewCompactShareSplitter(namespace.TxNamespace, appconsts.ShareVersionZero) + css := NewCompactShareSplitter(appns.TxNamespace, appconsts.ShareVersionZero) assert.Equal(t, 0, css.Count()) } diff --git a/pkg/square/builder_test.go b/pkg/square/builder_test.go index 9ef63d543c..afd6db12a1 100644 --- a/pkg/square/builder_test.go +++ b/pkg/square/builder_test.go @@ -21,8 +21,6 @@ import ( "github.com/celestiaorg/celestia-app/test/util/testfactory" "github.com/stretchr/testify/require" tmrand "github.com/tendermint/tendermint/libs/rand" - "github.com/tendermint/tendermint/types" - core "github.com/tendermint/tendermint/types" coretypes "github.com/tendermint/tendermint/types" ) @@ -216,7 +214,7 @@ func TestBuilderFindTxShareRange(t *testing.T) { var lastEnd int for idx, tx := range blockTxs { - blobTx, isBlobTx := types.UnmarshalBlobTx(tx) + blobTx, isBlobTx := coretypes.UnmarshalBlobTx(tx) if isBlobTx { tx = blobTx.Tx } @@ -409,7 +407,7 @@ func TestSquareBlobPostions(t *testing.T) { builder, err := square.NewBuilder(tt.squareSize, appconsts.DefaultSubtreeRootThreshold) require.NoError(t, err) for _, tx := range tt.blobTxs { - blobTx, isBlobTx := core.UnmarshalBlobTx(tx) + blobTx, isBlobTx := coretypes.UnmarshalBlobTx(tx) require.True(t, isBlobTx) _ = builder.AppendBlobTx(blobTx) } diff --git a/pkg/square/square_test.go b/pkg/square/square_test.go index fd139cb671..acd730d730 100644 --- a/pkg/square/square_test.go +++ b/pkg/square/square_test.go @@ -21,7 +21,6 @@ import ( "github.com/celestiaorg/rsmt2d" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/types" coretypes "github.com/tendermint/tendermint/types" ) @@ -53,9 +52,9 @@ func TestSquareTxShareRange(t *testing.T) { expectErr bool } - txOne := types.Tx{0x1} - txTwo := types.Tx(bytes.Repeat([]byte{2}, 600)) - txThree := types.Tx(bytes.Repeat([]byte{3}, 1000)) + txOne := coretypes.Tx{0x1} + txTwo := coretypes.Tx(bytes.Repeat([]byte{2}, 600)) + txThree := coretypes.Tx(bytes.Repeat([]byte{3}, 1000)) testCases := []test{ { @@ -190,7 +189,7 @@ func TestSquareDeconstruct(t *testing.T) { }) t.Run("NoPFBs", func(t *testing.T) { const numTxs = 10 - txs := types.Txs(blobfactory.GenerateManyRawSendTxs(encCfg.TxConfig, numTxs)).ToSliceOfBytes() + txs := coretypes.Txs(blobfactory.GenerateManyRawSendTxs(encCfg.TxConfig, numTxs)).ToSliceOfBytes() dataSquare, err := square.Construct(txs, appconsts.LatestVersion, appconsts.DefaultSquareSizeUpperBound) require.NoError(t, err) recomputedTxs, err := square.Deconstruct(dataSquare, encCfg.TxConfig.TxDecoder()) @@ -208,7 +207,7 @@ func TestSquareDeconstruct(t *testing.T) { t.Run("EmptySquare", func(t *testing.T) { tx, err := square.Deconstruct(square.EmptySquare(), encCfg.TxConfig.TxDecoder()) require.NoError(t, err) - require.Equal(t, types.Txs{}, tx) + require.Equal(t, coretypes.Txs{}, tx) }) } diff --git a/pkg/wrapper/nmt_wrapper_test.go b/pkg/wrapper/nmt_wrapper_test.go index 89a668e3a8..a958e41398 100644 --- a/pkg/wrapper/nmt_wrapper_test.go +++ b/pkg/wrapper/nmt_wrapper_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/celestiaorg/celestia-app/pkg/appconsts" - "github.com/celestiaorg/celestia-app/pkg/namespace" appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/celestiaorg/celestia-app/test/util/testfactory" "github.com/celestiaorg/nmt" @@ -50,7 +49,7 @@ func TestRootErasuredNamespacedMerkleTree(t *testing.T) { size := 8 data := testfactory.GenerateRandNamespacedRawData(size) nmtErasured := NewErasuredNamespacedMerkleTree(uint64(size), 0) - nmtStandard := nmt.New(sha256.New(), nmt.NamespaceIDSize(namespace.NamespaceSize), nmt.IgnoreMaxNamespace(true)) + nmtStandard := nmt.New(sha256.New(), nmt.NamespaceIDSize(appns.NamespaceSize), nmt.IgnoreMaxNamespace(true)) for _, d := range data { err := nmtErasured.Push(d) diff --git a/test/txsim/run.go b/test/txsim/run.go index ac6efb2f3b..7251058645 100644 --- a/test/txsim/run.go +++ b/test/txsim/run.go @@ -92,7 +92,7 @@ func Run( if err == nil { // should never happen continue } - if errors.Is(err, EndOfSequence) { + if errors.Is(err, ErrEndOfSequence) { log.Info().Err(err).Msg("sequence terminated") continue } diff --git a/test/txsim/send.go b/test/txsim/send.go index be7603113b..fed714f474 100644 --- a/test/txsim/send.go +++ b/test/txsim/send.go @@ -56,7 +56,7 @@ func (s *SendSequence) Init(_ context.Context, _ grpc.ClientConn, allocateAccoun // Next sumbits a transaction to remove funds from one account to the next func (s *SendSequence) Next(_ context.Context, _ grpc.ClientConn, rand *rand.Rand) (Operation, error) { if s.index >= s.numIterations { - return Operation{}, EndOfSequence + return Operation{}, ErrEndOfSequence } op := Operation{ Msgs: []types.Msg{ diff --git a/test/txsim/sequence.go b/test/txsim/sequence.go index b22c6b9cbd..126be3c985 100644 --- a/test/txsim/sequence.go +++ b/test/txsim/sequence.go @@ -47,9 +47,8 @@ const ( DefaultGasLimit = 1000000 ) -// EndOfSequence is a special error which indicates that the sequence has been terminated -// nolint: revive -var EndOfSequence = errors.New("end of sequence") +// ErrEndOfSequence is a special error which indicates that the sequence has been terminated +var ErrEndOfSequence = errors.New("end of sequence") // AccountAllocator reserves and funds a series of accounts to be used exclusively by // the Sequence. diff --git a/test/util/blobfactory/payforblob_factory.go b/test/util/blobfactory/payforblob_factory.go index 5f86434c20..cdbcb7c7b8 100644 --- a/test/util/blobfactory/payforblob_factory.go +++ b/test/util/blobfactory/payforblob_factory.go @@ -6,11 +6,8 @@ import ( "testing" "github.com/celestiaorg/celestia-app/pkg/appconsts" - "github.com/celestiaorg/celestia-app/pkg/namespace" appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/celestiaorg/celestia-app/test/util/testfactory" - "github.com/celestiaorg/celestia-app/x/blob/types" - apptypes "github.com/celestiaorg/celestia-app/x/blob/types" blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,7 +30,7 @@ var ( func RandMsgPayForBlobsWithSigner(rand *tmrand.Rand, singer string, size, blobCount int) (*blobtypes.MsgPayForBlobs, []*tmproto.Blob) { blobs := make([]*tmproto.Blob, blobCount) for i := 0; i < blobCount; i++ { - blob, err := types.NewBlob(appns.RandomBlobNamespaceWithPRG(rand), tmrand.Bytes(size), appconsts.ShareVersionZero) + blob, err := blobtypes.NewBlob(appns.RandomBlobNamespaceWithPRG(rand), tmrand.Bytes(size), appconsts.ShareVersionZero) if err != nil { panic(err) } @@ -53,7 +50,7 @@ func RandMsgPayForBlobsWithSigner(rand *tmrand.Rand, singer string, size, blobCo func RandBlobsWithNamespace(namespaces []appns.Namespace, sizes []int) []*tmproto.Blob { blobs := make([]*tmproto.Blob, len(namespaces)) for i, ns := range namespaces { - blob, err := types.NewBlob(ns, tmrand.Bytes(sizes[i]), appconsts.ShareVersionZero) + blob, err := blobtypes.NewBlob(ns, tmrand.Bytes(sizes[i]), appconsts.ShareVersionZero) if err != nil { panic(err) } @@ -63,7 +60,7 @@ func RandBlobsWithNamespace(namespaces []appns.Namespace, sizes []int) []*tmprot } func RandMsgPayForBlobsWithNamespaceAndSigner(signer string, ns appns.Namespace, size int) (*blobtypes.MsgPayForBlobs, *tmproto.Blob) { - blob, err := types.NewBlob(ns, tmrand.Bytes(size), appconsts.ShareVersionZero) + blob, err := blobtypes.NewBlob(ns, tmrand.Bytes(size), appconsts.ShareVersionZero) if err != nil { panic(err) } @@ -78,7 +75,7 @@ func RandMsgPayForBlobsWithNamespaceAndSigner(signer string, ns appns.Namespace, } func RandMsgPayForBlobs(rand *tmrand.Rand, size int) (*blobtypes.MsgPayForBlobs, *tmproto.Blob) { - blob, err := types.NewBlob(namespace.RandomBlobNamespaceWithPRG(rand), tmrand.Bytes(size), appconsts.ShareVersionZero) + blob, err := blobtypes.NewBlob(appns.RandomBlobNamespaceWithPRG(rand), tmrand.Bytes(size), appconsts.ShareVersionZero) if err != nil { panic(err) } @@ -525,7 +522,7 @@ func GenerateRandomBlobSizes(count int, rand *tmrand.Rand) []int { } // RandMultiBlobTxsSameSigner returns a slice of random Blob transactions (consisting of pfbCount number of txs) each with random number of blobs and blob sizes. -func RandMultiBlobTxsSameSigner(t *testing.T, enc sdk.TxEncoder, rand *tmrand.Rand, signer *apptypes.KeyringSigner, pfbCount int) []coretypes.Tx { +func RandMultiBlobTxsSameSigner(t *testing.T, enc sdk.TxEncoder, rand *tmrand.Rand, signer *blobtypes.KeyringSigner, pfbCount int) []coretypes.Tx { pfbTxs := make([]coretypes.Tx, pfbCount) for i := 0; i < pfbCount; i++ { // create one blob tx with random number of blobs and blob sizes diff --git a/test/util/blobfactory/test_util.go b/test/util/blobfactory/test_util.go index 314b7219f9..9c2950276b 100644 --- a/test/util/blobfactory/test_util.go +++ b/test/util/blobfactory/test_util.go @@ -2,7 +2,6 @@ package blobfactory import ( "github.com/celestiaorg/celestia-app/test/util/testfactory" - apptypes "github.com/celestiaorg/celestia-app/x/blob/types" blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" @@ -84,13 +83,13 @@ func GenerateRandomAmount(rand *tmrand.Rand) int64 { } // GenerateRandomRawSendTx generates a random raw send tx. -func GenerateRandomRawSendTx(txConfig client.TxConfig, rand *tmrand.Rand, signer *apptypes.KeyringSigner) (rawTx []byte) { +func GenerateRandomRawSendTx(txConfig client.TxConfig, rand *tmrand.Rand, signer *blobtypes.KeyringSigner) (rawTx []byte) { amount := GenerateRandomAmount(rand) return GenerateRawSendTx(txConfig, signer, amount) } // GenerateManyRandomRawSendTxsSameSigner generates count many random raw send txs. -func GenerateManyRandomRawSendTxsSameSigner(txConfig client.TxConfig, rand *tmrand.Rand, signer *apptypes.KeyringSigner, count int) []coretypes.Tx { +func GenerateManyRandomRawSendTxsSameSigner(txConfig client.TxConfig, rand *tmrand.Rand, signer *blobtypes.KeyringSigner, count int) []coretypes.Tx { txs := make([]coretypes.Tx, count) for i := 0; i < count; i++ { txs[i] = GenerateRandomRawSendTx(txConfig, rand, signer) diff --git a/test/util/testnode/config.go b/test/util/testnode/config.go index 91d7464538..31b1ffb7a0 100644 --- a/test/util/testnode/config.go +++ b/test/util/testnode/config.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" srvtypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/tendermint/tendermint/config" tmconfig "github.com/tendermint/tendermint/config" tmrand "github.com/tendermint/tendermint/libs/rand" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -136,8 +135,8 @@ func DefaultParams() *tmproto.ConsensusParams { return cparams } -func DefaultTendermintConfig() *config.Config { - tmCfg := config.DefaultConfig() +func DefaultTendermintConfig() *tmconfig.Config { + tmCfg := tmconfig.DefaultConfig() // Reduce the target height duration so that blocks are produced faster // during tests. tmCfg.Consensus.TargetHeightDuration = 300 * time.Millisecond diff --git a/test/util/testnode/node_interaction_api.go b/test/util/testnode/node_interaction_api.go index 2dc6a28d27..00feabf071 100644 --- a/test/util/testnode/node_interaction_api.go +++ b/test/util/testnode/node_interaction_api.go @@ -10,7 +10,6 @@ import ( "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/pkg/appconsts" - "github.com/celestiaorg/celestia-app/pkg/namespace" appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/celestiaorg/celestia-app/pkg/shares" "github.com/celestiaorg/celestia-app/x/blob/types" @@ -304,7 +303,7 @@ func (c *Context) FillBlock(squareSize int, accounts []string, broadcastMode str // we use a formula to guarantee that the tx is the exact size needed to force a specific square size. blobSize := shares.AvailableBytesFromSparseShares(shareCount) - return c.PostData(accounts[0], broadcastMode, namespace.RandomBlobNamespace(), tmrand.Bytes(blobSize)) + return c.PostData(accounts[0], broadcastMode, appns.RandomBlobNamespace(), tmrand.Bytes(blobSize)) } // HeightForTimestamp returns the block height for the first block after a diff --git a/x/blob/client/testutil/integration_test.go b/x/blob/client/testutil/integration_test.go index 419f8d838f..6b43c7c189 100644 --- a/x/blob/client/testutil/integration_test.go +++ b/x/blob/client/testutil/integration_test.go @@ -21,7 +21,6 @@ import ( appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/celestiaorg/celestia-app/test/util/network" "github.com/celestiaorg/celestia-app/test/util/testfactory" - "github.com/celestiaorg/celestia-app/x/blob/client/cli" paycli "github.com/celestiaorg/celestia-app/x/blob/client/cli" abci "github.com/tendermint/tendermint/abci/types" ) @@ -99,7 +98,7 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=1", cli.FlagShareVersion), + fmt.Sprintf("--%s=1", paycli.FlagShareVersion), }, expectErr: true, expectedCode: 0, @@ -128,7 +127,7 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=1", cli.FlagNamespaceVersion), + fmt.Sprintf("--%s=1", paycli.FlagNamespaceVersion), }, expectErr: true, expectedCode: 0, diff --git a/x/blob/types/blob_tx_test.go b/x/blob/types/blob_tx_test.go index 858948a8a4..397c53bb83 100644 --- a/x/blob/types/blob_tx_test.go +++ b/x/blob/types/blob_tx_test.go @@ -5,7 +5,6 @@ import ( "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/pkg/appconsts" - "github.com/celestiaorg/celestia-app/pkg/namespace" appns "github.com/celestiaorg/celestia-app/pkg/namespace" tmrand "github.com/tendermint/tendermint/libs/rand" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -23,14 +22,14 @@ const ( func TestNewBlob(t *testing.T) { rawBlob := []byte{1} - validBlob, err := NewBlob(namespace.RandomBlobNamespace(), rawBlob, appconsts.ShareVersionZero) + validBlob, err := NewBlob(appns.RandomBlobNamespace(), rawBlob, appconsts.ShareVersionZero) require.NoError(t, err) require.Equal(t, validBlob.Data, rawBlob) _, err = NewBlob(appns.TxNamespace, rawBlob, appconsts.ShareVersionZero) require.Error(t, err) - _, err = NewBlob(namespace.RandomBlobNamespace(), []byte{}, appconsts.ShareVersionZero) + _, err = NewBlob(appns.RandomBlobNamespace(), []byte{}, appconsts.ShareVersionZero) require.Error(t, err) } @@ -49,7 +48,7 @@ func TestVerifySignature(t *testing.T) { msg, blob := randMsgPayForBlobsWithNamespaceAndSigner( t, addr.String(), - namespace.RandomBlobNamespace(), + appns.RandomBlobNamespace(), 100, ) builder := signer.NewTxBuilder(opts...) diff --git a/x/blob/types/builder.go b/x/blob/types/builder.go index 9e3172cf19..7a13799961 100644 --- a/x/blob/types/builder.go +++ b/x/blob/types/builder.go @@ -5,7 +5,6 @@ import ( "sync" "github.com/celestiaorg/celestia-app/app/encoding" - "github.com/cosmos/cosmos-sdk/client" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -65,7 +64,7 @@ func (k *KeyringSigner) QueryAccountNumber(ctx context.Context, conn *grpc.Clien return nil } -func (k *KeyringSigner) UpdateAccountFromClient(clientCtx client.Context) error { +func (k *KeyringSigner) UpdateAccountFromClient(clientCtx sdkclient.Context) error { rec := k.GetSignerInfo() addr, err := rec.GetAddress() diff --git a/x/blob/types/payforblob.go b/x/blob/types/payforblob.go index d3cf2e38d2..5d15bd8957 100644 --- a/x/blob/types/payforblob.go +++ b/x/blob/types/payforblob.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/errors" "github.com/celestiaorg/celestia-app/pkg/appconsts" - "github.com/celestiaorg/celestia-app/pkg/namespace" appns "github.com/celestiaorg/celestia-app/pkg/namespace" appshares "github.com/celestiaorg/celestia-app/pkg/shares" "github.com/celestiaorg/nmt" @@ -146,7 +145,7 @@ func ValidateBlobNamespace(ns appns.Namespace) error { return ErrTailPaddingNamespace } - if ns.Version != namespace.NamespaceVersionZero { + if ns.Version != appns.NamespaceVersionZero { return ErrInvalidNamespaceVersion } diff --git a/x/blob/types/test/blob_tx_test.go b/x/blob/types/test/blob_tx_test.go index 424c1e611c..0dbb6dce67 100644 --- a/x/blob/types/test/blob_tx_test.go +++ b/x/blob/types/test/blob_tx_test.go @@ -8,14 +8,12 @@ import ( "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/pkg/appconsts" "github.com/celestiaorg/celestia-app/pkg/namespace" - appns "github.com/celestiaorg/celestia-app/pkg/namespace" "github.com/celestiaorg/celestia-app/test/util/blobfactory" "github.com/celestiaorg/celestia-app/x/blob/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/libs/rand" tmrand "github.com/tendermint/tendermint/libs/rand" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" coretypes "github.com/tendermint/tendermint/types" @@ -25,7 +23,7 @@ func TestValidateBlobTx(t *testing.T) { encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) acc := "test" signer := types.GenerateKeyringSigner(t, acc) - ns1 := appns.MustNewV0(bytes.Repeat([]byte{0x01}, appns.NamespaceVersionZeroIDSize)) + ns1 := namespace.MustNewV0(bytes.Repeat([]byte{0x01}, namespace.NamespaceVersionZeroIDSize)) signerAddr, err := signer.GetSignerInfo().GetAddress() require.NoError(t, err) @@ -69,7 +67,7 @@ func TestValidateBlobTx(t *testing.T) { name: "invalid transaction, no pfb", getTx: func() tmproto.BlobTx { sendTx := blobfactory.GenerateManyRawSendTxs(encCfg.TxConfig, 1) - blob, err := types.NewBlob(namespace.RandomBlobNamespace(), rand.Bytes(100), appconsts.ShareVersionZero) + blob, err := types.NewBlob(namespace.RandomBlobNamespace(), tmrand.Bytes(100), appconsts.ShareVersionZero) require.NoError(t, err) return tmproto.BlobTx{ Tx: sendTx[0], @@ -83,7 +81,7 @@ func TestValidateBlobTx(t *testing.T) { getTx: func() tmproto.BlobTx { rawBtx := validRawBtx() btx, _ := coretypes.UnmarshalBlobTx(rawBtx) - blob, err := types.NewBlob(namespace.RandomBlobNamespace(), rand.Bytes(100), appconsts.ShareVersionZero) + blob, err := types.NewBlob(namespace.RandomBlobNamespace(), tmrand.Bytes(100), appconsts.ShareVersionZero) require.NoError(t, err) btx.Blobs = append(btx.Blobs, blob) return btx @@ -93,7 +91,7 @@ func TestValidateBlobTx(t *testing.T) { { name: "invalid share commitment", getTx: func() tmproto.BlobTx { - blob, err := types.NewBlob(namespace.RandomBlobNamespace(), rand.Bytes(100), appconsts.ShareVersionZero) + blob, err := types.NewBlob(namespace.RandomBlobNamespace(), tmrand.Bytes(100), appconsts.ShareVersionZero) require.NoError(t, err) msg, err := types.NewMsgPayForBlobs( signerAddr.String(), @@ -105,7 +103,7 @@ func TestValidateBlobTx(t *testing.T) { &types.Blob{ NamespaceVersion: uint32(namespace.RandomBlobNamespace().Version), NamespaceId: namespace.RandomBlobNamespace().ID, - Data: rand.Bytes(99), + Data: tmrand.Bytes(99), ShareVersion: uint32(appconsts.ShareVersionZero), }) require.NoError(t, err) diff --git a/x/mint/keeper/genesis.go b/x/mint/keeper/genesis.go index 5b48c77d50..3f267967ca 100644 --- a/x/mint/keeper/genesis.go +++ b/x/mint/keeper/genesis.go @@ -6,19 +6,19 @@ import ( ) // InitGenesis initializes the x/mint store with data from the genesis state. -func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { - keeper.SetMinter(ctx, data.Minter) +func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { + k.SetMinter(ctx, data.Minter) // override the genesis time with the actual genesis time supplied in `InitChain` blockTime := ctx.BlockTime() gt := types.GenesisTime{ GenesisTime: &blockTime, } - keeper.SetGenesisTime(ctx, gt) + k.SetGenesisTime(ctx, gt) ak.GetModuleAccount(ctx, types.ModuleName) } // ExportGenesis returns a x/mint GenesisState for the given context. -func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - minter := keeper.GetMinter(ctx) +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + minter := k.GetMinter(ctx) return types.NewGenesisState(minter) } diff --git a/x/qgb/client/query.go b/x/qgb/client/query.go index e1069155f5..1ba2ec12d8 100644 --- a/x/qgb/client/query.go +++ b/x/qgb/client/query.go @@ -8,7 +8,6 @@ import ( "github.com/celestiaorg/celestia-app/x/qgb/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" "github.com/spf13/cobra" @@ -78,7 +77,7 @@ func CmdQueryAttestationByNonce() *cobra.Command { } // unmarshallAttestation unmarshal a wrapper protobuf `Any` type to an `AttestationRequestI`. -func unmarshallAttestation(attestation *cdctypes.Any) (types.AttestationRequestI, error) { +func unmarshallAttestation(attestation *codectypes.Any) (types.AttestationRequestI, error) { var unmarshalledAttestation types.AttestationRequestI err := makeInterfaceRegistry().UnpackAny(attestation, &unmarshalledAttestation) if err != nil { diff --git a/x/qgb/types/genesis.go b/x/qgb/types/genesis.go index 86cceb818c..945856f58e 100644 --- a/x/qgb/types/genesis.go +++ b/x/qgb/types/genesis.go @@ -18,7 +18,8 @@ const ( MinimumDataCommitmentWindow = 100 ) -// ParamsStoreKeyDataCommitmentWindow +// ParamsStoreKeyDataCommitmentWindow is the key used for the +// DataCommitmentWindow param. var ParamsStoreKeyDataCommitmentWindow = []byte("DataCommitmentWindow") // DefaultGenesis returns the default Capability genesis state