Skip to content

Commit

Permalink
write keeper debugging script (#10808)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanRHall authored Oct 4, 2023
1 parent 76cb642 commit 30dfa21
Show file tree
Hide file tree
Showing 28 changed files with 1,649 additions and 435 deletions.
8 changes: 8 additions & 0 deletions contracts/scripts/generate-automation-master-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ for (const abi of abis) {
const id = utils.id(JSON.stringify(entry))
if (!abiSet.has(id)) {
abiSet.add(id)
if (
entry.type === 'function' &&
(entry.name === 'checkUpkeep' ||
entry.name === 'checkCallback' ||
entry.name === 'simulatePerformUpkeep')
) {
entry.stateMutability = 'view' // override stateMutability for check / callback / simulate functions
}
combinedABI.push(entry)
}
}
Expand Down

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions contracts/src/v0.8/automation/v2_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ graph LR

The Master Interface is a deduped combination of all the interfaces from all contracts in the chain. We generate this interface programatically using the script `generate-automation-master-interface.ts`. This process is not a hardened one. Users of this script should take great care to ensure it's efficacy.

### Future Improvements

- We could use this script to change `checkUpkeep` from an executable function to a "view" function in the master interface - this would make interacting with the contract simpler in tests and (maybe) also from the core node.

[size-limit-eip]: https://eips.ethereum.org/EIPS/eip-170
[fallback]: https://docs.soliditylang.org/en/v0.8.12/contracts.html#fallback-function
[delegatecall]: https://docs.soliditylang.org/en/v0.8.12/introduction-to-smart-contracts.html?highlight=delegatecall#delegatecall-callcode-and-libraries
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ functions_billing_registry_events_mock: ../../contracts/solc/v0.8.6/FunctionsBil
functions_oracle_events_mock: ../../contracts/solc/v0.8.6/FunctionsOracleEventsMock.abi ../../contracts/solc/v0.8.6/FunctionsOracleEventsMock.bin 3ca70f966f8fe751987f0ccb50bebb6aa5be77e4a9f835d1ae99e0e9bfb7d52c
gas_wrapper: ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2.abi ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2.bin 4a5dcdac486d18fcd58e3488c15c1710ae76b977556a3f3191bd269a4bc75723
gas_wrapper_mock: ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock.abi ../../contracts/solc/v0.8.6/KeeperRegistryCheckUpkeepGasUsageWrapper1_2Mock.bin a9b08f18da59125c6fc305855710241f3d35161b8b9f3e3f635a7b1d5c6da9c8
i_keeper_registry_master_wrapper_2_1: ../../contracts/solc/v0.8.16/IKeeperRegistryMaster.abi ../../contracts/solc/v0.8.16/IKeeperRegistryMaster.bin 4426a320baaef8a66692699ec008e371eb7f841b1f9f02ff817c0eee0c63c7b5
i_keeper_registry_master_wrapper_2_1: ../../contracts/solc/v0.8.16/IKeeperRegistryMaster.abi ../../contracts/solc/v0.8.16/IKeeperRegistryMaster.bin 6501bb9bcf5048bab2737b00685c6984a24867e234ddf5b60a65904eee9a4ebc
i_log_automation: ../../contracts/solc/v0.8.16/ILogAutomation.abi ../../contracts/solc/v0.8.16/ILogAutomation.bin 296beccb6af655d6fc3a6e676b244831cce2da6688d3afc4f21f8738ae59e03e
keeper_registrar_wrapper1_2: ../../contracts/solc/v0.8.6/KeeperRegistrar.abi ../../contracts/solc/v0.8.6/KeeperRegistrar.bin e49b2f8b23da17af1ed2209b8ae0968cc04350554d636711e6c24a3ad3118692
keeper_registrar_wrapper1_2_mock: ../../contracts/solc/v0.8.6/KeeperRegistrar1_2Mock.abi ../../contracts/solc/v0.8.6/KeeperRegistrar1_2Mock.bin 5b155a7cb3def309fd7525de1d7cd364ebf8491bdc3060eac08ea0ff55ab29bc
Expand Down
7 changes: 4 additions & 3 deletions core/scripts/chaincli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

Before starting, you will need:
1. A working [Go](https://go.dev/doc/install) installation
2. EVM chain endpoint URLs
2. EVM chain endpoint URLs
- The endpoint can be a local node, or an externally hosted node, e.g. [alchemy](alchemy.com) or [infura](infura.io)
- Both the HTTPS and WSS URLs of your endpoint are needed
3. The chain ID corresponding to your chain, you can find the chain ID for your chosen chain [here](https://chainlist.org/)
4. The private key of an account funded with LINK, and the chain's native token (to pay transaction fees)
- Steps for exporting your private key from Metamask can be found [here](https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-Export-an-Account-Private-Key)
5. The LINK address, LINK-ETH feed address, fast gas feed address for your chain
6. Install [docker](https://docs.docker.com/get-docker/) for CLI and GUI (optional)
7. \[Optional\] get a [tenderly API key](https://docs.tenderly.co/other/platform-access/how-to-generate-api-access-tokens) and find your [username / project name](https://docs.tenderly.co/other/platform-access/how-to-find-the-project-slug-username-and-organization-name).

The example .env in this repo is for the Polygon Mumbai testnet. You can use [this faucet](https://faucets.chain.link/mumbai) to send testnet LINK
The example .env in this repo is for the Polygon Mumbai testnet. You can use [this faucet](https://faucets.chain.link/mumbai) to send testnet LINK
to your wallet ahead of executing the next steps

>Note: Be careful with your key. When using testnets, it's best to use a separate
Expand Down Expand Up @@ -121,4 +122,4 @@ You can use the `grep` and `grepv` flags to filter log lines, e.g. to only show

```shell
./chaincli keeper logs --grep keepers-plugin
```
```
20 changes: 20 additions & 0 deletions core/scripts/chaincli/command/keeper/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package keeper

import (
"github.com/spf13/cobra"

"github.com/smartcontractkit/chainlink/core/scripts/chaincli/config"
"github.com/smartcontractkit/chainlink/core/scripts/chaincli/handler"
)

// jobCmd represents the command to run the service
var debugCmd = &cobra.Command{
Use: "debug",
Short: "Debug an upkeep",
Long: `This command debugs an upkeep on the povided registry to figure out why it is not performing`,
Run: func(cmd *cobra.Command, args []string) {
cfg := config.New()
hdlr := handler.NewKeeper(cfg)
hdlr.Debug(cmd.Context(), args)
},
}
1 change: 1 addition & 0 deletions core/scripts/chaincli/command/keeper/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var RootCmd = &cobra.Command{

func init() {
RootCmd.AddCommand(deployCmd)
RootCmd.AddCommand(debugCmd)
RootCmd.AddCommand(jobCmd)
RootCmd.AddCommand(logsCmd)
RootCmd.AddCommand(registryCmd)
Expand Down
14 changes: 10 additions & 4 deletions core/scripts/chaincli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ type Config struct {
FeedDecimals uint8 `mapstructure:"FEED_DECIMALS"`

// Mercury Config
MercuryURL string `mapstructure:"MERCURY_URL"`
MercuryID string `mapstructure:"MERCURY_ID"`
MercuryKey string `mapstructure:"MERCURY_KEY"`
MercuryCredName string `mapstructure:"MERCURY_CRED_NAME"`
MercuryURL string `mapstructure:"MERCURY_URL"`
MercuryLegacyURL string `mapstructure:"MERCURY_LEGACY_URL"`
MercuryID string `mapstructure:"MERCURY_ID"`
MercuryKey string `mapstructure:"MERCURY_KEY"`
MercuryCredName string `mapstructure:"MERCURY_CRED_NAME"`

// Tenderly
TenderlyKey string `mapstructure:"TENDERLY_KEY"`
TenderlyAccountName string `mapstructure:"TENDERLY_ACCOUNT_NAME"`
TenderlyProjectName string `mapstructure:"TENDERLY_PROJECT_NAME"`
}

// New creates a new config
Expand Down
Loading

0 comments on commit 30dfa21

Please sign in to comment.