The benchmark_receive.py and benchmark_send.py scripts measure the time it takes to receive or send a multi-part payment. This assumes that a direct channel is established between the node that is to be benchmarked and another node that idealy has its database stored on a local ramfs to minimize its impact on the benchmark results.
Install Python 3.9 or newer.
Create a Python virtual environment
python3 -m venv lndActivate the virtual environment
source lnd/bin/activateInstall dependencies
pip install grpcio-toolsCopy the lightning.proto and router.proto files from the lnd repository or download them
curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
curl -o router.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.protoCompile the proto files
python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. lightning.proto
python -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. router.protoCreate a file called benchmark.ini with the following contents:
[Common]
NUMBER_OF_SHARDS = 100
AMOUNT = 100
CHANNEL_ID = 113249697726465
[Target]
TARGET_IPPORT = 192.168.0.100:10009
TARGET_MACAROON = admin_alice.macaroon
TARGET_TLS_CERT = tls_alice.cert
TARGET_PUBKEY = 02fc8b1dea7f00153be3bd449cedaabe73fda8761c9fe568f4c3e035b766530161
[Peer]
PEER_IPPORT = 192.168.0.200:10009
PEER_MACAROON = admin_bob.macaroon
PEER_TLS_CERT = tls_bob.cert
PEER_PUBKEY = 02155577dea6afd9eb20471ac3e9a82fd4893e06b4ff7b22a3b706d381faca3effAdjust the configuration parameters according to the following explanation:
NUMBER_OF_SHARDS: The number of parts a payment should be split into. The more parts, the longer it takes to settle the payment.AMOUNT: The number of sats per payment. This value must be divisible byNUMBER_OF_SHARDS. Changing the amount does not impact performance. It is recommended to set this to the same value asNUMBER_OF_SHARDS. (resulting in 1 satoshi per shard)CHANNEL_ID: The id of the direct channel between the two nodes. Obtain it by runninglncli listchannels | grep chan_idon either node.TARGET_IPPORT: The IP address and port of the gRPC API of the node that is to be benchmarked. To expose the gRPC API externally, setrpclisten=0.0.0.0:10009in thelnd.conffile of the node.TARGET_MACAROON: The path to theadmin.macaroonfile, of the node that is to be benchmarked, found at.lnd/data/chain/bitcoin/<network>/admin.macaroonTARGET_TLS_CERT: The path to thetls.certfile, of the node that is to be benchmarked, found at.lnd/tls.certTARGET_PUBKEY: The identity public key of the node that is to be benchmarked. It can be obtained by runninglncli getinfo | grep identity_pubkeyon the node that is to be benchmarked.PEER_IPPORT: The IP address and port of the gRPC API of the peer node. To expose the gRPC API externally, setrpclisten=0.0.0.0:10009in thelnd.conffile of the node.PEER_MACAROON: The path to theadmin.macaroonfile of the peer node found at.lnd/data/chain/bitcoin/<network>/admin.macaroonPEER_TLS_CERT: The path to thetls.certfile of the peer node found at.lnd/tls.certPEER_PUBKEY: The identity public key of the peer node. It can be obtained by runninglncli getinfo | grep identity_pubkeyon the peer node.
To run one iteration of the receiving benchmark simply run the benchmark_receive.py script.
./benchmark_receive.pyWhen completed successfully, this appends the time in seconds it took for all HTLCs to settle to a file called benchmark_receive.log. Note that the time taken to write preimages to the peer node's database is not included, as it is not relevant to the benchmark.
To run multiple iterations of the benchmark, simply call the script in a loop:
while true; do ./benchmark_receive.py; doneThis can be interrupted anytime with Ctrl + C.
To benchmark the sending performance, run the benchmark_send.py script.
while true; do ./benchmark_send.py; doneThis measures the time from payment initiation until all preimages are successfully written to the database. The time in seconds is appended to a file called benchmark_send.log.