Skip to content

Commit

Permalink
Merge pull request #574 from lavanet/PRT-725-add-indicative-errors-on…
Browse files Browse the repository at this point in the history
…-chain-fetcher-fails

PRT-725 added prints to chain fetcher fails
  • Loading branch information
Yaroms authored Jun 25, 2023
2 parents 850be5b + ce05e6d commit aca444c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ var Upgrades = []upgrades.Upgrade{
upgrades.Upgrade_0_13_1,
upgrades.Upgrade_0_14_0,
upgrades.Upgrade_0_15_0,
upgrades.Upgrade_0_15_1,
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/empty_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,9 @@ var Upgrade_0_15_0 = Upgrade{
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}

var Upgrade_0_15_1 = Upgrade{
UpgradeName: "v0.15.1",
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
25 changes: 20 additions & 5 deletions protocol/chainlib/chain_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ func (cf *ChainFetcher) FetchLatestBlockNum(ctx context.Context) (int64, error)
}
parserInput, err := cf.formatResponseForParsing(reply, chainMessage)
if err != nil {
return spectypes.NOT_APPLICABLE, err
return spectypes.NOT_APPLICABLE, utils.LavaFormatWarning(spectypes.GET_BLOCKNUM+" Failed formatResponseForParsing", err, []utils.Attribute{
{Key: "nodeUrl", Value: cf.endpoint.UrlsString()},
{Key: "Method", Value: serviceApi.GetName()},
{Key: "Response", Value: string(reply.Data)},
}...)
}
blockNum, err := parser.ParseBlockFromReply(parserInput, serviceApi.Parsing.ResultParsing)
if err != nil {
return spectypes.NOT_APPLICABLE, utils.LavaFormatWarning("Failed To Parse FetchLatestBlockNum", err, []utils.Attribute{
return spectypes.NOT_APPLICABLE, utils.LavaFormatWarning(spectypes.GET_BLOCKNUM+" Failed to parse Response", err, []utils.Attribute{
{Key: "nodeUrl", Value: cf.endpoint.UrlsString()},
{Key: "Method", Value: serviceApi.GetName()},
{Key: "Response", Value: string(reply.Data)},
Expand Down Expand Up @@ -76,10 +80,21 @@ func (cf *ChainFetcher) FetchBlockHashByNum(ctx context.Context, blockNum int64)
}
parserInput, err := cf.formatResponseForParsing(reply, chainMessage)
if err != nil {
return "", err
return "", utils.LavaFormatWarning(spectypes.GET_BLOCK_BY_NUM+" Failed formatResponseForParsing", err, []utils.Attribute{
{Key: "nodeUrl", Value: cf.endpoint.UrlsString()},
{Key: "Method", Value: serviceApi.GetName()},
{Key: "Response", Value: string(reply.Data)},
}...)
}

return parser.ParseMessageResponse(parserInput, serviceApi.Parsing.ResultParsing)
res, err := parser.ParseMessageResponse(parserInput, serviceApi.Parsing.ResultParsing)
if err != nil {
return "", utils.LavaFormatWarning(spectypes.GET_BLOCK_BY_NUM+" Failed ParseMessageResponse", err, []utils.Attribute{
{Key: "nodeUrl", Value: cf.endpoint.UrlsString()},
{Key: "Method", Value: serviceApi.GetName()},
{Key: "Response", Value: string(reply.Data)},
}...)
}
return res, nil
}

func (cf *ChainFetcher) formatResponseForParsing(reply *types.RelayReply, chainMessage ChainMessageForSend) (parsable parser.RPCInput, err error) {
Expand Down

0 comments on commit aca444c

Please sign in to comment.