-
Notifications
You must be signed in to change notification settings - Fork 269
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
Offers without extra plugin #2976
base: master
Are you sure you want to change the base?
Conversation
b8611f6
to
5e9bc0e
Compare
467a5a4
to
665ad0a
Compare
7e0cff1
to
4b60ea1
Compare
89ba629
to
2220ab7
Compare
2220ab7
to
d4261f5
Compare
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.
Mostly small architectural comments and nits at that point, the overall flow looks good!
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/OfferManager.scala
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/DefaultHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/db/pg/PgOffersDb.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/db/pg/PgOffersDb.scala
Outdated
Show resolved
Hide resolved
1f1f024
to
242fa8c
Compare
eclair-node/src/main/scala/fr/acinq/eclair/api/handlers/Offer.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/DefaultHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/DefaultOfferHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/DefaultOfferHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/DefaultOfferHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/DefaultOfferHandler.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/payment/offer/OfferManager.scala
Outdated
Show resolved
Hide resolved
3dde178
to
e6ed8fd
Compare
This commit doesn't contain any implementation change, it only focuses on refactoring, adding comments, logs, applying formatter suggestions and improving tests.
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.
Looks mostly good to me, apart from the tests. I've done some refactoring and clean-up in #3030, but it should be quite straightforward (the biggest refactoring is DefaultOfferHandler
, but it's purely refactoring).
postman: typed.ActorRef[Postman.Command], | ||
watcher: TestProbe, | ||
wallet: SingleKeyOnChainWallet, | ||
bitcoinClient: TestBitcoinCoreClient) { | ||
val nodeId = nodeParams.nodeId | ||
val routeParams = nodeParams.routerConf.pathFindingExperimentConf.experiments.values.head.getDefaultRouteParams | ||
|
||
val eclairImpl = new EclairImpl(Kit(nodeParams, system, watcher.ref.toTyped, paymentHandler, register, relayer, router, switchboard, paymentInitiator, TestProbe()(system).ref, TestProbe()(system).ref.toTyped, TestProbe()(system).ref.toTyped, postman, offerManager, defaultOfferHandler, wallet)) |
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.
I don't think this is a good idea, for the following reasons:
- this forces you to use
Await.Result
which should be avoided unless it cannot be helped: it blocks the current thread, which means that if any of those tests fail (and we already know that theOfferPaymentSpec
is flaky), it will kill our parallelism and slow down the whole test run EclairImpl
should be a very light shim on top of features provided by the actors that are exposed inMinimalNodeFixture
, so you're not really testing the code ofEclairImpl
here (which should rather be tested inEclairImplSpec
, when tested are needed)- a few actors aren't provided and are replaced by
TestProbe
s: this will make us lose time debugging new tests that believe they can use thiseclairImpl
object and don't have the expected results
I think it makes more sense to implement helper functions that use standard actor programming here to:
- create an offer (which spawns an
OfferCreator
like whatEclairImpl
does) - pay an offer
This should be quite straightforward to do and will keep the tests in OfferPaymentSpec
easy to read?
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.
Done
@@ -122,8 +122,7 @@ class OfferTypesSpec extends AnyFunSuite { | |||
val request = InvoiceRequest(offer, 500 msat, 1, Features.empty, payerKey, Block.LivenetGenesisBlock.hash) | |||
assert(request.isValid) | |||
assert(request.offer == offer) | |||
val withoutAmount = signInvoiceRequest(request.copy(records = TlvStream(request.records.records.filter { case InvoiceRequestAmount(_) => false case _ => true })), payerKey) | |||
assert(!withoutAmount.isValid) | |||
assertThrows[Exception](signInvoiceRequest(request.copy(records = TlvStream(request.records.records.filter { case InvoiceRequestAmount(_) => false case _ => true })), payerKey)) |
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.
This is a bit weird, it's not signInvoiceRequest
that throws, but directly the creation of the InvoiceRequest
object.
The change you added to provide an amount means we now immediately fail decoding those invoice_request
with an exception instead of failing cleanly in the validate
function...but it's fine, it makes it much simpler to use invoice requests in the codebase and nobody should be creating such invalid invoice requests (and if they do, too bad for them if we don't return a meaningful error message).
Enable basic offer management without the need for a plugin.
Offers allow a wide range of use-cases and it would be impossible to cover everything in eclair which is why we have relied on plugins to manage offers. However most users will not need advanced features, with this PR we aim to provide the basic features that will be enough for 95% of users. Advanced users can still use a plugin to manage more complex offers.
Supported use-cases: