diff --git a/deployment/keystone/capability_registry_deployer.go b/deployment/keystone/capability_registry_deployer.go index 71f9f8c47ba..efe1d23f11f 100644 --- a/deployment/keystone/capability_registry_deployer.go +++ b/deployment/keystone/capability_registry_deployer.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -25,11 +26,6 @@ func (c *CapabilitiesRegistryDeployer) Contract() *capabilities_registry.Capabil return c.contract } -var CapabilityRegistryTypeVersion = deployment.TypeAndVersion{ - Type: CapabilitiesRegistry, - Version: deployment.Version1_0_0, -} - func (c *CapabilitiesRegistryDeployer) Deploy(req DeployRequest) (*DeployResponse, error) { est, err := estimateDeploymentGas(req.Chain.Client, capabilities_registry.CapabilitiesRegistryABI) if err != nil { @@ -48,10 +44,19 @@ func (c *CapabilitiesRegistryDeployer) Deploy(req DeployRequest) (*DeployRespons if err != nil { return nil, fmt.Errorf("failed to confirm and save CapabilitiesRegistry: %w", err) } + tvStr, err := capabilitiesRegistry.TypeAndVersion(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("failed to get type and version: %w", err) + } + + tv, err := deployment.TypeAndVersionFromString(tvStr) + if err != nil { + return nil, fmt.Errorf("failed to parse type and version from %s: %w", tvStr, err) + } resp := &DeployResponse{ Address: capabilitiesRegistryAddr, Tx: tx.Hash(), - Tv: CapabilityRegistryTypeVersion, + Tv: tv, } c.contract = capabilitiesRegistry return resp, nil diff --git a/deployment/keystone/changeset/configure_contracts.go b/deployment/keystone/changeset/configure_contracts.go index 7254a34c4f3..885b87189cd 100644 --- a/deployment/keystone/changeset/configure_contracts.go +++ b/deployment/keystone/changeset/configure_contracts.go @@ -23,11 +23,11 @@ func ConfigureInitialContracts(lggr logger.Logger, req *kslib.ConfigureContracts foundForwarder := false for _, addr := range regAddrs { switch addr.Type { - case kslib.CapabilityRegistryTypeVersion.Type: + case kslib.CapabilitiesRegistry: foundRegistry = true - case kslib.OCR3CapabilityTypeVersion.Type: + case kslib.OCR3Capability: foundOCR3 = true - case kslib.ForwarderTypeVersion.Type: + case kslib.KeystoneForwarder: foundForwarder = true } } @@ -43,7 +43,7 @@ func ConfigureInitialContracts(lggr logger.Logger, req *kslib.ConfigureContracts return deployment.ChangesetOutput{}, fmt.Errorf("no addresses found for chain %d: %w", c.Selector, err2) } for _, addr := range addrs { - if addr.Type == kslib.ForwarderTypeVersion.Type { + if addr.Type == kslib.KeystoneForwarder { foundForwarder = true break } diff --git a/deployment/keystone/changeset/deploy_forwarder_test.go b/deployment/keystone/changeset/deploy_forwarder_test.go index 4cd0e5bc663..2783dcea5ff 100644 --- a/deployment/keystone/changeset/deploy_forwarder_test.go +++ b/deployment/keystone/changeset/deploy_forwarder_test.go @@ -24,12 +24,17 @@ func TestDeployForwarder(t *testing.T) { } env := memory.NewMemoryEnvironment(t, lggr, zapcore.DebugLevel, cfg) + var ( + ocrTV = deployment.NewTypeAndVersion(kslb.OCR3Capability, deployment.Version1_0_0) + crTV = deployment.NewTypeAndVersion(kslb.CapabilitiesRegistry, deployment.Version1_0_0) + ) + registrySel := env.AllChainSelectors()[0] t.Run("err if no capabilities registry on registry chain", func(t *testing.T) { ab := deployment.NewMemoryAddressBook() m := make(map[uint64]map[string]deployment.TypeAndVersion) m[registrySel] = map[string]deployment.TypeAndVersion{ - "0x0000000000000000000000000000000000000002": kslb.OCR3CapabilityTypeVersion, + "0x0000000000000000000000000000000000000002": ocrTV, } deployment.NewMemoryAddressBookFromMap(m) // capabilities registry and ocr3 must be deployed on registry chain @@ -41,7 +46,7 @@ func TestDeployForwarder(t *testing.T) { ab := deployment.NewMemoryAddressBook() m := make(map[uint64]map[string]deployment.TypeAndVersion) m[registrySel] = map[string]deployment.TypeAndVersion{ - "0x0000000000000000000000000000000000000001": kslb.CapabilityRegistryTypeVersion, + "0x0000000000000000000000000000000000000001": crTV, } deployment.NewMemoryAddressBookFromMap(m) // capabilities registry and ocr3 must be deployed on registry chain @@ -52,11 +57,11 @@ func TestDeployForwarder(t *testing.T) { t.Run("should deploy forwarder", func(t *testing.T) { ab := deployment.NewMemoryAddressBook() // fake capabilities registry - err := ab.Save(registrySel, "0x0000000000000000000000000000000000000001", kslb.CapabilityRegistryTypeVersion) + err := ab.Save(registrySel, "0x0000000000000000000000000000000000000001", crTV) require.NoError(t, err) // fake ocr3 - err = ab.Save(registrySel, "0x0000000000000000000000000000000000000002", kslb.OCR3CapabilityTypeVersion) + err = ab.Save(registrySel, "0x0000000000000000000000000000000000000002", ocrTV) require.NoError(t, err) // deploy forwarder resp, err := changeset.DeployForwarder(lggr, env, ab, registrySel) diff --git a/deployment/keystone/contract_set.go b/deployment/keystone/contract_set.go index e4e74aadfef..a0446dcfce0 100644 --- a/deployment/keystone/contract_set.go +++ b/deployment/keystone/contract_set.go @@ -56,7 +56,7 @@ func DeployCapabilitiesRegistry(lggr logger.Logger, chain deployment.Chain, ab d if err != nil { return fmt.Errorf("failed to save CapabilitiesRegistry: %w", err) } - lggr.Infof("Deployed %s chain selector %d addr %s", CapabilityRegistryTypeVersion.String(), chain.Selector, capabilitiesRegistryResp.Address.String()) + lggr.Infof("Deployed %s chain selector %d addr %s", capabilitiesRegistryResp.Tv.String(), chain.Selector, capabilitiesRegistryResp.Address.String()) return nil } diff --git a/deployment/keystone/forwarder_deployer.go b/deployment/keystone/forwarder_deployer.go index b13df1b7200..b7fde675973 100644 --- a/deployment/keystone/forwarder_deployer.go +++ b/deployment/keystone/forwarder_deployer.go @@ -3,6 +3,7 @@ package keystone import ( "fmt" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder" @@ -13,11 +14,6 @@ type KeystoneForwarderDeployer struct { contract *forwarder.KeystoneForwarder } -var ForwarderTypeVersion = deployment.TypeAndVersion{ - Type: KeystoneForwarder, - Version: deployment.Version1_0_0, -} - func (c *KeystoneForwarderDeployer) deploy(req DeployRequest) (*DeployResponse, error) { est, err := estimateDeploymentGas(req.Chain.Client, forwarder.KeystoneForwarderABI) if err != nil { @@ -36,10 +32,18 @@ func (c *KeystoneForwarderDeployer) deploy(req DeployRequest) (*DeployResponse, if err != nil { return nil, fmt.Errorf("failed to confirm and save KeystoneForwarder: %w", err) } + tvStr, err := forwarder.TypeAndVersion(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("failed to get type and version: %w", err) + } + tv, err := deployment.TypeAndVersionFromString(tvStr) + if err != nil { + return nil, fmt.Errorf("failed to parse type and version from %s: %w", tvStr, err) + } resp := &DeployResponse{ Address: forwarderAddr, Tx: tx.Hash(), - Tv: ForwarderTypeVersion, + Tv: tv, } c.contract = forwarder return resp, nil diff --git a/deployment/keystone/ocr3_deployer.go b/deployment/keystone/ocr3_deployer.go index b4f7d2b0852..5f2ba34f42c 100644 --- a/deployment/keystone/ocr3_deployer.go +++ b/deployment/keystone/ocr3_deployer.go @@ -3,6 +3,7 @@ package keystone import ( "fmt" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/ocr3_capability" @@ -13,11 +14,6 @@ type OCR3Deployer struct { contract *ocr3_capability.OCR3Capability } -var OCR3CapabilityTypeVersion = deployment.TypeAndVersion{ - Type: OCR3Capability, - Version: deployment.Version1_0_0, -} - func (c *OCR3Deployer) deploy(req DeployRequest) (*DeployResponse, error) { est, err := estimateDeploymentGas(req.Chain.Client, ocr3_capability.OCR3CapabilityABI) if err != nil { @@ -36,10 +32,18 @@ func (c *OCR3Deployer) deploy(req DeployRequest) (*DeployResponse, error) { if err != nil { return nil, fmt.Errorf("failed to confirm transaction %s: %w", tx.Hash().String(), err) } + tvStr, err := ocr3.TypeAndVersion(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("failed to get type and version: %w", err) + } + tv, err := deployment.TypeAndVersionFromString(tvStr) + if err != nil { + return nil, fmt.Errorf("failed to parse type and version from %s: %w", tvStr, err) + } resp := &DeployResponse{ Address: ocr3Addr, Tx: tx.Hash(), - Tv: OCR3CapabilityTypeVersion, + Tv: tv, } c.contract = ocr3 return resp, nil diff --git a/deployment/keystone/state.go b/deployment/keystone/state.go index 21fd06744bb..be62400b4a9 100644 --- a/deployment/keystone/state.go +++ b/deployment/keystone/state.go @@ -49,9 +49,6 @@ func loadContractSet(chain deployment.Chain, addresses map[string]deployment.Typ for addr, tv := range addresses { // todo handle versions - if !tv.Version.Equal(&deployment.Version1_0_0) { - return nil, fmt.Errorf("unsupported version %s", tv.Version.String()) - } switch tv.Type { case CapabilitiesRegistry: c, err := capabilities_registry.NewCapabilitiesRegistry(common.HexToAddress(addr), chain.Client) diff --git a/deployment/keystone/types.go b/deployment/keystone/types.go index 40d5d4aa424..0d2a1b6f58e 100644 --- a/deployment/keystone/types.go +++ b/deployment/keystone/types.go @@ -24,9 +24,10 @@ import ( ) var ( - CapabilitiesRegistry deployment.ContractType = "CapabilitiesRegistry" - KeystoneForwarder deployment.ContractType = "KeystoneForwarder" - OCR3Capability deployment.ContractType = "OCR3Capability" + CapabilitiesRegistry deployment.ContractType = "CapabilitiesRegistry" // https://github.com/smartcontractkit/chainlink/blob/50c1b3dbf31bd145b312739b08967600a5c67f30/contracts/src/v0.8/keystone/CapabilitiesRegistry.sol#L392 + KeystoneForwarder deployment.ContractType = "KeystoneForwarder" // https://github.com/smartcontractkit/chainlink/blob/50c1b3dbf31bd145b312739b08967600a5c67f30/contracts/src/v0.8/keystone/KeystoneForwarder.sol#L90 + OCR3Capability deployment.ContractType = "OCR3Capability" // https://github.com/smartcontractkit/chainlink/blob/50c1b3dbf31bd145b312739b08967600a5c67f30/contracts/src/v0.8/keystone/OCR3Capability.sol#L12 + FeedConsumer deployment.ContractType = "FeedConsumer" // no type and a version in contract https://github.com/smartcontractkit/chainlink/blob/89183a8a5d22b1aeca0ade3b76d16aa84067aa57/contracts/src/v0.8/keystone/KeystoneFeedsConsumer.sol#L1 ) type DeployResponse struct {