Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server/{db,swap},client/core: no maker redemption ack, no redeem confs #706

Merged
merged 4 commits into from
Oct 9, 2020

Conversation

chappjc
Copy link
Member

@chappjc chappjc commented Sep 28, 2020

NOTE: This PR is now targeting on the status-integ.

server/db

  • Remove aSigAckOfBRedeem column from matches table.
  • Storing the participant (taker) redeem coin sets active = FALSE. Previously this was set when both redemption acks were received.

Now any match in the table with status MatchComplete will also be inactive. Previously matches could be (and often were) MatchComplete but also active. This was not great.

server/swap

  • processBlock no longer checks the redeem txns for their confirmations. We were checking against swapConf, but confirmations on the redeem txns never were important, only that both parties could author and bcast their redeem txns (the secret was shared and both parties used it to spend the respective contract outputs).
  • processBlock just checks swap txns against swapConf, and it now unlocks the order funding coins for the order when the swap txn that spent them reaches swapConf (previously it waited to do this when the entire match was completed). This reflects the "event-based" and "block-based" inaction check distinction.
  • processRedeem is now the spot where a match is deleted, when the taker's redeem is validated (when MatchComplete and active=FALSE are set). Note that this means there will no longer be matches in Swapper memory with MatchComplete status.
  • processRedeem now does the cancellation rate accounting that was previously done in processAck since it is the 'redeem' validation that marks the end of the match for the user, not the redemption ack.
  • processRedeem no longer sends a 'redemption' request to the maker.
  • processAck no longer processes 'redemption' acks from the maker.

UPDATE for status-integ rebase:

client/core

  • Maker no longer requires 'redemption' request following taker's redeem to move to MatchComplete.
  • Maker is only MakerRedeemed if their 'redeem' request following the actual broadcast fails, otherwise they jump straight to MatchComplete. This is switched by auth.RedeemSig.
  • Fix some calls references to MatchProof.IsRevoked in logging statements not being called as a function.

@chappjc chappjc linked an issue Sep 28, 2020 that may be closed by this pull request
Comment on lines 58 to 70
bRedeemTime INT8, -- server time stamp
aSigAckOfBRedeem BYTEA -- counterparty's (initiator) sig with ack of participant REDEEM data
bRedeemTime INT8 -- server time stamp
)`

RetrieveSwapData = `SELECT status, sigMatchAckMaker, sigMatchAckTaker,
aContractCoinID, aContract, aContractTime, bSigAckOfAContract,
bContractCoinID, bContract, bContractTime, aSigAckOfBContract,
aRedeemCoinID, aRedeemSecret, aRedeemTime, bSigAckOfARedeem,
bRedeemCoinID, bRedeemTime, aSigAckOfBRedeem
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fortunately an explicit upgrade is not required since there are no select * queries where the number of columns is implicit.

Comment on lines -270 to -298
RedeemAAckTime int64 // time that B's signature of redeem A data was received
RedeemBCoinID []byte
RedeemBTime int64
RedeemBAckSig []byte // A's signature of redeem B data
RedeemBAckTime int64 // time that A's signature of redeem B data was received
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AckTimes were never stored.

@chappjc chappjc force-pushed the no-redeem-ack-match-complete branch 2 times, most recently from 3d666a5 to d7f8e2d Compare October 2, 2020 21:51
@chappjc chappjc changed the base branch from master to status-integ October 2, 2020 21:51
@chappjc chappjc marked this pull request as ready for review October 5, 2020 14:47
@chappjc
Copy link
Member Author

chappjc commented Oct 5, 2020

I have no further changes in mind for this PR. It has the potential to break stuff since it redefines match "completion" on both client and server, but it also fixes issues noted in #692

@chappjc chappjc force-pushed the no-redeem-ack-match-complete branch from 480a90a to 51c7927 Compare October 6, 2020 13:01
@chappjc chappjc changed the base branch from status-integ to master October 6, 2020 13:01
@chappjc chappjc changed the title server,{db,swap}: no maker redemption ack, no redeem confs server/{db,swap},client/core: no maker redemption ack, no redeem confs Oct 6, 2020
@chappjc chappjc force-pushed the no-redeem-ack-match-complete branch from 51c7927 to 0bf6beb Compare October 7, 2020 17:24
client/core/trade.go Outdated Show resolved Hide resolved
server/swap/swap_test.go Show resolved Hide resolved
@chappjc chappjc force-pushed the no-redeem-ack-match-complete branch from 0bf6beb to 4abca25 Compare October 8, 2020 23:46
Comment on lines +1748 to +1757
if dbMatch.Side == order.Taker {
err = t.processMakersRedemption(match, redemption.CoinID, redemption.Secret)
if err != nil {
errs.addErr(err)
}
}
// The server does not send a redemption request to the maker for the
// taker's redeem since match negotiation is complete server-side when the
// taker redeems, and it is complete client-side when we redeem. If we are
// both sides, there is another trackedTrade and matchTracker for that side.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now client will not even respond if it gets a redemption request as maker. We'll have to updated server pronto when this is merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction, it still responds (t.dc.ack above), it just doesn't record the TakerRedeem coin anymore. No server update urgency.

@chappjc chappjc merged commit bf36635 into decred:master Oct 9, 2020
@chappjc chappjc deleted the no-redeem-ack-match-complete branch October 9, 2020 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eliminate maker's ack of taker's redeem
2 participants