From 7eaf43b7ef418a1599feb1a84f381c9690289754 Mon Sep 17 00:00:00 2001 From: Kristijan Rebernisak Date: Wed, 22 Dec 2021 13:07:07 +0100 Subject: [PATCH] Rename job spec 'NodeEndpointRPC' arg as 'NodeEndpointHTTP' --- ops/main.go | 2 +- pkg/solana/config_digester.go | 5 ++-- pkg/solana/config_digester_test.go | 41 ------------------------------ pkg/solana/relay.go | 6 ++--- pkg/solana/types.go | 4 +-- shell.nix | 10 +++++--- tests/e2e/smoke/common.go | 11 ++++---- 7 files changed, 22 insertions(+), 57 deletions(-) diff --git a/ops/main.go b/ops/main.go index 5ba6687c4..44521224a 100644 --- a/ops/main.go +++ b/ops/main.go @@ -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], diff --git a/pkg/solana/config_digester.go b/pkg/solana/config_digester.go index 1bacf3a23..9f0e59971 100644 --- a/pkg/solana/config_digester.go +++ b/pkg/solana/config_digester.go @@ -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 @@ -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 } diff --git a/pkg/solana/config_digester_test.go b/pkg/solana/config_digester_test.go index a472818c6..6b2a938b5 100644 --- a/pkg/solana/config_digester_test.go +++ b/pkg/solana/config_digester_test.go @@ -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 -} diff --git a/pkg/solana/relay.go b/pkg/solana/relay.go index fe2efe585..cf9a96027 100644 --- a/pkg/solana/relay.go +++ b/pkg/solana/relay.go @@ -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 @@ -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 } diff --git a/pkg/solana/types.go b/pkg/solana/types.go index cf042e6af..9a31626ec 100644 --- a/pkg/solana/types.go +++ b/pkg/solana/types.go @@ -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"` diff --git a/shell.nix b/shell.nix index 7aea50c0d..7b3f19e32 100644 --- a/shell.nix +++ b/shell.nix @@ -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 diff --git a/tests/e2e/smoke/common.go b/tests/e2e/smoke/common.go index 2b58fb25d..14af853db 100644 --- a/tests/e2e/smoke/common.go +++ b/tests/e2e/smoke/common.go @@ -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" @@ -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 ( @@ -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(),