Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions build/devenv/chainreg/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"github.com/smartcontractkit/chainlink-ccv/build/devenv/services/committeeverifier"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/services/executor"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/util"
"github.com/smartcontractkit/chainlink-ccv/protocol"
cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
"github.com/smartcontractkit/chainlink-deployments-framework/deployment"
ctfblockchain "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
)
Expand Down Expand Up @@ -83,6 +85,25 @@ type ExecutorModifier = executor.ReqModifier
// ExtraArgsSerializer serializes message extra args for a destination chain family.
type ExtraArgsSerializer = cciptestinterfaces.ExtraArgsSerializer

// AddressResolver is used by the test framework to resolve addresses of certain
// on-chain contracts. It is expected that it is implemented per-family.
type AddressResolver interface {
// GetContractReceiver returns the receiver contract address for the given chain selector and qualifier.
// This typically returns the mock receiver contract, extensively used in tests.
GetContractReceiver(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error)

// GetExecutor returns the executor contract address for the given chain selector and qualifier.
GetExecutor(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error)

// GetCommitteeCCV returns the committee CCV address for the given chain selector and qualifier.
// This address must be usable as a CCV contract address onchain.
// For EVM, this is typically the committee verifier resolver proxy address.
GetCommitteeCCV(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error)

// GetTokenPool returns the token pool address for the given chain selector and qualifier.
GetTokenPool(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error)
}

// Registration groups every devenv extension for one chain family.
// Fields are optional; callers should set what the family supports.
type Registration struct {
Expand All @@ -93,4 +114,5 @@ type Registration struct {
VerifierModifier VerifierModifier
ExecutorModifier ExecutorModifier
ExtraArgsSerializers map[uint8]ExtraArgsSerializer
AddressResolver AddressResolver
}
62 changes: 62 additions & 0 deletions build/devenv/evm/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ import (
cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
cldf_evm_provider "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm/provider"
"github.com/smartcontractkit/chainlink-deployments-framework/chain/evm/provider/rpcclient"
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
"github.com/smartcontractkit/chainlink-deployments-framework/deployment"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"

"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_5_0/operations/burn_mint_erc20_with_drip"
adapters_1_6_1 "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_1/adapters"
evmadapters "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v2_0_0/adapters"
executorops "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v2_0_0/operations/executor"
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v2_0_0/operations/mock_receiver_v2"
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v2_0_0/sequences"
"github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v2_0_0/versioned_verifier_resolver"
tokenscore "github.com/smartcontractkit/chainlink-ccip/deployment/tokens"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/cciptestinterfaces"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/chainreg"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/services"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/services/committeeverifier"
"github.com/smartcontractkit/chainlink-ccv/build/devenv/services/executor"
"github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm"
"github.com/smartcontractkit/chainlink-ccv/protocol"
)

var tokenPoolVersions = []string{
Expand All @@ -49,6 +56,7 @@ func init() {
2: BuildEVMExtraArgsV2,
3: SerializeMessageV3ExtraArgs,
},
AddressResolver: &AddressResolver{},
}); err != nil {
panic("evm chainreg: " + err.Error())
}
Expand Down Expand Up @@ -239,3 +247,57 @@ func ChainConfigLoader(outputs []*blockchain.Output) (map[string]any, error) {

return infos, nil
}

func getContractAddress(ds datastore.DataStore, chainSelector uint64, contractType datastore.ContractType, version, qualifier, contractName string) (protocol.UnknownAddress, error) {
ref, err := ds.Addresses().Get(
datastore.NewAddressRefKey(chainSelector, contractType, semver.MustParse(version), qualifier),
)
if err != nil {
return protocol.UnknownAddress{}, fmt.Errorf("failed to get %s address for chain selector %d, ContractType: %s, ContractVersion: %s: %w",
contractName, chainSelector, contractType, version, err)
}
return protocol.NewUnknownAddressFromHex(ref.Address)
}

// AddressResolver implements [chainreg.AddressResolver] for EVM chains using v2.0.0 devenv deployments.
type AddressResolver struct{}

// GetContractReceiver implements [chainreg.AddressResolver].
func (AddressResolver) GetContractReceiver(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error) {
return getContractAddress(ds, chainSelector,
datastore.ContractType(mock_receiver_v2.ContractType),
mock_receiver_v2.Deploy.Version(),
qualifier,
"mock receiver",
)
}

// GetExecutor implements [chainreg.AddressResolver].
func (AddressResolver) GetExecutor(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error) {
return getContractAddress(ds, chainSelector,
datastore.ContractType(sequences.ExecutorProxyType),
executorops.Deploy.Version(),
qualifier,
"executor",
)
}

// GetCommitteeCCV implements [chainreg.AddressResolver].
func (AddressResolver) GetCommitteeCCV(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error) {
return getContractAddress(ds, chainSelector,
datastore.ContractType(versioned_verifier_resolver.CommitteeVerifierResolverType),
versioned_verifier_resolver.Version.String(),
qualifier,
"committee verifier proxy",
)
}

// GetTokenPool implements [chainreg.AddressResolver].
func (AddressResolver) GetTokenPool(ds datastore.DataStore, chainSelector uint64, qualifier string) (protocol.UnknownAddress, error) {
return getContractAddress(ds, chainSelector,
datastore.ContractType(burn_mint_erc20_with_drip.ContractType),
burn_mint_erc20_with_drip.Deploy.Version(),
qualifier,
"burn mint erc677",
)
}
Loading
Loading