diff --git a/lumera/Readme.md b/lumera/Readme.md new file mode 100644 index 00000000..dbba164b --- /dev/null +++ b/lumera/Readme.md @@ -0,0 +1,153 @@ +# Lumera Client + +A Go client for interacting with the Lumera blockchain. + +## Features + +- Connect to Lumera nodes via gRPC +- Interact with all Lumera modules: + - Action module - manage and query action data + - SuperNode module - interact with supernodes + - Transaction module - broadcast and query transactions + - Node module - query node status and blockchain info +- Configurable connection options +- Clean, modular API design with clear separation of interfaces and implementations + +## Installation + +```bash +go get github.com/LumeraProtocol/lumera-client +``` + +## Quick Start + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/LumeraProtocol/lumera-client/client" +) + +func main() { + // Create a context + ctx := context.Background() + + // Initialize the client with options + lumeraClient, err := client.NewClient( + ctx, + client.WithGRPCAddr("localhost:9090"), + client.WithChainID("lumera-mainnet"), + client.WithTimeout(30), + ) + if err != nil { + log.Fatalf("Failed to create Lumera client: %v", err) + } + defer lumeraClient.Close() + + // Get the latest block height + latestBlock, err := lumeraClient.Node().GetLatestBlock(ctx) + if err != nil { + log.Fatalf("Failed to get latest block: %v", err) + } + + fmt.Printf("Latest block height: %d\n", latestBlock.Block.Header.Height) +} +``` + +## Examples + +The repository includes example applications demonstrating how to use the client: + +- **Basic Example**: Shows simple queries and interactions with the Lumera blockchain +- **Advanced Example**: Demonstrates a complete transaction flow with error handling and retries + +To run the examples: + +```bash +# Build and run the basic example +make run-basic + +# Build and run the advanced example +make run-advanced +``` + +## Project Structure + +``` +lumera-client/ +│ # Core client package +│ interface.go # Client interface definitions +│ client.go # Client implementation +│ config.go # Configuration types +│ options.go # Option functions +│ connection.go # Connection handling +├── modules/ # Module-specific packages +│ ├── action/ # Action module +│ ├── node/ # Node module +│ ├── supernode/ # SuperNode module +│ └── tx/ # Transaction module +└── examples/ # Example applications + └── main.go # Basic usage example + +``` + +## Module Documentation + +### Action Module + +The Action module allows you to interact with Lumera actions, which are the core data processing units in the Lumera blockchain. + +```go +// Get action by ID +action, err := client.Action().GetAction(ctx, "action-id-123") + +// Calculate fee for action with specific data size +fee, err := client.Action().GetActionFee(ctx, "1024") // 1KB data +``` + +### Node Module + +The Node module provides information about the blockchain and node status. + +```go +// Get latest block +block, err := client.Node().GetLatestBlock(ctx) + +// Get specific block by height +block, err := client.Node().GetBlockByHeight(ctx, 1000) + +// Get node information +nodeInfo, err := client.Node().GetNodeInfo(ctx) +``` + +### SuperNode Module + +The SuperNode module allows you to interact with Lumera supernodes. + +```go +// Get top supernodes for a specific block +topNodes, err := client.SuperNode().GetTopSuperNodesForBlock(ctx, 1000) + +// Get specific supernode by address +node, err := client.SuperNode().GetSuperNode(ctx, "validator-address") +``` + +### Transaction Module + +The Transaction module handles transaction broadcasting and querying. + +```go +// Broadcast a signed transaction +resp, err := client.Tx().BroadcastTx(ctx, txBytes, sdktx.BroadcastMode_BROADCAST_MODE_SYNC) + +// Simulate a transaction +sim, err := client.Tx().SimulateTx(ctx, txBytes) + +// Get transaction by hash +tx, err := client.Tx().GetTx(ctx, "tx-hash") +``` + diff --git a/lumera/client.go b/lumera/client.go new file mode 100644 index 00000000..edccfb54 --- /dev/null +++ b/lumera/client.go @@ -0,0 +1,98 @@ +package lumera + +import ( + "context" + + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/action" + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/node" + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/supernode" + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/tx" +) + +// lumeraClient implements the Client interface +type lumeraClient struct { + cfg *Config + actionMod action.Module + supernodeMod supernode.Module + txMod tx.Module + nodeMod node.Module + conn Connection +} + +// newClient creates a new Lumera client with provided options +func newClient(ctx context.Context, opts ...Option) (Client, error) { + cfg := DefaultConfig() + + // Apply all options + for _, opt := range opts { + opt(cfg) + } + + // Create a single gRPC connection to be shared by all modules + conn, err := newGRPCConnection(ctx, cfg.GRPCAddr) + if err != nil { + return nil, err + } + + // Initialize all module clients with the shared connection + actionModule, err := action.NewModule(conn.GetConn()) + if err != nil { + conn.Close() + return nil, err + } + + supernodeModule, err := supernode.NewModule(conn.GetConn()) + if err != nil { + conn.Close() + return nil, err + } + + txModule, err := tx.NewModule(conn.GetConn()) + if err != nil { + conn.Close() + return nil, err + } + + nodeModule, err := node.NewModule(conn.GetConn()) + if err != nil { + conn.Close() + return nil, err + } + + return &lumeraClient{ + cfg: cfg, + actionMod: actionModule, + supernodeMod: supernodeModule, + txMod: txModule, + nodeMod: nodeModule, + conn: conn, + }, nil +} + +// Action returns the Action module client +func (c *lumeraClient) Action() action.Module { + return c.actionMod +} + +// SuperNode returns the SuperNode module client +func (c *lumeraClient) SuperNode() supernode.Module { + return c.supernodeMod +} + +// Tx returns the Transaction module client +func (c *lumeraClient) Tx() tx.Module { + return c.txMod +} + +// Node returns the Node module client +func (c *lumeraClient) Node() node.Module { + return c.nodeMod +} + +// Close closes all connections +func (c *lumeraClient) Close() error { + if c.conn != nil { + return c.conn.Close() + } + return nil +} diff --git a/lumera/config.go b/lumera/config.go new file mode 100644 index 00000000..6a370bf0 --- /dev/null +++ b/lumera/config.go @@ -0,0 +1,22 @@ +package lumera + +// Config holds all the configuration needed for the client +type Config struct { + // GRPCAddr is the gRPC endpoint address + GRPCAddr string + + // ChainID is the ID of the chain + ChainID string + + // Timeout is the default request timeout in seconds + Timeout int +} + +// DefaultConfig returns a default configuration +func DefaultConfig() *Config { + return &Config{ + GRPCAddr: "localhost:9090", + ChainID: "lumera", + Timeout: 10, + } +} diff --git a/lumera/connection.go b/lumera/connection.go new file mode 100644 index 00000000..77855e6f --- /dev/null +++ b/lumera/connection.go @@ -0,0 +1,55 @@ +package lumera + +import ( + "context" + "fmt" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +// Connection defines the interface for a client connection +type Connection interface { + Close() error + GetConn() *grpc.ClientConn +} + +// grpcConnection wraps a gRPC connection +type grpcConnection struct { + conn *grpc.ClientConn +} + +// newGRPCConnection creates a new gRPC connection +func newGRPCConnection(ctx context.Context, addr string) (Connection, error) { + dialCtx, cancel := context.WithTimeout(ctx, 10*time.Second) + defer cancel() + + // Note: Cosmos SDK doesn't support TLS for gRPC so we use insecure credentials + conn, err := grpc.DialContext( + dialCtx, + addr, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithBlock(), + ) + if err != nil { + return nil, fmt.Errorf("failed to connect to gRPC server: %w", err) + } + + return &grpcConnection{ + conn: conn, + }, nil +} + +// Close closes the gRPC connection +func (c *grpcConnection) Close() error { + if c.conn != nil { + return c.conn.Close() + } + return nil +} + +// GetConn returns the underlying gRPC connection +func (c *grpcConnection) GetConn() *grpc.ClientConn { + return c.conn +} diff --git a/lumera/interface.go b/lumera/interface.go new file mode 100644 index 00000000..1e1d8737 --- /dev/null +++ b/lumera/interface.go @@ -0,0 +1,26 @@ +package lumera + +import ( + "context" + + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/action" + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/node" + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/supernode" + "github.com/LumeraProtocol/supernode/pkg/lumera/modules/tx" +) + +// Client defines the main interface for interacting with Lumera blockchain +type Client interface { + // Module accessors + Action() action.Module + SuperNode() supernode.Module + Tx() tx.Module + Node() node.Module + + Close() error +} + +// NewClient creates a new Lumera client with provided options +func NewClient(ctx context.Context, opts ...Option) (Client, error) { + return newClient(ctx, opts...) +} diff --git a/lumera/modules/action/impl.go b/lumera/modules/action/impl.go new file mode 100644 index 00000000..016dbd7d --- /dev/null +++ b/lumera/modules/action/impl.go @@ -0,0 +1,49 @@ +package action + +import ( + "context" + "fmt" + + "github.com/LumeraProtocol/lumera/x/action/types" + "google.golang.org/grpc" +) + +// module implements the Module interface +type module struct { + client types.QueryClient +} + +// newModule creates a new Action module client +func newModule(conn *grpc.ClientConn) (Module, error) { + if conn == nil { + return nil, fmt.Errorf("connection cannot be nil") + } + + return &module{ + client: types.NewQueryClient(conn), + }, nil +} + +// GetAction fetches an action by ID +func (m *module) GetAction(ctx context.Context, actionID string) (*types.QueryGetActionResponse, error) { + resp, err := m.client.GetAction(ctx, &types.QueryGetActionRequest{ + ActionID: actionID, + }) + if err != nil { + return nil, fmt.Errorf("failed to get action: %w", err) + } + + return resp, nil +} + +// GetActionFee calculates fee for processing data with given size +func (m *module) GetActionFee(ctx context.Context, dataSize string) (*types.QueryGetActionFeeResponse, error) { + resp, err := m.client.GetActionFee(ctx, &types.QueryGetActionFeeRequest{ + DataSize: dataSize, + }) + if err != nil { + return nil, fmt.Errorf("failed to get action fee: %w", err) + } + + return resp, nil +} diff --git a/lumera/modules/action/interface.go b/lumera/modules/action/interface.go new file mode 100644 index 00000000..844d80c3 --- /dev/null +++ b/lumera/modules/action/interface.go @@ -0,0 +1,19 @@ +package action + +import ( + "context" + + "github.com/LumeraProtocol/lumera/x/action/types" + "google.golang.org/grpc" +) + +// Module defines the interface for interacting with the action module +type Module interface { + GetAction(ctx context.Context, actionID string) (*types.QueryGetActionResponse, error) + GetActionFee(ctx context.Context, dataSize string) (*types.QueryGetActionFeeResponse, error) +} + +// NewModule creates a new Action module client +func NewModule(conn *grpc.ClientConn) (Module, error) { + return newModule(conn) +} diff --git a/lumera/modules/node/impl.go b/lumera/modules/node/impl.go new file mode 100644 index 00000000..e1d9deea --- /dev/null +++ b/lumera/modules/node/impl.go @@ -0,0 +1,89 @@ +package node + +import ( + "context" + "fmt" + + cmtservice "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" + "google.golang.org/grpc" +) + +// module implements the Module interface +type module struct { + client cmtservice.ServiceClient +} + +// newModule creates a new Node module client +func newModule(conn *grpc.ClientConn) (Module, error) { + if conn == nil { + return nil, fmt.Errorf("connection cannot be nil") + } + + return &module{ + client: cmtservice.NewServiceClient(conn), + }, nil +} + +// GetLatestBlock gets the latest block information +func (m *module) GetLatestBlock(ctx context.Context) (*cmtservice.GetLatestBlockResponse, error) { + resp, err := m.client.GetLatestBlock(ctx, &cmtservice.GetLatestBlockRequest{}) + if err != nil { + return nil, fmt.Errorf("failed to get latest block: %w", err) + } + + return resp, nil +} + +// GetBlockByHeight gets block information at a specific height +func (m *module) GetBlockByHeight(ctx context.Context, height int64) (*cmtservice.GetBlockByHeightResponse, error) { + resp, err := m.client.GetBlockByHeight(ctx, &cmtservice.GetBlockByHeightRequest{ + Height: height, + }) + if err != nil { + return nil, fmt.Errorf("failed to get block at height %d: %w", height, err) + } + + return resp, nil +} + +// GetNodeInfo gets information about the node +func (m *module) GetNodeInfo(ctx context.Context) (*cmtservice.GetNodeInfoResponse, error) { + resp, err := m.client.GetNodeInfo(ctx, &cmtservice.GetNodeInfoRequest{}) + if err != nil { + return nil, fmt.Errorf("failed to get node info: %w", err) + } + + return resp, nil +} + +// GetSyncing returns syncing state of the node +func (m *module) GetSyncing(ctx context.Context) (*cmtservice.GetSyncingResponse, error) { + resp, err := m.client.GetSyncing(ctx, &cmtservice.GetSyncingRequest{}) + if err != nil { + return nil, fmt.Errorf("failed to get syncing status: %w", err) + } + + return resp, nil +} + +// GetLatestValidatorSet gets the latest validator set +func (m *module) GetLatestValidatorSet(ctx context.Context) (*cmtservice.GetLatestValidatorSetResponse, error) { + resp, err := m.client.GetLatestValidatorSet(ctx, &cmtservice.GetLatestValidatorSetRequest{}) + if err != nil { + return nil, fmt.Errorf("failed to get latest validator set: %w", err) + } + + return resp, nil +} + +// GetValidatorSetByHeight gets the validator set at a specific height +func (m *module) GetValidatorSetByHeight(ctx context.Context, height int64) (*cmtservice.GetValidatorSetByHeightResponse, error) { + resp, err := m.client.GetValidatorSetByHeight(ctx, &cmtservice.GetValidatorSetByHeightRequest{ + Height: height, + }) + if err != nil { + return nil, fmt.Errorf("failed to get validator set at height %d: %w", height, err) + } + + return resp, nil +} diff --git a/lumera/modules/node/interface.go b/lumera/modules/node/interface.go new file mode 100644 index 00000000..0694e2af --- /dev/null +++ b/lumera/modules/node/interface.go @@ -0,0 +1,34 @@ +package node + +import ( + "context" + + cmtservice "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" + "google.golang.org/grpc" +) + +// Module defines the interface for interacting with node status information +type Module interface { + // GetLatestBlock gets the latest block information + GetLatestBlock(ctx context.Context) (*cmtservice.GetLatestBlockResponse, error) + + // GetBlockByHeight gets block information at a specific height + GetBlockByHeight(ctx context.Context, height int64) (*cmtservice.GetBlockByHeightResponse, error) + + // GetNodeInfo gets information about the node + GetNodeInfo(ctx context.Context) (*cmtservice.GetNodeInfoResponse, error) + + // GetSyncing returns syncing state of the node + GetSyncing(ctx context.Context) (*cmtservice.GetSyncingResponse, error) + + // GetLatestValidatorSet gets the latest validator set + GetLatestValidatorSet(ctx context.Context) (*cmtservice.GetLatestValidatorSetResponse, error) + + // GetValidatorSetByHeight gets the validator set at a specific height + GetValidatorSetByHeight(ctx context.Context, height int64) (*cmtservice.GetValidatorSetByHeightResponse, error) +} + +// NewModule creates a new Node module client +func NewModule(conn *grpc.ClientConn) (Module, error) { + return newModule(conn) +} diff --git a/lumera/modules/supernode/impl.go.go b/lumera/modules/supernode/impl.go.go new file mode 100644 index 00000000..b31d52c6 --- /dev/null +++ b/lumera/modules/supernode/impl.go.go @@ -0,0 +1,49 @@ +package supernode + +import ( + "context" + "fmt" + + "github.com/LumeraProtocol/lumera/x/supernode/types" + "google.golang.org/grpc" +) + +// module implements the Module interface +type module struct { + client types.QueryClient +} + +// newModule creates a new SuperNode module client +func newModule(conn *grpc.ClientConn) (Module, error) { + if conn == nil { + return nil, fmt.Errorf("connection cannot be nil") + } + + return &module{ + client: types.NewQueryClient(conn), + }, nil +} + +// GetTopSuperNodesForBlock gets the top supernodes for a specific block height +func (m *module) GetTopSuperNodesForBlock(ctx context.Context, blockHeight uint64) (*types.QueryGetTopSuperNodesForBlockResponse, error) { + resp, err := m.client.GetTopSuperNodesForBlock(ctx, &types.QueryGetTopSuperNodesForBlockRequest{ + BlockHeight: int32(blockHeight), + }) + if err != nil { + return nil, fmt.Errorf("failed to get top supernodes: %w", err) + } + + return resp, nil +} + +// GetSuperNode gets a supernode by account address +func (m *module) GetSuperNode(ctx context.Context, address string) (*types.QueryGetSuperNodeResponse, error) { + resp, err := m.client.GetSuperNode(ctx, &types.QueryGetSuperNodeRequest{ + ValidatorAddress: address, + }) + if err != nil { + return nil, fmt.Errorf("failed to get supernode: %w", err) + } + + return resp, nil +} diff --git a/lumera/modules/supernode/interface.go b/lumera/modules/supernode/interface.go new file mode 100644 index 00000000..37e57b12 --- /dev/null +++ b/lumera/modules/supernode/interface.go @@ -0,0 +1,19 @@ +package supernode + +import ( + "context" + + "github.com/LumeraProtocol/lumera/x/supernode/types" + "google.golang.org/grpc" +) + +// Module defines the interface for interacting with the supernode module +type Module interface { + GetTopSuperNodesForBlock(ctx context.Context, blockHeight uint64) (*types.QueryGetTopSuperNodesForBlockResponse, error) + GetSuperNode(ctx context.Context, address string) (*types.QueryGetSuperNodeResponse, error) +} + +// NewModule creates a new SuperNode module client +func NewModule(conn *grpc.ClientConn) (Module, error) { + return newModule(conn) +} diff --git a/lumera/modules/tx/impl.go.go b/lumera/modules/tx/impl.go.go new file mode 100644 index 00000000..caca4889 --- /dev/null +++ b/lumera/modules/tx/impl.go.go @@ -0,0 +1,68 @@ +package tx + +import ( + "context" + "fmt" + + sdktx "github.com/cosmos/cosmos-sdk/types/tx" + "google.golang.org/grpc" +) + +// module implements the Module interface +type module struct { + client sdktx.ServiceClient +} + +// newModule creates a new Transaction module client +func newModule(conn *grpc.ClientConn) (Module, error) { + if conn == nil { + return nil, fmt.Errorf("connection cannot be nil") + } + + return &module{ + client: sdktx.NewServiceClient(conn), + }, nil +} + +// BroadcastTx broadcasts a signed transaction +func (m *module) BroadcastTx(ctx context.Context, txBytes []byte, mode sdktx.BroadcastMode) (*sdktx.BroadcastTxResponse, error) { + req := &sdktx.BroadcastTxRequest{ + TxBytes: txBytes, + Mode: mode, + } + + resp, err := m.client.BroadcastTx(ctx, req) + if err != nil { + return nil, fmt.Errorf("failed to broadcast transaction: %w", err) + } + + return resp, nil +} + +// SimulateTx simulates a transaction +func (m *module) SimulateTx(ctx context.Context, txBytes []byte) (*sdktx.SimulateResponse, error) { + req := &sdktx.SimulateRequest{ + TxBytes: txBytes, + } + + resp, err := m.client.Simulate(ctx, req) + if err != nil { + return nil, fmt.Errorf("failed to simulate transaction: %w", err) + } + + return resp, nil +} + +// GetTx gets transaction by hash +func (m *module) GetTx(ctx context.Context, hash string) (*sdktx.GetTxResponse, error) { + req := &sdktx.GetTxRequest{ + Hash: hash, + } + + resp, err := m.client.GetTx(ctx, req) + if err != nil { + return nil, fmt.Errorf("failed to get transaction: %w", err) + } + + return resp, nil +} diff --git a/lumera/modules/tx/interface.go b/lumera/modules/tx/interface.go new file mode 100644 index 00000000..b5502c20 --- /dev/null +++ b/lumera/modules/tx/interface.go @@ -0,0 +1,25 @@ +package tx + +import ( + "context" + + sdktx "github.com/cosmos/cosmos-sdk/types/tx" + "google.golang.org/grpc" +) + +// Module defines the interface for transaction-related operations +type Module interface { + // BroadcastTx broadcasts a signed transaction + BroadcastTx(ctx context.Context, txBytes []byte, mode sdktx.BroadcastMode) (*sdktx.BroadcastTxResponse, error) + + // SimulateTx simulates a transaction + SimulateTx(ctx context.Context, txBytes []byte) (*sdktx.SimulateResponse, error) + + // GetTx gets transaction by hash + GetTx(ctx context.Context, hash string) (*sdktx.GetTxResponse, error) +} + +// NewModule creates a new Transaction module client +func NewModule(conn *grpc.ClientConn) (Module, error) { + return newModule(conn) +} diff --git a/lumera/options.go b/lumera/options.go new file mode 100644 index 00000000..862194ac --- /dev/null +++ b/lumera/options.go @@ -0,0 +1,25 @@ +package lumera + +// Option is a function that applies a change to Config +type Option func(*Config) + +// WithGRPCAddr sets the gRPC endpoint address +func WithGRPCAddr(addr string) Option { + return func(c *Config) { + c.GRPCAddr = addr + } +} + +// WithChainID sets the chain ID +func WithChainID(chainID string) Option { + return func(c *Config) { + c.ChainID = chainID + } +} + +// WithTimeout sets the default timeout +func WithTimeout(seconds int) Option { + return func(c *Config) { + c.Timeout = seconds + } +} diff --git a/pkg/lumera/action/client.go b/pkg/lumera/action/client.go deleted file mode 100644 index 8ace206a..00000000 --- a/pkg/lumera/action/client.go +++ /dev/null @@ -1,35 +0,0 @@ -package action - -import ( - "context" - "fmt" - - "google.golang.org/grpc" - - lumeraaction "github.com/LumeraProtocol/lumera/x/action/types" -) - -type Client struct { - conn *grpc.ClientConn - actionService lumeraaction.QueryClient -} - -type Service interface { - GetAction(ctx context.Context, r GetActionRequest) (Action, error) -} - -func NewClient(serverAddr string) (Service, error) { - conn, err := grpc.Dial(serverAddr, grpc.WithInsecure(), grpc.WithBlock()) - if err != nil { - return nil, fmt.Errorf("failed to connect to gRPC server: %w", err) - } - - return &Client{ - conn: conn, - actionService: lumeraaction.NewQueryClient(conn), - }, nil -} - -func (c *Client) Close() { - c.conn.Close() -} diff --git a/pkg/lumera/action/get_action.go b/pkg/lumera/action/get_action.go deleted file mode 100644 index 708831ae..00000000 --- a/pkg/lumera/action/get_action.go +++ /dev/null @@ -1,139 +0,0 @@ -package action - -import ( - "context" - "fmt" - - lumeraaction "github.com/LumeraProtocol/lumera/x/action/types" - "github.com/LumeraProtocol/supernode/pkg/logtrace" - "github.com/LumeraProtocol/supernode/pkg/net" -) - -type ActionState int32 -type ActionType string - -const ( - ActionStateUnspecified ActionState = 0 - ActionStatePending ActionState = 1 - ActionStateDone ActionState = 2 - ActionStateApproved ActionState = 3 - ActionStateRejected ActionState = 4 - ActionStateFailed ActionState = 5 - - CascadeActionType ActionType = "cascade" - SenseActionType ActionType = "sense" -) - -type GetActionRequest struct { - ActionID string - Type ActionType -} - -type Action struct { - Creator string - ActionID string - Metadata *Metadata - Price string - ExpirationTime string - BlockHeight int64 - State ActionState -} - -type Metadata struct { - SenseMetadata - CascadeMetadata -} - -type SenseMetadata struct { - DataHash string - DdAndFingerprintsIc int32 - DdAndFingerprintsMax int32 - DdAndFingerprintsIds []string -} - -type CascadeMetadata struct { - DataHash string - FileName string - RqIds []string - RqMax int32 - RqIc int32 - RqOti []byte -} - -func (c *Client) GetAction(ctx context.Context, r GetActionRequest) (Action, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "GetAction", - logtrace.FieldModule: logtrace.ValueLumeraSDK, - logtrace.FieldRequest: r, - } - logtrace.Info(ctx, "fetching action details", fields) - - resp, err := c.actionService.GetAction(ctx, &lumeraaction.QueryGetActionRequest{ - ActionID: r.ActionID, - }) - if err != nil { - fields[logtrace.FieldError] = err.Error() - logtrace.Error(ctx, "failed to fetch action detail", fields) - return Action{}, fmt.Errorf("failed to fetch action: %w", err) - } - - logtrace.Info(ctx, "successfully fetched the action details", fields) - - return toAction(resp), nil -} - -func toAction(ac *lumeraaction.QueryGetActionResponse) Action { - var meta *Metadata - switch x := ac.Action.Metadata.MetadataType.(type) { - case *lumeraaction.Metadata_SenseMetadata: - meta = &Metadata{ - SenseMetadata: SenseMetadata{ - DataHash: x.SenseMetadata.DataHash, - DdAndFingerprintsIc: x.SenseMetadata.DdAndFingerprintsIc, - DdAndFingerprintsMax: x.SenseMetadata.DdAndFingerprintsMax, - DdAndFingerprintsIds: x.SenseMetadata.DdAndFingerprintsIds, - }, - } - case *lumeraaction.Metadata_CascadeMetadata: - meta = &Metadata{ - CascadeMetadata: CascadeMetadata{ - DataHash: x.CascadeMetadata.DataHash, - FileName: x.CascadeMetadata.FileName, - RqIds: x.CascadeMetadata.RqIds, - RqMax: x.CascadeMetadata.RqMax, - RqIc: x.CascadeMetadata.RqIc, - RqOti: x.CascadeMetadata.RqOti, - }, - } - default: - meta = nil - } - - return Action{ - Creator: ac.Action.Creator, - ActionID: ac.Action.ActionID, - Metadata: meta, - Price: ac.Action.Price, - ExpirationTime: ac.Action.ExpirationTime, - BlockHeight: ac.Action.BlockHeight, - State: ActionState(ac.Action.State), - } -} - -func (m *Metadata) GetCascadeMetadata() *CascadeMetadata { - if m != nil { - return &m.CascadeMetadata - } - - return nil -} - -func (m *Metadata) GetSenseMetadata() *SenseMetadata { - if m != nil { - return &m.SenseMetadata - } - - return nil -} diff --git a/pkg/lumera/broadcast_tx.go b/pkg/lumera/broadcast_tx.go deleted file mode 100644 index 12c228c7..00000000 --- a/pkg/lumera/broadcast_tx.go +++ /dev/null @@ -1,64 +0,0 @@ -package lumera - -import ( - "context" - "fmt" - "github.com/LumeraProtocol/supernode/pkg/net" - - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/LumeraProtocol/supernode/pkg/logtrace" -) - -type BroadcastMode string - -const ( - BroadcastModeSync BroadcastMode = "sync" - BroadcastModeAsync BroadcastMode = "async" - BroadcastModeBlock BroadcastMode = "block" -) - -type BroadcastRequest struct { - TxBytes []byte `json:"tx_bytes"` - Mode BroadcastMode `json:"mode"` -} - -type BroadcastResponse struct { - TxHash string `json:"tx_hash"` -} - -func (c *Client) BroadcastTx(ctx context.Context, req BroadcastRequest) (BroadcastResponse, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "Broadcast", - logtrace.FieldModule: logtrace.ValueTransaction, - logtrace.FieldRequest: req, - } - logtrace.Info(ctx, "broadcasting tx", fields) - - res, err := c.txClient.BroadcastTx(ctx, &tx.BroadcastTxRequest{ - TxBytes: req.TxBytes, - Mode: req.Mode.toTxBroadcastMode(), - }) - if err != nil { - fields[logtrace.FieldError] = err.Error() - return BroadcastResponse{}, fmt.Errorf("broadcast tx error: %w", err) - } - - logtrace.Info(ctx, "tx broadcasted", fields) - - return BroadcastResponse{TxHash: res.String()}, nil -} - -func (m BroadcastMode) toTxBroadcastMode() tx.BroadcastMode { - switch m { - case BroadcastModeAsync: - return tx.BroadcastMode_BROADCAST_MODE_ASYNC - case BroadcastModeSync: - return tx.BroadcastMode_BROADCAST_MODE_SYNC - case BroadcastModeBlock: - return tx.BroadcastMode_BROADCAST_MODE_BLOCK - default: - return tx.BroadcastMode_BROADCAST_MODE_ASYNC - } -} diff --git a/pkg/lumera/client.go b/pkg/lumera/client.go deleted file mode 100644 index e7dc3121..00000000 --- a/pkg/lumera/client.go +++ /dev/null @@ -1,90 +0,0 @@ -package lumera - -import ( - "context" - - tendermintv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/types/tx" - ltc "github.com/LumeraProtocol/supernode/pkg/net/credentials" -) - -type DummyClient interface { - MasterNodesExtra(ctx context.Context) (SuperNodeAddressInfos, error) - MasterNodesTop(ctx context.Context) (SuperNodeAddressInfos, error) - Sign(ctx context.Context, data []byte, pastelID string, passphrase string, algorithm string) (signature string, err error) - Verify(ctx context.Context, data []byte, signature string, pastelID string, algorithm string) (bool, error) -} - -type Client struct { - cosmosSdk client.Context - txClient tx.ServiceClient - tendermintClient tendermintv1beta1.ServiceClient -} - -type CosmosBase interface { - GetLatestBlock(ctx context.Context) (Block, error) - GetBlockByHeight(ctx context.Context, height int64) (Block, error) - BroadcastTx(ctx context.Context, req BroadcastRequest) (BroadcastResponse, error) - GetTx(ctx context.Context, req GetTxRequest) (GetTxResponse, error) -} - -func NewTendermintClient(opts ...Option) (CosmosBase, error) { - c := &Client{} - - // Apply all options to the client context - c.WithOptions(opts...) - - return c, nil -} - -func (c *Client) GetKeyring() keyring.Keyring { - return c.cosmosSdk.Keyring -} - -type SuperNodeAddressInfo struct { - ExtKey string - ExtAddress string - ExtP2P string -} - -type SuperNodeAddressInfos []SuperNodeAddressInfo - -type LumeraNetwork struct { - nodes SuperNodeAddressInfos // list of SuperNodes address info -} - -// NewLumeraNetwork creates a new mock client with pre-configured nodes -func NewLumeraNetwork(nodeConfig ltc.LumeraAddresses) *LumeraNetwork { - nodes := make([]SuperNodeAddressInfo, len(nodeConfig)) - for i, cfg := range nodeConfig { - nodes[i] = SuperNodeAddressInfo{ - ExtKey: cfg.Identity, // LumeraID of the node - ExtAddress: cfg.HostPort(), // IP:Port for general communication - ExtP2P: cfg.HostPort(), // Same address for P2P - in real network this might be different - } - } - - return &LumeraNetwork{ - nodes: nodes, - } -} - -func (m *LumeraNetwork) MasterNodesExtra(ctx context.Context) (SuperNodeAddressInfos, error) { - return m.nodes, nil -} - -func (m *LumeraNetwork) MasterNodesTop(ctx context.Context) (SuperNodeAddressInfos, error) { - return m.nodes, nil -} - -func (m *LumeraNetwork) Sign(_ context.Context, _ []byte, _ string, _ string, _ string) (string, error) { - // For demo, just return a dummy signature - return "dummy-signature", nil -} - -func (m *LumeraNetwork) Verify(_ context.Context, _ []byte, _ string, _ string, _ string) (bool, error) { - // For demo, always verify as true - return true, nil -} diff --git a/pkg/lumera/get_block_by_height.go b/pkg/lumera/get_block_by_height.go deleted file mode 100644 index b2d7fd99..00000000 --- a/pkg/lumera/get_block_by_height.go +++ /dev/null @@ -1,62 +0,0 @@ -package lumera - -import ( - "context" - "fmt" - - "github.com/LumeraProtocol/supernode/pkg/logtrace" - "github.com/LumeraProtocol/supernode/pkg/net" - - "cosmossdk.io/api/tendermint/types" - - tendermintv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1" -) - -func (c *Client) GetBlockByHeight(ctx context.Context, height int64) (Block, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "GetBlockByHeight", - logtrace.FieldModule: logtrace.ValueBaseTendermint, - logtrace.FieldBlockHeight: height, - } - logtrace.Info(ctx, "fetching block by given height", fields) - - res, err := c.tendermintClient.GetBlockByHeight(ctx, &tendermintv1beta1.GetBlockByHeightRequest{ - Height: height, - }) - if err != nil { - fields[logtrace.FieldError] = err.Error() - return Block{}, fmt.Errorf("error fetching block by height: %w", err) - } - - logtrace.Info(ctx, "block details retrieved", fields) - - return toBlock(res), nil -} - -func toBlock(b interface{}) Block { - var h *tendermintv1beta1.Header - var blockID *types.BlockID - - switch v := b.(type) { - case *tendermintv1beta1.GetLatestBlockResponse: - h = v.GetSdkBlock().GetHeader() - blockID = v.BlockId - case *tendermintv1beta1.GetBlockByHeightResponse: - h = v.GetSdkBlock().GetHeader() - blockID = v.BlockId - default: - panic("toBlock: unexpected type provided") - } - - return Block{ - Height: h.Height, - Hash: blockID.Hash, - LastBlockHash: h.LastBlockId.Hash, - ChainID: h.ChainId, - DataHash: h.DataHash, - AppHash: h.AppHash, - Version: fmt.Sprintf("Block Protocol: %v, App: %v", h.Version.Block, h.Version.App), - } -} diff --git a/pkg/lumera/get_latest_block.go b/pkg/lumera/get_latest_block.go deleted file mode 100644 index 9629013c..00000000 --- a/pkg/lumera/get_latest_block.go +++ /dev/null @@ -1,41 +0,0 @@ -package lumera - -import ( - "context" - "fmt" - "github.com/LumeraProtocol/supernode/pkg/logtrace" - "github.com/LumeraProtocol/supernode/pkg/net" - - tendermintv1beta1 "cosmossdk.io/api/cosmos/base/tendermint/v1beta1" -) - -type Block struct { - Height int64 `json:"height"` - ChainID string `json:"chain_id"` - Version string `json:"version"` - - Hash []byte `json:"block_hash"` - LastBlockHash []byte `json:"last_block_hash"` - DataHash []byte `json:"data_hash"` - AppHash []byte `json:"app_hash"` -} - -func (c *Client) GetLatestBlock(ctx context.Context) (Block, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "GetLatestBlock", - logtrace.FieldModule: logtrace.ValueBaseTendermint, - } - logtrace.Info(ctx, "fetching latest block", fields) - - res, err := c.tendermintClient.GetLatestBlock(ctx, &tendermintv1beta1.GetLatestBlockRequest{}) - if err != nil { - fields[logtrace.FieldError] = err.Error() - return Block{}, fmt.Errorf("error fetching latest block: %w", err) - } - - logtrace.Info(ctx, "block details retrieved", fields) - - return toBlock(res), nil -} diff --git a/pkg/lumera/get_tx.go b/pkg/lumera/get_tx.go deleted file mode 100644 index 9765761b..00000000 --- a/pkg/lumera/get_tx.go +++ /dev/null @@ -1,75 +0,0 @@ -package lumera - -import ( - "context" - "fmt" - - "github.com/cosmos/cosmos-sdk/types/tx" - - "github.com/LumeraProtocol/supernode/pkg/logtrace" - "github.com/LumeraProtocol/supernode/pkg/net" -) - -type GetTxRequest struct { - TxHash string `json:"tx_hash"` -} - -type TxResponse struct { - Height int64 `json:"height,omitempty"` - TxHash string `json:"txhash,omitempty"` - Codespace string `json:"codespace,omitempty"` - Code uint32 `json:"code,omitempty"` - Data string `json:"data,omitempty"` - RawLog string `json:"raw_log,omitempty"` - Info string `json:"info,omitempty"` - GasWanted int64 `json:"gas_wanted,omitempty"` - GasUsed int64 `json:"gas_used,omitempty"` - Tx []byte `json:"tx,omitempty"` - Timestamp string `json:"timestamp,omitempty"` -} - -// GetTxResponse is the response type for the Service.GetTx method. -type GetTxResponse struct { - Tx *tx.Tx `json:"tx,omitempty"` - TxResponse *TxResponse `json:"tx_response,omitempty"` -} - -func (c *Client) GetTx(ctx context.Context, req GetTxRequest) (GetTxResponse, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "GetTx", - logtrace.FieldModule: logtrace.ValueTransaction, - logtrace.FieldRequest: req, - } - logtrace.Info(ctx, "fetching tx", fields) - - res, err := c.txClient.GetTx(ctx, &tx.GetTxRequest{ - Hash: req.TxHash, - }) - if err != nil { - fields[logtrace.FieldError] = err.Error() - return GetTxResponse{}, fmt.Errorf("error fetching tx: %w", err) - } - - logtrace.Info(ctx, "tx retrieved", fields) - - return toGetTxResponse(res), nil -} - -func toGetTxResponse(sdkResp *tx.GetTxResponse) GetTxResponse { - return GetTxResponse{ - TxResponse: &TxResponse{ - Height: sdkResp.TxResponse.Height, - TxHash: sdkResp.TxResponse.TxHash, - Codespace: sdkResp.TxResponse.Codespace, - Code: sdkResp.TxResponse.Code, - Data: sdkResp.TxResponse.Data, - RawLog: sdkResp.TxResponse.RawLog, - Info: sdkResp.TxResponse.Info, - GasWanted: sdkResp.TxResponse.GasWanted, - GasUsed: sdkResp.TxResponse.GasUsed, - Timestamp: sdkResp.TxResponse.Timestamp, - }, - } -} diff --git a/pkg/lumera/options.go b/pkg/lumera/options.go deleted file mode 100644 index 8bcbca61..00000000 --- a/pkg/lumera/options.go +++ /dev/null @@ -1,36 +0,0 @@ -package lumera - -import ( - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "google.golang.org/grpc" -) - -// Example usage: -// -// client, err := NewTendermintClient( -// WithKeyring(myKeyring), -// WithTxClient(myConnection), -// ) - -// Option defines the functional option signature -type Option func(c *Client) - -func (c *Client) WithOptions(opts ...Option) { - for _, opt := range opts { - opt(c) - } -} - -func WithTxClient(conn *grpc.ClientConn) Option { - return func(c *Client) { - c.txClient = tx.NewServiceClient(conn) - } -} - -func WithKeyring(kr keyring.Keyring) Option { - return func(c *Client) { - c.cosmosSdk.Keyring = kr - } -} - diff --git a/pkg/lumera/sign.go b/pkg/lumera/sign.go deleted file mode 100644 index 57330d91..00000000 --- a/pkg/lumera/sign.go +++ /dev/null @@ -1,31 +0,0 @@ -package lumera - -import ( - "context" - "fmt" - - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/types" -) - -func (c *Client) Sign(ctx context.Context, senderName string, msgs []types.Msg) ([]byte, error) { - txf := tx.Factory{}. - WithKeybase(c.cosmosSdk.Keyring). - WithChainID(c.cosmosSdk.ChainID) - - txBuilder, err := txf.BuildUnsignedTx(msgs...) - if err != nil { - return nil, fmt.Errorf("build tx error: %w", err) - } - - if err := tx.Sign(ctx, txf, senderName, txBuilder, true); err != nil { - return nil, fmt.Errorf("sign tx error: %w", err) - } - - txBytes, err := c.cosmosSdk.TxConfig.TxEncoder()(txBuilder.GetTx()) - if err != nil { - return nil, fmt.Errorf("encode tx error: %w", err) - } - - return txBytes, nil -} diff --git a/pkg/lumera/supernode/client.go b/pkg/lumera/supernode/client.go deleted file mode 100644 index 903c332f..00000000 --- a/pkg/lumera/supernode/client.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:generate mockgen -destination=supernode_mock.go -package=supernode -source=client.go - -package supernode - -import ( - "context" - "fmt" - - "google.golang.org/grpc" - - lumerasn "github.com/LumeraProtocol/lumera/x/supernode/types" -) - -type Client struct { - conn *grpc.ClientConn - supernodeService lumerasn.QueryClient -} - -type Service interface { - GetTopSNsByBlockHeight(ctx context.Context, r GetTopSupernodesForBlockRequest) (GetTopSupernodesForBlockResponse, error) - GetSupernodeByAddress(ctx context.Context, r GetSupernodeRequest) (lumerasn.SuperNode, error) -} - -func NewClient(serverAddr string) (Service, error) { - conn, err := grpc.Dial(serverAddr, grpc.WithInsecure(), grpc.WithBlock()) - if err != nil { - return nil, fmt.Errorf("failed to connect to gRPC server: %w", err) - } - - return &Client{ - conn: conn, - supernodeService: lumerasn.NewQueryClient(conn), - }, nil -} - -func (c *Client) Close() { - c.conn.Close() -} diff --git a/pkg/lumera/supernode/get_sn_by_address.go b/pkg/lumera/supernode/get_sn_by_address.go deleted file mode 100644 index fbf764fe..00000000 --- a/pkg/lumera/supernode/get_sn_by_address.go +++ /dev/null @@ -1,49 +0,0 @@ -package supernode - -import ( - "context" - "fmt" - - . "github.com/LumeraProtocol/lumera/x/supernode/types" - "github.com/LumeraProtocol/supernode/pkg/logtrace" - "github.com/LumeraProtocol/supernode/pkg/net" -) - -type GetSupernodeRequest struct { - ValidatorAddress string -} - -func (c *Client) GetSupernodeByAddress(ctx context.Context, r GetSupernodeRequest) (SuperNode, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "GetSupernodeByAddress", - logtrace.FieldModule: logtrace.ValueLumeraSDK, - logtrace.FieldRequest: r, - } - logtrace.Info(ctx, "fetching supernode details", fields) - - resp, err := c.supernodeService.GetSuperNode(ctx, &QueryGetSuperNodeRequest{ - ValidatorAddress: r.ValidatorAddress, - }) - if err != nil { - fields[logtrace.FieldError] = err.Error() - logtrace.Error(ctx, "failed to fetch supernode detail", fields) - return SuperNode{}, fmt.Errorf("failed to fetch lumera: %w", err) - } - - logtrace.Info(ctx, "successfully fetched the supernode details", fields) - - return toSupernode(resp), nil -} - -func toSupernode(sn *QueryGetSuperNodeResponse) SuperNode { - return SuperNode{ValidatorAddress: sn.Supernode.ValidatorAddress, - States: mapStates(sn.Supernode.States), - Evidence: mapEvidence(sn.Supernode.Evidence), - PrevIpAddresses: mapIPAddressHistory(sn.Supernode.PrevIpAddresses), - Version: sn.Supernode.Version, - Metrics: mapMetrics(sn.Supernode.Metrics), - SupernodeAccount: sn.Supernode.SupernodeAccount, - } -} diff --git a/pkg/lumera/supernode/get_top_sns.go b/pkg/lumera/supernode/get_top_sns.go deleted file mode 100644 index 2af3a95d..00000000 --- a/pkg/lumera/supernode/get_top_sns.go +++ /dev/null @@ -1,128 +0,0 @@ -package supernode - -import ( - "context" - "fmt" - - . "github.com/LumeraProtocol/lumera/x/supernode/types" - "github.com/LumeraProtocol/supernode/pkg/logtrace" - "github.com/LumeraProtocol/supernode/pkg/net" -) - -type Supernodes []SuperNode - -type GetTopSupernodesForBlockRequest struct { - BlockHeight int32 `json:"block_height"` - Limit int32 `json:"limit"` - State SuperNodeState `json:"state"` -} - -type GetTopSupernodesForBlockResponse struct { - Supernodes Supernodes -} - -func (c *Client) GetTopSNsByBlockHeight(ctx context.Context, r GetTopSupernodesForBlockRequest) (GetTopSupernodesForBlockResponse, error) { - ctx = net.AddCorrelationID(ctx) - - fields := logtrace.Fields{ - logtrace.FieldMethod: "GetTopSNsByBlockHeight", - logtrace.FieldModule: logtrace.ValueLumeraSDK, - logtrace.FieldBlockHeight: r.BlockHeight, - logtrace.FieldLimit: r.Limit, - logtrace.FieldSupernodeState: r.State, - } - logtrace.Info(ctx, "fetching top supernodes for block", fields) - - resp, err := c.supernodeService.GetTopSuperNodesForBlock(ctx, &QueryGetTopSuperNodesForBlockRequest{ - BlockHeight: r.BlockHeight, - Limit: r.Limit, - State: r.State.String(), - }) - if err != nil { - fields[logtrace.FieldError] = err.Error() - logtrace.Error(ctx, "failed to fetch top supernodes", fields) - return GetTopSupernodesForBlockResponse{}, fmt.Errorf("failed to fetch lumera: %w", err) - } - - logtrace.Info(ctx, "successfully fetched top supernodes", fields) - return toGetTopSNsForBlockResponse(resp), nil -} - -func toGetTopSNsForBlockResponse(response *QueryGetTopSuperNodesForBlockResponse) GetTopSupernodesForBlockResponse { - var sns Supernodes - - for _, sn := range response.Supernodes { - sns = append(sns, SuperNode{ - ValidatorAddress: sn.ValidatorAddress, - States: mapStates(sn.States), - Evidence: mapEvidence(sn.Evidence), - PrevIpAddresses: mapIPAddressHistory(sn.PrevIpAddresses), - Version: sn.Version, - Metrics: mapMetrics(sn.Metrics), - SupernodeAccount: sn.SupernodeAccount, - }) - } - - return GetTopSupernodesForBlockResponse{ - Supernodes: sns, - } -} - -// Helper function to map repeated SuperNodeStateRecord -func mapStates(states []*SuperNodeStateRecord) []*SuperNodeStateRecord { - var stateRecords []*SuperNodeStateRecord - for _, state := range states { - stateRecords = append(stateRecords, &SuperNodeStateRecord{ - State: SuperNodeState(state.State), - Height: state.Height, - }) - } - return stateRecords -} - -// Helper function to map repeated Evidence -func mapEvidence(evidences []*Evidence) []*Evidence { - var evidenceList []*Evidence - for _, ev := range evidences { - evidenceList = append(evidenceList, &Evidence{ - ReporterAddress: ev.ReporterAddress, - ValidatorAddress: ev.ValidatorAddress, - ActionId: ev.ActionId, - EvidenceType: ev.EvidenceType, - Description: ev.Description, - Severity: ev.Severity, - Height: ev.Height, - }) - } - return evidenceList -} - -// Helper function to map repeated IPAddressHistory -func mapIPAddressHistory(addresses []*IPAddressHistory) []*IPAddressHistory { - var ipHistory []*IPAddressHistory - for _, addr := range addresses { - ipHistory = append(ipHistory, &IPAddressHistory{ - Address: addr.Address, - Height: addr.Height, - }) - } - return ipHistory -} - -// Helper function to map MetricsAggregate -func mapMetrics(metrics *MetricsAggregate) *MetricsAggregate { - if metrics == nil { - return &MetricsAggregate{} - } - - convertedMetrics := make(map[string]float64) - for key, val := range metrics.Metrics { - convertedMetrics[key] = val - } - - return &MetricsAggregate{ - Metrics: convertedMetrics, - ReportCount: metrics.ReportCount, - Height: metrics.Height, - } -} diff --git a/pkg/lumera/supernode/supernode_mock.go b/pkg/lumera/supernode/supernode_mock.go deleted file mode 100644 index bec4768a..00000000 --- a/pkg/lumera/supernode/supernode_mock.go +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: client.go - -// Package supernode is a generated GoMock package. -package supernode - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockService is a mock of Service interface. -type MockService struct { - ctrl *gomock.Controller - recorder *MockServiceMockRecorder -} - -// MockServiceMockRecorder is the mock recorder for MockService. -type MockServiceMockRecorder struct { - mock *MockService -} - -// NewMockService creates a new mock instance. -func NewMockService(ctrl *gomock.Controller) *MockService { - mock := &MockService{ctrl: ctrl} - mock.recorder = &MockServiceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockService) EXPECT() *MockServiceMockRecorder { - return m.recorder -} - -// GetTopSNsByBlockHeight mocks base method. -func (m *MockService) GetTopSNsByBlockHeight(ctx context.Context, r GetTopSupernodesForBlockRequest) (GetTopSupernodesForBlockResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTopSNsByBlockHeight", ctx, r) - ret0, _ := ret[0].(GetTopSupernodesForBlockResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTopSNsByBlockHeight indicates an expected call of GetTopSNsByBlockHeight. -func (mr *MockServiceMockRecorder) GetTopSNsByBlockHeight(ctx, r interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTopSNsByBlockHeight", reflect.TypeOf((*MockService)(nil).GetTopSNsByBlockHeight), ctx, r) -}