-
Notifications
You must be signed in to change notification settings - Fork 267
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
Liquidity Ads #2550
Liquidity Ads #2550
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2550 +/- ##
==========================================
+ Coverage 85.96% 86.07% +0.11%
==========================================
Files 219 220 +1
Lines 18441 18709 +268
Branches 762 809 +47
==========================================
+ Hits 15853 16104 +251
- Misses 2588 2605 +17
|
709ce50
to
b077e3e
Compare
7344ecd
to
2ab7242
Compare
eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LiquidityAds.scala
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LiquidityAds.scala
Outdated
Show resolved
Hide resolved
0030428
to
5cf3b6d
Compare
eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LiquidityAds.scala
Show resolved
Hide resolved
FYI, here is a patch on diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Monitoring.scala b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Monitoring.scala
index fa15594cc0..4900a46467 100644
--- a/eclair-core/src/main/scala/fr/acinq/eclair/channel/Monitoring.scala
+++ b/eclair-core/src/main/scala/fr/acinq/eclair/channel/Monitoring.scala
@@ -57,10 +57,18 @@ object Monitoring {
*/
def recordSplice(fundingParams: InteractiveTxParams, sharedTx: SharedTransaction): Unit = {
if (fundingParams.localContribution > 0.sat) {
- Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Local).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceIn).record(fundingParams.localContribution.toLong)
+ if (fundingParams.isInitiator) {
+ Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Local).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceIn).record(fundingParams.localContribution.toLong)
+ } else {
+ Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Local).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceLiquidity).record(fundingParams.localContribution.toLong)
+ }
}
if (fundingParams.remoteContribution > 0.sat) {
- Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Remote).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceIn).record(fundingParams.remoteContribution.toLong)
+ if (fundingParams.isInitiator) {
+ Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Remote).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceLiquidity).record(fundingParams.remoteContribution.toLong)
+ } else {
+ Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Remote).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceIn).record(fundingParams.remoteContribution.toLong)
+ }
}
if (sharedTx.localOnlyNonChangeOutputs.nonEmpty) {
Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Local).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceOut).record(sharedTx.localOnlyNonChangeOutputs.map(_.amount).sum.toLong)
@@ -68,10 +76,10 @@ object Monitoring {
if (sharedTx.remoteOutputs.nonEmpty) {
Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Remote).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceOut).record(sharedTx.remoteOutputs.map(_.amount).sum.toLong)
}
- if (fundingParams.localContribution < 0.sat && sharedTx.localOutputs.isEmpty) {
+ if (fundingParams.localContribution < 0.sat && sharedTx.localOutputs.isEmpty && fundingParams.remoteContribution == 0.sat) {
Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Local).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceCpfp).record(Math.abs(fundingParams.localContribution.toLong))
}
- if (fundingParams.remoteContribution < 0.sat && sharedTx.remoteOutputs.isEmpty) {
+ if (fundingParams.remoteContribution < 0.sat && sharedTx.remoteOutputs.isEmpty && fundingParams.localContribution == 0.sat) {
Metrics.Splices.withTag(Tags.Origin, Tags.Origins.Remote).withTag(Tags.SpliceType, Tags.SpliceTypes.SpliceCpfp).record(Math.abs(fundingParams.remoteContribution.toLong))
}
}
@@ -114,6 +122,7 @@ object Monitoring {
val SpliceIn = "splice-in"
val SpliceOut = "splice-out"
val SpliceCpfp = "splice-cpfp"
+ val SpliceLiquidity = "splice-liquidity"
}
} A "purer" way would have been to add a |
Implement a prototype for liquidity ads, compatible with ACINQ/eclair#2550 Note that we only implement the buyer side, which limits testing. The specification is available here: lightning/bolts#878 We currently don't add CLTV locks to the commitment transactions, for simplicity's sake.
Please rebase 🙏 |
The initiator of `open_channel2`, `tx_init_rbf` and `splice_init` can request funding from the remote node. The non-initiator node will: - let the open-channel-interceptor plugin decide whether to lease liquidity for new channels or not, and how much - always honor liquidity requests on existing channels (RBF and splice) We currently don't modify commitment transactions to enforce the lease. This is different from lightning/bolts#878 and instead matches lightning/bolts#1145. We currently use the temporary tlv tag 1337 while we're waiting for feedback on our spec proposal. Liquidity ads are included in the `node_announcement` message, which lets buyers compare sellers and connect to sellers that provide rates they are comfortable with. We store every liquidity purchase (whether we're buyer or seller) in the audit DB. This is important information when choosing which peers are worth keeping channels with.
Rebased and squashed! I'll work on porting the annoying-to-rebase parts to |
@@ -114,6 +115,11 @@ class PgAuditDb(implicit ds: DataSource) extends AuditDb with Logging { | |||
statement.executeUpdate("CREATE INDEX transactions_published_channel_id_idx ON audit.transactions_published(channel_id)") | |||
} | |||
|
|||
def migration1213(statement: Statement): Unit = { | |||
statement.executeUpdate("CREATE TABLE IF NOT EXISTS audit.liquidity_purchases (tx_id TEXT NOT NULL, channel_id TEXT NOT NULL, node_id TEXT NOT NULL, is_buyer BOOLEAN NOT NULL, amount_sat BIGINT NOT NULL, mining_fee_sat BIGINT NOT NULL, service_fee_sat BIGINT NOT NULL, funding_tx_index BIGINT NOT NULL, capacity_sat BIGINT NOT NULL, local_contribution_sat BIGINT NOT NULL, remote_contribution_sat BIGINT NOT NULL, local_balance_msat BIGINT NOT NULL, remote_balance_msat BIGINT NOT NULL, outgoing_htlc_count BIGINT NOT NULL, incoming_htlc_count BIGINT NOT NULL, seller_sig TEXT NOT NULL, witness TEXT NOT NULL, created_at TIMESTAMP WITH TIME ZONE NOT NULL, confirmed_at TIMESTAMP WITH TIME ZONE)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: we should remove the IF NOT EXISTS
added in a few places, they're just an artifact from private branches.
Superseded by #2848 |
The initiator of
open_channel2
,tx_init_rbf
andsplice_init
can request funding from the remote node. The non-initiator node will:We currently don't modify commitment transactions to enforce the lease. This is different from lightning/bolts#878 and instead matches lightning/bolts#1145.
We currently use the temporary tlv tag 1337 while we're waiting for feedback on our spec proposal.
Liquidity ads are included in the
node_announcement
message, which lets buyers compare sellers and connect to sellers that provide rates they are comfortable with.We store every liquidity purchase (whether we're buyer or seller) in the audit DB. This is important information when choosing which peers are worth keeping channels with.