diff --git a/deployment/environment.go b/deployment/environment.go index 98fd18fd9eb..eb202b740be 100644 --- a/deployment/environment.go +++ b/deployment/environment.go @@ -332,7 +332,6 @@ func NodeInfo(nodeIDs []string, oc NodeChainConfigsLister) (Nodes, error) { // Might make sense to change proto as peerID/multiAddr is 1-1 with nodeID? peerID = MustPeerIDFromString(chainConfig.Ocr2Config.P2PKeyBundle.PeerId) multiAddr = chainConfig.Ocr2Config.Multiaddr - adminAddr = chainConfig.AdminAddress if chainConfig.Ocr2Config.IsBootstrap { // NOTE: Assume same peerID for all chains. // Might make sense to change proto as peerID is 1-1 with nodeID? @@ -364,6 +363,8 @@ func NodeInfo(nodeIDs []string, oc NodeChainConfigsLister) (Nodes, error) { return nil, err } case nodev1.ChainType_CHAIN_TYPE_EVM: + // NOTE: Assume same adminAddr for all chains. We always use EVM addr + adminAddr = chainConfig.AdminAddress details, err = chain_selectors.GetChainDetailsByChainIDAndFamily(chainConfig.Chain.Id, chain_selectors.FamilyEVM) if err != nil { return nil, err diff --git a/deployment/keystone/changeset/internal/update_don_test.go b/deployment/keystone/changeset/internal/update_don_test.go index 6720b639ccc..e500ade60d7 100644 --- a/deployment/keystone/changeset/internal/update_don_test.go +++ b/deployment/keystone/changeset/internal/update_don_test.go @@ -3,6 +3,7 @@ package internal_test import ( "bytes" "encoding/hex" + "fmt" "math/big" "sort" "strconv" @@ -189,14 +190,21 @@ func newNode(t *testing.T, cfg minimalNodeCfg) deployment.Node { signingAddr, err := hex.DecodeString(cfg.signingAddr) require.NoError(t, err) + var pubkey [32]byte + if _, err := hex.Decode(pubkey[:], []byte(cfg.pubKey)); err != nil { + panic(fmt.Sprintf("failed to decode pubkey %s: %v", pubkey, err)) + } + return deployment.Node{ NodeID: cfg.id, + PeerID: cfg.p2p.PeerID(), CSAKey: cfg.pubKey, AdminAddr: cfg.admin.String(), SelToOCRConfig: map[chainsel.ChainDetails]deployment.OCRConfig{ registryChainDetails: { - OnchainPublicKey: signingAddr, - PeerID: cfg.p2p.PeerID(), + OnchainPublicKey: signingAddr, + PeerID: cfg.p2p.PeerID(), + ConfigEncryptionPublicKey: pubkey, }, }, } @@ -305,11 +313,3 @@ func testDon(t *testing.T, don kslib.DonInfo) kstest.Don { CapabilityConfigs: capabilityConfigs, } } - -func newP2PSignerEnc(signer [32]byte, p2pkey p2pkey.PeerID, encryptionPublicKey [32]byte) *internal.P2PSignerEnc { - return &internal.P2PSignerEnc{ - Signer: signer, - P2PKey: p2pkey, - EncryptionPublicKey: encryptionPublicKey, - } -} diff --git a/deployment/keystone/changeset/update_node_capabilities.go b/deployment/keystone/changeset/update_node_capabilities.go index 5730d14323d..1d6dde6af5a 100644 --- a/deployment/keystone/changeset/update_node_capabilities.go +++ b/deployment/keystone/changeset/update_node_capabilities.go @@ -23,19 +23,21 @@ func NewP2PSignerEnc(n *deployment.Node, registryChainSel uint64) (*P2PSignerEnc // TODO: deduplicate everywhere registryChainID, err := chainsel.ChainIdFromSelector(registryChainSel) if err != nil { - panic(err) + return nil, err } registryChainDetails, err := chainsel.GetChainDetailsByChainIDAndFamily(strconv.Itoa(int(registryChainID)), chainsel.FamilyEVM) if err != nil { - panic(err) + return nil, err + } + evmCC, exists := n.SelToOCRConfig[registryChainDetails] + if !exists { + return nil, fmt.Errorf("NewP2PSignerEnc: registryChainSel not found on node: %v", registryChainSel) } - evmCC := n.SelToOCRConfig[registryChainDetails] var signer [32]byte copy(signer[:], evmCC.OnchainPublicKey) var csakey [32]byte copy(csakey[:], evmCC.ConfigEncryptionPublicKey[:]) - // TODO: return error return value return &P2PSignerEnc{ Signer: signer, P2PKey: n.PeerID, diff --git a/deployment/keystone/deploy.go b/deployment/keystone/deploy.go index 6206dc7bea4..99602d493e6 100644 --- a/deployment/keystone/deploy.go +++ b/deployment/keystone/deploy.go @@ -669,7 +669,10 @@ func registerNodes(lggr logger.Logger, req *registerNodesRequest) (*registerNode params, ok := nodeIDToParams[n.NodeID] if !ok { - evmCC := n.SelToOCRConfig[registryChainDetails] + evmCC, exists := n.SelToOCRConfig[registryChainDetails] + if !exists { + return nil, fmt.Errorf("config for selector not found on node: %v", req.chain.Selector) + } var signer [32]byte copy(signer[:], evmCC.OnchainPublicKey) var csakey [32]byte @@ -905,7 +908,7 @@ func configureForwarder(lggr logger.Logger, chain deployment.Chain, fwdr *kf.Key continue } ver := dn.Info.ConfigCount // note config count on the don info is the version on the forwarder - signers := dn.signers(chain.Selector) + signers := dn.signers(chainsel.FamilyEVM) tx, err := fwdr.SetConfig(chain.DeployerKey, dn.Info.Id, ver, dn.Info.F, signers) if err != nil { err = DecodeErr(kf.KeystoneForwarderABI, err) diff --git a/deployment/keystone/types.go b/deployment/keystone/types.go index 3542d3eac67..56c3e4e362c 100644 --- a/deployment/keystone/types.go +++ b/deployment/keystone/types.go @@ -242,25 +242,33 @@ type RegisteredDon struct { Nodes []deployment.Node } -func (d RegisteredDon) signers(registryChainSel uint64) []common.Address { +func (d RegisteredDon) signers(chainFamily string) []common.Address { sort.Slice(d.Nodes, func(i, j int) bool { return d.Nodes[i].PeerID.String() < d.Nodes[j].PeerID.String() }) - registryChainID, err := chainsel.ChainIdFromSelector(registryChainSel) - if err != nil { - panic(err) - } - registryChainDetails, err := chainsel.GetChainDetailsByChainIDAndFamily(strconv.Itoa(int(registryChainID)), chainsel.FamilyEVM) - if err != nil { - panic(err) - } var out []common.Address for _, n := range d.Nodes { if n.IsBootstrap { continue } + var found bool + var registryChainDetails chainsel.ChainDetails + for details, _ := range n.SelToOCRConfig { + if family, err := chainsel.GetSelectorFamily(details.ChainSelector); err == nil && family == chainFamily { + found = true + registryChainDetails = details + + } + } + if !found { + panic(fmt.Sprintf("chainType not found: %v", chainFamily)) + } // eth address is the first 20 bytes of the Signer - signer := n.SelToOCRConfig[registryChainDetails].OnchainPublicKey + config, exists := n.SelToOCRConfig[registryChainDetails] + if !exists { + panic(fmt.Sprintf("chainID not found: %v", registryChainDetails)) + } + signer := config.OnchainPublicKey signerAddress := common.BytesToAddress(signer) out = append(out, signerAddress) }