Skip to content

build: update to btcec/v2 and btcd/btcutil #55

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

Merged
merged 3 commits into from
Feb 11, 2022
Merged

build: update to btcec/v2 and btcd/btcutil #55

merged 3 commits into from
Feb 11, 2022

Conversation

Roasbeef
Copy link
Member

In this commit we update our deps to use the new btcec/v2 APIs as well
as point to the new btcd/btcutil repo.

Along the way, we get a ~8% speed up in packet construction, and a ~9%
speed up in packet processing due to the more optimized EC routines that
btcec/v2 uses.

Benchmark run with the new changes:

goos: darwin
goarch: amd64
pkg: github.com/lightningnetwork/lightning-onion
cpu: VirtualApple @ 2.50GHz
BenchmarkPathPacketConstruction-8   	     366	   3260221 ns/op	  174541 B/op	    1411 allocs/op
BenchmarkProcessPacket-8            	    4926	    247395 ns/op	   21059 B/op	      68 allocs/op
PASS

Benchmark run with the old code:

goos: darwin
goarch: amd64
pkg: github.com/lightningnetwork/lightning-onion
cpu: VirtualApple @ 2.50GHz
BenchmarkPathPacketConstruction-8   	     332	   3522599 ns/op	  170336 B/op	    1410 allocs/op
BenchmarkProcessPacket-8            	    4425	    270806 ns/op	   22166 B/op	      99 allocs/op
PASS

In this commit we update our deps to use the new `btcec/v2` APIs as well
as point to the new `btcd/btcutil` repo.

Along the way, we get a ~8% speed up in packet construction, and a ~9%
speed up in packet processing due to the more optimized EC routines that
`btcec/v2` uses.

Benchmark run with the new changes:
```
goos: darwin
goarch: amd64
pkg: github.com/lightningnetwork/lightning-onion
cpu: VirtualApple @ 2.50GHz
BenchmarkPathPacketConstruction-8   	     366	   3260221 ns/op	  174541 B/op	    1411 allocs/op
BenchmarkProcessPacket-8            	    4926	    247395 ns/op	   21059 B/op	      68 allocs/op
PASS
```

Benchmark run with the old code:
```
goos: darwin
goarch: amd64
pkg: github.com/lightningnetwork/lightning-onion
cpu: VirtualApple @ 2.50GHz
BenchmarkPathPacketConstruction-8   	     332	   3522599 ns/op	  170336 B/op	    1410 allocs/op
BenchmarkProcessPacket-8            	    4425	    270806 ns/op	   22166 B/op	      99 allocs/op
PASS
```
Turns out in practice, the 27 hop limit is actually _too large_, so we
fall back to the old 20 hop limit for now. We'll want to circle back and
emperically derive the _true_ hop limit.
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@Roasbeef Roasbeef merged commit b62f49f into master Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants