Skip to content

Commit

Permalink
moving over from deployment-memory-solana
Browse files Browse the repository at this point in the history
  • Loading branch information
yashnevatia committed Jan 8, 2025
1 parent 074dacf commit 1d13322
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 94 deletions.
4 changes: 2 additions & 2 deletions deployment/environment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ func NewNodes(t *testing.T, logLevel zapcore.Level, chains map[uint64]deployment
// since we won't run a bootstrapper and a plugin oracle on the same
// chainlink node in production.
for i := 0; i < numBootstraps; i++ {
node := NewNode(t, ports[i], chains, logLevel, true /* bootstrap */, registryConfig)
node := NewNode(t, ports[i], chains, nil, logLevel, true /* bootstrap */, registryConfig)
nodesByPeerID[node.Keys.PeerID.String()] = *node
// Note in real env, this ID is allocated by JD.
}
for i := 0; i < numNodes; i++ {
// grab port offset by numBootstraps, since above loop also takes some ports.
node := NewNode(t, ports[numBootstraps+i], chains, logLevel, false /* bootstrap */, registryConfig)
node := NewNode(t, ports[numBootstraps+i], chains, nil, logLevel, false /* bootstrap */, registryConfig)
nodesByPeerID[node.Keys.PeerID.String()] = *node
// Note in real env, this ID is allocated by JD.
}
Expand Down
46 changes: 4 additions & 42 deletions deployment/environment/memory/job_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"slices"
"strconv"
"strings"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -153,49 +152,12 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode
if !ok {
return nil, fmt.Errorf("node id not found: %s", in.Filter.NodeIds[0])
}
evmBundle := n.Keys.OCRKeyBundles[chaintype.EVM]
offpk := evmBundle.OffchainPublicKey()
cpk := evmBundle.ConfigEncryptionPublicKey()

evmKeyBundle := &nodev1.OCR2Config_OCRKeyBundle{
BundleId: evmBundle.ID(),
ConfigPublicKey: common.Bytes2Hex(cpk[:]),
OffchainPublicKey: common.Bytes2Hex(offpk[:]),
OnchainSigningAddress: evmBundle.OnChainPublicKey(),
}

var chainConfigs []*nodev1.ChainConfig
for evmChainID, transmitter := range n.Keys.TransmittersByEVMChainID {
chainConfigs = append(chainConfigs, &nodev1.ChainConfig{
Chain: &nodev1.Chain{
Id: strconv.Itoa(int(evmChainID)),
Type: nodev1.ChainType_CHAIN_TYPE_EVM,
},
AccountAddress: transmitter.String(),
AdminAddress: transmitter.String(), // TODO: custom address
Ocr1Config: nil,
Ocr2Config: &nodev1.OCR2Config{
Enabled: true,
IsBootstrap: n.IsBoostrap,
P2PKeyBundle: &nodev1.OCR2Config_P2PKeyBundle{
PeerId: n.Keys.PeerID.String(),
},
OcrKeyBundle: evmKeyBundle,
Multiaddr: n.Addr.String(),
Plugins: nil,
ForwarderAddress: ptr(""),
},
})
}
for _, selector := range n.Chains {
family, err := chainsel.GetSelectorFamily(selector)
if err != nil {
return nil, err
}
if family == chainsel.FamilyEVM {
// already handled above
continue
}

// NOTE: this supports non-EVM too
chainID, err := chainsel.GetChainIDFromSelector(selector)
Expand All @@ -220,7 +182,6 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode
}

bundle := n.Keys.OCRKeyBundles[ocrtype]

offpk := bundle.OffchainPublicKey()
cpk := bundle.ConfigEncryptionPublicKey()

Expand All @@ -245,13 +206,15 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode
panic(fmt.Sprintf("Unsupported chain family %v", family))
}

transmitter := n.Keys.Transmitters[selector]

chainConfigs = append(chainConfigs, &nodev1.ChainConfig{
Chain: &nodev1.Chain{
Id: chainID,
Type: ctype,
},
AccountAddress: "", // TODO: support AccountAddress
AdminAddress: "",
AccountAddress: transmitter,
AdminAddress: transmitter,
Ocr1Config: nil,
Ocr2Config: &nodev1.OCR2Config{
Enabled: true,
Expand All @@ -266,7 +229,6 @@ func (j JobClient) ListNodeChainConfigs(ctx context.Context, in *nodev1.ListNode
},
})
}
// TODO: I think we can pull it from the feeds manager.
return &nodev1.ListNodeChainConfigsResponse{
ChainConfigs: chainConfigs,
}, nil
Expand Down
Loading

0 comments on commit 1d13322

Please sign in to comment.