Skip to content

Commit

Permalink
Update dependencies and enable fatal warnings (#1885)
Browse files Browse the repository at this point in the history
Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
  • Loading branch information
pm47 and t-bast committed Jul 16, 2021
1 parent 79729c7 commit c22596b
Show file tree
Hide file tree
Showing 89 changed files with 788 additions and 783 deletions.
8 changes: 4 additions & 4 deletions eclair-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<dependency>
<groupId>org.json4s</groupId>
<artifactId>json4s-jackson_${scala.version.short}</artifactId>
<version>3.6.7</version>
<version>3.6.11</version>
</dependency>
<dependency>
<groupId>com.softwaremill.sttp</groupId>
Expand Down Expand Up @@ -202,7 +202,7 @@
<dependency>
<groupId>org.scodec</groupId>
<artifactId>scodec-core_${scala.version.short}</artifactId>
<version>1.11.7</version>
<version>1.11.8</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand All @@ -224,11 +224,11 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.34.0</version>
<version>3.36.0.1</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<version>42.2.12</version>
<version>42.2.23</version>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ case class MilliSatoshi(private val underlying: Long) extends Ordered[MilliSatos
def *(m: Long) = MilliSatoshi(underlying * m)
def *(m: Double) = MilliSatoshi((underlying * m).toLong)
def /(d: Long) = MilliSatoshi(underlying / d)
def unary_-() = MilliSatoshi(-underlying)
def unary_- = MilliSatoshi(-underlying)

override def compare(other: MilliSatoshi): Int = underlying.compareTo(other.underlying)
// Since BtcAmount is a sealed trait that MilliSatoshi cannot extend, we need to redefine comparison operators.
Expand Down
2 changes: 1 addition & 1 deletion eclair-core/src/main/scala/fr/acinq/eclair/PimpKamon.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object KamonExt {
def timeFuture[T](timer: Timer)(f: => Future[T])(implicit ec: ExecutionContext): Future[T] = {
val started = timer.start()
val res = f
res onComplete (_ => started.stop)
res onComplete (_ => started.stop())
res
}

Expand Down
28 changes: 15 additions & 13 deletions eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,21 @@ class Setup(val datadir: File,
case _ =>
new FallbackFeeProvider(new SmoothFeeProvider(new BitcoinCoreFeeProvider(bitcoin, defaultFeerates), smoothFeerateWindow) :: Nil, minFeeratePerByte)
}
_ = system.scheduler.schedule(0 seconds, 10 minutes)(feeProvider.getFeerates.onComplete {
case Success(feerates) =>
feeratesPerKB.set(feerates)
feeratesPerKw.set(FeeratesPerKw(feerates))
channel.Monitoring.Metrics.LocalFeeratePerKw.withoutTags().update(feeratesPerKw.get.feePerBlock(nodeParams.onChainFeeConf.feeTargets.commitmentBlockTarget).toLong)
blockchain.Monitoring.Metrics.MempoolMinFeeratePerKw.withoutTags().update(feeratesPerKw.get.mempoolMinFee.toLong)
system.eventStream.publish(CurrentFeerates(feeratesPerKw.get))
logger.info(s"current feeratesPerKB=${feeratesPerKB.get} feeratesPerKw=${feeratesPerKw.get}")
feeratesRetrieved.trySuccess(Done)
case Failure(exception) =>
logger.warn(s"cannot retrieve feerates: ${exception.getMessage}")
blockchain.Monitoring.Metrics.CannotRetrieveFeeratesCount.withoutTags().increment()
feeratesRetrieved.tryFailure(CannotRetrieveFeerates)
_ = system.scheduler.scheduleWithFixedDelay(0 seconds, 10 minutes)(new Runnable {
override def run(): Unit = feeProvider.getFeerates.onComplete {
case Success(feerates) =>
feeratesPerKB.set(feerates)
feeratesPerKw.set(FeeratesPerKw(feerates))
channel.Monitoring.Metrics.LocalFeeratePerKw.withoutTags().update(feeratesPerKw.get.feePerBlock(nodeParams.onChainFeeConf.feeTargets.commitmentBlockTarget).toLong.toDouble)
blockchain.Monitoring.Metrics.MempoolMinFeeratePerKw.withoutTags().update(feeratesPerKw.get.mempoolMinFee.toLong.toDouble)
system.eventStream.publish(CurrentFeerates(feeratesPerKw.get))
logger.info(s"current feeratesPerKB=${feeratesPerKB.get} feeratesPerKw=${feeratesPerKw.get}")
feeratesRetrieved.trySuccess(Done)
case Failure(exception) =>
logger.warn(s"cannot retrieve feerates: ${exception.getMessage}")
blockchain.Monitoring.Metrics.CannotRetrieveFeeratesCount.withoutTags().increment()
feeratesRetrieved.tryFailure(CannotRetrieveFeerates)
}
})
_ <- feeratesRetrieved.future

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@ private class BalanceActor(context: ActorContext[Command],
log.info("current balance: total={} onchain.confirmed={} onchain.unconfirmed={} offchain={}", result.total.toDouble, result.onChain.confirmed.toDouble, result.onChain.unconfirmed.toDouble, result.offChain.total.toDouble)
log.debug("current balance details : {}", result)
Metrics.GlobalBalance.withoutTags().update(result.total.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.OnchainConfirmed).update(result.onChain.confirmed.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.OnchainUnconfirmed).update(result.onChain.unconfirmed.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.waitForFundingConfirmed).update(result.offChain.waitForFundingConfirmed.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.waitForFundingLocked).update(result.offChain.waitForFundingLocked.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.normal).update(result.offChain.normal.total.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.shutdown).update(result.offChain.shutdown.total.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.closingLocal).update(result.offChain.closing.localCloseBalance.total.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.closingRemote).update(result.offChain.closing.remoteCloseBalance.total.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.closingUnknown).update(result.offChain.closing.unknownCloseBalance.total.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.waitForPublishFutureCommitment).update(result.offChain.waitForPublishFutureCommitment.toMilliBtc.toLong)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.OnchainConfirmed).update(result.onChain.confirmed.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.OnchainUnconfirmed).update(result.onChain.unconfirmed.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.waitForFundingConfirmed).update(result.offChain.waitForFundingConfirmed.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.waitForFundingLocked).update(result.offChain.waitForFundingLocked.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.normal).update(result.offChain.normal.total.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.shutdown).update(result.offChain.shutdown.total.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.closingLocal).update(result.offChain.closing.localCloseBalance.total.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.closingRemote).update(result.offChain.closing.remoteCloseBalance.total.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.closingUnknown).update(result.offChain.closing.unknownCloseBalance.total.toMilliBtc.toDouble)
Metrics.GlobalBalanceDetailed.withTag(Tags.BalanceType, Tags.BalanceTypes.Offchain).withTag(Tags.OffchainState, Tags.OffchainStates.waitForPublishFutureCommitment).update(result.offChain.waitForPublishFutureCommitment.toMilliBtc.toDouble)
refBalance_opt match {
case Some(refBalance) =>
val normalizedValue = 100 + (if (refBalance.total.toSatoshi.toLong > 0) (result.total.toSatoshi.toLong - refBalance.total.toSatoshi.toLong) * 1000D / refBalance.total.toSatoshi.toLong else 0)
val diffValue = result.total.toSatoshi.toLong - refBalance.total.toSatoshi.toLong
log.info("relative balance: current={} reference={} normalized={} diff={}", result.total.toDouble, refBalance.total.toDouble, normalizedValue, diffValue)
Metrics.GlobalBalanceNormalized.withoutTags().update(normalizedValue)
Metrics.GlobalBalanceDiff.withTag(Tags.DiffSign, Tags.DiffSigns.plus).update(diffValue.max(0))
Metrics.GlobalBalanceDiff.withTag(Tags.DiffSign, Tags.DiffSigns.minus).update((-diffValue).max(0))
Metrics.GlobalBalanceDiff.withTag(Tags.DiffSign, Tags.DiffSigns.plus).update(diffValue.max(0).toDouble)
Metrics.GlobalBalanceDiff.withTag(Tags.DiffSign, Tags.DiffSigns.minus).update((-diffValue).max(0).toDouble)
Behaviors.same
case None =>
log.info("using balance={} as reference", result.total.toDouble)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fr.acinq.eclair.blockchain.bitcoind.rpc.ExtendedBitcoinClient
import fr.acinq.eclair.channel.Helpers.Closing
import fr.acinq.eclair.channel.Helpers.Closing.{CurrentRemoteClose, LocalClose, NextRemoteClose, RemoteClose}
import fr.acinq.eclair.channel._
import fr.acinq.eclair.db.{Databases, PendingCommandsDb}
import fr.acinq.eclair.db.Databases
import fr.acinq.eclair.transactions.DirectedHtlc.{incoming, outgoing}
import fr.acinq.eclair.transactions.Transactions
import fr.acinq.eclair.transactions.Transactions.{ClaimHtlcSuccessTx, ClaimHtlcTimeoutTx, HtlcSuccessTx, HtlcTimeoutTx}
Expand Down Expand Up @@ -220,7 +220,8 @@ object CheckBalance {
val remoteClose = if (d.remoteCommitPublished.isDefined) {
CurrentRemoteClose(d.commitments.remoteCommit, d.remoteCommitPublished.get)
} else {
NextRemoteClose(d.commitments.remoteNextCommitInfo.left.get.nextRemoteCommit, d.nextRemoteCommitPublished.get)
val Left(waitingForRevocation) = d.commitments.remoteNextCommitInfo
NextRemoteClose(waitingForRevocation.nextRemoteCommit, d.nextRemoteCommitPublished.get)
}
r.modify(_.closing.remoteCloseBalance).using(updatePossiblyPublishedBalance(computeRemoteCloseBalance(d.commitments, remoteClose, knownPreimages)))
case _ => r.modify(_.closing.unknownCloseBalance).using(updateMainAndHtlcBalance(d.commitments.localCommit, knownPreimages))
Expand Down Expand Up @@ -267,8 +268,8 @@ object CheckBalance {
def computeOnChainBalance(bitcoinClient: ExtendedBitcoinClient)(implicit ec: ExecutionContext): Future[CorrectedOnChainBalance] = for {
utxos <- bitcoinClient.listUnspent()
detailed = utxos.foldLeft(DetailedBalance()) {
case (total, utxo) if utxo.confirmations > 0 => total.modify(_.confirmed).using(_ + utxo.amount)
case (total, utxo) if utxo.confirmations == 0 => total.modify(_.unconfirmed).using(_ + utxo.amount)
case (total, utxo) => total.modify(_.confirmed).using(_ + utxo.amount)
}
} yield CorrectedOnChainBalance(detailed.confirmed, detailed.unconfirmed)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import fr.acinq.bitcoin._
import fr.acinq.eclair.blockchain.Monitoring.Metrics
import fr.acinq.eclair.blockchain._
import fr.acinq.eclair.blockchain.bitcoind.rpc.ExtendedBitcoinClient
import fr.acinq.eclair.blockchain.bitcoind.rpc.ExtendedBitcoinClient.Utxo
import fr.acinq.eclair.blockchain.watchdogs.BlockchainWatchdog
import fr.acinq.eclair.wire.protocol.ChannelAnnouncement
import fr.acinq.eclair.{KamonExt, ShortChannelId}
import org.json4s.JsonAST._

import java.util.concurrent.atomic.AtomicLong
import scala.concurrent.duration._
Expand Down Expand Up @@ -381,6 +379,7 @@ private class ZmqWatcher(chainHash: ByteVector32, blockCount: AtomicLong, client
}
}
}
case _ => Future.successful((): Unit)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class BatchingClient(rpcClient: BasicBitcoinJsonRPCClient) extends Actor with Ac
override def receive: Receive = {
case request: JsonRPCRequest =>
// immediately process isolated request
process(queue = Queue(Pending(request, sender)))
process(queue = Queue(Pending(request, sender())))
}

def waiting(queue: Queue[Pending], processing: Seq[Pending]): Receive = {
case request: JsonRPCRequest =>
// there is already a batch in flight, just add this request to the queue
context become waiting(queue :+ Pending(request, sender), processing)
context become waiting(queue :+ Pending(request, sender()), processing)

case responses: Seq[JsonRPCResponse]@unchecked =>
log.debug("got {} responses", responses.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object BitcoinCoreFeeProvider {
def parseFeeEstimate(json: JValue): FeeratePerKB = {
json \ "errors" match {
case JNothing =>
json \ "feerate" match {
(json \ "feerate": @unchecked) match {
case JDecimal(feerate) =>
// estimatesmartfee returns a fee rate in Btc/KB
FeeratePerKB(Btc(feerate).toSatoshi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object BlockchainWatchdog {
} else {
context.log.info("{}: we are {} blocks late", source, missingBlocks)
}
Metrics.BitcoinBlocksSkew.withTag(Tags.Source, source).update(missingBlocks)
Metrics.BitcoinBlocksSkew.withTag(Tags.Source, source).update(missingBlocks.toDouble)
Behaviors.same
}
}
Expand Down

0 comments on commit c22596b

Please sign in to comment.