Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions gen/lumera/action/types/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package types

import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
// this line is used by starport scaffolding # 1
)

func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgRequestAction{},
)
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgFinalizeAction{},
)
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgApproveAction{},
)
// this line is used by starport scaffolding # 3

registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgUpdateParams{},
)
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
16 changes: 10 additions & 6 deletions p2p/kademlia/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/LumeraProtocol/supernode/pkg/errors"
"github.com/LumeraProtocol/supernode/pkg/utils"

"github.com/LumeraProtocol/supernode/pkg/log"
ltc "github.com/LumeraProtocol/supernode/pkg/net/credentials"
Expand All @@ -20,21 +21,21 @@ const (
)

func (s *DHT) skipBadBootstrapAddrs() {
skipAddress1 := fmt.Sprintf("%s:%d", "127.0.0.1", s.options.Port)
skipAddress2 := fmt.Sprintf("%s:%d", "localhost", s.options.Port)
s.cache.Set(skipAddress1, []byte("true"))
s.cache.Set(skipAddress2, []byte("true"))
//skipAddress1 := fmt.Sprintf("%s:%d", "127.0.0.1", s.options.Port)
//skipAddress2 := fmt.Sprintf("%s:%d", "localhost", s.options.Port)
//s.cache.Set(skipAddress1, []byte("true"))
//s.cache.Set(skipAddress2, []byte("true"))
}

func (s *DHT) parseNode(extP2P string, selfAddr string) (*Node, error) {
if extP2P == "" {
return nil, errors.New("empty address")
}

if strings.Contains(extP2P, "0.0.0.0") {
/*if strings.Contains(extP2P, "0.0.0.0") {
fmt.Println("skippping node")
return nil, errors.New("invalid address")
}
}*/

if extP2P == selfAddr {
return nil, errors.New("self address")
Expand Down Expand Up @@ -157,6 +158,9 @@ func (s *DHT) ConfigureBootstrapNodes(ctx context.Context, bootstrapNodes string

// Convert the map to a slice
for _, node := range mapNodes {
node.Port = node.Port + 1
hID, _ := utils.Sha3256hash(node.ID)
node.HashedID = hID
fmt.Println("node adding", node.String(), "hashed id", string(node.HashedID))
boostrapNodes = append(boostrapNodes, node)
}
Expand Down
4 changes: 4 additions & 0 deletions p2p/kademlia/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func NewDHT(ctx context.Context, store Store, metaStore MetaStore, options *Opti
return s, nil
}

func (s *DHT) NodesLen() int {
return len(s.ht.nodes())
}

func (s *DHT) getExternalIP() (string, error) {
s.mtx.Lock()
defer s.mtx.Unlock()
Expand Down
11 changes: 4 additions & 7 deletions pkg/log/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ package log

import (
"context"
"io"
"net"
"net/http"

"github.com/LumeraProtocol/supernode/pkg/errors"
"github.com/LumeraProtocol/supernode/pkg/log/hooks"
)

Expand Down Expand Up @@ -56,11 +52,12 @@ func init() {

// GetExternalIPAddress returns external IP address
func GetExternalIPAddress() (externalIP string, err error) {
if ip != "" {
return "localhost", nil
/*if ip != "" {
return ip, nil
}

resp, err := http.Get("http://ipinfo.io/ip")
resp, err := http.Get("https://api.ipify.org")
if err != nil {
return "", err
}
Expand All @@ -76,5 +73,5 @@ func GetExternalIPAddress() (externalIP string, err error) {
return "", errors.Errorf("invalid IP response from %s", "ipconf.ip")
}

return string(body), nil
return string(body), nil*/
}
19 changes: 19 additions & 0 deletions pkg/lumera/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/LumeraProtocol/supernode/pkg/lumera/modules/action"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/action_msg"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/auth"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/node"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/supernode"
Expand All @@ -15,6 +16,7 @@ type lumeraClient struct {
cfg *Config
authMod auth.Module
actionMod action.Module
actionMsgMod action_msg.Module
supernodeMod supernode.Module
txMod tx.Module
nodeMod node.Module
Expand Down Expand Up @@ -49,6 +51,17 @@ func newClient(ctx context.Context, opts ...Option) (Client, error) {
return nil, err
}

actionMsgModule, err := action_msg.NewModule(
conn.GetConn(),
cfg.keyring,
cfg.KeyName,
cfg.ChainID,
)
if err != nil {
conn.Close()
return nil, err
}

supernodeModule, err := supernode.NewModule(conn.GetConn())
if err != nil {
conn.Close()
Expand All @@ -71,6 +84,7 @@ func newClient(ctx context.Context, opts ...Option) (Client, error) {
cfg: cfg,
authMod: authModule,
actionMod: actionModule,
actionMsgMod: actionMsgModule,
supernodeMod: supernodeModule,
txMod: txModule,
nodeMod: nodeModule,
Expand All @@ -88,6 +102,11 @@ func (c *lumeraClient) Action() action.Module {
return c.actionMod
}

// ActionMsg returns the ActionMsg module client
func (c *lumeraClient) ActionMsg() action_msg.Module {
return c.actionMsgMod
}

// SuperNode returns the SuperNode module client
func (c *lumeraClient) SuperNode() supernode.Module {
return c.supernodeMod
Expand Down
6 changes: 5 additions & 1 deletion pkg/lumera/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ type Config struct {

// keyring is the keyring conf for the node sign & verify
keyring keyring.Keyring

// KeyName is the name of the key to use for signing
KeyName string
}

// DefaultConfig returns a default configuration
func DefaultConfig() *Config {
return &Config{
GRPCAddr: "localhost:9090",
ChainID: "lumera",
Timeout: 10,
Timeout: 30,
KeyName: "",
}
}
2 changes: 2 additions & 0 deletions pkg/lumera/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"

"github.com/LumeraProtocol/supernode/pkg/lumera/modules/action"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/action_msg"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/auth"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/node"
"github.com/LumeraProtocol/supernode/pkg/lumera/modules/supernode"
Expand All @@ -15,6 +16,7 @@ import (
type Client interface {
Auth() auth.Module
Action() action.Module
ActionMsg() action_msg.Module
SuperNode() supernode.Module
Tx() tx.Module
Node() node.Module
Expand Down
10 changes: 10 additions & 0 deletions pkg/lumera/modules/action/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ func (m *module) GetActionFee(ctx context.Context, dataSize string) (*types.Quer

return resp, nil
}

// GetParams fetches the action module parameters
func (m *module) GetParams(ctx context.Context) (*types.QueryParamsResponse, error) {
resp, err := m.client.Params(ctx, &types.QueryParamsRequest{})
if err != nil {
return nil, fmt.Errorf("failed to get action params: %w", err)
}

return resp, nil
}
1 change: 1 addition & 0 deletions pkg/lumera/modules/action/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
type Module interface {
GetAction(ctx context.Context, actionID string) (*types.QueryGetActionResponse, error)
GetActionFee(ctx context.Context, dataSize string) (*types.QueryGetActionFeeResponse, error)
GetParams(ctx context.Context) (*types.QueryParamsResponse, error)
}

// NewModule creates a new Action module client
Expand Down
141 changes: 0 additions & 141 deletions pkg/lumera/modules/action/tx/impl.go

This file was deleted.

22 changes: 0 additions & 22 deletions pkg/lumera/modules/action/tx/interface.go

This file was deleted.

Loading