Skip to content

Commit

Permalink
PRT - Adding hash logs to payment tx (lavanet#1115)
Browse files Browse the repository at this point in the history
* GROW-1144 makefile fixes for macos

* fixing file

* code compiles

* new relay server works

* new relay server works

* removing my prints and undo changes in init_lava_only_with_node

* adding missing nil checks

* adding option flag on the init node script

* passing lint

* adding my own script

* adding my own script

* following pr feedback for relayserver, did more testing locally

* spliting the code into more functions

* more fixups - tested locally - works

* passing lint

* making a function for the key generation

* refactor small part

* change log level

* chaning log levels

* fix lava script

* adding debug logs to debug reward tx bug

* adding lavad warnings and errors for debugging e2e

* continue on error

---------

Co-authored-by: Michael Cotic <[email protected]>
Co-authored-by: OneEuroQuestion <[email protected]>
Co-authored-by: OneEuroQuestion <[email protected]>
  • Loading branch information
4 people authored Jan 7, 2024
1 parent 387a059 commit 1d813dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ jobs:
- name: Run Lava E2E Tests -timeout 1200s
run: go test ./testutil/e2e/ -run ^TestLavaProtocol$ -v -timeout 1200s # 20mins

- name: tail -n 300 Lavad Logs
- name: tail -n 1000 Lavad Logs
if: always()
run: tail -n 1000 testutil/e2e/protocolLogs/00_StartLava.log

- name: Print all warnings and errors from lavad
continue-on-error: true
if: always()
run: tail -n 300 testutil/e2e/protocolLogs/00_StartLava.log
run: cat testutil/e2e/protocolLogs/00_StartLava.log | grep 'WRN |ERR '

- name: Stake Lava All Logs
if: always()
Expand Down
8 changes: 5 additions & 3 deletions protocol/rpcprovider/rewardserver/reward_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type ConsumerRewards struct {

func (csrw *ConsumerRewards) PrepareRewardsForClaim() (retProofs []*pairingtypes.RelaySession, errRet error) {
for _, proof := range csrw.proofs {
utils.LavaFormatDebug("Adding reward id for claim", utils.LogAttr("Id", proof.SessionId))
retProofs = append(retProofs, proof)
}
return
Expand Down Expand Up @@ -224,8 +225,10 @@ func (rws *RewardServer) sendRewardsClaim(ctx context.Context, epoch uint64) err

failedRewardRequestsToRetry := rws.gatherFailedRequestPaymentsToRetry(earliestSavedEpoch)
if len(failedRewardRequestsToRetry) > 0 {
utils.LavaFormatDebug("Found failed reward claims, retrying", utils.LogAttr("number_of_rewards", len((failedRewardRequestsToRetry))))
specs := map[string]struct{}{}
for _, relay := range failedRewardRequestsToRetry {
utils.LavaFormatDebug("[sendRewardsClaim] retrying failed id", utils.LogAttr("id", relay.SessionId))
specs[relay.SpecId] = struct{}{}
}

Expand Down Expand Up @@ -442,13 +445,13 @@ func (rws *RewardServer) PaymentHandler(payment *PaymentRequest) {
utils.LavaFormatWarning("tried removing payment that wasn't expected", nil, utils.Attribute{Key: "payment", Value: payment})
}

utils.LavaFormatDebug("deleting claimed rewards", utils.Attribute{Key: "payment uid", Value: payment.UniqueIdentifier})
utils.LavaFormatDebug("Reward Server detected successful payment request, deleting claimed rewards", utils.Attribute{Key: "payment-uid", Value: payment.UniqueIdentifier})

err = rws.rewardDB.DeleteClaimedRewards(payment.PaymentEpoch, payment.Client.String(), payment.UniqueIdentifier, payment.ConsumerRewardsKey)
if err != nil {
utils.LavaFormatWarning("failed deleting claimed rewards", err)
} else {
utils.LavaFormatDebug("deleted claimed rewards successfully")
utils.LavaFormatDebug("deleted claimed rewards successfully", utils.Attribute{Key: "payment-uid", Value: payment.UniqueIdentifier})
}
}
}
Expand Down Expand Up @@ -604,7 +607,6 @@ func (rws *RewardServer) gatherFailedRequestPaymentsToRetry(earliestSavedEpoch u
sessionsToDelete = append(sessionsToDelete, key)
continue
}

rewardsForClaim = append(rewardsForClaim, val.relaySession)
}

Expand Down
10 changes: 5 additions & 5 deletions protocol/statetracker/tx_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (ts *TxSender) SimulateAndBroadCastTxWithRetryOnSeqMismatch(msg sdk.Msg, ch
latestResult := common.TxResultData{}
var gasUsed uint64
for ; idx < RETRY_INCORRECT_SEQUENCE && !success; idx++ {
utils.LavaFormatDebug("Attempting to send relay payment transaction", utils.LogAttr("index", idx))
utils.LavaFormatDebug("Attempting to send relay payment transaction", utils.LogAttr("index", idx+1))
txfactory, gasUsed, err = ts.simulateTxWithRetry(clientCtx, txfactory, msg)
if err != nil {
return utils.LavaFormatError("Failed Simulating transaction", err)
Expand Down Expand Up @@ -196,7 +196,7 @@ func (ts *TxSender) SendTxAndVerifyCommit(txfactory tx.Factory, msg sdk.Msg) (pa
utils.LavaFormatDebug("transaction results", utils.Attribute{Key: "jsonParsedResult", Value: jsonParsedResult})
}
resultData, err := common.ParseTransactionResult(jsonParsedResult)
utils.LavaFormatDebug("Sent Transaction", utils.LogAttr("Hash", string(resultData.Txhash)))
utils.LavaFormatDebug("Sent Transaction", utils.LogAttr("Hash", hex.EncodeToString(resultData.Txhash)))
if err != nil {
return common.TxResultData{}, err
}
Expand All @@ -219,7 +219,7 @@ func (ts *TxSender) waitForTxCommit(resultData common.TxResultData) (common.TxRe
result, err := clientCtx.Client.Tx(ctx, resultData.Txhash, false)
cancel()
if err == nil {
utils.LavaFormatDebug("Tx Found successfully on chain!", utils.LogAttr("Hash", string(resultData.Txhash)))
utils.LavaFormatDebug("Tx Found successfully on chain!", utils.LogAttr("Hash", hex.EncodeToString(resultData.Txhash)))
txResultChan <- result
return
}
Expand All @@ -237,10 +237,10 @@ func (ts *TxSender) waitForTxCommit(resultData common.TxResultData) (common.TxRe
Txhash: resultData.Txhash,
Code: int(txRes.TxResult.Code),
}
utils.LavaFormatDebug("Tx Hash found on blockchain", utils.LogAttr("Txhash", string(resultData.Txhash)), utils.LogAttr("Code", resultData.Code))
utils.LavaFormatDebug("Tx Hash found on blockchain", utils.LogAttr("Txhash", hex.EncodeToString(resultData.Txhash)), utils.LogAttr("Code", resultData.Code))
break
case <-time.After(5 * time.Minute):
return common.TxResultData{}, utils.LavaFormatError("failed sending tx, wasn't found after timeout", nil, utils.Attribute{Key: "hash", Value: string(resultData.Txhash)})
return common.TxResultData{}, utils.LavaFormatError("failed sending tx, wasn't found after timeout", nil, utils.Attribute{Key: "hash", Value: hex.EncodeToString(resultData.Txhash)})
}
// we found the tx on chain and it failed
if resultData.Code != 0 {
Expand Down

0 comments on commit 1d813dd

Please sign in to comment.