Skip to content

Commit

Permalink
rebase and update
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill committed Dec 13, 2023
1 parent ea6ae94 commit f0dc63f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
34 changes: 22 additions & 12 deletions core/scripts/chaincli/handler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
mercuryConfig := evm21.NewMercuryConfig(mc, core.StreamsCompatibleABI)
lggr, _ := logger.NewLogger()
blockSub := &blockSubscriber{k.client}
streams := streams.NewStreamsLookup(packer, mercuryConfig, blockSub, k.rpcClient, keeperRegistry21, lggr)
streams := streams.NewStreamsLookup(mercuryConfig, blockSub, k.rpcClient, keeperRegistry21, lggr)

var streamsLookupErr *mercury.StreamsLookupError
streamsLookupErr, err := mercuryPacker.DecodeStreamsLookupRequest(checkResult.PerformData)
streamsLookupErr, err = mercuryPacker.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)))
Expand All @@ -283,7 +283,7 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
message("using mercury lookup v0.2")
// check if upkeep is allowed to use mercury v0.2
var allowed bool
_, _, _, allowed, err = streams.AllowedToUseMercury(latestCallOpts, upkeepID)
_, _, _, allowed, err = streams.AllowedToUseMercury(triggerCallOpts, upkeepID)
if err != nil {
failUnknown("failed to check if upkeep is allowed to use mercury", err)
}
Expand All @@ -308,10 +308,10 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
var values [][]byte
values, err = streams.DoMercuryRequest(ctx, streamsLookup, checkResults, 0)

if automationCheckResult.IneligibilityReason == uint8(mercury.MercuryUpkeepFailureReasonInvalidRevertDataInput) {
if checkResults[0].IneligibilityReason == uint8(mercury.MercuryUpkeepFailureReasonInvalidRevertDataInput) {
resolveIneligible("upkeep used invalid revert data")
}
if automationCheckResult.PipelineExecutionState == uint8(mercury.InvalidMercuryRequest) {
if checkResults[0].PipelineExecutionState == uint8(mercury.InvalidMercuryRequest) {
resolveIneligible("the mercury request data is invalid")
}
if err != nil {
Expand All @@ -323,10 +323,10 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
if err != nil {
failUnknown("failed to execute mercury callback ", err)
}
if automationCheckResult.IneligibilityReason != 0 {
message(fmt.Sprintf("checkCallback failed with UpkeepFailureReason %d", automationCheckResult.IneligibilityReason))
if checkResults[0].IneligibilityReason != 0 {
message(fmt.Sprintf("checkCallback failed with UpkeepFailureReason %d", checkResults[0].IneligibilityReason))
}
upkeepNeeded, performData = automationCheckResult.Eligible, automationCheckResult.PerformData
upkeepNeeded, performData = checkResults[0].Eligible, checkResults[0].PerformData
// do tenderly simulations for checkCallback
var rawCall []byte
rawCall, err = core.RegistryABI.Pack("checkCallback", upkeepID, values, streamsLookup.ExtraData)
Expand All @@ -346,13 +346,23 @@ func (k *Keeper) Debug(ctx context.Context, args []string) {
if !upkeepNeeded {
resolveIneligible("upkeep is not needed")
}
// simulate perform ukeep
simulateResult, err := keeperRegistry21.SimulatePerformUpkeep(latestCallOpts, upkeepID, performData)
// simulate perform upkeep
simulateResult, err := keeperRegistry21.SimulatePerformUpkeep(triggerCallOpts, upkeepID, performData)
if err != nil {
failUnknown("failed to simulate perform upkeep: ", err)
}

// do tenderly simulation
rawCall, err := core.RegistryABI.Pack("simulatePerformUpkeep", upkeepID, performData)
if err != nil {
failUnknown("failed to pack raw simulatePerformUpkeep call", err)
}
addLink("simulatePerformUpkeep simulation", tenderlySimLink(k.cfg, chainID, blockNum, rawCall, registryAddress))

if simulateResult.Success {
resolveEligible()
} else {
resolveIneligible("simulate perform upkeep unsuccessful")
}
}

Expand Down Expand Up @@ -467,11 +477,11 @@ func warning(msg string) {
}

func resolveIneligible(msg string) {
exit(fmt.Sprintf("✅ %s: this upkeep is not currently eligible", msg), nil, 0)
exit(fmt.Sprintf("this upkeep is not eligible: %s", msg), nil, 0)
}

func resolveEligible() {
exit(" this upkeep is currently eligible", nil, 0)
exit(" this upkeep is eligible", nil, 0)
}

func rerun(msg string, err error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (s *streams) CheckCallback(ctx context.Context, values [][]byte, lookup *me
checkResults[i].IneligibilityReason = uint8(mercury.MercuryUpkeepFailureReasonNone)
checkResults[i].Eligible = true
checkResults[i].PerformData = performData
s.lggr.Infof("at block %d upkeep %s requested time %s successful with perform data: %s", lookup.Block, lookup.UpkeepId, lookup.Time, hexutil.Encode(performData))
s.lggr.Infof("at block %d upkeep %s requested time %s CheckCallback successful with perform data: %s", lookup.Block, lookup.UpkeepId, lookup.Time, hexutil.Encode(performData))

return nil
}
Expand Down

0 comments on commit f0dc63f

Please sign in to comment.