core/scripts/chaincli/DEBUGGING.md
Use this script to debug and diagnose possible issues with registered upkeeps in Automation v2 registries. The script can debug custom logic upkeeps, log-trigger upkeeps, and upkeeps that use StreamsLookup.
Before starting, you will need:
Clone the chainlink repo and navigate to the core/scripts/chaincli
directory:
git clone https://github.com/smartcontractkit/chainlink.git && cd chainlink/core/scripts/chaincli
Create a .env file based on the example .env.debugging.example:
cp .env.debugging.example .env
Fill in the values for these mandatory fields in your .env file:
NODE_URL: Archival node URL for the network to "simulate" the upkeep. Use your own node or get an endpoint from Alchemy or Infura.KEEPER_REGISTRY_ADDRESS: Address of the registry where your upkeep is registered. Refer to the Supported Networks doc for registry addresses.For example
If your targeted upkeep involves StreamsLookup, please provide the following details. If you are using Data Streams v0.3 (which is likely), only provide the DATA_STREAMS_URL. Ignore DATA_STREAMS_LEGACY_URL.
DATA_STREAMS_IDDATA_STREAMS_KEYDATA_STREAMS_URLFor detailed transaction simulation logs, set up Tenderly credentials. Refer to the Tenderly documentation to learn how to create an API key, account name, and project name on Tenderly.
TENDERLY_KEYTENDERLY_ACCOUNT_NAMETENDERLY_PROJECT_NAMEExecute the following command based on your upkeep type:
For custom logic:
go run main.go keeper debug UPKEEP_ID [BLOCK_NUMBER]
If you don't specify a block number, the debugging script uses the latest block for checkUpkeep and simulatePerformUpkeep. For conditional upkeeps using streams lookup, a BLOCK_NUMBER is required.
For log trigger upkeep:
go run main.go keeper debug UPKEEP_ID TX_HASH LOG_INDEX
The script runs these basic checks on all upkeeps based on the TX_HASH or BLOCK_NUMBER (if provided)
For Custom Logic Upkeep:
performUpkeepFor Log Trigger Upkeep:
Check if the upkeep has already run for log-trigger-based upkeep
Verify if log matches trigger configuration
Check upkeep
If check result indicates a streams lookup is required (TargetCheckReverted):
Simulate performUpkeep
Eligible and log trigger based and using mercury lookup v0.3:
go run main.go keeper debug 5591498142036749453487419299781783197030971023186134955311257372668222176389 0xdc6d0e547a5aa85fefa5b0f3a37e3493eafb5aeba8b5f3071ce53c9e9a539e9c 0
Ineligible and conditional upkeep:
go run main.go keeper debug 52635131310730056105456985154251306793887717546629785340977553840883117540096
Ineligible and Log does not match trigger config:
go run main.go keeper debug 5591498142036749453487419299781783197030971023186134955311257372668222176389 0xc0686ae85d2a7a976ef46df6c613517b9fd46f23340ac583be4e44f5c8b7a186 1
checkUpkeep function.Log-trigger upkeeps require that you also supply the txn hash containing the log and the index of the log that would have triggered your upkeep. You can find both in the block scanner of the chain in question. For example the txn hash is in the URL and the block number in the green circle on the left.