smartcontractkit / smartcontractkit/chainlink
kaiko OCR - foreign key constraint violation deleting a chain without nodes from UI
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 8.2k
- Forks
- 2k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 202
Description
Description
Had a Avalanche EVM ChainID 41113 registered with 5 nodes attached to it.
Was an error, so I did change EVM ChainId to 41114 with the very same 5 nodes.
Both times, chains/nodes provisionned from EVM_NODES env variable.
Deleting the bad 41113 chain from interface (which has no more nodes associated to it, it is give an exception and didn't succeed in removing the chain :
ERROR: update or delete on table "evm_chains" violates foreign key constraint "eth_key_states_evm_chain_id_fkey" on table "evm_key_states" (SQLSTATE 23503)
Basic Information
[replace this line with basic information about the issue you are experiencing, including but not limited to all relevant logs and any other relevant information, such as if you are using a Docker container to run the node, job specification, oracle contract address, transaction IDs, etc.]
- Network: Ethereum Mainnet (1) + Avalanche Mainnet (43114)
- Blockchain Client: geth 1.10.21 + TTD set & avalanchego v1.8.5
- Hosting Provider: OVH
This happens if the chain is enabled or disabled, same error trying to remove it
Sep 12 07:52:43 offchainreporting00-chainlink-ovh docker[1741695]: 2022-09-12T07:52:43.264Z [INFO] DELETE /v2/chains/evm/43113 web/router.go:533 clientIP=10.170.0.38 errors=Error #01: ERROR: update or delete on table "evm_chains" violates foreign key constraint "eth_key_states_evm_chain_id_fkey" on table "evm_key_states" (SQLSTATE 23503)
Sep 12 07:58:40 offchainreporting00-chainlink-ovh docker[1741695]: 2022-09-12T07:58:40.070Z [INFO] DELETE /v2/chains/evm/43113 web/router.go:533 clientIP=10.170.0.38 errors=Error #01: ERROR: update or delete on table "evm_chains" violates foreign key constraint "eth_key_states_evm_chain_id_fkey" on table "evm_key_states" (SQLSTATE 23503)
Sep 12 08:04:17 offchainreporting00-chainlink-ovh docker[1741695]: 2022-09-12T08:04:17.748Z [INFO] DELETE /v2/chains/evm/43113 web/router.go:533 clientIP=10.170.0.38 errors=Error #01: ERROR: update or delete on table "evm_chains" violates foreign key constraint "eth_key_states_evm_chain_id_fkey" on table "evm_key_states" (SQLSTATE 23503)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the DELETE /v2/chains/evm/43113 request and the web/router.go:533 log location, then trace how the evm_chains record is removed. Inspect the eth_key_states_evm_chain_id_fkey relationship and reproduce the failure with a chain that has no nodes. Done means the UI deletion no longer returns SQLSTATE 23503 and the related database state remains consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100