Skip to content

Commit

Permalink
Rename job spec 'NodeEndpointRPC' arg as 'NodeEndpointHTTP'
Browse files Browse the repository at this point in the history
  • Loading branch information
krebernisak committed Dec 22, 2021
1 parent cc97015 commit 7eaf43b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 57 deletions.
2 changes: 1 addition & 1 deletion ops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {

func RelayConfig(ctx *pulumi.Context, addresses map[int]string) (map[string]string, error) {
return map[string]string{
"nodeEndpointRPC": config.Require(ctx, "CL-RELAY_HTTP"),
"nodeEndpointHTTP": config.Require(ctx, "CL-RELAY_HTTP"),
"nodeEndpointWS": config.Require(ctx, "CL-RELAY_WS"),
"stateID": addresses[solana.OCRFeed],
"transmissionsID": addresses[solana.OCRTransmissions],
Expand Down
5 changes: 3 additions & 2 deletions pkg/solana/config_digester.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (d OffchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.Co
if err := binary.Write(buf, binary.BigEndian, uint8(len(cfg.Signers))); err != nil {
return digest, err
}

for _, signer := range cfg.Signers {
if _, err := buf.Write(signer); err != nil {
return digest, err
Expand Down Expand Up @@ -84,12 +85,12 @@ func (d OffchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.Co
}

digest[0] = 0x00
digest[1] = uint8(ConfigDigestPrefixSolana)
digest[1] = uint8(d.ConfigDigestPrefix())

return digest, nil
}

// This should return the same constant value on every invocation
func (d OffchainConfigDigester) ConfigDigestPrefix() types.ConfigDigestPrefix {
func (_ OffchainConfigDigester) ConfigDigestPrefix() types.ConfigDigestPrefix {
return ConfigDigestPrefixSolana
}
41 changes: 0 additions & 41 deletions pkg/solana/config_digester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,3 @@ func TestConfigDigester(t *testing.T) {
expectedDigest := mockState.ConfigDigestHex
require.Equal(t, expectedDigest, actualDigest.Hex())
}

// Helpers

type tmpOracleKeys struct {
signerKey types.OnchainPublicKey
transmitter types.Account
}

func sortOraclesBySigningKey(
signers []types.OnchainPublicKey,
transmitters []types.Account,
) (
[]types.OnchainPublicKey,
[]types.Account,
error,
) {
if len(signers) != len(transmitters) {
return nil, nil, fmt.Errorf(
"number of signers (%d) and transmitters (%d) is different",
len(signers), len(transmitters))
}

oracles := []tmpOracleKeys{}
for i := 0; i < len(signers); i++ {
oracles = append(oracles, tmpOracleKeys{
signers[i],
transmitters[i],
})
}
sort.SliceStable(oracles, func(i, j int) bool {
return bytes.Compare(oracles[i].signerKey, oracles[j].signerKey) < 0
})
newSigners := []types.OnchainPublicKey{}
newTransmitters := []types.Account{}
for i := 0; i < len(oracles); i++ {
newSigners = append(newSigners, oracles[i].signerKey)
newTransmitters = append(newTransmitters, oracles[i].transmitter)
}

return newSigners, newTransmitters, nil
}
6 changes: 3 additions & 3 deletions pkg/solana/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type OCR2Spec struct {
IsBootstrap bool

// network data
NodeEndpointRPC string
NodeEndpointWS string
NodeEndpointHTTP string
NodeEndpointWS string

// on-chain program + 2x state accounts (state + transmissions) + validator program
ProgramID solana.PublicKey
Expand Down Expand Up @@ -100,7 +100,7 @@ func (r *Relayer) NewOCR2Provider(externalJobID uuid.UUID, s interface{}) (relay
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
// establish network connection RPC + WS (reuses existing WS client if available)
client, err := r.connections.NewConnectedClient(ctx, spec.NodeEndpointRPC, spec.NodeEndpointWS)
client, err := r.connections.NewConnectedClient(ctx, spec.NodeEndpointHTTP, spec.NodeEndpointWS)
if err != nil {
return provider, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/solana/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ type Validator struct {
// CL Core OCR2 job spec RelayConfig member for Solana
type RelayConfig struct {
// network data
NodeEndpointRPC string `json:"nodeEndpointRPC"`
NodeEndpointWS string `json:"nodeEndpointWS"`
NodeEndpointHTTP string `json:"nodeEndpointHTTP"`
NodeEndpointWS string `json:"nodeEndpointWS"`

// on-chain program + 2x state accounts (state + transmissions) + validator programID
StateID string `json:"stateID"`
Expand Down
10 changes: 7 additions & 3 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ pkgs.mkShell {
libudev
openssl

# Solana
solana-full
spl-token-cli
anchor
nodePackages.typescript-language-server
nodejs-14_x
(yarn.override { nodejs = nodejs-14_x; })

# Golang
go_1_17
gopls
delve
golangci-lint

# NodeJS + TS
nodePackages.typescript-language-server
nodejs-14_x
(yarn.override { nodejs = nodejs-14_x; })
];
RUST_BACKTRACE = "1";
# https://github.com/rust-lang/rust/issues/55979
Expand Down
11 changes: 6 additions & 5 deletions tests/e2e/smoke/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"bytes"
"encoding/hex"
"fmt"
"math/big"
"sort"
"strings"
"time"

uuid "github.com/satori/go.uuid"
"github.com/smartcontractkit/chainlink-solana/tests/e2e/utils"
"github.com/smartcontractkit/helmenv/environment"
Expand All @@ -13,10 +18,6 @@ import (
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2/types"
"golang.org/x/crypto/curve25519"
"math/big"
"sort"
"strings"
"time"
)

const (
Expand Down Expand Up @@ -134,7 +135,7 @@ func CreateOCR2Jobs(
ocr2 contracts.OCRv2,
validator contracts.OCRv2DeviationFlaggingValidator) error {
relayConfig := map[string]string{
"nodeEndpointRPC": "http://sol:8899",
"nodeEndpointHTTP": "http://sol:8899",
"nodeEndpointWS": "ws://sol:8900",
"stateID": ocr2.Address(),
"transmissionsID": ocr2.TransmissionsAddr(),
Expand Down

0 comments on commit 7eaf43b

Please sign in to comment.