Skip to content

Commit

Permalink
Misc fixes for CCIP1.6 staging (#14665)
Browse files Browse the repository at this point in the history
* Fix grpc creds, add balance

* Add cap reg view

* Lint

* Pass in creds

* Cap reg comment
  • Loading branch information
connorwstein authored Oct 4, 2024
1 parent b13b8db commit e82fb0c
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 32 deletions.
7 changes: 7 additions & 0 deletions integration-tests/deployment/ccip/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
22 changes: 12 additions & 10 deletions integration-tests/deployment/ccip/view/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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),
}
}
45 changes: 45 additions & 0 deletions integration-tests/deployment/ccip/view/v1_6/capreg.go
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 2 additions & 0 deletions integration-tests/deployment/devenv/build_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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{
Expand Down
14 changes: 2 additions & 12 deletions integration-tests/deployment/devenv/jd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions integration-tests/deployment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 0 additions & 10 deletions integration-tests/deployment/multiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e82fb0c

Please sign in to comment.