Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ private[channel] object ChannelCodecs5 {

private val waitForRevCodec: Codec[WaitForRev] = ("sentAfterLocalCommitIndex" | uint64overflow).as[WaitForRev]

private val updateMessageCodec: Codec[UpdateMessage] = lengthDelimited(lightningMessageCodec.narrow[UpdateMessage](f => Attempt.successful(f.asInstanceOf[UpdateMessage]), g => g))
private val updateMessageCodec: Codec[UpdateMessage] = lengthDelimited(lightningMessageCodec.narrow[UpdateMessage]({
case f: UpdateMessage => Attempt.successful(f)
case _ => Attempt.failure(Err("not an UpdateMessage"))
}, g => g))

private val localChangesCodec: Codec[LocalChanges] = (
("proposed" | listOfN(uint16, updateMessageCodec)) ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

package fr.acinq.eclair.wire.protocol

import fr.acinq.eclair.wire.protocol.CommonCodecs.varint
import fr.acinq.eclair.wire.protocol.TlvCodecs.tlvStream
import scodec.Codec
import scodec.codecs.discriminated
import scodec.codecs.provide

/**
* Created by thomash on 10/09/2021.
Expand All @@ -28,5 +26,7 @@ import scodec.codecs.discriminated
sealed trait OnionMessageTlv extends Tlv

object OnionMessageTlv {
val onionMessageTlvCodec: Codec[TlvStream[OnionMessageTlv]] = tlvStream(discriminated[OnionMessageTlv].by(varint))
// We don't support any TLV for onion messages yet. Since onion messages can be spammy, we don't need to waste any
// resources trying to decode unknown TLVs that we'll throw away anyway.
val onionMessageTlvCodec: Codec[TlvStream[OnionMessageTlv]] = provide(TlvStream.empty[OnionMessageTlv])
}
11 changes: 6 additions & 5 deletions eclair-front/src/main/scala/fr/acinq/eclair/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@

package fr.acinq.eclair

import java.io.File

import akka.actor.ActorSystem
import com.typesafe.config.{ConfigFactory, ConfigParseOptions, ConfigSyntax}
import grizzled.slf4j.Logging
import kamon.Kamon

import java.io.File
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success}

object Boot extends App with Logging {
try {
val datadir = new File(sys.props.getOrElse("eclair.datadir", sys.props("user.home") + "/.eclair"))
val config = ConfigFactory.parseString(
sys.env.getOrElse("AKKA_CONF", "").replace(";", "\n"),
ConfigParseOptions.defaults().setSyntax(ConfigSyntax.PROPERTIES))
sys.env.getOrElse("AKKA_CONF", "").replace(";", "\n"),
ConfigParseOptions.defaults().setSyntax(ConfigSyntax.PROPERTIES))
.withFallback(ConfigFactory.parseProperties(System.getProperties))
.withFallback(ConfigFactory.parseFile(new File(datadir, "eclair.conf")))
.withFallback(ConfigFactory.load())
// It's unsafe to use the cluster mode with plain tcp: communications MUST be encrypted.
require(config.getString("akka.remote.artery.transport") == "tls-tcp", "frontend cluster communication must use tls-tcp")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should have the same check in eclair-node/src/main/scala/fr/acinq/eclair/Boot.scala.
Cluster.md should be updated now that tlc-tcp is required in cluster mode, and it should be explained in the release notes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Cluster.md already says that tls-tcp is required in cluster mode, there's nothing to update there? Also, I don't see how you would add a check in the eclair-node part, we don't parse that part of the configuration. It is when there are eclair-front nodes that it means we're using cluster mode, so I'm not sure what you want to change. Otherwise please send the exact changes you'd like to add?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cluster.md says it is recommended, not required.
What I mean about eclair-node is that we should add:

    require(config.getString("akka.remote.artery.transport") == "tls-tcp", "backend cluster communication must use tls-tcp")

after we've loaded the configuration.


// the actor system name needs to be the same for all members of the cluster
implicit val system: ActorSystem = ActorSystem("eclair-node", config)
Expand All @@ -54,7 +55,7 @@ object Boot extends App with Logging {
case t: Throwable => onError(t)
}

def onError(t: Throwable): Unit = {
private def onError(t: Throwable): Unit = {
val errorMsg = if (t.getMessage != null) t.getMessage else t.getClass.getSimpleName
System.err.println(s"fatal error: $errorMsg")
logger.error(s"fatal error: $errorMsg", t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ trait ErrorDirective {
private val apiExceptionHandler = ExceptionHandler {
case t: IllegalArgumentException =>
logger.error(s"API call failed with cause=${t.getMessage}")
Comment thread
t-bast marked this conversation as resolved.
complete(StatusCodes.BadRequest, ErrorResponse(t.getMessage))
complete(StatusCodes.BadRequest, ErrorResponse("API call failed: check logs for more details"))
case t: Throwable =>
logger.error(s"API call failed with cause=${t.getMessage}")
Comment thread
t-bast marked this conversation as resolved.
complete(StatusCodes.InternalServerError, ErrorResponse(t.getMessage))
complete(StatusCodes.InternalServerError, ErrorResponse("API call failed: check logs for more details"))
}

// map all the rejections to a JSON error object ErrorResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
assert(handled)
assert(status == BadRequest)
val resp = entityAs[ErrorResponse](Json4sSupport.unmarshaller, ClassTag(classOf[ErrorResponse]))
assert(resp.error == "invoice has expired")
assert(resp.error == "API call failed: check logs for more details")
eclair.send(None, 1258000 msat, any, any, any, any, any)(any[Timeout]).wasCalled(once)
}
}
Expand Down
Loading