From e8f60ed319788671dea106b3bb281bf19615adda Mon Sep 17 00:00:00 2001 From: Connor Stein Date: Thu, 1 Aug 2024 17:45:46 -0400 Subject: [PATCH] Combine cap dirs (#1248) ## Motivation CCIP cap code in one place ## Solution Move tests + cap code into capabilities/ccip --- .mockery.yaml | 2 +- .../ccip}/ccip_integration_tests/.gitignore | 0 .../ccipreader/ccipreader_test.go | 0 .../chainreader/Makefile | 0 .../chainreader/chainreader_test.go | 0 .../chainreader/mycontract.go | 0 .../chainreader/mycontract.sol | 0 .../ccip}/ccip_integration_tests/helpers.go | 11 +- .../ccip_integration_tests/home_chain_test.go | 7 +- .../integrationhelpers/integration_helpers.go | 5 +- .../ccip_integration_tests/ocr3_node_test.go | 0 .../ccip_integration_tests/ocr_node_helper.go | 3 +- .../ccip_integration_tests/ping_pong_test.go | 0 .../ccip}/ccipevm/commitcodec.go | 0 .../ccip}/ccipevm/commitcodec_test.go | 0 .../ccip}/ccipevm/executecodec.go | 0 .../ccip}/ccipevm/executecodec_test.go | 0 .../ccip}/ccipevm/helpers.go | 0 .../ccip}/ccipevm/helpers_test.go | 0 .../ccip}/ccipevm/msghasher.go | 0 .../ccip}/ccipevm/msghasher_test.go | 0 .../ccip}/common/common.go | 0 .../ccip}/common/common_test.go | 3 +- .../ccip}/configs/evm/chain_writer.go | 0 .../ccip}/configs/evm/contract_reader.go | 0 .../ccip}/delegate.go | 11 +- core/capabilities/ccip/delegate_test.go | 1 + .../ccip}/launcher/README.md | 4 +- .../ccip}/launcher/bluegreen.go | 3 +- .../ccip}/launcher/bluegreen_test.go | 5 +- .../launcher/ccip_capability_launcher.png | Bin .../launcher/ccip_config_state_machine.png | Bin .../ccip}/launcher/diff.go | 3 +- .../ccip}/launcher/diff_test.go | 3 +- .../ccip}/launcher/integration_test.go | 5 +- .../ccip}/launcher/launcher.go | 3 +- .../ccip}/launcher/launcher_test.go | 117 +++++++++--------- .../ccip}/ocrimpls/config_digester.go | 0 .../ccip}/ocrimpls/config_tracker.go | 4 +- .../ccip}/ocrimpls/contract_transmitter.go | 0 .../ocrimpls/contract_transmitter_test.go | 5 +- .../ccip}/ocrimpls/keyring.go | 0 .../ccip}/oraclecreator/inprocess.go | 15 +-- .../ccip}/oraclecreator/inprocess_test.go | 5 +- .../ccip}/types/mocks/ccip_oracle.go | 0 .../ccip}/types/mocks/home_chain_reader.go | 0 .../ccip}/types/mocks/oracle_creator.go | 2 +- .../ccip}/types/types.go | 0 .../ccip}/validate/validate.go | 0 .../ccip}/validate/validate_test.go | 3 +- core/services/ccipcapability/delegate_test.go | 1 - core/services/chainlink/application.go | 5 +- core/services/job/job_orm_test.go | 3 +- 53 files changed, 124 insertions(+), 105 deletions(-) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/.gitignore (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/ccipreader/ccipreader_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/chainreader/Makefile (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/chainreader/chainreader_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/chainreader/mycontract.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/chainreader/mycontract.sol (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/helpers.go (99%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/home_chain_test.go (96%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/integrationhelpers/integration_helpers.go (98%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/ocr3_node_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/ocr_node_helper.go (99%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccip_integration_tests/ping_pong_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/commitcodec.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/commitcodec_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/executecodec.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/executecodec_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/helpers.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/helpers_test.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/msghasher.go (100%) rename core/{services/ocr3/plugins => capabilities/ccip}/ccipevm/msghasher_test.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/common/common.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/common/common_test.go (94%) rename core/{services/ccipcapability => capabilities/ccip}/configs/evm/chain_writer.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/configs/evm/contract_reader.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/delegate.go (96%) create mode 100644 core/capabilities/ccip/delegate_test.go rename core/{services/ccipcapability => capabilities/ccip}/launcher/README.md (97%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/bluegreen.go (98%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/bluegreen_test.go (99%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/ccip_capability_launcher.png (100%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/ccip_config_state_machine.png (100%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/diff.go (98%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/diff_test.go (99%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/integration_test.go (94%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/launcher.go (99%) rename core/{services/ccipcapability => capabilities/ccip}/launcher/launcher_test.go (78%) rename core/{services/ccipcapability => capabilities/ccip}/ocrimpls/config_digester.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/ocrimpls/config_tracker.go (96%) rename core/{services/ccipcapability => capabilities/ccip}/ocrimpls/contract_transmitter.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/ocrimpls/contract_transmitter_test.go (99%) rename core/{services/ccipcapability => capabilities/ccip}/ocrimpls/keyring.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/oraclecreator/inprocess.go (95%) rename core/{services/ccipcapability => capabilities/ccip}/oraclecreator/inprocess_test.go (98%) rename core/{services/ccipcapability => capabilities/ccip}/types/mocks/ccip_oracle.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/types/mocks/home_chain_reader.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/types/mocks/oracle_creator.go (98%) rename core/{services/ccipcapability => capabilities/ccip}/types/types.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/validate/validate.go (100%) rename core/{services/ccipcapability => capabilities/ccip}/validate/validate_test.go (92%) delete mode 100644 core/services/ccipcapability/delegate_test.go diff --git a/.mockery.yaml b/.mockery.yaml index d458eef5d5..7fb335620c 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -458,7 +458,7 @@ packages: outpkg: mock_optimism_dispute_game_factory interfaces: OptimismDisputeGameFactoryInterface: - github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types: + github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types: interfaces: CCIPOracle: OracleCreator: diff --git a/core/services/ocr3/plugins/ccip_integration_tests/.gitignore b/core/capabilities/ccip/ccip_integration_tests/.gitignore similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/.gitignore rename to core/capabilities/ccip/ccip_integration_tests/.gitignore diff --git a/core/services/ocr3/plugins/ccip_integration_tests/ccipreader/ccipreader_test.go b/core/capabilities/ccip/ccip_integration_tests/ccipreader/ccipreader_test.go similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/ccipreader/ccipreader_test.go rename to core/capabilities/ccip/ccip_integration_tests/ccipreader/ccipreader_test.go diff --git a/core/services/ocr3/plugins/ccip_integration_tests/chainreader/Makefile b/core/capabilities/ccip/ccip_integration_tests/chainreader/Makefile similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/chainreader/Makefile rename to core/capabilities/ccip/ccip_integration_tests/chainreader/Makefile diff --git a/core/services/ocr3/plugins/ccip_integration_tests/chainreader/chainreader_test.go b/core/capabilities/ccip/ccip_integration_tests/chainreader/chainreader_test.go similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/chainreader/chainreader_test.go rename to core/capabilities/ccip/ccip_integration_tests/chainreader/chainreader_test.go diff --git a/core/services/ocr3/plugins/ccip_integration_tests/chainreader/mycontract.go b/core/capabilities/ccip/ccip_integration_tests/chainreader/mycontract.go similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/chainreader/mycontract.go rename to core/capabilities/ccip/ccip_integration_tests/chainreader/mycontract.go diff --git a/core/services/ocr3/plugins/ccip_integration_tests/chainreader/mycontract.sol b/core/capabilities/ccip/ccip_integration_tests/chainreader/mycontract.sol similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/chainreader/mycontract.sol rename to core/capabilities/ccip/ccip_integration_tests/chainreader/mycontract.sol diff --git a/core/services/ocr3/plugins/ccip_integration_tests/helpers.go b/core/capabilities/ccip/ccip_integration_tests/helpers.go similarity index 99% rename from core/services/ocr3/plugins/ccip_integration_tests/helpers.go rename to core/capabilities/ccip/ccip_integration_tests/helpers.go index 142337480e..3a87b72351 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/helpers.go +++ b/core/capabilities/ccip/ccip_integration_tests/helpers.go @@ -9,11 +9,17 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccip_integration_tests/integrationhelpers" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" + "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/arm_proxy_contract" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config" @@ -29,11 +35,6 @@ import ( kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/shared/generated/link_token" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/plugins/ccip_integration_tests/integrationhelpers" - - confighelper2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper" chainsel "github.com/smartcontractkit/chain-selectors" diff --git a/core/services/ocr3/plugins/ccip_integration_tests/home_chain_test.go b/core/capabilities/ccip/ccip_integration_tests/home_chain_test.go similarity index 96% rename from core/services/ocr3/plugins/ccip_integration_tests/home_chain_test.go rename to core/capabilities/ccip/ccip_integration_tests/home_chain_test.go index 8e4c70d7fb..2188e9ea75 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/home_chain_test.go +++ b/core/capabilities/ccip/ccip_integration_tests/home_chain_test.go @@ -4,6 +4,8 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccip_integration_tests/integrationhelpers" + mapset "github.com/deckarep/golang-set/v2" "github.com/onsi/gomega" @@ -13,12 +15,11 @@ import ( cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" + "github.com/stretchr/testify/require" + capcfg "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/plugins/ccip_integration_tests/integrationhelpers" - - "github.com/stretchr/testify/require" ) func TestHomeChainReader(t *testing.T) { diff --git a/core/services/ocr3/plugins/ccip_integration_tests/integrationhelpers/integration_helpers.go b/core/capabilities/ccip/ccip_integration_tests/integrationhelpers/integration_helpers.go similarity index 98% rename from core/services/ocr3/plugins/ccip_integration_tests/integrationhelpers/integration_helpers.go rename to core/capabilities/ccip/ccip_integration_tests/integrationhelpers/integration_helpers.go index 7c32734d9b..c23cd21403 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/integrationhelpers/integration_helpers.go +++ b/core/capabilities/ccip/ccip_integration_tests/integrationhelpers/integration_helpers.go @@ -9,6 +9,9 @@ import ( "testing" "time" + configsevm "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" @@ -22,8 +25,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ocr3_config_encoder" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - configsevm "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/evm" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink-common/pkg/types" diff --git a/core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go b/core/capabilities/ccip/ccip_integration_tests/ocr3_node_test.go similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/ocr3_node_test.go rename to core/capabilities/ccip/ccip_integration_tests/ocr3_node_test.go diff --git a/core/services/ocr3/plugins/ccip_integration_tests/ocr_node_helper.go b/core/capabilities/ccip/ccip_integration_tests/ocr_node_helper.go similarity index 99% rename from core/services/ocr3/plugins/ccip_integration_tests/ocr_node_helper.go rename to core/capabilities/ccip/ccip_integration_tests/ocr_node_helper.go index 5a3efefd4f..11fb203de5 100644 --- a/core/services/ocr3/plugins/ccip_integration_tests/ocr_node_helper.go +++ b/core/capabilities/ccip/ccip_integration_tests/ocr_node_helper.go @@ -10,13 +10,14 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/validate" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" gethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/jmoiron/sqlx" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/validate" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" diff --git a/core/services/ocr3/plugins/ccip_integration_tests/ping_pong_test.go b/core/capabilities/ccip/ccip_integration_tests/ping_pong_test.go similarity index 100% rename from core/services/ocr3/plugins/ccip_integration_tests/ping_pong_test.go rename to core/capabilities/ccip/ccip_integration_tests/ping_pong_test.go diff --git a/core/services/ocr3/plugins/ccipevm/commitcodec.go b/core/capabilities/ccip/ccipevm/commitcodec.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/commitcodec.go rename to core/capabilities/ccip/ccipevm/commitcodec.go diff --git a/core/services/ocr3/plugins/ccipevm/commitcodec_test.go b/core/capabilities/ccip/ccipevm/commitcodec_test.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/commitcodec_test.go rename to core/capabilities/ccip/ccipevm/commitcodec_test.go diff --git a/core/services/ocr3/plugins/ccipevm/executecodec.go b/core/capabilities/ccip/ccipevm/executecodec.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/executecodec.go rename to core/capabilities/ccip/ccipevm/executecodec.go diff --git a/core/services/ocr3/plugins/ccipevm/executecodec_test.go b/core/capabilities/ccip/ccipevm/executecodec_test.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/executecodec_test.go rename to core/capabilities/ccip/ccipevm/executecodec_test.go diff --git a/core/services/ocr3/plugins/ccipevm/helpers.go b/core/capabilities/ccip/ccipevm/helpers.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/helpers.go rename to core/capabilities/ccip/ccipevm/helpers.go diff --git a/core/services/ocr3/plugins/ccipevm/helpers_test.go b/core/capabilities/ccip/ccipevm/helpers_test.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/helpers_test.go rename to core/capabilities/ccip/ccipevm/helpers_test.go diff --git a/core/services/ocr3/plugins/ccipevm/msghasher.go b/core/capabilities/ccip/ccipevm/msghasher.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/msghasher.go rename to core/capabilities/ccip/ccipevm/msghasher.go diff --git a/core/services/ocr3/plugins/ccipevm/msghasher_test.go b/core/capabilities/ccip/ccipevm/msghasher_test.go similarity index 100% rename from core/services/ocr3/plugins/ccipevm/msghasher_test.go rename to core/capabilities/ccip/ccipevm/msghasher_test.go diff --git a/core/services/ccipcapability/common/common.go b/core/capabilities/ccip/common/common.go similarity index 100% rename from core/services/ccipcapability/common/common.go rename to core/capabilities/ccip/common/common.go diff --git a/core/services/ccipcapability/common/common_test.go b/core/capabilities/ccip/common/common_test.go similarity index 94% rename from core/services/ccipcapability/common/common_test.go rename to core/capabilities/ccip/common/common_test.go index fc22f6ac58..a7484a83ad 100644 --- a/core/services/ccipcapability/common/common_test.go +++ b/core/capabilities/ccip/common/common_test.go @@ -3,6 +3,8 @@ package common_test import ( "testing" + capcommon "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common" + "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" @@ -11,7 +13,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" - capcommon "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/common" ) func Test_HashedCapabilityId(t *testing.T) { diff --git a/core/services/ccipcapability/configs/evm/chain_writer.go b/core/capabilities/ccip/configs/evm/chain_writer.go similarity index 100% rename from core/services/ccipcapability/configs/evm/chain_writer.go rename to core/capabilities/ccip/configs/evm/chain_writer.go diff --git a/core/services/ccipcapability/configs/evm/contract_reader.go b/core/capabilities/ccip/configs/evm/contract_reader.go similarity index 100% rename from core/services/ccipcapability/configs/evm/contract_reader.go rename to core/capabilities/ccip/configs/evm/contract_reader.go diff --git a/core/services/ccipcapability/delegate.go b/core/capabilities/ccip/delegate.go similarity index 96% rename from core/services/ccipcapability/delegate.go rename to core/capabilities/ccip/delegate.go index 757417bc94..1b4b9e25ae 100644 --- a/core/services/ccipcapability/delegate.go +++ b/core/capabilities/ccip/delegate.go @@ -1,10 +1,15 @@ -package ccipcapability +package ccip import ( "context" "fmt" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common" + configsevm "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/launcher" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/oraclecreator" + ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types" "github.com/smartcontractkit/chainlink-ccip/pkg/consts" @@ -17,10 +22,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/common" - configsevm "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/evm" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/launcher" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/oraclecreator" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key" diff --git a/core/capabilities/ccip/delegate_test.go b/core/capabilities/ccip/delegate_test.go new file mode 100644 index 0000000000..dd8a5124b5 --- /dev/null +++ b/core/capabilities/ccip/delegate_test.go @@ -0,0 +1 @@ +package ccip diff --git a/core/services/ccipcapability/launcher/README.md b/core/capabilities/ccip/launcher/README.md similarity index 97% rename from core/services/ccipcapability/launcher/README.md rename to core/capabilities/ccip/launcher/README.md index e3cdc14205..41fbecfdbd 100644 --- a/core/services/ccipcapability/launcher/README.md +++ b/core/capabilities/ccip/launcher/README.md @@ -22,7 +22,7 @@ DON deletion is permanent. ## Architecture Diagram -![CCIP Capability Launcher](./ccip_capability_launcher.png) +![CCIP Capability Launcher](ccip_capability_launcher.png) The above diagram shows how the CCIP capability launcher interacts with the rest of the components in the CCIP system. @@ -41,7 +41,7 @@ in order to match the configuration that was posted on-chain in the CR and the C ## Config State Diagram -![CCIP Config State Machine](./ccip_config_state_machine.png) +![CCIP Config State Machine](ccip_config_state_machine.png) CCIP's blue/green deployment paradigm is intentionally kept as simple as possible. diff --git a/core/services/ccipcapability/launcher/bluegreen.go b/core/capabilities/ccip/launcher/bluegreen.go similarity index 98% rename from core/services/ccipcapability/launcher/bluegreen.go rename to core/capabilities/ccip/launcher/bluegreen.go index 442925c04e..6245846629 100644 --- a/core/services/ccipcapability/launcher/bluegreen.go +++ b/core/capabilities/ccip/launcher/bluegreen.go @@ -3,10 +3,11 @@ package launcher import ( "fmt" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "go.uber.org/multierr" ccipreaderpkg "github.com/smartcontractkit/chainlink-ccip/pkg/reader" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" ) // blueGreenDeployment represents a blue-green deployment of OCR instances. diff --git a/core/services/ccipcapability/launcher/bluegreen_test.go b/core/capabilities/ccip/launcher/bluegreen_test.go similarity index 99% rename from core/services/ccipcapability/launcher/bluegreen_test.go rename to core/capabilities/ccip/launcher/bluegreen_test.go index a18e02eda3..9fd71a0cb4 100644 --- a/core/services/ccipcapability/launcher/bluegreen_test.go +++ b/core/capabilities/ccip/launcher/bluegreen_test.go @@ -4,11 +4,12 @@ import ( "errors" "testing" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + mocktypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types/mocks" + "github.com/stretchr/testify/require" ccipreaderpkg "github.com/smartcontractkit/chainlink-ccip/pkg/reader" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" - mocktypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types/mocks" ) func Test_ccipDeployment_Close(t *testing.T) { diff --git a/core/services/ccipcapability/launcher/ccip_capability_launcher.png b/core/capabilities/ccip/launcher/ccip_capability_launcher.png similarity index 100% rename from core/services/ccipcapability/launcher/ccip_capability_launcher.png rename to core/capabilities/ccip/launcher/ccip_capability_launcher.png diff --git a/core/services/ccipcapability/launcher/ccip_config_state_machine.png b/core/capabilities/ccip/launcher/ccip_config_state_machine.png similarity index 100% rename from core/services/ccipcapability/launcher/ccip_config_state_machine.png rename to core/capabilities/ccip/launcher/ccip_config_state_machine.png diff --git a/core/services/ccipcapability/launcher/diff.go b/core/capabilities/ccip/launcher/diff.go similarity index 98% rename from core/services/ccipcapability/launcher/diff.go rename to core/capabilities/ccip/launcher/diff.go index bbc5684edf..e44b5478ed 100644 --- a/core/services/ccipcapability/launcher/diff.go +++ b/core/capabilities/ccip/launcher/diff.go @@ -3,10 +3,11 @@ package launcher import ( "fmt" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common" + ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/common" "github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer" ) diff --git a/core/services/ccipcapability/launcher/diff_test.go b/core/capabilities/ccip/launcher/diff_test.go similarity index 99% rename from core/services/ccipcapability/launcher/diff_test.go rename to core/capabilities/ccip/launcher/diff_test.go index 5892933207..37371945ab 100644 --- a/core/services/ccipcapability/launcher/diff_test.go +++ b/core/capabilities/ccip/launcher/diff_test.go @@ -6,11 +6,12 @@ import ( "reflect" "testing" + capcommon "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common" + ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types" "github.com/stretchr/testify/require" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" - capcommon "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/common" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types" "github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer" diff --git a/core/services/ccipcapability/launcher/integration_test.go b/core/capabilities/ccip/launcher/integration_test.go similarity index 94% rename from core/services/ccipcapability/launcher/integration_test.go rename to core/capabilities/ccip/launcher/integration_test.go index 29a2b92f0c..58b6a5d6a2 100644 --- a/core/services/ccipcapability/launcher/integration_test.go +++ b/core/capabilities/ccip/launcher/integration_test.go @@ -4,14 +4,15 @@ import ( "testing" "time" + it "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccip_integration_tests/integrationhelpers" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/onsi/gomega" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/ccip_config" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" - it "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/plugins/ccip_integration_tests/integrationhelpers" "github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer" ) diff --git a/core/services/ccipcapability/launcher/launcher.go b/core/capabilities/ccip/launcher/launcher.go similarity index 99% rename from core/services/ccipcapability/launcher/launcher.go rename to core/capabilities/ccip/launcher/launcher.go index 66aaef8cc0..9acfebfa9a 100644 --- a/core/services/ccipcapability/launcher/launcher.go +++ b/core/capabilities/ccip/launcher/launcher.go @@ -6,6 +6,8 @@ import ( "sync" "time" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "go.uber.org/multierr" ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types" @@ -16,7 +18,6 @@ import ( ccipreader "github.com/smartcontractkit/chainlink-ccip/pkg/reader" kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" "github.com/smartcontractkit/chainlink/v2/core/logger" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" "github.com/smartcontractkit/chainlink/v2/core/services/job" p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types" "github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer" diff --git a/core/services/ccipcapability/launcher/launcher_test.go b/core/capabilities/ccip/launcher/launcher_test.go similarity index 78% rename from core/services/ccipcapability/launcher/launcher_test.go rename to core/capabilities/ccip/launcher/launcher_test.go index 6f8fa7b664..493f962c2c 100644 --- a/core/services/ccipcapability/launcher/launcher_test.go +++ b/core/capabilities/ccip/launcher/launcher_test.go @@ -6,6 +6,9 @@ import ( "reflect" "testing" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types/mocks" + ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -15,8 +18,6 @@ import ( kcr "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/logger" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" - mockcctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types/mocks" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/p2pkey" "github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer" ) @@ -29,21 +30,21 @@ func Test_createOracle(t *testing.T) { myP2PKey := p2pKeys[0] type args struct { p2pID ragep2ptypes.PeerID - oracleCreator *mockcctypes.OracleCreator + oracleCreator *mocks.OracleCreator pluginType cctypes.PluginType ocrConfigs []ccipreaderpkg.OCR3ConfigWithMeta } tests := []struct { name string args args - expect func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator) + expect func(t *testing.T, args args, oracleCreator *mocks.OracleCreator) wantErr bool }{ { "success, no bootstrap", args{ myP2PKey, - mockcctypes.NewOracleCreator(t), + mocks.NewOracleCreator(t), cctypes.PluginTypeCCIPCommit, []ccipreaderpkg.OCR3ConfigWithMeta{ { @@ -53,10 +54,10 @@ func Test_createOracle(t *testing.T) { }, }, }, - func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator) { + func(t *testing.T, args args, oracleCreator *mocks.OracleCreator) { oracleCreator. On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, cctypes.OCR3ConfigWithMeta(args.ocrConfigs[0])). - Return(mockcctypes.NewCCIPOracle(t), nil) + Return(mocks.NewCCIPOracle(t), nil) }, false, }, @@ -64,7 +65,7 @@ func Test_createOracle(t *testing.T) { "success, with bootstrap", args{ myP2PKey, - mockcctypes.NewOracleCreator(t), + mocks.NewOracleCreator(t), cctypes.PluginTypeCCIPCommit, []ccipreaderpkg.OCR3ConfigWithMeta{ { @@ -76,13 +77,13 @@ func Test_createOracle(t *testing.T) { }, }, }, - func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator) { + func(t *testing.T, args args, oracleCreator *mocks.OracleCreator) { oracleCreator. On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, cctypes.OCR3ConfigWithMeta(args.ocrConfigs[0])). - Return(mockcctypes.NewCCIPOracle(t), nil) + Return(mocks.NewCCIPOracle(t), nil) oracleCreator. On("CreateBootstrapOracle", cctypes.OCR3ConfigWithMeta(args.ocrConfigs[0])). - Return(mockcctypes.NewCCIPOracle(t), nil) + Return(mocks.NewCCIPOracle(t), nil) }, false, }, @@ -90,7 +91,7 @@ func Test_createOracle(t *testing.T) { "error creating plugin oracle", args{ myP2PKey, - mockcctypes.NewOracleCreator(t), + mocks.NewOracleCreator(t), cctypes.PluginTypeCCIPCommit, []ccipreaderpkg.OCR3ConfigWithMeta{ { @@ -100,7 +101,7 @@ func Test_createOracle(t *testing.T) { }, }, }, - func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator) { + func(t *testing.T, args args, oracleCreator *mocks.OracleCreator) { oracleCreator. On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, cctypes.OCR3ConfigWithMeta(args.ocrConfigs[0])). Return(nil, errors.New("error creating oracle")) @@ -111,7 +112,7 @@ func Test_createOracle(t *testing.T) { "error creating bootstrap oracle", args{ myP2PKey, - mockcctypes.NewOracleCreator(t), + mocks.NewOracleCreator(t), cctypes.PluginTypeCCIPCommit, []ccipreaderpkg.OCR3ConfigWithMeta{ { @@ -123,10 +124,10 @@ func Test_createOracle(t *testing.T) { }, }, }, - func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator) { + func(t *testing.T, args args, oracleCreator *mocks.OracleCreator) { oracleCreator. On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, cctypes.OCR3ConfigWithMeta(args.ocrConfigs[0])). - Return(mockcctypes.NewCCIPOracle(t), nil) + Return(mocks.NewCCIPOracle(t), nil) oracleCreator. On("CreateBootstrapOracle", cctypes.OCR3ConfigWithMeta(args.ocrConfigs[0])). Return(nil, errors.New("error creating oracle")) @@ -151,14 +152,14 @@ func Test_createDON(t *testing.T) { type args struct { lggr logger.Logger p2pID ragep2ptypes.PeerID - homeChainReader *mockcctypes.HomeChainReader - oracleCreator *mockcctypes.OracleCreator + homeChainReader *mocks.HomeChainReader + oracleCreator *mocks.OracleCreator don kcr.CapabilitiesRegistryDONInfo } tests := []struct { name string args args - expect func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator, homeChainReader *mockcctypes.HomeChainReader) + expect func(t *testing.T, args args, oracleCreator *mocks.OracleCreator, homeChainReader *mocks.HomeChainReader) wantErr bool }{ { @@ -166,8 +167,8 @@ func Test_createDON(t *testing.T) { args{ logger.TestLogger(t), ragep2ptypes.PeerID(p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1)).PeerID()), - mockcctypes.NewHomeChainReader(t), - mockcctypes.NewOracleCreator(t), + mocks.NewHomeChainReader(t), + mocks.NewOracleCreator(t), kcr.CapabilitiesRegistryDONInfo{ NodeP2PIds: [][32]byte{ p2pkey.MustNewV2XXXTestingOnly(big.NewInt(2)).PeerID(), @@ -175,7 +176,7 @@ func Test_createDON(t *testing.T) { Id: 2, }, }, - func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator, homeChainReader *mockcctypes.HomeChainReader) { + func(t *testing.T, args args, oracleCreator *mocks.OracleCreator, homeChainReader *mocks.HomeChainReader) { }, false, }, @@ -184,8 +185,8 @@ func Test_createDON(t *testing.T) { args{ logger.TestLogger(t), ragep2ptypes.PeerID(p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1)).PeerID()), - mockcctypes.NewHomeChainReader(t), - mockcctypes.NewOracleCreator(t), + mocks.NewHomeChainReader(t), + mocks.NewOracleCreator(t), kcr.CapabilitiesRegistryDONInfo{ NodeP2PIds: [][32]byte{ p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1)).PeerID(), @@ -193,7 +194,7 @@ func Test_createDON(t *testing.T) { Id: 1, }, }, - func(t *testing.T, args args, oracleCreator *mockcctypes.OracleCreator, homeChainReader *mockcctypes.HomeChainReader) { + func(t *testing.T, args args, oracleCreator *mocks.OracleCreator, homeChainReader *mocks.HomeChainReader) { homeChainReader. On("GetOCRConfigs", mock.Anything, uint32(1), uint8(cctypes.PluginTypeCCIPCommit)). Return([]ccipreaderpkg.OCR3ConfigWithMeta{{}}, nil) @@ -202,10 +203,10 @@ func Test_createDON(t *testing.T) { Return([]ccipreaderpkg.OCR3ConfigWithMeta{{}}, nil) oracleCreator. On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, mock.Anything). - Return(mockcctypes.NewCCIPOracle(t), nil) + Return(mocks.NewCCIPOracle(t), nil) oracleCreator. On("CreatePluginOracle", cctypes.PluginTypeCCIPExec, mock.Anything). - Return(mockcctypes.NewCCIPOracle(t), nil) + Return(mocks.NewCCIPOracle(t), nil) }, false, }, @@ -229,7 +230,7 @@ func Test_createFutureBlueGreenDeployment(t *testing.T) { type args struct { prevDeployment ccipDeployment ocrConfigs []ccipreaderpkg.OCR3ConfigWithMeta - oracleCreator *mockcctypes.OracleCreator + oracleCreator *mocks.OracleCreator pluginType cctypes.PluginType } tests := []struct { @@ -258,8 +259,8 @@ func Test_updateDON(t *testing.T) { type args struct { lggr logger.Logger p2pID ragep2ptypes.PeerID - homeChainReader *mockcctypes.HomeChainReader - oracleCreator *mockcctypes.OracleCreator + homeChainReader *mocks.HomeChainReader + oracleCreator *mocks.OracleCreator prevDeployment ccipDeployment don kcr.CapabilitiesRegistryDONInfo } @@ -289,8 +290,8 @@ func Test_launcher_processDiff(t *testing.T) { type fields struct { lggr logger.Logger p2pID ragep2ptypes.PeerID - homeChainReader *mockcctypes.HomeChainReader - oracleCreator *mockcctypes.OracleCreator + homeChainReader *mocks.HomeChainReader + oracleCreator *mocks.OracleCreator dons map[registrysyncer.DonID]*ccipDeployment regState registrysyncer.State } @@ -311,15 +312,15 @@ func Test_launcher_processDiff(t *testing.T) { 1: { commit: blueGreenDeployment{ blue: newMock(t, - func(t *testing.T) *mockcctypes.CCIPOracle { return mockcctypes.NewCCIPOracle(t) }, - func(m *mockcctypes.CCIPOracle) { + func(t *testing.T) *mocks.CCIPOracle { return mocks.NewCCIPOracle(t) }, + func(m *mocks.CCIPOracle) { m.On("Close").Return(nil) }), }, exec: blueGreenDeployment{ blue: newMock(t, - func(t *testing.T) *mockcctypes.CCIPOracle { return mockcctypes.NewCCIPOracle(t) }, - func(m *mockcctypes.CCIPOracle) { + func(t *testing.T) *mocks.CCIPOracle { return mocks.NewCCIPOracle(t) }, + func(m *mocks.CCIPOracle) { m.On("Close").Return(nil) }), }, @@ -353,20 +354,20 @@ func Test_launcher_processDiff(t *testing.T) { fields{ lggr: logger.TestLogger(t), p2pID: ragep2ptypes.PeerID(p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1)).PeerID()), - homeChainReader: newMock(t, func(t *testing.T) *mockcctypes.HomeChainReader { - return mockcctypes.NewHomeChainReader(t) - }, func(m *mockcctypes.HomeChainReader) { + homeChainReader: newMock(t, func(t *testing.T) *mocks.HomeChainReader { + return mocks.NewHomeChainReader(t) + }, func(m *mocks.HomeChainReader) { m.On("GetOCRConfigs", mock.Anything, uint32(1), uint8(cctypes.PluginTypeCCIPCommit)). Return([]ccipreaderpkg.OCR3ConfigWithMeta{{}}, nil) m.On("GetOCRConfigs", mock.Anything, uint32(1), uint8(cctypes.PluginTypeCCIPExec)). Return([]ccipreaderpkg.OCR3ConfigWithMeta{{}}, nil) }), - oracleCreator: newMock(t, func(t *testing.T) *mockcctypes.OracleCreator { - return mockcctypes.NewOracleCreator(t) - }, func(m *mockcctypes.OracleCreator) { - commitOracle := mockcctypes.NewCCIPOracle(t) + oracleCreator: newMock(t, func(t *testing.T) *mocks.OracleCreator { + return mocks.NewOracleCreator(t) + }, func(m *mocks.OracleCreator) { + commitOracle := mocks.NewCCIPOracle(t) commitOracle.On("Start").Return(nil) - execOracle := mockcctypes.NewCCIPOracle(t) + execOracle := mocks.NewCCIPOracle(t) execOracle.On("Start").Return(nil) m.On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, mock.Anything). Return(commitOracle, nil) @@ -401,20 +402,20 @@ func Test_launcher_processDiff(t *testing.T) { fields{ lggr: logger.TestLogger(t), p2pID: ragep2ptypes.PeerID(p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1)).PeerID()), - homeChainReader: newMock(t, func(t *testing.T) *mockcctypes.HomeChainReader { - return mockcctypes.NewHomeChainReader(t) - }, func(m *mockcctypes.HomeChainReader) { + homeChainReader: newMock(t, func(t *testing.T) *mocks.HomeChainReader { + return mocks.NewHomeChainReader(t) + }, func(m *mocks.HomeChainReader) { m.On("GetOCRConfigs", mock.Anything, uint32(1), uint8(cctypes.PluginTypeCCIPCommit)). Return([]ccipreaderpkg.OCR3ConfigWithMeta{{}, {}}, nil) m.On("GetOCRConfigs", mock.Anything, uint32(1), uint8(cctypes.PluginTypeCCIPExec)). Return([]ccipreaderpkg.OCR3ConfigWithMeta{{}, {}}, nil) }), - oracleCreator: newMock(t, func(t *testing.T) *mockcctypes.OracleCreator { - return mockcctypes.NewOracleCreator(t) - }, func(m *mockcctypes.OracleCreator) { - commitOracle := mockcctypes.NewCCIPOracle(t) + oracleCreator: newMock(t, func(t *testing.T) *mocks.OracleCreator { + return mocks.NewOracleCreator(t) + }, func(m *mocks.OracleCreator) { + commitOracle := mocks.NewCCIPOracle(t) commitOracle.On("Start").Return(nil) - execOracle := mockcctypes.NewCCIPOracle(t) + execOracle := mocks.NewCCIPOracle(t) execOracle.On("Start").Return(nil) m.On("CreatePluginOracle", cctypes.PluginTypeCCIPCommit, mock.Anything). Return(commitOracle, nil) @@ -424,14 +425,14 @@ func Test_launcher_processDiff(t *testing.T) { dons: map[registrysyncer.DonID]*ccipDeployment{ 1: { commit: blueGreenDeployment{ - blue: newMock(t, func(t *testing.T) *mockcctypes.CCIPOracle { - return mockcctypes.NewCCIPOracle(t) - }, func(m *mockcctypes.CCIPOracle) {}), + blue: newMock(t, func(t *testing.T) *mocks.CCIPOracle { + return mocks.NewCCIPOracle(t) + }, func(m *mocks.CCIPOracle) {}), }, exec: blueGreenDeployment{ - blue: newMock(t, func(t *testing.T) *mockcctypes.CCIPOracle { - return mockcctypes.NewCCIPOracle(t) - }, func(m *mockcctypes.CCIPOracle) {}), + blue: newMock(t, func(t *testing.T) *mocks.CCIPOracle { + return mocks.NewCCIPOracle(t) + }, func(m *mocks.CCIPOracle) {}), }, }, }, diff --git a/core/services/ccipcapability/ocrimpls/config_digester.go b/core/capabilities/ccip/ocrimpls/config_digester.go similarity index 100% rename from core/services/ccipcapability/ocrimpls/config_digester.go rename to core/capabilities/ccip/ocrimpls/config_digester.go diff --git a/core/services/ccipcapability/ocrimpls/config_tracker.go b/core/capabilities/ccip/ocrimpls/config_tracker.go similarity index 96% rename from core/services/ccipcapability/ocrimpls/config_tracker.go rename to core/capabilities/ccip/ocrimpls/config_tracker.go index 2bf329b55e..f32c796a7a 100644 --- a/core/services/ccipcapability/ocrimpls/config_tracker.go +++ b/core/capabilities/ccip/ocrimpls/config_tracker.go @@ -3,10 +3,10 @@ package ocrimpls import ( "context" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + gethcommon "github.com/ethereum/go-ethereum/common" "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" ) type configTracker struct { diff --git a/core/services/ccipcapability/ocrimpls/contract_transmitter.go b/core/capabilities/ccip/ocrimpls/contract_transmitter.go similarity index 100% rename from core/services/ccipcapability/ocrimpls/contract_transmitter.go rename to core/capabilities/ccip/ocrimpls/contract_transmitter.go diff --git a/core/services/ccipcapability/ocrimpls/contract_transmitter_test.go b/core/capabilities/ccip/ocrimpls/contract_transmitter_test.go similarity index 99% rename from core/services/ccipcapability/ocrimpls/contract_transmitter_test.go rename to core/capabilities/ccip/ocrimpls/contract_transmitter_test.go index 46d96f83d8..4e0a7162aa 100644 --- a/core/services/ccipcapability/ocrimpls/contract_transmitter_test.go +++ b/core/capabilities/ccip/ocrimpls/contract_transmitter_test.go @@ -7,6 +7,9 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" "github.com/ethereum/go-ethereum/common" @@ -39,8 +42,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/ocrimpls" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" kschaintype "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" diff --git a/core/services/ccipcapability/ocrimpls/keyring.go b/core/capabilities/ccip/ocrimpls/keyring.go similarity index 100% rename from core/services/ccipcapability/ocrimpls/keyring.go rename to core/capabilities/ccip/ocrimpls/keyring.go diff --git a/core/services/ccipcapability/oraclecreator/inprocess.go b/core/capabilities/ccip/oraclecreator/inprocess.go similarity index 95% rename from core/services/ccipcapability/oraclecreator/inprocess.go rename to core/capabilities/ccip/oraclecreator/inprocess.go index 594ff73a76..1d17867846 100644 --- a/core/services/ccipcapability/oraclecreator/inprocess.go +++ b/core/capabilities/ccip/oraclecreator/inprocess.go @@ -5,6 +5,11 @@ import ( "fmt" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" + evmconfig "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/configs/evm" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ocrimpls" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/google/uuid" @@ -28,13 +33,9 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm" "github.com/smartcontractkit/chainlink/v2/core/logger" - evmconfigs "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/configs/evm" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/ocrimpls" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype" "github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key" - "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/plugins/ccipevm" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" "github.com/smartcontractkit/chainlink/v2/core/services/relay" "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm" @@ -153,9 +154,9 @@ func (i *inprocessOracleCreator) CreatePluginOracle(pluginType cctypes.PluginTyp for _, chain := range i.chains.Slice() { var chainReaderConfig evmrelaytypes.ChainReaderConfig if chain.ID().Uint64() == destChainID { - chainReaderConfig = evmconfigs.DestReaderConfig() + chainReaderConfig = evmconfig.DestReaderConfig() } else { - chainReaderConfig = evmconfigs.SourceReaderConfig() + chainReaderConfig = evmconfig.SourceReaderConfig() } cr, err2 := evm.NewChainReaderService( context.Background(), @@ -207,7 +208,7 @@ func (i *inprocessOracleCreator) CreatePluginOracle(pluginType cctypes.PluginTyp chain.Client(), chain.TxManager(), chain.GasEstimator(), - evmconfigs.ChainWriterConfigRaw(fromAddress, chain.Config().EVM().GasEstimator().PriceMaxKey(fromAddress)), + evmconfig.ChainWriterConfigRaw(fromAddress, chain.Config().EVM().GasEstimator().PriceMaxKey(fromAddress)), ) if err2 != nil { return nil, fmt.Errorf("failed to create chain writer for chain %s: %w", chain.ID(), err2) diff --git a/core/services/ccipcapability/oraclecreator/inprocess_test.go b/core/capabilities/ccip/oraclecreator/inprocess_test.go similarity index 98% rename from core/services/ccipcapability/oraclecreator/inprocess_test.go rename to core/capabilities/ccip/oraclecreator/inprocess_test.go index dfc5aac10e..639f01e62e 100644 --- a/core/services/ccipcapability/oraclecreator/inprocess_test.go +++ b/core/capabilities/ccip/oraclecreator/inprocess_test.go @@ -5,6 +5,9 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/oraclecreator" + cctypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/google/uuid" "github.com/hashicorp/consul/sdk/freeport" @@ -29,8 +32,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest" "github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest" "github.com/smartcontractkit/chainlink/v2/core/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/oraclecreator" - cctypes "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" diff --git a/core/services/ccipcapability/types/mocks/ccip_oracle.go b/core/capabilities/ccip/types/mocks/ccip_oracle.go similarity index 100% rename from core/services/ccipcapability/types/mocks/ccip_oracle.go rename to core/capabilities/ccip/types/mocks/ccip_oracle.go diff --git a/core/services/ccipcapability/types/mocks/home_chain_reader.go b/core/capabilities/ccip/types/mocks/home_chain_reader.go similarity index 100% rename from core/services/ccipcapability/types/mocks/home_chain_reader.go rename to core/capabilities/ccip/types/mocks/home_chain_reader.go diff --git a/core/services/ccipcapability/types/mocks/oracle_creator.go b/core/capabilities/ccip/types/mocks/oracle_creator.go similarity index 98% rename from core/services/ccipcapability/types/mocks/oracle_creator.go rename to core/capabilities/ccip/types/mocks/oracle_creator.go index 5a0f892af1..d83ad042bf 100644 --- a/core/services/ccipcapability/types/mocks/oracle_creator.go +++ b/core/capabilities/ccip/types/mocks/oracle_creator.go @@ -3,7 +3,7 @@ package mocks import ( - types "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/types" + types "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" mock "github.com/stretchr/testify/mock" ) diff --git a/core/services/ccipcapability/types/types.go b/core/capabilities/ccip/types/types.go similarity index 100% rename from core/services/ccipcapability/types/types.go rename to core/capabilities/ccip/types/types.go diff --git a/core/services/ccipcapability/validate/validate.go b/core/capabilities/ccip/validate/validate.go similarity index 100% rename from core/services/ccipcapability/validate/validate.go rename to core/capabilities/ccip/validate/validate.go diff --git a/core/services/ccipcapability/validate/validate_test.go b/core/capabilities/ccip/validate/validate_test.go similarity index 92% rename from core/services/ccipcapability/validate/validate_test.go rename to core/capabilities/ccip/validate/validate_test.go index e56da69336..97958f4cf9 100644 --- a/core/services/ccipcapability/validate/validate_test.go +++ b/core/capabilities/ccip/validate/validate_test.go @@ -3,9 +3,10 @@ package validate_test import ( "testing" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/validate" + "github.com/stretchr/testify/require" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/validate" "github.com/smartcontractkit/chainlink/v2/core/services/job" ) diff --git a/core/services/ccipcapability/delegate_test.go b/core/services/ccipcapability/delegate_test.go deleted file mode 100644 index b725c930ad..0000000000 --- a/core/services/ccipcapability/delegate_test.go +++ /dev/null @@ -1 +0,0 @@ -package ccipcapability diff --git a/core/services/chainlink/application.go b/core/services/chainlink/application.go index 28ad951050..de3e4c6280 100644 --- a/core/services/chainlink/application.go +++ b/core/services/chainlink/application.go @@ -8,6 +8,8 @@ import ( "net/http" "sync" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/google/uuid" @@ -27,7 +29,6 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox" "github.com/smartcontractkit/chainlink/v2/core/capabilities" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability" "github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities" "github.com/smartcontractkit/chainlink/v2/core/static" @@ -522,7 +523,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) { cfg.Insecure(), opts.RelayerChainInteroperators, ) - delegates[job.CCIP] = ccipcapability.NewDelegate( + delegates[job.CCIP] = ccip.NewDelegate( globalLogger, loopRegistrarConfig, pipelineRunner, diff --git a/core/services/job/job_orm_test.go b/core/services/job/job_orm_test.go index 36ce025630..348d29747d 100644 --- a/core/services/job/job_orm_test.go +++ b/core/services/job/job_orm_test.go @@ -7,6 +7,8 @@ import ( "testing" "time" + "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/validate" + "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" "github.com/lib/pq" @@ -34,7 +36,6 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/blockhashstore" "github.com/smartcontractkit/chainlink/v2/core/services/blockheaderfeeder" - "github.com/smartcontractkit/chainlink/v2/core/services/ccipcapability/validate" "github.com/smartcontractkit/chainlink/v2/core/services/chainlink" "github.com/smartcontractkit/chainlink/v2/core/services/directrequest" "github.com/smartcontractkit/chainlink/v2/core/services/job"