From 7cf985afa77b34b69567474a9f6a7b227e1ab9e0 Mon Sep 17 00:00:00 2001 From: connorwstein Date: Fri, 4 Oct 2024 10:57:15 -0400 Subject: [PATCH 1/5] Fix grpc creds, add balance --- integration-tests/deployment/devenv/jd.go | 5 ++--- integration-tests/deployment/environment.go | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-tests/deployment/devenv/jd.go b/integration-tests/deployment/devenv/jd.go index feac1c4ffb4..1cdd57a54d1 100644 --- a/integration-tests/deployment/devenv/jd.go +++ b/integration-tests/deployment/devenv/jd.go @@ -2,11 +2,11 @@ package devenv import ( "context" + "crypto/tls" "fmt" "google.golang.org/grpc" "google.golang.org/grpc/credentials" - "google.golang.org/grpc/credentials/insecure" "github.com/smartcontractkit/chainlink/integration-tests/deployment" csav1 "github.com/smartcontractkit/chainlink/integration-tests/deployment/jd/csa/v1" @@ -27,8 +27,7 @@ func NewJDConnection(cfg JDConfig) (*grpc.ClientConn, error) { if cfg.creds != nil { opts = append(opts, grpc.WithTransportCredentials(cfg.creds)) } else { - opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) - + opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) } conn, err := grpc.NewClient(cfg.GRPC, opts...) diff --git a/integration-tests/deployment/environment.go b/integration-tests/deployment/environment.go index 32c1c3befd7..eb2ecca645a 100644 --- a/integration-tests/deployment/environment.go +++ b/integration-tests/deployment/environment.go @@ -31,6 +31,7 @@ type OnchainClient interface { // to abstract chain clients. bind.ContractBackend bind.DeployBackend + BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) } type OffchainClient interface { From 68f694725232350a0cb92c63dce5fd50b00469e9 Mon Sep 17 00:00:00 2001 From: connorwstein Date: Fri, 4 Oct 2024 11:59:01 -0400 Subject: [PATCH 2/5] Add cap reg view --- integration-tests/deployment/ccip/state.go | 7 ++++ .../deployment/ccip/view/chain.go | 22 +++++----- .../deployment/ccip/view/v1_6/capreg.go | 41 +++++++++++++++++++ integration-tests/deployment/multiclient.go | 10 ----- 4 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 integration-tests/deployment/ccip/view/v1_6/capreg.go diff --git a/integration-tests/deployment/ccip/state.go b/integration-tests/deployment/ccip/state.go index 14ff794b6d0..75ceb0a878b 100644 --- a/integration-tests/deployment/ccip/state.go +++ b/integration-tests/deployment/ccip/state.go @@ -150,6 +150,13 @@ func (c CCIPChainState) GenerateView() (view.ChainView, error) { } chainView.RMNProxy[c.RMNProxy.Address().Hex()] = rmnProxyView } + if c.CapabilityRegistry != nil { + capRegView, err := v1_6.GenerateCapRegView(c.CapabilityRegistry) + if err != nil { + return chainView, err + } + chainView.CapabilityRegistry[c.CapabilityRegistry.Address().Hex()] = capRegView + } return chainView, nil } diff --git a/integration-tests/deployment/ccip/view/chain.go b/integration-tests/deployment/ccip/view/chain.go index 06f0059e67b..27c30002052 100644 --- a/integration-tests/deployment/ccip/view/chain.go +++ b/integration-tests/deployment/ccip/view/chain.go @@ -16,11 +16,12 @@ type ChainView struct { TokenAdminRegistry map[string]v1_5.TokenAdminRegistryView `json:"tokenAdminRegistry,omitempty"` CommitStore map[string]v1_5.CommitStoreView `json:"commitStore,omitempty"` // v1.6 - FeeQuoter map[string]v1_6.FeeQuoterView `json:"feeQuoter,omitempty"` - NonceManager map[string]v1_6.NonceManagerView `json:"nonceManager,omitempty"` - RMN map[string]v1_6.RMNRemoteView `json:"rmn,omitempty"` - OnRamp map[string]v1_6.OnRampView `json:"onRamp,omitempty"` - OffRamp map[string]v1_6.OffRampView `json:"offRamp,omitempty"` + FeeQuoter map[string]v1_6.FeeQuoterView `json:"feeQuoter,omitempty"` + NonceManager map[string]v1_6.NonceManagerView `json:"nonceManager,omitempty"` + RMN map[string]v1_6.RMNRemoteView `json:"rmn,omitempty"` + OnRamp map[string]v1_6.OnRampView `json:"onRamp,omitempty"` + OffRamp map[string]v1_6.OffRampView `json:"offRamp,omitempty"` + CapabilityRegistry map[string]v1_6.CapRegView `json:"capabilityRegistry,omitempty"` } func NewChain() ChainView { @@ -33,10 +34,11 @@ func NewChain() ChainView { TokenAdminRegistry: make(map[string]v1_5.TokenAdminRegistryView), CommitStore: make(map[string]v1_5.CommitStoreView), // v1.6 - FeeQuoter: make(map[string]v1_6.FeeQuoterView), - NonceManager: make(map[string]v1_6.NonceManagerView), - RMN: make(map[string]v1_6.RMNRemoteView), - OnRamp: make(map[string]v1_6.OnRampView), - OffRamp: make(map[string]v1_6.OffRampView), + FeeQuoter: make(map[string]v1_6.FeeQuoterView), + NonceManager: make(map[string]v1_6.NonceManagerView), + RMN: make(map[string]v1_6.RMNRemoteView), + OnRamp: make(map[string]v1_6.OnRampView), + OffRamp: make(map[string]v1_6.OffRampView), + CapabilityRegistry: make(map[string]v1_6.CapRegView), } } diff --git a/integration-tests/deployment/ccip/view/v1_6/capreg.go b/integration-tests/deployment/ccip/view/v1_6/capreg.go new file mode 100644 index 00000000000..b01054ffaa3 --- /dev/null +++ b/integration-tests/deployment/ccip/view/v1_6/capreg.go @@ -0,0 +1,41 @@ +package v1_6 + +import ( + "github.com/ethereum/go-ethereum/common" + + "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/types" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" +) + +type CapRegView struct { + types.ContractMetaData + Capabilities []CapabilityView `json:"capabilities,omitempty"` +} + +type CapabilityView struct { + LabelledName string `json:"labelledName"` + Version string `json:"version"` + ConfigContract common.Address `json:"configContract"` +} + +func GenerateCapRegView(capReg *capabilities_registry.CapabilitiesRegistry) (CapRegView, error) { + tv, err := types.NewContractMetaData(capReg, capReg.Address()) + if err != nil { + return CapRegView{}, err + } + caps, err := capReg.GetCapabilities(nil) + if err != nil { + return CapRegView{}, err + } + var capViews []CapabilityView + for _, capability := range caps { + capViews = append(capViews, CapabilityView{ + LabelledName: capability.LabelledName, + Version: capability.Version, + ConfigContract: capability.ConfigurationContract, + }) + } + return CapRegView{ + ContractMetaData: tv, + }, nil +} diff --git a/integration-tests/deployment/multiclient.go b/integration-tests/deployment/multiclient.go index 02a18f760df..eb172f906bb 100644 --- a/integration-tests/deployment/multiclient.go +++ b/integration-tests/deployment/multiclient.go @@ -67,16 +67,6 @@ func NewMultiClient(rpcs []RPC, opts ...func(client *MultiClient)) (*MultiClient return &mc, nil } -func (mc *MultiClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { - var receipt *types.Receipt - err := mc.retryWithBackups(func(client *ethclient.Client) error { - var err error - receipt, err = client.TransactionReceipt(ctx, txHash) - return err - }) - return receipt, err -} - func (mc *MultiClient) SendTransaction(ctx context.Context, tx *types.Transaction) error { return mc.retryWithBackups(func(client *ethclient.Client) error { return client.SendTransaction(ctx, tx) From 1cabb5c7c9a150c6880592a9bfd0aa35934596a6 Mon Sep 17 00:00:00 2001 From: connorwstein Date: Fri, 4 Oct 2024 12:27:43 -0400 Subject: [PATCH 3/5] Lint --- integration-tests/deployment/ccip/view/v1_6/capreg.go | 1 + integration-tests/deployment/devenv/jd.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/integration-tests/deployment/ccip/view/v1_6/capreg.go b/integration-tests/deployment/ccip/view/v1_6/capreg.go index b01054ffaa3..b6ee3bca08d 100644 --- a/integration-tests/deployment/ccip/view/v1_6/capreg.go +++ b/integration-tests/deployment/ccip/view/v1_6/capreg.go @@ -37,5 +37,6 @@ func GenerateCapRegView(capReg *capabilities_registry.CapabilitiesRegistry) (Cap } return CapRegView{ ContractMetaData: tv, + Capabilities: capViews, }, nil } diff --git a/integration-tests/deployment/devenv/jd.go b/integration-tests/deployment/devenv/jd.go index 1cdd57a54d1..d939048956d 100644 --- a/integration-tests/deployment/devenv/jd.go +++ b/integration-tests/deployment/devenv/jd.go @@ -27,7 +27,9 @@ func NewJDConnection(cfg JDConfig) (*grpc.ClientConn, error) { if cfg.creds != nil { opts = append(opts, grpc.WithTransportCredentials(cfg.creds)) } else { - opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) + opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ + MinVersion: tls.VersionTLS12, + }))) } conn, err := grpc.NewClient(cfg.GRPC, opts...) From 6b6aa4c39aea0c72116d9124307d1df3f437a795 Mon Sep 17 00:00:00 2001 From: connorwstein Date: Fri, 4 Oct 2024 13:33:17 -0400 Subject: [PATCH 4/5] Pass in creds --- integration-tests/deployment/devenv/build_env.go | 2 ++ integration-tests/deployment/devenv/jd.go | 15 ++------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/integration-tests/deployment/devenv/build_env.go b/integration-tests/deployment/devenv/build_env.go index 3e5af0866fa..6e06f23aaa2 100644 --- a/integration-tests/deployment/devenv/build_env.go +++ b/integration-tests/deployment/devenv/build_env.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/require" "github.com/subosito/gotenv" "golang.org/x/sync/errgroup" + "google.golang.org/grpc/credentials/insecure" "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext" @@ -105,6 +106,7 @@ func CreateDockerEnv(t *testing.T) ( GRPC: jd.Grpc, // we will use internal wsrpc for nodes on same docker network to connect to JD WSRPC: jd.InternalWSRPC, + Creds: insecure.NewCredentials(), } } else { jdConfig = JDConfig{ diff --git a/integration-tests/deployment/devenv/jd.go b/integration-tests/deployment/devenv/jd.go index d939048956d..f8902d7da1c 100644 --- a/integration-tests/deployment/devenv/jd.go +++ b/integration-tests/deployment/devenv/jd.go @@ -2,7 +2,6 @@ package devenv import ( "context" - "crypto/tls" "fmt" "google.golang.org/grpc" @@ -17,22 +16,12 @@ import ( type JDConfig struct { GRPC string WSRPC string - creds credentials.TransportCredentials + Creds credentials.TransportCredentials nodeInfo []NodeInfo } func NewJDConnection(cfg JDConfig) (*grpc.ClientConn, error) { - var opts []grpc.DialOption - // TODO: add auth details - if cfg.creds != nil { - opts = append(opts, grpc.WithTransportCredentials(cfg.creds)) - } else { - opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ - MinVersion: tls.VersionTLS12, - }))) - } - - conn, err := grpc.NewClient(cfg.GRPC, opts...) + conn, err := grpc.NewClient(cfg.GRPC, grpc.WithTransportCredentials(cfg.Creds)) if err != nil { return nil, fmt.Errorf("failed to connect Job Distributor service. Err: %w", err) } From 42d61448999552c70f5f15975c2df53b2281bcb8 Mon Sep 17 00:00:00 2001 From: connorwstein Date: Fri, 4 Oct 2024 13:34:57 -0400 Subject: [PATCH 5/5] Cap reg comment --- integration-tests/deployment/ccip/view/v1_6/capreg.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/integration-tests/deployment/ccip/view/v1_6/capreg.go b/integration-tests/deployment/ccip/view/v1_6/capreg.go index b6ee3bca08d..8f93bd9a6f2 100644 --- a/integration-tests/deployment/ccip/view/v1_6/capreg.go +++ b/integration-tests/deployment/ccip/view/v1_6/capreg.go @@ -7,6 +7,9 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" ) +// CapRegView denotes a view of the capabilities registry contract. +// Note that the contract itself is 1.0.0 versioned, but we're releasing it first +// as part of 1.6. type CapRegView struct { types.ContractMetaData Capabilities []CapabilityView `json:"capabilities,omitempty"`