Skip to content

Upgrade to bitcoin-kmp 0.31.0#108

Merged
sstone merged 5 commits into
masterfrom
update-bitcoin-kmp
Jun 3, 2026
Merged

Upgrade to bitcoin-kmp 0.31.0#108
sstone merged 5 commits into
masterfrom
update-bitcoin-kmp

Conversation

@sstone

@sstone sstone commented May 19, 2026

Copy link
Copy Markdown
Member

We update bitcoin-lib to 0.31.0 which includes some API changes (see https://github.com/ACINQ/bitcoin-kmp/releases/tag/v0.31.0).

sstone added 3 commits June 1, 2026 10:48
Wrapping a bitcoin-kmp transaction instance is much more efficient and benefits from optimizations added in ACINQ/bitcoin-kmp#184, at the
cost of having to provide "update" methods instead of using `.copy()`.

We also use `.toArrayUnsafe()` to convert scodec byte vectors to byte arrays, which should be more efficient (we use mostly small byte arrays, which would be simply wrapped
by scodec and would be passed directly to bitcoin-kmp instead of creating copies).
@sstone sstone force-pushed the update-bitcoin-kmp branch from f417361 to 5b9d9b2 Compare June 1, 2026 09:08
@sstone sstone marked this pull request as ready for review June 1, 2026 09:14
@sstone sstone requested a review from t-bast June 1, 2026 09:15
/**
* Transaction
* Instead of using a pure Scala case class, we simply wrap an instance of bitcoin-kmp transaction.
* This is done because kmp<->scala conversion is expensive and to benefit from optmisations (such as

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.

nit:

Suggested change
* This is done because kmp<->scala conversion is expensive and to benefit from optmisations (such as
* This is done because kmp<->scala conversion is expensive and to benefit from optimisations (such as

* @param lockTime The block number or timestamp at which this transaction is locked
*/
case class Transaction(version: Long, txIn: Seq[TxIn], txOut: Seq[TxOut], lockTime: Long) extends BtcSerializable[Transaction] {
case class Transaction(inner: bitcoinkmp.Transaction) extends BtcSerializable[Transaction] {

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 need to test that change on eclair before deciding whether we want to move forward with this. I honestly don't know if this provides meaningful benefits compared to the additional complexity: we don't validate blocks in eclair, and we don't frequently broadcast transaction (only when funding, splicing and closing, which isn't on the hot path for performance).

The only place where we do transaction signing a lot is when sending/receiving commit_sig, but is that worth it? I think we need to do some benchmarking of the current code and the updated code with that change to see if it has a real impact or not. We must make sure this is worth the extra complexity.

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.

I think it's worth it (it also speeds up serialisation and would enable further optimisations in bitcoin-kmp) but should be done in another PR. I've reverted Transaction back to a standard case class, and added a lazy val to store its bitcoin-kmp counterpart and avoid re-computing it.

sstone added 2 commits June 1, 2026 14:49
This will have less impact downstream and sill benefits from bitcoin-kmp optimisations.
@sstone sstone force-pushed the update-bitcoin-kmp branch from 6460eb7 to defabf9 Compare June 3, 2026 07:30

@t-bast t-bast left a comment

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.

I have no idea what the pom.xml changes do, but apart from that everything look good.

@sstone

sstone commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

I have no idea what the pom.xml changes do, but apart from that everything look good.

They fix the snapshot configuration so we can easily publish snapshots and remove a redondant gpg configuration section.

@sstone sstone merged commit 20c072f into master Jun 3, 2026
1 check passed
@sstone sstone deleted the update-bitcoin-kmp branch June 3, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants