Skip to content

Commit

Permalink
fix: don't fail tenderly on anvil
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Mar 6, 2024
1 parent 30a582b commit 22694d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions services/execute_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ExecuteParams struct {
type ExecuteParser struct {
IgnoreCMEventIds map[common.Hash]bool
trace_service.InternalFetcher
client core.ClientI
}

func getCMEventIds() map[common.Hash]bool {
Expand All @@ -53,6 +54,7 @@ func NewExecuteParser(cfg *config.Config, client core.ClientI) ds.ExecuteParserI
return &ExecuteParser{
IgnoreCMEventIds: getCMEventIds(),
InternalFetcher: trace_service.NewInternalFetcher(cfg, client),
client: client,
}
}

Expand All @@ -61,6 +63,9 @@ func (ep *ExecuteParser) GetExecuteCalls(version core.VersionType, txHash, credi
return nil
}
trace := ep.GetTxTrace(txHash, true)
if trace_service.ExecCallsEmptyOnMainnet(trace, core.GetChainId(ep.client)) {
return nil
}
filter := ExecuteFilter{paramsList: paramsList,
creditManager: common.HexToAddress(creditManagerAddr),
}
Expand Down Expand Up @@ -97,6 +102,9 @@ func (ep *ExecuteParser) GetExecuteCalls(version core.VersionType, txHash, credi
// currently only valid for closeCreditAccount v2
func (ep *ExecuteParser) GetTransfersAtClosev2(txHash, account, underlyingToken string, users ds.BorrowerAndTo) core.Transfers {
trace := ep.GetTxTrace(txHash, true)
if trace_service.IgnoreExecCallsIfTestnetIsntMain(trace, core.GetChainId(ep.client)) {

Check failure on line 105 in services/execute_parser.go

View workflow job for this annotation

GitHub Actions / build

undefined: trace_service.IgnoreExecCallsIfTestnetIsntMain
return nil
}
return getCloseAccountv2Transfers(trace, account, underlyingToken, users)
}

Expand Down
7 changes: 6 additions & 1 deletion services/trace_service/tenderly_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (ep *TenderlyFetcher) getUrl(link string) (*TenderlyTrace, error) {
return trace, nil
}

func ExecCallsEmptyOnMainnet(trace *TenderlyTrace, chainId int64) bool {
return trace.CallTrace == nil && log.GetBaseNet(chainId) == "MAINNET"
}

func (ep *TenderlyFetcher) getTxTrace(txHash string) (*TenderlyTrace, error) {
trace, err := ep.getTenderly(txHash)
if err != nil {
Expand All @@ -95,7 +99,7 @@ func (ep *TenderlyFetcher) getTxTrace(txHash string) (*TenderlyTrace, error) {
if err != nil {
return nil, log.WrapErrWithLine(err)
}
if trace.CallTrace == nil {
if ExecCallsEmptyOnMainnet(trace, ep.ChainId) { // if not anvil then fail
log.Fatal("Retry failed for tenderly: ", txHash)
}
return trace, nil
Expand Down Expand Up @@ -176,6 +180,7 @@ func (ep InternalFetcher) GetTxTrace(txHash string, canLoadLogsFromRPC bool) *Te
if err != nil {
log.Info("fallback on tenderly due to", err, " for ", txHash)
trace, err = ep.tenderlyFetcher.getTxTrace(txHash)
log.CheckFatal(err)
}
}
//
Expand Down

0 comments on commit 22694d1

Please sign in to comment.