Skip to content

CLD-2059: Add catalog delete#964

Open
DimitriosNaikopoulos wants to merge 13 commits intomainfrom
CLD-2059-catalog-deletes
Open

CLD-2059: Add catalog delete#964
DimitriosNaikopoulos wants to merge 13 commits intomainfrom
CLD-2059-catalog-deletes

Conversation

@DimitriosNaikopoulos
Copy link
Copy Markdown
Contributor

@DimitriosNaikopoulos DimitriosNaikopoulos commented Apr 29, 2026

CLD-2059: Add catalog delete

Implements catalog delete for removing data from the catalog version of the datastore.

  • Implement all delete methods
  • Add testing
  • Update the container for catalog testing to the latest version which implements the semantic delete
  • Update protos
  • Use a common function for executing edits over GRPC to reduce code duplication between methods that implement the same functionality but we different proto and error handling

Tested E2E locally

Adding data

op_catalog_db=# SELECT * FROM address_reference;
 domain | environment | chain_selector | contract_type | version | qualifier  | address | label_set |          created_at           |          updated_at           |                  id                  | deleted_at
--------+-------------+----------------+---------------+---------+------------+---------+-----------+-------------------------------+-------------------------------+--------------------------------------+------------
 opdev  | local       |              1 | type1         | 1.0.0   | qualifier1 | 0x123   | {label1}  | 2026-04-30 11:29:43.626517+00 | 2026-04-30 11:29:43.626517+00 | 1256c2e4-3035-4ccf-9003-827462bfb6cd |
(1 row)

op_catalog_db=# SELECT * FROM contract_metadata;
 domain | environment | chain_selector | address |                 metadata                 | row_version |          created_at           |          updated_at           |                  id                  | deleted_at
--------+-------------+----------------+---------+------------------------------------------+-------------+-------------------------------+-------------------------------+--------------------------------------+------------
 opdev  | local       |              1 | 0x123   | {"testMetadata": "testContractMetadata"} |           1 | 2026-04-30 11:29:43.638126+00 | 2026-04-30 11:29:43.638126+00 | ff27a166-ca69-4151-8714-0fa1f856a61b |
(1 row)

op_catalog_db=# SELECT * FROM chain_metadata;
 domain | environment | chain_selector |               metadata                | row_version |          created_at           |          updated_at           |                  id                  | deleted_at
--------+-------------+----------------+---------------------------------------+-------------+-------------------------------+-------------------------------+--------------------------------------+------------
 opdev  | local       |              1 | {"testMetadata": "testChainMetadata"} |           1 | 2026-04-30 11:29:43.635836+00 | 2026-04-30 11:29:43.635836+00 | 1268e71e-7f67-48a4-be97-7364d1fe1713 |
(1 row)

Removing the same data

op_catalog_db=# SELECT * FROM address_reference;
 domain | environment | chain_selector | contract_type | version | qualifier  | address | label_set |          created_at           |          updated_at           |                  id                  |          deleted_at
--------+-------------+----------------+---------------+---------+------------+---------+-----------+-------------------------------+-------------------------------+--------------------------------------+-------------------------------
 opdev  | local       |              1 | type1         | 1.0.0   | qualifier1 | 0x123   | {label1}  | 2026-04-30 11:29:43.626517+00 | 2026-04-30 11:33:44.395726+00 | 1256c2e4-3035-4ccf-9003-827462bfb6cd | 2026-04-30 11:33:44.395726+00
(1 row)

op_catalog_db=# SELECT * FROM contract_metadata;
 domain | environment | chain_selector | address |                 metadata                 | row_version |          created_at           |          updated_at           |                  id                  |          deleted_at
--------+-------------+----------------+---------+------------------------------------------+-------------+-------------------------------+-------------------------------+--------------------------------------+-------------------------------
 opdev  | local       |              1 | 0x123   | {"testMetadata": "testContractMetadata"} |           2 | 2026-04-30 11:29:43.638126+00 | 2026-04-30 11:33:44.401438+00 | ff27a166-ca69-4151-8714-0fa1f856a61b | 2026-04-30 11:33:44.401438+00
(1 row)

op_catalog_db=# SELECT * FROM chain_metadata;
 domain | environment | chain_selector |               metadata                | row_version |          created_at           |          updated_at           |                  id                  |          deleted_at
--------+-------------+----------------+---------------------------------------+-------------+-------------------------------+-------------------------------+--------------------------------------+-------------------------------
 opdev  | local       |              1 | {"testMetadata": "testChainMetadata"} |           2 | 2026-04-30 11:29:43.635836+00 | 2026-04-30 11:33:44.399648+00 | 1268e71e-7f67-48a4-be97-7364d1fe1713 | 2026-04-30 11:33:44.399648+00
(1 row)

Restore by creating the same data will add different labels, metadata to tell the difference

op_catalog_db=# SELECT * FROM address_reference;
 domain | environment | chain_selector | contract_type | version | qualifier  | address |     label_set     |          created_at           |          updated_at           |                  id                  | deleted_at
--------+-------------+----------------+---------------+---------+------------+---------+-------------------+-------------------------------+-------------------------------+--------------------------------------+------------
 opdev  | local       |              1 | type1         | 1.0.0   | qualifier1 | 0x123   | {label1_restored} | 2026-04-30 11:29:43.626517+00 | 2026-04-30 11:37:16.805992+00 | 1256c2e4-3035-4ccf-9003-827462bfb6cd |
(1 row)

op_catalog_db=# SELECT * FROM contract_metadata;
 domain | environment | chain_selector | address |                     metadata                      | row_version |          created_at           |          updated_at           |                  id                  | deleted_at
--------+-------------+----------------+---------+---------------------------------------------------+-------------+-------------------------------+-------------------------------+--------------------------------------+------------
 opdev  | local       |              1 | 0x123   | {"testMetadata": "testContractMetadata_Restored"} |           3 | 2026-04-30 11:29:43.638126+00 | 2026-04-30 11:37:16.814155+00 | ff27a166-ca69-4151-8714-0fa1f856a61b |
(1 row)

op_catalog_db=# SELECT * FROM chain_metadata;
 domain | environment | chain_selector |                    metadata                    | row_version |          created_at           |          updated_at           |                  id                  | deleted_at
--------+-------------+----------------+------------------------------------------------+-------------+-------------------------------+-------------------------------+--------------------------------------+------------
 opdev  | local       |              1 | {"testMetadata": "testChainMetadata_Restored"} |           3 | 2026-04-30 11:29:43.635836+00 | 2026-04-30 11:37:16.811407+00 | 1268e71e-7f67-48a4-be97-7364d1fe1713 |
(1 row)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

🦋 Changeset detected

Latest commit: cae8ad9

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread datastore/catalog_syncer.go
Comment thread datastore/catalog_syncer.go
Comment thread datastore/catalog_syncer.go
Comment thread datastore/catalog_syncer.go
@DimitriosNaikopoulos DimitriosNaikopoulos marked this pull request as ready for review April 30, 2026 12:01
@DimitriosNaikopoulos DimitriosNaikopoulos requested a review from a team as a code owner April 30, 2026 12:01
@giogam
Copy link
Copy Markdown
Contributor

giogam commented May 1, 2026

The opName string parameter in executeEdit has an inconsistency worth fixing: the address_ref_store calls include the verb ("add address ref", "upsert address ref"), but the chain_metadata_store, contract_metadata_store, and
env_metadata_store pass verb-free names ("chain metadata", "env metadata"). This means errors like "chain metadata failed" don't tell you what operation failed.

Rather than fixing the raw strings, what do you think about adding two small internal types like:

type catalogOp string                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                  
const (
    opAdd    catalogOp = "add"                                                                                                                                                                                                                    
    opUpsert catalogOp = "upsert"
    opUpdate catalogOp = "update"
    opDelete catalogOp = "delete"
)                                                                                                                                                                                                                                                 
 
type catalogEntity string                                                                                                                                                                                                                         
                          
const (
    entityAddressRef       catalogEntity = "address ref"
    entityChainMetadata    catalogEntity = "chain metadata"
    entityContractMetadata catalogEntity = "contract metadata"
    entityEnvMetadata      catalogEntity = "env metadata"
)                                                                                                                                                                                                                                                 
 
executeEdit would take op catalogOp, entity catalogEntity and compose the label internally. Calls become opAdd, entityAddressRef, typo-safe and consistently formatted across all stores.                                                   

Copilot AI review requested due to automatic review settings May 1, 2026 10:02
@DimitriosNaikopoulos
Copy link
Copy Markdown
Contributor Author

The opName string parameter in executeEdit has an inconsistency worth fixing: the address_ref_store calls include the verb ("add address ref", "upsert address ref"), but the chain_metadata_store, contract_metadata_store, and env_metadata_store pass verb-free names ("chain metadata", "env metadata"). This means errors like "chain metadata failed" don't tell you what operation failed.

Rather than fixing the raw strings, what do you think about adding two small internal types like:

type catalogOp string                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                  
const (
    opAdd    catalogOp = "add"                                                                                                                                                                                                                    
    opUpsert catalogOp = "upsert"
    opUpdate catalogOp = "update"
    opDelete catalogOp = "delete"
)                                                                                                                                                                                                                                                 
 
type catalogEntity string                                                                                                                                                                                                                         
                          
const (
    entityAddressRef       catalogEntity = "address ref"
    entityChainMetadata    catalogEntity = "chain metadata"
    entityContractMetadata catalogEntity = "contract metadata"
    entityEnvMetadata      catalogEntity = "env metadata"
)                                                                                                                                                                                                                                                 
 
executeEdit would take op catalogOp, entity catalogEntity and compose the label internally. Calls become opAdd, entityAddressRef, typo-safe and consistently formatted across all stores.                                                   

@giogam updated the PR but I figure that we already known all this info from the proto, therefore, I added a couple of helper function so that we automatically discover what operation and for which entity we want to execute during edits a4131c3

This comment was marked as off-topic.

{name: "add env metadata", req: envMetadataOp(pb.EditSemantics_SEMANTICS_INSERT), expected: "add env metadata"},
{name: "upsert env metadata", req: envMetadataOp(pb.EditSemantics_SEMANTICS_UPSERT), expected: "upsert env metadata"},
{name: "update env metadata", req: envMetadataOp(pb.EditSemantics_SEMANTICS_UPDATE), expected: "update env metadata"},
{name: "delete env metadata", req: envMetadataOp(pb.EditSemantics_SEMANTICS_DELETE), expected: "delete env metadata"},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not supported by the catalog api

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed cae8ad9

@cl-sonarqube-production
Copy link
Copy Markdown

@DimitriosNaikopoulos DimitriosNaikopoulos changed the title Cld 2059 catalog deletes CLD-2059: Add catalog delete May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants