-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core/store/migrate/migrations: add ccip cap spec migration (#13459) (#…
…1010) ## Motivation We need this particular migration from core in order to start working on the ccip capability job spec itself. ## Solution Cherry pick PR smartcontractkit/chainlink#13459 from core. This PR must be regular merged and not squashed in order to preserve history. There are no gaps between the latest migration in ccip-develop and this one so this should be safe to do.
- Loading branch information
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"ccip": patch | ||
--- | ||
|
||
#db_update ccip capability specs migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
core/store/migrate/migrations/0243_ccip_capability_specs.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
|
||
-- The ccip_specs table will hold the CCIP capability job specs. | ||
-- For each new CCIP capability version, we will create a new CCIP capability job. | ||
-- A single CCIP capability job manages all CCIP OCR instances across all chains. | ||
CREATE TABLE ccip_specs( | ||
id BIGSERIAL PRIMARY KEY, | ||
|
||
-- The CCIP capability version, specified in the capability registry. | ||
capability_version TEXT NOT NULL, | ||
|
||
-- The CCIP capability labelled name, specified in the capability registry. | ||
capability_labelled_name TEXT NOT NULL, | ||
|
||
-- A mapping of chain family to OCR key bundle ID. | ||
-- Every chain family will have its own OCR key bundle. | ||
ocr_key_bundle_ids JSONB NOT NULL, | ||
|
||
-- The P2P ID for the node. | ||
-- The same P2P ID can be used across many chain families and OCR DONs. | ||
p2p_key_id TEXT NOT NULL, | ||
|
||
-- The P2P V2 bootstrappers, used to bootstrap the DON network. | ||
-- These are of the form nodeP2PID@nodeIP:nodePort. | ||
p2pv2_bootstrappers TEXT[] NOT NULL, | ||
|
||
-- A mapping of chain family to relay configuration for that family. | ||
-- Relay configuration typically consists of contract reader and contract writer | ||
-- configurations. | ||
relay_configs JSONB NOT NULL, | ||
|
||
-- A mapping of ccip plugin type to plugin configuration for that plugin. | ||
-- For example, the token price pipeline can live in the plugin config of | ||
-- the commit plugin. | ||
plugin_config JSONB NOT NULL, | ||
|
||
created_at TIMESTAMP WITH TIME ZONE NOT NULL, | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL | ||
); | ||
|
||
-- The ccip_bootstrap_specs table will hold the CCIP capability bootstrap job specs. | ||
-- Similar to the CCIP capability job specs, these specs are scoped to a single CCIP | ||
-- capability version. | ||
-- A single CCIP bootstrap job will be able to bootstrap all CCIP OCR instances across all chains. | ||
CREATE TABLE ccip_bootstrap_specs( | ||
id BIGSERIAL PRIMARY KEY, | ||
|
||
-- The CCIP capability version, specified in the capability registry. | ||
capability_version TEXT NOT NULL, | ||
|
||
-- The CCIP capability labelled name, specified in the capability registry. | ||
capability_labelled_name TEXT NOT NULL, | ||
|
||
-- Relay config of the home chain. | ||
relay_config JSONB NOT NULL, | ||
|
||
created_at TIMESTAMP WITH TIME ZONE NOT NULL, | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL | ||
); | ||
|
||
ALTER TABLE jobs | ||
ADD COLUMN ccip_spec_id INT REFERENCES ccip_specs (id), | ||
ADD COLUMN ccip_bootstrap_spec_id INT REFERENCES ccip_bootstrap_specs (id), | ||
DROP CONSTRAINT chk_specs, | ||
ADD CONSTRAINT chk_specs CHECK ( | ||
num_nonnulls( | ||
ocr_oracle_spec_id, ocr2_oracle_spec_id, | ||
direct_request_spec_id, flux_monitor_spec_id, | ||
keeper_spec_id, cron_spec_id, webhook_spec_id, | ||
vrf_spec_id, blockhash_store_spec_id, | ||
block_header_feeder_spec_id, bootstrap_spec_id, | ||
gateway_spec_id, | ||
legacy_gas_station_server_spec_id, | ||
legacy_gas_station_sidecar_spec_id, | ||
eal_spec_id, | ||
workflow_spec_id, | ||
standard_capabilities_spec_id, | ||
ccip_spec_id, | ||
ccip_bootstrap_spec_id, | ||
CASE "type" | ||
WHEN 'stream' | ||
THEN 1 | ||
ELSE NULL | ||
END -- 'stream' type lacks a spec but should not cause validation to fail | ||
) = 1 | ||
); | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
ALTER TABLE jobs | ||
DROP CONSTRAINT chk_specs, | ||
ADD CONSTRAINT chk_specs CHECK ( | ||
num_nonnulls( | ||
ocr_oracle_spec_id, ocr2_oracle_spec_id, | ||
direct_request_spec_id, flux_monitor_spec_id, | ||
keeper_spec_id, cron_spec_id, webhook_spec_id, | ||
vrf_spec_id, blockhash_store_spec_id, | ||
block_header_feeder_spec_id, bootstrap_spec_id, | ||
gateway_spec_id, | ||
legacy_gas_station_server_spec_id, | ||
legacy_gas_station_sidecar_spec_id, | ||
eal_spec_id, | ||
workflow_spec_id, | ||
standard_capabilities_spec_id, | ||
CASE "type" | ||
WHEN 'stream' | ||
THEN 1 | ||
ELSE NULL | ||
END -- 'stream' type lacks a spec but should not cause validation to fail | ||
) = 1 | ||
); | ||
|
||
ALTER TABLE jobs | ||
DROP COLUMN ccip_spec_id; | ||
|
||
ALTER TABLE jobs | ||
DROP COLUMN ccip_bootstrap_spec_id; | ||
|
||
DROP TABLE ccip_specs; | ||
DROP TABLE ccip_bootstrap_specs; | ||
-- +goose StatementEnd |