perf: support sign message in batch #225
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What Changed
This PR resolve #222
Motivation
It takes too long to sign a big transaction containing many inputs with different locks.
For example, on my machine, it takes about 1 minute to sign a transaction with 30 inputs.
Currently it's because every signature is generated separately, I have tried to figure out which step we can optimize by logging the time elapsed:
and the sample result:
which means getting
extendedPrivateKey
takes most of time, by batching the sign requests,we just need to generate
extendedPrivateKey
once in signing one tx, much improving the performance when signing a tx with multiple inputs.Benchmark Results:
As expected, the performance is not significantly improved when there is only one cell in the tx inputs, but it improves about
500%
when there are 20 cell inputs in the tx.benchmark.ts
Change Type
Indicate the type of change your pull request is:
documentation
patch
minor
major