handshake-org / handshake-org/hsd

Coin select slowdown

Open
#478 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.1k
Forks
306
PR merge metrics
No merged PRs in 30d

Description

Sending transactions, particularly opens, seems to have slowed down significantly. After investigating a bit further it seems that `wallet.fill` is the root cause.

Here’s a wallet I created to test. It has ~16 thousand, 1 coin none txos, sent over about 160 blocks. In my testing, I was getting open times of around 150 ms and transaction times of 50 ms.

If you want to test yourself, here’s the steps I took to see the time to send an open.

In `~/.hsd/regtest`
`unzip /path/to/file/wallet.zip -d wallet`

[wallet.zip](https://github.com/handshake-org/hsd/files/4949294/wallet.zip)
Change lines 1639-1648 in `hsd/lib/wallet/wallet.js` to the following to log the time.
```
async sendOpen(name, force, options) {
console.time('SEND OPEN');
const unlock = await this.fundLock.lock();
try {
return await this._sendOpen(name, force, options);
} finally {
unlock();
console.timeEnd('SEND OPEN');
}
}
```

Run the node
`./bin/hsd --network=regtest --index-address=false --index-tx=false`

Grind a new name, send the open, and check the logs for ‘SEND OPEN’
`./bin/hsd-cli rpc --network=regtest grindname 10`
`./bin/hsw-cli rpc sendopen --network=regtest [NAME]`

Contributor guide

Open the contributing guide

Research direction

Start in hsd/lib/wallet/wallet.js, focusing on wallet.fill and the sendOpen/_sendOpen path. Reproduce the slowdown with the supplied wallet.zip on regtest using the documented hsd and hsw-cli commands, then profile the coin-selection work. Done means the cause is addressed and open and transaction timings no longer show the reported slowdown.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.