Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deployments: keystone: Leverage job-distributor #15179

Merged
merged 28 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
58956ba
deployment: Support other chain types in CreateCCIPOCRSupportedChains
archseer Oct 18, 2024
cbfbdc1
nix: Upgrade to postgres 15
archseer Oct 22, 2024
ac23edc
keystone: Migrate from CLO to JD
archseer Oct 25, 2024
a54149f
CLO compat
archseer Oct 28, 2024
4044d5e
Allow setting labels on nodes
archseer Oct 28, 2024
0fc498b
Rename function
archseer Oct 28, 2024
87f50ad
Tag nodes with p2p_id for easy lookup
archseer Oct 31, 2024
02f2575
Lookup nodes according to p2p_id
archseer Oct 31, 2024
e99f24d
Implement label & id filtering in the memory job client
archseer Nov 4, 2024
0d9c915
Merge branch 'develop' into aptos-deployment
krehermann Nov 5, 2024
a2d4640
Update the CLO job client as well
archseer Nov 5, 2024
8f58772
go mod tidy
archseer Nov 5, 2024
5c981eb
Fix DeployCLO
archseer Nov 5, 2024
b029545
Fix CLO job client test
archseer Nov 5, 2024
bb34269
Merge remote-tracking branch 'origin/develop' into aptos-deployments
archseer Nov 6, 2024
dfea6a1
add TODOs
archseer Nov 7, 2024
1c53546
Merge remote-tracking branch 'origin/develop' into aptos-deployments
archseer Nov 7, 2024
8e7a624
fix up tests again
archseer Nov 8, 2024
ef3f120
Merge remote-tracking branch 'origin/develop' into aptos-deployments
archseer Nov 9, 2024
876a723
Fix compilation, remove nodeIdToNop indirection
archseer Nov 10, 2024
2a7da8b
fix TestDeployCLO
archseer Nov 11, 2024
3097d52
Merge remote-tracking branch 'origin/develop' into aptos-deployments
archseer Nov 12, 2024
0014980
add clo utils to bridge tooling gap
krehermann Nov 12, 2024
b19ca3e
add utils to remap clo node id to peer id
krehermann Nov 12, 2024
0c11ef4
fix p2p filter in clo jd impl; fix mis-matched id vs p2p usage
krehermann Nov 13, 2024
b063830
Add credential support to jd client
archseer Nov 13, 2024
ae89cd6
go mod tidy
archseer Nov 13, 2024
5e9d58d
rm pointer lib
krehermann Nov 13, 2024
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
1 change: 1 addition & 0 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/AlekSi/pointer v1.1.0 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/CosmWasm/wasmd v0.40.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ func NewMemoryEnvironment(t *testing.T, lggr logger.Logger, numChains int, numNo
require.GreaterOrEqual(t, numChains, 2, "numChains must be at least 2 for home and feed chains")
require.GreaterOrEqual(t, numNodes, 4, "numNodes must be at least 4")
ctx := testcontext.Get(t)
chains, evmChains := memory.NewMemoryChains(t, numChains)
chains := memory.NewMemoryChains(t, numChains)
homeChainSel, feedSel := allocateCCIPChainSelectors(chains)
replayBlocks, err := LatestBlocksByChain(ctx, chains)
require.NoError(t, err)

ab := deployment.NewMemoryAddressBook()
crConfig := DeployTestContracts(t, lggr, ab, homeChainSel, feedSel, chains)
nodes := memory.NewNodes(t, zapcore.InfoLevel, evmChains, numNodes, 1, crConfig)
nodes := memory.NewNodes(t, zapcore.InfoLevel, chains, numNodes, 1, crConfig)
for _, node := range nodes {
require.NoError(t, node.App.Start(ctx))
t.Cleanup(func() {
Expand Down
137 changes: 0 additions & 137 deletions deployment/environment/clo/env.go

This file was deleted.

99 changes: 76 additions & 23 deletions deployment/environment/clo/offchain_client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ package clo

import (
"context"
"fmt"
"slices"
"strings"

"go.uber.org/zap"
"google.golang.org/grpc"

"github.com/AlekSi/pointer"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
csav1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/csa"
jobv1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/job"
nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node"
"github.com/smartcontractkit/chainlink-protos/job-distributor/v1/shared/ptypes"
"github.com/smartcontractkit/chainlink/deployment/environment/clo/models"
)

Expand Down Expand Up @@ -60,39 +65,68 @@ 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{}
include := func(id string) bool {
if in.Filter == nil || len(in.Filter.Ids) == 0 {
include := func(node *nodev1.Node) bool {
if in.Filter == nil {
return true
}
// lazy init
if len(fiterIds) == 0 {
for _, id := range in.Filter.Ids {
fiterIds[id] = struct{}{}
if len(in.Filter.Ids) > 0 {
idx := slices.IndexFunc(in.Filter.Ids, func(id string) bool {
return node.Id == id
})
if idx < 0 {
return false
}
}
_, ok := fiterIds[id]
return ok
for _, selector := range in.Filter.Selectors {
idx := slices.IndexFunc(node.Labels, func(label *ptypes.Label) bool {
return label.Key == selector.Key
})
if idx < 0 {
return false
}
label := node.Labels[idx]

switch selector.Op {
case ptypes.SelectorOp_IN:
values := strings.Split(*selector.Value, ",")
found := slices.Contains(values, *label.Value)
if !found {
return false
}
default:
panic("unimplemented selector")
}
}
return true
}
var nodes []*nodev1.Node
for _, nop := range j.NodeOperators {
for _, n := range nop.Nodes {
if include(n.ID) {
nodes = append(nodes, &nodev1.Node{
Id: n.ID,
Name: n.Name,
PublicKey: *n.PublicKey, // is this the correct val?
IsEnabled: n.Enabled,
IsConnected: n.Connected,
})
p2pId, err := NodeP2PId(n)
if err != nil {
return nil, fmt.Errorf("failed to get p2p id for node %s: %w", n.ID, err)
}
node := &nodev1.Node{
Id: n.ID,
Name: n.Name,
PublicKey: *n.PublicKey,
IsEnabled: n.Enabled,
IsConnected: n.Connected,
Labels: []*ptypes.Label{
{
Key: "p2p_id",
Value: pointer.ToString(p2pId), // here n.ID is also peer ID
},
},
}
if include(node) {
nodes = append(nodes, node)
}
}
}
return &nodev1.ListNodesResponse{
Nodes: nodes,
}, nil

}

func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNodeChainConfigsRequest, opts ...grpc.CallOption) (*nodev1.ListNodeChainConfigsResponse, error) {
Expand Down Expand Up @@ -160,13 +194,18 @@ type GetNodeOperatorsResponse struct {
NodeOperators []*models.NodeOperator `json:"nodeOperators"`
}

func NewJobClient(lggr logger.Logger, nops []*models.NodeOperator) *JobClient {
type JobClientConfig struct {
Nops []*models.NodeOperator
}

func NewJobClient(lggr logger.Logger, cfg JobClientConfig) *JobClient {

c := &JobClient{
NodeOperators: nops,
NodeOperators: cfg.Nops,
nodesByID: make(map[string]*models.Node),
lggr: lggr,
}
for _, nop := range nops {
for _, nop := range c.NodeOperators {
for _, n := range nop.Nodes {
node := n
c.nodesByID[n.ID] = node // maybe should use the public key instead?
Expand All @@ -184,10 +223,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
Loading
Loading