Skip to content

Commit

Permalink
Handle missing consumer promise when setting withdrawal amount
Browse files Browse the repository at this point in the history
If latest promise is invalid, issue a new promise with amount equal to settled+amount to withdraw. This way we can still recover and withdraw even though provider is has corrupted data.
On hermes side we will also be able to recover withdraw promises using the help of this change.
  • Loading branch information
tomasmik committed Nov 25, 2021
1 parent b8a3c96 commit dab2eeb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion session/pingpong/hermes_promise_settler.go
Expand Up @@ -512,7 +512,13 @@ func (aps *hermesPromiseSettler) Withdraw(
}

// 2. issue a self promise
msg, err := aps.issueSelfPromise(fromChainID, toChainID, amountToWithdraw, data.LatestPromise.Amount, providerID, consumerChannelAddress, hermesID)
promisedAmount := data.LatestPromise.Amount
if promisedAmount.Cmp(data.Settled) < 0 {
// If consumer has an incorrect promise. Issue a correct one
// together with a withdrawal request.
promisedAmount = data.Settled
}
msg, err := aps.issueSelfPromise(fromChainID, toChainID, amountToWithdraw, promisedAmount, providerID, consumerChannelAddress, hermesID)
if err != nil {
return err
}
Expand Down

0 comments on commit dab2eeb

Please sign in to comment.