#structure #benchmark #testing

macro bolt-derive

A library implementing Bitcoin Lightning style serialization for structures

4 releases (2 breaking)

0.3.1 Aug 4, 2024
0.3.0 Jun 26, 2024
0.2.0 Aug 10, 2023
0.1.0 Mar 5, 2023

#250 in #benchmark

Download history 548/week @ 2024-12-09 743/week @ 2024-12-16 171/week @ 2024-12-23 281/week @ 2024-12-30 641/week @ 2025-01-06 477/week @ 2025-01-13 796/week @ 2025-01-20 384/week @ 2025-01-27 383/week @ 2025-02-03 466/week @ 2025-02-10 518/week @ 2025-02-17 174/week @ 2025-02-24 432/week @ 2025-03-03 329/week @ 2025-03-10 171/week @ 2025-03-17 533/week @ 2025-03-24

1,475 downloads per month
Used in 13 crates (2 directly)

Apache-2.0

11KB
212 lines

Validating Lightning Signer

Please see the VLS Project Overview for more information. Our web site.

Limitations

The following remain to be implemented:

  • vlsd2 --recover-to can only handle a simple force-close by us. It cannot sweep a force-close or a breach by the peer. It also cannot sweep HTLC outputs.
  • there is no facility to recover from loss of signer state.
  • on-chain tracking is not fully implemented, so a malicious node can steal funds by failing to remedy a breach (for example)

Additional Crates

Development Information

Additional HOWTO Documentation

We recommend using the nightly version of Rust only in specific cases, such as for cargo fmt and no-std. Otherwise, we explicitly recommend using the stable version.

Formatting Code

Enable formatting precommit hooks:

./scripts/enable-githooks

For some reason, the ignore configuration for rustfmt is only available on the nightly channel, even though it's documented as stable.

rustup install nightly

cargo +nightly fmt

Building Validating Lightning Signer

Build VLS and related crates:

cargo build

Running Unit Tests

cargo test

To enable logging for a failing test (adjust log level to preference):

RUST_LOG=trace cargo test

Using llvm-cov for Code Coverage

Dependencies:

cargo +stable install cargo-llvm-cov --locked

Run coverage:

./scripts/run-llvm-cov

Changing linker to mold instead of ld:

cp .cargo/config.sample.toml .cargo/config.toml

Benchmarks

Running Benchmarks

cargo bench -p vls-core --bench secp_bench

Note that you might need to add --features=test_utils if you want to run all benches in vls-core.

Without optimizations:

cargo bench -p vls-core --bench secp_bench --profile=dev

Expect something like:

    test fib1_bench        ... bench:           1 ns/iter (+/- 0)
    test fib_bench         ... bench:      17,247 ns/iter (+/- 198)
    test hash_bench        ... bench:         258 ns/iter (+/- 2)
    test secp_create_bench ... bench:      49,981 ns/iter (+/- 642)
    test sign_bench        ... bench:      25,692 ns/iter (+/- 391)
    test verify_bench      ... bench:      31,705 ns/iter (+/- 1,445)

i.e. around 30 microseconds per secp256k1 crypto operation. We also see that creating a secp context is expensive, but not prohibitively so.

Dependencies

~1.5MB
~38K SLoC