From 7ed2b8801abcdbcfda7a48ba115e4e66aa4d9c20 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Tue, 30 Apr 2024 14:25:50 -0500 Subject: [PATCH] 2024 04 30 upgrade eclair `v0.10.0` (#5557) * Fix open, audit commands for v0.10.0 * Get all unit tests passing * Add logger.error() to try to debug channel state * Try adding delay to see if dual funding process can complete before we generate blocks * scalafmt * Try bumping number of blocks generated * Try disabling dual funding * Cleanup --- .../commons/jsonmodels/eclair/EclairModels.scala | 7 +++++-- .../bitcoins/commons/serializers/JsonReaders.scala | 9 ++++++--- bitcoind-rpc/bitcoind-rpc.sbt | 1 + .../core/protocol/ln/channel/ChannelState.scala | 4 +++- .../org/bitcoins/eclair/rpc/EclairRpcClientTest.scala | 11 ++++++----- eclair-rpc/eclair-rpc.sbt | 7 ++++--- .../bitcoins/eclair/rpc/client/EclairRpcClient.scala | 4 ++-- lnd-rpc/lnd-rpc.sbt | 1 + testkit-core/.jvm/src/main/resources/logback-test.xml | 2 +- .../testkit/eclair/rpc/EclairRpcTestUtil.scala | 11 +++++++---- 10 files changed, 36 insertions(+), 21 deletions(-) diff --git a/app-commons/src/main/scala/org/bitcoins/commons/jsonmodels/eclair/EclairModels.scala b/app-commons/src/main/scala/org/bitcoins/commons/jsonmodels/eclair/EclairModels.scala index a77b80512b..48154bcdb9 100644 --- a/app-commons/src/main/scala/org/bitcoins/commons/jsonmodels/eclair/EclairModels.scala +++ b/app-commons/src/main/scala/org/bitcoins/commons/jsonmodels/eclair/EclairModels.scala @@ -222,13 +222,16 @@ object ReceivedPayment { ) } +case class RelayTimestamp(iso: Instant, unix: Long) + case class RelayedPayment( amountIn: MilliSatoshis, amountOut: MilliSatoshis, paymentHash: Sha256Digest, fromChannelId: FundedChannelId, toChannelId: FundedChannelId, - timestamp: Instant // milliseconds + startedAt: RelayTimestamp, + settledAt: RelayTimestamp ) case class SentPayment( @@ -489,7 +492,7 @@ case class WalletTransaction( address: String, amount: Satoshis, fees: Satoshis, - blockHash: DoubleSha256DigestBE, + blockId_opt: Option[DoubleSha256DigestBE], confirmations: Long, txid: DoubleSha256DigestBE, timestamp: Long diff --git a/app-commons/src/main/scala/org/bitcoins/commons/serializers/JsonReaders.scala b/app-commons/src/main/scala/org/bitcoins/commons/serializers/JsonReaders.scala index 17333ac7c9..838fb13a8f 100644 --- a/app-commons/src/main/scala/org/bitcoins/commons/serializers/JsonReaders.scala +++ b/app-commons/src/main/scala/org/bitcoins/commons/serializers/JsonReaders.scala @@ -1451,6 +1451,8 @@ object JsonReaders { implicit val sentPaymentReads: Reads[SentPayment] = Json.reads[SentPayment] + implicit val relayTimestampReads: Reads[RelayTimestamp] = + Json.reads[RelayTimestamp] implicit val relayedPaymentReads: Reads[RelayedPayment] = Reads { js => for { amountIn <- (js \ "amountIn").validate[MilliSatoshis] @@ -1458,15 +1460,16 @@ object JsonReaders { paymentHash <- (js \ "paymentHash").validate[Sha256Digest] fromChannelId <- (js \ "fromChannelId").validate[FundedChannelId] toChannelId <- (js \ "toChannelId").validate[FundedChannelId] - timestamp <- (js \ "timestamp" \ "unix") - .validate[Instant](instantReadsMilliseconds) + startedAt <- (js \ "startedAt").validate[RelayTimestamp] + settledAt <- (js \ "settledAt").validate[RelayTimestamp] } yield RelayedPayment( amountIn, amountOut, paymentHash, fromChannelId, toChannelId, - timestamp + startedAt, + settledAt ) } implicit val auditResultReads: Reads[AuditResult] = Json.reads[AuditResult] diff --git a/bitcoind-rpc/bitcoind-rpc.sbt b/bitcoind-rpc/bitcoind-rpc.sbt index 14d730c90c..68f36861f6 100644 --- a/bitcoind-rpc/bitcoind-rpc.sbt +++ b/bitcoind-rpc/bitcoind-rpc.sbt @@ -130,6 +130,7 @@ TaskKeys.downloadBitcoind := { logger.info(s"Extracting archive with command: $extractCommand") extractCommand.!! } else { + Files.delete(expectedEndLocation) logger.error( s"Downloaded invalid version of bitcoind v$version, got $hash, expected ${expectedHash(version)}") } diff --git a/core/src/main/scala/org/bitcoins/core/protocol/ln/channel/ChannelState.scala b/core/src/main/scala/org/bitcoins/core/protocol/ln/channel/ChannelState.scala index fc8db3e45f..ef305472a6 100644 --- a/core/src/main/scala/org/bitcoins/core/protocol/ln/channel/ChannelState.scala +++ b/core/src/main/scala/org/bitcoins/core/protocol/ln/channel/ChannelState.scala @@ -32,6 +32,7 @@ object ChannelState extends StringFactory[ChannelState] { case object SYNCING extends ChannelState case object WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT extends ChannelState case object ERR_INFORMATION_LEAK extends ChannelState + case object WAIT_FOR_DUAL_FUNDING_SIGNED extends ChannelState private lazy val all: Map[String, ChannelState] = List( WAIT_FOR_INIT_INTERNAL, @@ -57,7 +58,8 @@ object ChannelState extends StringFactory[ChannelState] { OFFLINE, SYNCING, WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT, - ERR_INFORMATION_LEAK + ERR_INFORMATION_LEAK, + WAIT_FOR_DUAL_FUNDING_SIGNED ).map(state => state.toString -> state).toMap override def fromStringOpt(str: String): Option[ChannelState] = { diff --git a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala index eddcbdb3b0..5c15d4113c 100644 --- a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala +++ b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala @@ -223,8 +223,8 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { _ <- EclairRpcTestUtil .awaitUntilIncomingPaymentStatus[IncomingPaymentStatus.Received]( - client4, - invoice.lnTags.paymentHash.hash, + client = client4, + paymentHash = invoice.lnTags.paymentHash.hash, interval = 1.second ) @@ -262,7 +262,8 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { _ <- EclairRpcTestUtil.openAndConfirmChannel(clientF, otherClientF) _ <- EclairRpcTestUtil.awaitEclairInSync(otherClient, bitcoind) _ <- EclairRpcTestUtil.awaitEclairInSync(client, bitcoind) - invoice <- otherClient.createInvoice("abc", 50.msats) + invoice <- otherClient.createInvoice(description = "abc", + amountMsat = 50.msats) info <- otherClient.getInfo _ = assert(info.nodeId == invoice.nodeId) paymentResult <- @@ -460,7 +461,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { val getChannelId = (client: EclairRpcClient, otherClient: EclairRpcClient) => { otherClient.getInfo.flatMap { info => - val amt = Satoshis(100000) + val amt = Satoshis(10000000) val openedChanF = clientF.flatMap(_.open(info.nodeId, amt)) openedChanF.flatMap { channelId => @@ -1002,7 +1003,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest { c2: EclairRpcClient ): Future[FundedChannelId] = { EclairRpcTestUtil - .openChannel(c1, c2, Satoshis(500000), MilliSatoshis(500000)) + .openChannel(c1, c2, Satoshis(50000000), MilliSatoshis(500000)) } val openedChannelsF: Future[(ChannelId, ChannelId)] = { diff --git a/eclair-rpc/eclair-rpc.sbt b/eclair-rpc/eclair-rpc.sbt index 1221dfbb29..f10b084cdd 100644 --- a/eclair-rpc/eclair-rpc.sbt +++ b/eclair-rpc/eclair-rpc.sbt @@ -19,8 +19,8 @@ TaskKeys.downloadEclair := { Files.createDirectories(binaryDir) } - val version = "0.9.0" - val commit = "623f7e4" + val version = "0.10.0" + val commit = "a63d2c2" logger.debug(s"(Maybe) downloading Eclair binaries for version: $version") @@ -48,7 +48,7 @@ TaskKeys.downloadEclair := { .mkString val expectedHash = - "249604de45c54dc48f02c7335b49ff2896334fd44541dbb175e56aff66054cdc" + "ee221cac0f3f8379fcac3eb7b558690de92b417365cc005524da2a6305d41e03" val success = hash.equalsIgnoreCase(expectedHash) if (success) { @@ -58,6 +58,7 @@ TaskKeys.downloadEclair := { logger.info(s"Extracting archive with command: $extractCommand") extractCommand.!! } else { + Files.delete(versionDir) logger.error( s"Downloaded invalid version of eclair, got $hash, expected $expectedHash") } diff --git a/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/client/EclairRpcClient.scala b/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/client/EclairRpcClient.scala index 91e5d3092e..b1465b7042 100644 --- a/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/client/EclairRpcClient.scala +++ b/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/client/EclairRpcClient.scala @@ -1081,10 +1081,10 @@ object EclairRpcClient { ) = new EclairRpcClient(instance, binary) /** The current commit we support of Eclair */ - private[bitcoins] val commit = "623f7e4" + private[bitcoins] val commit = "a63d2c2" /** The current version we support of Eclair */ - private[bitcoins] val version = "0.9.0" + private[bitcoins] val version = "0.10.0" /** The bitcoind version that eclair is officially tested & supported with by * ACINQ diff --git a/lnd-rpc/lnd-rpc.sbt b/lnd-rpc/lnd-rpc.sbt index ee64b94de4..8c3eaa4abf 100644 --- a/lnd-rpc/lnd-rpc.sbt +++ b/lnd-rpc/lnd-rpc.sbt @@ -92,6 +92,7 @@ TaskKeys.downloadLnd := { logger.info(s"Extracting archive with command: $extractCommand") extractCommand.!! } else { + Files.delete(versionDir) logger.error( s"Downloaded invalid version of lnd, got $hash, expected $expectedHash") } diff --git a/testkit-core/.jvm/src/main/resources/logback-test.xml b/testkit-core/.jvm/src/main/resources/logback-test.xml index 54acea7eca..13a50f9de0 100644 --- a/testkit-core/.jvm/src/main/resources/logback-test.xml +++ b/testkit-core/.jvm/src/main/resources/logback-test.xml @@ -20,7 +20,7 @@ - + diff --git a/testkit/src/main/scala/org/bitcoins/testkit/eclair/rpc/EclairRpcTestUtil.scala b/testkit/src/main/scala/org/bitcoins/testkit/eclair/rpc/EclairRpcTestUtil.scala index d2dbb1eee1..aec4817269 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/eclair/rpc/EclairRpcTestUtil.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/eclair/rpc/EclairRpcTestUtil.scala @@ -10,7 +10,7 @@ import org.bitcoins.commons.jsonmodels.eclair.{ } import org.bitcoins.commons.util.BitcoinSLogger import org.bitcoins.core.compat.JavaConverters._ -import org.bitcoins.core.currency.{CurrencyUnit, Satoshis} +import org.bitcoins.core.currency.{Bitcoins, CurrencyUnit, Satoshis} import org.bitcoins.core.protocol.ln.channel.{ ChannelId, ChannelState, @@ -125,7 +125,10 @@ trait EclairRpcTestUtil extends BitcoinSLogger { "eclair.alias" -> "suredbits", "eclair.channel.fulfill-safety-before-timeout-blocks" -> 1, "eclair.channel.min-final-expiry-delta-blocks" -> 2, - "eclair.features.keysend" -> "optional" + "eclair.features.keysend" -> "optional", + // for some reason dual funded channels causes tests to fail on CI + // but not locally on my laptop, disable them for now + "eclair.features.option_dual_fund" -> "disabled" ) } val c = ConfigFactory.parseMap(configMap.asJava) @@ -457,7 +460,7 @@ trait EclairRpcTestUtil extends BitcoinSLogger { def openAndConfirmChannel( client1F: Future[EclairRpcClient], client2F: Future[EclairRpcClient], - amount: CurrencyUnit = Satoshis(1000000) + amount: CurrencyUnit = Satoshis(10000000) )(implicit system: ActorSystem): Future[ChannelId] = { import system.dispatcher val bitcoindRpcF = client1F.map(EclairRpcTestUtil.getBitcoindRpc(_)) @@ -681,7 +684,7 @@ trait EclairRpcTestUtil extends BitcoinSLogger { resultF } - private val DEFAULT_CHANNEL_MSAT_AMT = MilliSatoshis(500000000L) + private val DEFAULT_CHANNEL_MSAT_AMT = MilliSatoshis(Bitcoins.one.satoshis) /** Opens a channel from n1 -> n2 */ def openChannel(