handshake-org / handshake-org/hsd
Coin select slowdown
- 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
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