Skip to content

[6/?] StaticAddr: Quoting #750

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

Merged
merged 4 commits into from
Jun 25, 2024

Conversation

hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented May 22, 2024

the last 4 commits are relevant

Depends on #721

This PR introduces quoting for static address loop-ins while reusing the existing loop-in quoting infrastructure.

@hieblmi hieblmi self-assigned this May 22, 2024
@hieblmi hieblmi marked this pull request as draft May 22, 2024 15:57
@hieblmi hieblmi force-pushed the static-addr-6 branch 3 times, most recently from be24617 to f6d49f9 Compare May 24, 2024 09:21
@hieblmi hieblmi force-pushed the static-addr-staging branch 2 times, most recently from f614090 to 70a74bd Compare May 27, 2024 11:20
@hieblmi hieblmi force-pushed the static-addr-staging branch 7 times, most recently from dbc351a to c4012d0 Compare June 5, 2024 09:37
@hieblmi hieblmi force-pushed the static-addr-6 branch 2 times, most recently from ac2a2ae to e1d833d Compare June 6, 2024 11:48
@hieblmi hieblmi force-pushed the static-addr-staging branch from 385f3ea to 17618f2 Compare June 6, 2024 11:48
@hieblmi hieblmi force-pushed the static-addr-6 branch 2 times, most recently from 18593dc to 470ce4e Compare June 6, 2024 13:31
@hieblmi hieblmi marked this pull request as ready for review June 6, 2024 13:32
@hieblmi hieblmi requested review from bhandras, starius and sputn1ck June 6, 2024 13:32
@hieblmi hieblmi force-pushed the static-addr-6 branch 2 times, most recently from ec46c45 to 08bb91d Compare June 7, 2024 07:34
@lightninglabs-deploy
Copy link

@bhandras: review reminder
@starius: review reminder
@sputn1ck: review reminder

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

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

The first part of the review :-)
Reviewed until commit staticaddr: static address manager.

@@ -0,0 +1 @@
DROP TABLE IF EXISTS static_addresses;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line end missing.

-- downgrades their protocol version for static address outputs already in
-- use.
protocol_version INTEGER NOT NULL
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line end missing.


-- expiry denotes the CSV delay at which funds at a specific static address
-- can be swept back to the client.
expiry INT NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

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

In other places INTEGER is used, not INT. Can INTEGER be used here as well. (Also in next two fields.)

$5,
$6,
$7
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line end missing.

bytes server_key = 1;

// The CSV expiry for the MuSig2 static address output.
uint32 expiry = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line end missing.

return nil, err
}

var result []*AddressParameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

result := make([]*AddressParameters, 0, len(staticAddresses))

Comment on lines 31 to 32
func (s *SqlStore) ExecTx(ctx context.Context, txOptions loopdb.TxOptions,
txBody func(queries *sqlc.Queries) error) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you call baseDB's ExecTx here?

m.Lock()
addresses, err := m.cfg.Store.GetAllStaticAddresses(ctx)
if err != nil {
m.Unlock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can m.Unlock() call be done right after GetAllStaticAddresses call? In all 3 branches the first action is m.Unlock().

Comment on lines 87 to 90
clientPubKey := addresses[0].ClientPubkey
serverPubKey := addresses[0].ServerPubkey
expiry := int64(addresses[0].Expiry)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the order of addresses deterministic? If there are more than one, can addresses[0] be different in several calls (would be confusing for the user).

ClientPubkey: clientPubKey.PubKey,
ServerPubkey: serverPubKey,
PkScript: pkScript,
Expiry: serverParams.Expiry,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should serverParams.Expiry be validated? E.g. that it is within some range (positive, not too high, fits into int32).

@hieblmi hieblmi force-pushed the static-addr-staging branch from 17618f2 to 6f9539b Compare June 19, 2024 21:03
Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

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

Comment on lines 798 to 799
// The requested amount is 0 here if the request contained deposit
// outpoints. In case we quote for deposits we send the server both the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be enforced with a check?

if amount != 0 && len(summary.FilteredDeposits) > 0 {
  return nil, error

@@ -33,20 +35,36 @@ var quoteInCommand = cli.Command{
verboseFlag,
privateFlag,
routeHintsFlag,
cli.StringSliceFlag{
Name: "deposit_outpoint",
Usage: "one or more static address deposit outpoints " +
Copy link
Collaborator

Choose a reason for hiding this comment

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

one or more

Can you specify how to pass multiple outpoints, please?

Copy link
Member

Choose a reason for hiding this comment

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

+1

Comment on lines 140 to 142
var (
depositAmt btcutil.Amount
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

var depositAmt btcutil.Amount
also it can be moved before the loop, since it is used there.

@hieblmi
Copy link
Collaborator Author

hieblmi commented Jun 20, 2024

Thank you for your review @starius, there seems to have been outdated commits present in your last review. I've now rebased with the latest master changes.

It would be great if you could give the prevous PR #721 a look.

@hieblmi hieblmi force-pushed the static-addr-6 branch 2 times, most recently from d94cabe to 11e9b12 Compare June 20, 2024 09:01
@@ -1395,6 +1426,201 @@ func (s *swapClientServer) WithdrawDeposits(ctx context.Context,
return &clientrpc.WithdrawDepositsResponse{}, err
}

// GetStaticAddressSummary returns a summary static address related information.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nit: grammar

Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM, very clean PR 🎉

var summaryCommand = cli.Command{
Name: "summary",
ShortName: "s",
Usage: "Display a summary of static address related data.",
Copy link
Member

Choose a reason for hiding this comment

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

nit: instead of "data" i'd word it as "information".

func filter(deposits []*deposit.Deposit, f filterFunc) []*clientrpc.Deposit {
var clientDeposits []*clientrpc.Deposit
for _, d := range deposits {
if f(d) {
Copy link
Member

Choose a reason for hiding this comment

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

style+nit: if !f(d) { continue }?

@@ -760,6 +760,13 @@ message QuoteRequest {
probing and payment.
*/
bool private = 7;

/*
Static address deposit outpoints that will be quoted for. This option only
Copy link
Member

Choose a reason for hiding this comment

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

nit: commit message could be reformatted for readability.

@@ -33,20 +35,36 @@ var quoteInCommand = cli.Command{
verboseFlag,
privateFlag,
routeHintsFlag,
cli.StringSliceFlag{
Name: "deposit_outpoint",
Usage: "one or more static address deposit outpoints " +
Copy link
Member

Choose a reason for hiding this comment

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

+1

@hieblmi hieblmi force-pushed the static-addr-staging branch from add5263 to 48cc041 Compare June 24, 2024 17:00
@hieblmi hieblmi force-pushed the static-addr-6 branch 2 times, most recently from bef49c2 to 5184bbd Compare June 24, 2024 17:12
hieblmi added 3 commits June 25, 2024 13:55
This commit adds static address deposit outpoints to the
QuoteRequest message. It allows to quote for loop in swaps
with the total value of specified deposits.
This commit adds the number of deposits to the
ServerLoopInQuoteRequest that the client wants
to quote for.
@hieblmi hieblmi merged commit 3e289a7 into lightninglabs:static-addr-staging Jun 25, 2024
4 checks passed
@hieblmi hieblmi deleted the static-addr-6 branch June 25, 2024 12:39
@hieblmi hieblmi mentioned this pull request Jun 28, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants