Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logIndex bug in debugging script #10939

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions core/scripts/chaincli/handler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,18 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
}
addLink("trigger", common.ExplorerLink(chainID, txHash))
blockNum = receipt.BlockNumber.Uint64()
if len(receipt.Logs) <= int(logIndex) {
failCheckArgs(fmt.Sprintf("the provided transaction has %d logs but index %d was requested", len(receipt.Logs), logIndex), err)
// find matching log event in tx
var triggeringEvent *types.Log
for i, log := range receipt.Logs {
if log.Index == uint(logIndex) {
triggeringEvent = receipt.Logs[i]
}
}
if triggeringEvent == nil {
failCheckArgs(fmt.Sprintf("unable to find log with index %d in transaction", logIndex), nil)
}
triggeringEvent := receipt.Logs[logIndex]
message(fmt.Sprintf("log #%d found in transaction", logIndex))
// check that tx for this upkeep / tx was not already performed
message(fmt.Sprintf("LogTrigger{blockNum: %d, blockHash: %s, txHash: %s, logIndex: %d}", blockNum, receipt.BlockHash.Hex(), txHash, logIndex))
workID := mustUpkeepWorkID(upkeepID, blockNum, receipt.BlockHash, txHash, logIndex)
message(fmt.Sprintf("workID computed: %s", hex.EncodeToString(workID[:])))
hasKey, err := keeperRegistry21.HasDedupKey(latestCallOpts, workID)
Expand Down Expand Up @@ -204,12 +210,14 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
if err != nil {
failUnknown("failed to check upkeep", err)
}
// do tenderly simulation
// do tenderly simulations
rawCall, err := core.RegistryABI.Pack("checkUpkeep", upkeepID, triggerData)
if err != nil {
failUnknown("failed to pack raw checkUpkeep call", err)
}
addLink("checkUpkeep simulation", tenderlySimLink(k.cfg, chainID, blockNum, rawCall, registryAddress))
rawCall = append(core.ILogAutomationABI.Methods["checkLog"].ID, triggerData...)
addLink("checkLog (direct) simulation", tenderlySimLink(k.cfg, chainID, blockNum, rawCall, upkeepInfo.Target))
} else {
resolveIneligible(fmt.Sprintf("invalid trigger type: %d", triggerType))
}
Expand All @@ -222,6 +230,7 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
streamsLookupErr, err := packer.DecodeStreamsLookupRequest(checkResult.PerformData)
if err == nil {
message("upkeep reverted with StreamsLookup")
message(fmt.Sprintf("StreamsLookup data: {FeedParamKey: %s, Feeds: %v, TimeParamKey: %s, Time: %d, ExtraData: %s}", streamsLookupErr.FeedParamKey, streamsLookupErr.Feeds, streamsLookupErr.TimeParamKey, streamsLookupErr.Time.Uint64(), hexutil.Encode(streamsLookupErr.ExtraData)))
if streamsLookupErr.FeedParamKey == feedIdHex && streamsLookupErr.TimeParamKey == blockNumber {
message("using mercury lookup v0.2")
// handle v0.2
Expand Down Expand Up @@ -269,6 +278,8 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
failUnknown("failed to pack raw checkUpkeep call", err)
}
addLink("checkCallback simulation", tenderlySimLink(k.cfg, chainID, blockNum, rawCall, registryAddress))
} else {
message("did not revert with StreamsLookup error")
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is so important

}
}
if !upkeepNeeded {
Expand Down
2 changes: 2 additions & 0 deletions core/services/ocr2/plugins/ocr2keeper/evm21/core/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_utils_2_1"
iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_log_automation"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/streams_lookup_compatible_interface"
)

var UtilsABI = types.MustGetABI(automation_utils_2_1.AutomationUtilsABI)
var RegistryABI = types.MustGetABI(iregistry21.IKeeperRegistryMasterABI)
var StreamsCompatibleABI = types.MustGetABI(streams_lookup_compatible_interface.StreamsLookupCompatibleInterfaceABI)
var ILogAutomationABI = types.MustGetABI(i_log_automation.ILogAutomationABI)
Loading