Skip to content

Commit

Permalink
ignore incomplete comment, fix namings for golint
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylNaumenko committed Jul 19, 2024
1 parent cac7268 commit 33d3d94
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: go install golang.org/x/lint/golint@latest

- name: Run golint
run: golint ./...
run: golint ./... | grep -v "should have comment or be unexported"

- name: Test
run: go test -race -vet=off -v ./...
4 changes: 2 additions & 2 deletions example/wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func WasmCreator() vm.AppCreator {

srvCfg := *srvconfig.DefaultConfig()
grpcCfg := srvCfg.GRPC
var vmCfg vmtypes.VmConfig
var vmCfg vmtypes.VMConfig
vmCfg.SetDefaults()
if len(config.ConfigBytes) > 0 {
if err := json.Unmarshal(config.ConfigBytes, &vmCfg); err != nil {
Expand Down Expand Up @@ -101,7 +101,7 @@ func WasmCreator() vm.AppCreator {
WithInterfaceRegistry(interfaceRegistry).
WithChainID(chainID)

avaChainID, err := ids.ToID(config.ChainId)
avaChainID, err := ids.ToID(config.ChainID)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions grpcutils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var DefaultDialOptions = []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
}

// gRPC clients created from this ClientConn will wait forever for the Server to
// Dial gRPC clients created from this ClientConn will wait forever for the Server to
// become Ready. If you desire a dial timeout ensure context is properly plumbed
// to the client and use context.WithTimeout.
//
Expand All @@ -67,7 +67,7 @@ type DialOptions struct {
opts []grpc.DialOption
}

// append(DefaultDialOptions, ...) will always allocate a new slice and will
// newDialOpts append(DefaultDialOptions, ...) will always allocate a new slice and will
// not overwrite any potential data that may have previously been appended to
// DefaultServerOptions https://go.dev/ref/spec#Composite_literals
func newDialOpts(opts ...DialOption) []grpc.DialOption {
Expand Down
5 changes: 3 additions & 2 deletions grpcutils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

httppb "github.com/consideritdone/landslidevm/proto/http"
spb "google.golang.org/genproto/googleapis/rpc/status"
tspb "google.golang.org/protobuf/types/known/timestamppb"

httppb "github.com/consideritdone/landslidevm/proto/http"
)

func Errorf(code int, tmpl string, args ...interface{}) error {
Expand All @@ -24,7 +25,7 @@ func Errorf(code int, tmpl string, args ...interface{}) error {
})
}

// GetGRPCErrorFromHTTPRespone takes an HandleSimpleHTTPResponse as input and returns a gRPC error.
// GetGRPCErrorFromHTTPResponse takes an HandleSimpleHTTPResponse as input and returns a gRPC error.
func GetGRPCErrorFromHTTPResponse(resp *httppb.HandleSimpleHTTPResponse) error {
a, err := anypb.New(resp)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion utils/linkedhashmap/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

var _ Iter[int, struct{}] = (*iterator[int, struct{}])(nil)

// Iterates over the keys and values in a LinkedHashmap
// Iter Iterates over the keys and values in a LinkedHashmap
// from oldest to newest elements.
// Assumes the underlying LinkedHashmap is not modified while
// the iterator is in use, except to delete elements that
Expand Down
12 changes: 6 additions & 6 deletions utils/sorting.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ type Sortable[T any] interface {
Compare(T) int
}

// Sorts the elements of [s].
// Sort sorts the elements of [s].
func Sort[T Sortable[T]](s []T) {
slices.SortFunc(s, T.Compare)
}

// Sorts the elements of [s] based on their hashes.
// SortByHash sorts the elements of [s] based on their hashes.
func SortByHash[T ~[]byte](s []T) {
slices.SortFunc(s, func(i, j T) int {
iHash := hashing.ComputeHash256(i)
Expand All @@ -28,7 +28,7 @@ func SortByHash[T ~[]byte](s []T) {
})
}

// Returns true iff the elements in [s] are sorted.
// IsSortedBytes returns true iff the elements in [s] are sorted.
func IsSortedBytes[T ~[]byte](s []T) bool {
for i := 0; i < len(s)-1; i++ {
if bytes.Compare(s[i], s[i+1]) == 1 {
Expand All @@ -38,7 +38,7 @@ func IsSortedBytes[T ~[]byte](s []T) bool {
return true
}

// Returns true iff the elements in [s] are unique and sorted.
// IsSortedAndUnique returns true iff the elements in [s] are unique and sorted.
func IsSortedAndUnique[T Sortable[T]](s []T) bool {
for i := 0; i < len(s)-1; i++ {
if s[i].Compare(s[i+1]) >= 0 {
Expand All @@ -48,7 +48,7 @@ func IsSortedAndUnique[T Sortable[T]](s []T) bool {
return true
}

// Returns true iff the elements in [s] are unique and sorted.
// IsSortedAndUniqueOrdered returns true iff the elements in [s] are unique and sorted.
func IsSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool {
for i := 0; i < len(s)-1; i++ {
if s[i] >= s[i+1] {
Expand All @@ -58,7 +58,7 @@ func IsSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool {
return true
}

// Returns true iff the elements in [s] are unique and sorted
// IsSortedAndUniqueByHash returns true iff the elements in [s] are unique and sorted
// based by their hashes.
func IsSortedAndUniqueByHash[T ~[]byte](s []T) bool {
if len(s) <= 1 {
Expand Down
10 changes: 5 additions & 5 deletions vm/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,17 @@ func (rpc *RPC) GenesisChunked(_ *rpctypes.Context, chunk uint) (*ctypes.ResultG
}, nil
}

// ToDo: no peers, because it's vm
// NetInfo ToDo: no peers, because it's vm
func (rpc *RPC) NetInfo(_ *rpctypes.Context) (*ctypes.ResultNetInfo, error) {
return nil, nil
}

// ToDo: we doesn't have consensusState
// DumpConsensusState ToDo: we doesn't have consensusState
func (rpc *RPC) DumpConsensusState(_ *rpctypes.Context) (*ctypes.ResultDumpConsensusState, error) {
return nil, nil
}

// ToDo: we doesn't have consensusState
// GetConsensusState ToDo: we doesn't have consensusState
func (rpc *RPC) GetConsensusState(_ *rpctypes.Context) (*ctypes.ResultConsensusState, error) {
return nil, nil
}
Expand All @@ -375,7 +375,7 @@ func (rpc *RPC) Health(*rpctypes.Context) (*ctypes.ResultHealth, error) {
return &ctypes.ResultHealth{}, nil
}

// bsHeight can be either latest committed or uncommitted (+1) height.
// getHeight bsHeight can be either latest committed or uncommitted (+1) height.
func getHeight(bs *store.BlockStore, heightPtr *int64) (int64, error) {
bsHeight := bs.Height()
if heightPtr != nil {
Expand Down Expand Up @@ -747,7 +747,7 @@ func (rpc *RPC) Status(_ *rpctypes.Context) (*ctypes.ResultStatus, error) {
version.BlockProtocol,
0,
),
DefaultNodeID: p2p.ID(rpc.vm.appOpts.NodeId),
DefaultNodeID: p2p.ID(rpc.vm.appOpts.NodeID),
ListenAddr: "",
Network: rpc.vm.networkName,
Version: version.TMCoreSemVer,
Expand Down
2 changes: 1 addition & 1 deletion vm/types/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/cometbft/cometbft/types"
)

func BlockParentHash(block *types.Block) [32]byte {
func ParentHash(block *types.Block) [32]byte {
var parentHash [32]byte
if block.LastBlockID.Hash != nil {
parentHash = [32]byte(block.LastBlockID.Hash)
Expand Down
8 changes: 4 additions & 4 deletions vm/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const (
defaultTimeoutBroadcastTxCommit time.Duration = 30 * time.Second
)

// VmConfig ...
type VmConfig struct {
// VMConfig ...
type VMConfig struct {
RPCPort uint16 `json:"rpc_port"`
GRPCPort uint16 `json:"grpc_port"`
GRPCMaxOpenConnections int `json:"grpc_max_open_connections"`
Expand All @@ -22,7 +22,7 @@ type VmConfig struct {
}

// SetDefaults sets the default values for the config.
func (c *VmConfig) SetDefaults() {
func (c *VMConfig) SetDefaults() {
c.RPCPort = defaultRPCPort
c.GRPCPort = defaultGRPCPort
c.GRPCMaxOpenConnections = defaultMaxOpenConnections
Expand All @@ -31,7 +31,7 @@ func (c *VmConfig) SetDefaults() {
}

// Validate returns an error if this is an invalid config.
func (c *VmConfig) Validate() error {
func (c *VMConfig) Validate() error {
if c.GRPCMaxOpenConnections < 0 {
return fmt.Errorf("grpc_max_open_connections can't be negative")
}
Expand Down
40 changes: 20 additions & 20 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ type (
Application = abcitypes.Application

AppCreatorOpts struct {
NetworkId uint32
SubnetId []byte
ChainId []byte
NodeId []byte
NetworkID uint32
SubnetID []byte
ChainID []byte
NodeID []byte
PublicKey []byte
XChainId []byte
CChainId []byte
AvaxAssetId []byte
XChainID []byte
CChainID []byte
AvaxAssetID []byte
GenesisBytes []byte
UpgradeBytes []byte
ConfigBytes []byte
Expand Down Expand Up @@ -256,14 +256,14 @@ func (vm *LandslideVM) Initialize(_ context.Context, req *vmpb.InitializeRequest
vm.stateStore = state.NewStore(dbStateStore, state.StoreOptions{DiscardABCIResponses: false})

vm.appOpts = &AppCreatorOpts{
NetworkId: req.NetworkId,
SubnetId: req.SubnetId,
ChainId: req.ChainId,
NodeId: req.NodeId,
NetworkID: req.NetworkId,
SubnetID: req.SubnetId,
ChainID: req.ChainId,
NodeID: req.NodeId,
PublicKey: req.PublicKey,
XChainId: req.XChainId,
CChainId: req.CChainId,
AvaxAssetId: req.AvaxAssetId,
XChainID: req.XChainId,
CChainID: req.CChainId,
AvaxAssetID: req.AvaxAssetId,
GenesisBytes: req.GenesisBytes,
UpgradeBytes: req.UpgradeBytes,
ConfigBytes: req.ConfigBytes,
Expand All @@ -275,7 +275,7 @@ func (vm *LandslideVM) Initialize(_ context.Context, req *vmpb.InitializeRequest
}

// Set the default configuration
var vmCfg vmtypes.VmConfig
var vmCfg vmtypes.VMConfig
vmCfg.SetDefaults()
if len(vm.appOpts.ConfigBytes) > 0 {
if err := json.Unmarshal(vm.appOpts.ConfigBytes, &vmCfg); err != nil {
Expand Down Expand Up @@ -405,10 +405,10 @@ func (vm *LandslideVM) Initialize(_ context.Context, req *vmpb.InitializeRequest
if err != nil {
return nil, err
}
//vm.logger.Debug("initialize block", "bytes ", blockBytes)
// vm.logger.Debug("initialize block", "bytes ", blockBytes)
vm.logger.Info("vm initialization completed")

parentHash := block.BlockParentHash(blk)
parentHash := block.ParentHash(blk)

return &vmpb.InitializeResponse{
LastAcceptedId: blk.Hash(),
Expand Down Expand Up @@ -437,7 +437,7 @@ func (vm *LandslideVM) SetState(_ context.Context, req *vmpb.SetStateRequest) (*
}

vm.logger.Debug("SetState", "LastAcceptedId", vm.state.LastBlockID.Hash, "block", blk.Hash())
parentHash := block.BlockParentHash(blk)
parentHash := block.ParentHash(blk)
res := vmpb.SetStateResponse{
LastAcceptedId: blk.Hash(),
LastAcceptedParentId: parentHash[:],
Expand Down Expand Up @@ -583,7 +583,7 @@ func (vm *LandslideVM) BuildBlock(context.Context, *vmpb.BuildBlockRequest) (*vm
// ParseBlock attempt to create a block from a stream of bytes.
func (vm *LandslideVM) ParseBlock(_ context.Context, req *vmpb.ParseBlockRequest) (*vmpb.ParseBlockResponse, error) {
vm.logger.Info("ParseBlock")
//vm.logger.Debug("ParseBlock", "bytes", req.Bytes)
// vm.logger.Debug("ParseBlock", "bytes", req.Bytes)
var (
blk *types.Block
blkStatus vmpb.Status
Expand Down Expand Up @@ -839,7 +839,7 @@ func (vm *LandslideVM) GetStateSummary(context.Context, *vmpb.GetStateSummaryReq

func (vm *LandslideVM) BlockVerify(_ context.Context, req *vmpb.BlockVerifyRequest) (*vmpb.BlockVerifyResponse, error) {
vm.logger.Info("BlockVerify")
//vm.logger.Debug("block verify", "bytes", req.Bytes)
// vm.logger.Debug("block verify", "bytes", req.Bytes)

blk, blkStatus, err := vmstate.DecodeBlockWithStatus(req.Bytes)
if err != nil {
Expand Down

0 comments on commit 33d3d94

Please sign in to comment.