This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
refactor: opti build circuit input by cache previous block hashes #1766
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.
Description
When proving each block, to construct the witness needs to obtain at least the previous(except the block number > 256) block hash, which need 256 times RPC.(It's a bit cost).
Analysis
Support each block needs 8s. The oldest block which the witness needed has existed
8s*256=2048s=34mins
.This means, that when the proving time is within 34min, some of the previous block hash can be reused.
Solution
Add cache for them.
NOTE
The optimize only works in the second proving task.(The first one cache, the later ones use from cache)
Type of change
Contents
Rationale
[design decisions and extended information]
How Has This Been Tested?
[explanation]
How to fill a PR description
Please give a concise description of your PR.
The target readers could be future developers, reviewers, and auditors. By reading your description, they should easily understand the changes proposed in this pull request.
MUST: Reference the issue to resolve
Single responsibility
Is RECOMMENDED to create single responsibility commits, but not mandatory.
Anyway, you MUST enumerate the changes in a unitary way, e.g.
Design choices
RECOMMENDED to: