Skip to content

Commit

Permalink
fix(swaps): add resolve request validation slippage
Browse files Browse the repository at this point in the history
In this commit we're relaxing raiden's resolve request validation by 3
blocks in order to prevent an issue where new blocks are mined during the
payment.
  • Loading branch information
Karl Ranna committed Sep 9, 2019
1 parent 9b2d6b3 commit 99600c4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/swaps/Swaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,17 @@ class Swaps extends EventEmitter {
source = 'Taker';
destination = 'Maker';
const lockExpirationDelta = expiration - chain_height;
if (deal.makerCltvDelta! > lockExpirationDelta) {
this.logger.error(`cltvDelta of ${lockExpirationDelta} does not meet ${deal.makerCltvDelta!} minimum`);
// We relax the validation by LOCK_EXPIRATION_SLIPPAGE blocks because
// new blocks could be mined during the time it takes from taker's
// payment to reach the maker for validation.
// This usually happens in simulated environments with fast mining enabled.
const LOCK_EXPIRATION_SLIPPAGE = 3;
if (deal.makerCltvDelta! - LOCK_EXPIRATION_SLIPPAGE > lockExpirationDelta) {
this.logger.error(`
lockExpirationDelta of ${lockExpirationDelta} does not meet
makerCltvDelta ${deal.makerCltvDelta!} - LOCK_EXPIRATION_SLIPPAGE ${LOCK_EXPIRATION_SLIPPAGE}
= ${deal.makerCltvDelta! - LOCK_EXPIRATION_SLIPPAGE} minimum
`);
this.failDeal(deal, SwapFailureReason.InvalidResolveRequest, 'Insufficient CLTV received on first leg');
return false;
}
Expand Down

0 comments on commit 99600c4

Please sign in to comment.