diff --git a/.golangci.yml b/.golangci.yml index 2fe26b19387..981aa9c918c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,5 +33,8 @@ linters-settings: rules: - name: package-comments disabled: true + - name: duplicated-imports + severity: warning + goimports: local-prefixes: github.com/rollkit diff --git a/node/block_exchange.go b/node/block_exchange.go index 1bc223a4628..a11539c144d 100644 --- a/node/block_exchange.go +++ b/node/block_exchange.go @@ -11,7 +11,7 @@ import ( goheaderstore "github.com/celestiaorg/go-header/store" goheadersync "github.com/celestiaorg/go-header/sync" "github.com/cometbft/cometbft/libs/log" - tmtypes "github.com/cometbft/cometbft/types" + cmtypes "github.com/cometbft/cometbft/types" ds "github.com/ipfs/go-datastore" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/host" @@ -29,7 +29,7 @@ import ( // Uses the go-header library for handling all P2P logic. type BlockExchangeService struct { conf config.NodeConfig - genesis *tmtypes.GenesisDoc + genesis *cmtypes.GenesisDoc p2p *p2p.Client ex *goheaderp2p.Exchange[*types.Block] sub *goheaderp2p.Subscriber[*types.Block] @@ -43,7 +43,7 @@ type BlockExchangeService struct { ctx context.Context } -func NewBlockExchangeService(ctx context.Context, store ds.TxnDatastore, conf config.NodeConfig, genesis *tmtypes.GenesisDoc, p2p *p2p.Client, logger log.Logger) (*BlockExchangeService, error) { +func NewBlockExchangeService(ctx context.Context, store ds.TxnDatastore, conf config.NodeConfig, genesis *cmtypes.GenesisDoc, p2p *p2p.Client, logger log.Logger) (*BlockExchangeService, error) { if genesis == nil { return nil, errors.New("genesis doc cannot be nil") } diff --git a/node/full_client.go b/node/full_client.go index 9bb3e3f6d1a..0dd8f2ac2d1 100644 --- a/node/full_client.go +++ b/node/full_client.go @@ -9,7 +9,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/config" - bytes "github.com/cometbft/cometbft/libs/bytes" cmbytes "github.com/cometbft/cometbft/libs/bytes" cmmath "github.com/cometbft/cometbft/libs/math" cmpubsub "github.com/cometbft/cometbft/libs/pubsub" @@ -802,7 +801,7 @@ func (c *FullClient) Header(ctx context.Context, height *int64) (*ctypes.ResultH return &ctypes.ResultHeader{Header: &blockMeta.Header}, nil } -func (c *FullClient) HeaderByHash(ctx context.Context, hash bytes.HexBytes) (*ctypes.ResultHeader, error) { +func (c *FullClient) HeaderByHash(ctx context.Context, hash cmbytes.HexBytes) (*ctypes.ResultHeader, error) { // N.B. The hash parameter is HexBytes so that the reflective parameter // decoding logic in the HTTP service will correctly translate from JSON. // See https://github.com/cometbft/cometbft/issues/6802 for context. diff --git a/node/header_exchange.go b/node/header_exchange.go index fec2de53cbb..fabd91c663c 100644 --- a/node/header_exchange.go +++ b/node/header_exchange.go @@ -12,7 +12,6 @@ import ( goheadersync "github.com/celestiaorg/go-header/sync" "github.com/cometbft/cometbft/libs/log" cmtypes "github.com/cometbft/cometbft/types" - tmtypes "github.com/cometbft/cometbft/types" ds "github.com/ipfs/go-datastore" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/libp2p/go-libp2p/core/host" @@ -44,7 +43,7 @@ type HeaderExchangeService struct { ctx context.Context } -func NewHeaderExchangeService(ctx context.Context, store ds.TxnDatastore, conf config.NodeConfig, genesis *tmtypes.GenesisDoc, p2p *p2p.Client, logger log.Logger) (*HeaderExchangeService, error) { +func NewHeaderExchangeService(ctx context.Context, store ds.TxnDatastore, conf config.NodeConfig, genesis *cmtypes.GenesisDoc, p2p *p2p.Client, logger log.Logger) (*HeaderExchangeService, error) { if genesis == nil { return nil, errors.New("genesis doc cannot be nil") } diff --git a/node/light_client.go b/node/light_client.go index 7e4b7ccb0e5..d48ccab5410 100644 --- a/node/light_client.go +++ b/node/light_client.go @@ -3,8 +3,7 @@ package node import ( "context" - bytes "github.com/cometbft/cometbft/libs/bytes" - cmtypes "github.com/cometbft/cometbft/libs/bytes" + cmbytes "github.com/cometbft/cometbft/libs/bytes" rpcclient "github.com/cometbft/cometbft/rpc/client" ctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cometbft/cometbft/types" @@ -29,12 +28,12 @@ func (c *LightClient) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, err } // ABCIQuery queries for data from application. -func (c *LightClient) ABCIQuery(ctx context.Context, path string, data cmtypes.HexBytes) (*ctypes.ResultABCIQuery, error) { +func (c *LightClient) ABCIQuery(ctx context.Context, path string, data cmbytes.HexBytes) (*ctypes.ResultABCIQuery, error) { panic("Not implemented") } // ABCIQueryWithOptions queries for data from application. -func (c *LightClient) ABCIQueryWithOptions(ctx context.Context, path string, data cmtypes.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { +func (c *LightClient) ABCIQueryWithOptions(ctx context.Context, path string, data cmbytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error) { panic("Not implemented") } @@ -184,6 +183,6 @@ func (c *LightClient) Header(ctx context.Context, height *int64) (*ctypes.Result panic("Not implemented") } -func (c *LightClient) HeaderByHash(ctx context.Context, hash bytes.HexBytes) (*ctypes.ResultHeader, error) { +func (c *LightClient) HeaderByHash(ctx context.Context, hash cmbytes.HexBytes) (*ctypes.ResultHeader, error) { panic("Not implemented") } diff --git a/node/test_helpers.go b/node/test_helpers.go index 853382b3f12..a3bf17e411d 100644 --- a/node/test_helpers.go +++ b/node/test_helpers.go @@ -9,7 +9,7 @@ import ( testutils "github.com/celestiaorg/utils/test" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cometbft/cometbft/p2p" - tmtypes "github.com/cometbft/cometbft/types" + cmtypes "github.com/cometbft/cometbft/types" "github.com/libp2p/go-libp2p/core/crypto" "github.com/rollkit/rollkit/conv" @@ -93,14 +93,14 @@ func waitForAtLeastNBlocks(node Node, n int, useBlockExchange bool) error { } // TODO: use n and return n validators -func getGenesisValidatorSetWithSigner(n int) ([]tmtypes.GenesisValidator, crypto.PrivKey) { +func getGenesisValidatorSetWithSigner(n int) ([]cmtypes.GenesisValidator, crypto.PrivKey) { nodeKey := &p2p.NodeKey{ PrivKey: genesisValidatorKey, } signingKey, _ := conv.GetNodeKey(nodeKey) pubKey := genesisValidatorKey.PubKey() - genesisValidators := []tmtypes.GenesisValidator{ + genesisValidators := []cmtypes.GenesisValidator{ {Address: pubKey.Address(), PubKey: pubKey, Power: int64(100), Name: "gen #1"}, } return genesisValidators, signingKey diff --git a/rpc/json/test_helpers.go b/rpc/json/test_helpers.go index 0b7c5478775..d37bc65f253 100644 --- a/rpc/json/test_helpers.go +++ b/rpc/json/test_helpers.go @@ -12,7 +12,7 @@ import ( "github.com/cometbft/cometbft/p2p" "github.com/cometbft/cometbft/proxy" rpcclient "github.com/cometbft/cometbft/rpc/client" - tmtypes "github.com/cometbft/cometbft/types" + cmtypes "github.com/cometbft/cometbft/types" "github.com/libp2p/go-libp2p/core/crypto" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -53,10 +53,10 @@ func getRPC(t *testing.T) (*mocks.Application, rpcclient.Client) { signingKey, _ := conv.GetNodeKey(nodeKey) pubKey := validatorKey.PubKey() - genesisValidators := []tmtypes.GenesisValidator{ + genesisValidators := []cmtypes.GenesisValidator{ {Address: pubKey.Address(), PubKey: pubKey, Power: int64(100), Name: "gen #1"}, } - n, err := node.NewNode(context.Background(), config.NodeConfig{Aggregator: true, DALayer: "mock", BlockManagerConfig: config.BlockManagerConfig{BlockTime: 1 * time.Second}, Light: false}, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test", Validators: genesisValidators}, log.TestingLogger()) + n, err := node.NewNode(context.Background(), config.NodeConfig{Aggregator: true, DALayer: "mock", BlockManagerConfig: config.BlockManagerConfig{BlockTime: 1 * time.Second}, Light: false}, key, signingKey, proxy.NewLocalClientCreator(app), &cmtypes.GenesisDoc{ChainID: "test", Validators: genesisValidators}, log.TestingLogger()) require.NoError(err) require.NotNil(n) diff --git a/types/test_utils.go b/types/test_utils.go index 0637ee061db..2afa6f02a90 100644 --- a/types/test_utils.go +++ b/types/test_utils.go @@ -5,21 +5,21 @@ import ( "time" "github.com/cometbft/cometbft/crypto/ed25519" - tmtypes "github.com/cometbft/cometbft/types" + cmtypes "github.com/cometbft/cometbft/types" ) // TODO: accept argument for number of validators / proposer index -func GetRandomValidatorSet() *tmtypes.ValidatorSet { +func GetRandomValidatorSet() *cmtypes.ValidatorSet { valSet, _ := GetRandomValidatorSetWithPrivKey() return valSet } -func GetRandomValidatorSetWithPrivKey() (*tmtypes.ValidatorSet, ed25519.PrivKey) { +func GetRandomValidatorSetWithPrivKey() (*cmtypes.ValidatorSet, ed25519.PrivKey) { privKey := ed25519.GenPrivKey() pubKey := privKey.PubKey() - return &tmtypes.ValidatorSet{ - Proposer: &tmtypes.Validator{PubKey: pubKey, Address: pubKey.Address()}, - Validators: []*tmtypes.Validator{ + return &cmtypes.ValidatorSet{ + Proposer: &cmtypes.Validator{PubKey: pubKey, Address: pubKey.Address()}, + Validators: []*cmtypes.Validator{ {PubKey: pubKey, Address: pubKey.Address()}, }, }, privKey