Skip to content

Commit

Permalink
CLO compat
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Oct 29, 2024
1 parent 269886e commit 3a39742
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 144 deletions.
136 changes: 0 additions & 136 deletions integration-tests/deployment/clo/env.go

This file was deleted.

21 changes: 18 additions & 3 deletions integration-tests/deployment/clo/offchain_client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package clo

import (
"context"
"fmt"

"go.uber.org/zap"
"google.golang.org/grpc"
Expand Down Expand Up @@ -61,7 +62,7 @@ func (j JobClient) GetNode(ctx context.Context, in *nodev1.GetNodeRequest, opts

func (j JobClient) ListNodes(ctx context.Context, in *nodev1.ListNodesRequest, opts ...grpc.CallOption) (*nodev1.ListNodesResponse, error) {
//TODO CCIP-3108
var fiterIds map[string]struct{}
fiterIds := make(map[string]any)
include := func(id string) bool {
if in.Filter == nil || len(in.Filter.Ids) == 0 {
return true
Expand All @@ -82,7 +83,7 @@ func (j JobClient) ListNodes(ctx context.Context, in *nodev1.ListNodesRequest, o
nodes = append(nodes, &nodev1.Node{
Id: n.ID,
Name: n.Name,
PublicKey: *n.PublicKey, // is this the correct val?
PublicKey: *n.PublicKey,
IsEnabled: n.Enabled,
IsConnected: n.Connected,
})
Expand Down Expand Up @@ -184,10 +185,24 @@ func cloNodeToChainConfigs(n *models.Node) []*nodev1.ChainConfig {
}

func cloChainCfgToJDChainCfg(ccfg *models.NodeChainConfig) *nodev1.ChainConfig {
var ctype nodev1.ChainType
switch ccfg.Network.ChainType {
case models.ChainTypeEvm:
ctype = nodev1.ChainType_CHAIN_TYPE_EVM
case models.ChainTypeSolana:
ctype = nodev1.ChainType_CHAIN_TYPE_SOLANA
case models.ChainTypeStarknet:
ctype = nodev1.ChainType_CHAIN_TYPE_STARKNET
case models.ChainTypeAptos:
ctype = nodev1.ChainType_CHAIN_TYPE_APTOS
default:
panic(fmt.Sprintf("Unsupported chain family %v", ccfg.Network.ChainType))
}

return &nodev1.ChainConfig{
Chain: &nodev1.Chain{
Id: ccfg.Network.ChainID,
Type: nodev1.ChainType_CHAIN_TYPE_EVM, // TODO: write conversion func from clo to jd tyes
Type: ctype,
},
AccountAddress: ccfg.AccountAddress,
AdminAddress: ccfg.AdminAddress,
Expand Down
23 changes: 20 additions & 3 deletions integration-tests/deployment/keystone/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ type DonInfo struct {

type Node struct {
ID string
P2PID string
Name string
PublicKey *string
ChainConfigs []*nodev1.ChainConfig
Expand All @@ -166,7 +167,14 @@ func NodesFromJD(name string, nodeIDs []string, jd deployment.OffchainClient) ([
nodesFromJD, err := jd.ListNodes(context.Background(), &nodev1.ListNodesRequest{
Filter: &nodev1.ListNodesRequest_Filter{
Enabled: 1,
Ids: nodeIDs,
Ids: nodeIDs, // TODO: use p2p_id selectors instead of IDs
// Selectors: []*ptypes.Selector{
// {
// Key: "p2p_id",
// Op: ptypes.SelectorOp_IN,
// Value: pointer.ToString(""), // TODO:
// },
// },
},
})
if err != nil {
Expand All @@ -184,11 +192,20 @@ func NodesFromJD(name string, nodeIDs []string, jd deployment.OffchainClient) ([
if idx < 0 {
return nil, fmt.Errorf("node id not found")
}
jdNode := nodesFromJD.Nodes[idx]

// labelIdx := slices.IndexFunc(jdNode.GetLabels(), func(label *ptypes.Label) bool { return label.Key == "p2p_id" })
// if labelIdx < 0 {
// return nil, fmt.Errorf("p2p_id label not found")
// }
// p2pID := *jdNode.Labels[labelIdx].Value

nodes = append(nodes, Node{
ID: nodeID,
ID: nodeID,
// P2PID: p2pID, // TODO:
P2PID: nodeID,
Name: name,
PublicKey: &nodesFromJD.Nodes[idx].PublicKey,
PublicKey: &jdNode.PublicKey,
// PublicKey TODO fetch via ListNodes
ChainConfigs: nodeChainConfigs.GetChainConfigs(),
})
Expand Down
Loading

0 comments on commit 3a39742

Please sign in to comment.