From e82fb0c8dd0727aa3384ef21738d287262b407b2 Mon Sep 17 00:00:00 2001 From: Connor Stein Date: Fri, 4 Oct 2024 14:45:50 -0400 Subject: [PATCH] Misc fixes for CCIP1.6 staging (#14665) * Fix grpc creds, add balance * Add cap reg view * Lint * Pass in creds * Cap reg comment --- integration-tests/deployment/ccip/state.go | 7 +++ .../deployment/ccip/view/chain.go | 22 ++++----- .../deployment/ccip/view/v1_6/capreg.go | 45 +++++++++++++++++++ .../deployment/devenv/build_env.go | 2 + integration-tests/deployment/devenv/jd.go | 14 +----- integration-tests/deployment/environment.go | 1 + integration-tests/deployment/multiclient.go | 10 ----- 7 files changed, 69 insertions(+), 32 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..8f93bd9a6f2 --- /dev/null +++ b/integration-tests/deployment/ccip/view/v1_6/capreg.go @@ -0,0 +1,45 @@ +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" +) + +// 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"` +} + +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, + Capabilities: capViews, + }, nil +} 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 feac1c4ffb4..f8902d7da1c 100644 --- a/integration-tests/deployment/devenv/jd.go +++ b/integration-tests/deployment/devenv/jd.go @@ -6,7 +6,6 @@ import ( "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" @@ -17,21 +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(insecure.NewCredentials())) - - } - - 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) } 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 { 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)