-
Notifications
You must be signed in to change notification settings - Fork 101
Improved scanner modes part3 - check-block mode
#499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
syntrust
wants to merge
18
commits into
main
Choose a base branch
from
scanner/mode4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
aec900a
refactor
syntrust 5ae205a
use existed blob method
syntrust 782b060
refactors
syntrust 948e8b3
tests
syntrust 449e453
fix lock
syntrust 2db5211
support mode 1,2,3
syntrust 87b574e
minor
syntrust 1d1fb69
substract consts
syntrust e48afad
fix comments
syntrust 42a3f9f
fix interval
syntrust e697185
Merge branch 'main' of https://github.com/ethstorage/es-node into sca…
syntrust ceb8ff1
merge
syntrust 7ebde8d
Merge branch 'main' of https://github.com/ethstorage/es-node into sca…
syntrust b218b35
block mode
syntrust 096f2d0
doc update
syntrust ca4426c
fix fmt
syntrust 41c316e
merge
syntrust 5eafa4d
rm useless
syntrust File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,65 @@ | ||
| # EthStorage Scanner | ||
|
|
||
| A data verification service periodically checks if the data hashes of the blobs in local storage files align with the key-value hashes in the storage contract. If any mismatch found, the service looks for the correct blob in the p2p network, and update the data in the local storage. | ||
| A data verification service that periodically checks whether locally stored KV blobs match the on-chain KV meta hash (commit) from the storage contract. | ||
|
|
||
| This service offers a lightweight yet effective way to maintain network-wide data consistency. | ||
| If a mismatch is detected, the scanner can attempt to repair the local data by re-fetching the blob from the network and rewriting it with meta validation. | ||
|
|
||
| ### Usage | ||
| ## Options | ||
|
|
||
| The scanner service is enabled with `check meta` mode by default: | ||
| - `--scanner.mode` Data scan mode, 0: disabled, 1: check meta, 2: check blob (default: 1)[`ES_NODE_SCANNER_MODE`]. | ||
| | Flag | Default | Env var | Description | | ||
| | --- | --- | --- | --- | | ||
| | `--scanner.mode` | `1` | `ES_NODE_SCANNER_MODE` | Data scan mode (bitmask): `0`=disabled, `1`=meta, `2`=blob, `4`=block. Combine via sum/OR (e.g. `3`=`1+2`, `5`=`1+4`, `7`=`1+2+4`). | | ||
| | `--scanner.batch-size` | `8192` | `ES_NODE_SCANNER_BATCH_SIZE` | The number of KVs to scan per batch for check-meta and check-blob modes. No impact on check-block mode. | | ||
| | `--scanner.interval.meta` | `3` (minutes) | `ES_NODE_SCANNER_INTERVAL_META` | Scan interval for `check-meta`. | | ||
| | `--scanner.interval.blob` | `60` (minutes) | `ES_NODE_SCANNER_INTERVAL_BLOB` | Scan interval for `check-blob`. | | ||
| | `--scanner.interval.block` | `1440` (minutes) | `ES_NODE_SCANNER_INTERVAL_BLOCK` | Scan interval for `check-block`. | | ||
|
|
||
| The following settings are required if the service is not disabled manually: | ||
| - `--scanner.batch-size` Data scan batch size (default: 8192) [`$ES_NODE_SCANNER_BATCH_SIZE`] | ||
| - `--scanner.interval` Data scan interval in minutes (default: 3) [`$ES_NODE_SCANNER_INTERVAL`] | ||
| ## Scan modes explained | ||
|
|
||
| The flag / env `--scanner.mode` (default: `1`) [`ES_NODE_SCANNER_MODE`] is a bitmask: | ||
|
|
||
| - `0`: disabled | ||
| - `1`: check-meta (compare local meta with on-chain meta) | ||
| - `2`: check-blob (read local blob and validate its commit against on-chain meta) | ||
| - `4`: check-block (scan recently updated KVs from finalized blocks, then run check-blob on them) | ||
|
|
||
| ### Quick comparison | ||
|
|
||
| | Name | `--scanner.mode` | What it does | Performance impact | Notes | | ||
| | --- | ---: | --- | --- | --- | | ||
| | check-meta | `1` | Read local meta and compare with on-chain meta | Low | Minimal impact; may miss some mismatches | | ||
| | check-blob | `2` | Compute the commit from a local blob and validate it against on-chain meta | High | Best precision; highest IO/CPU cost when many blobs | | ||
| | check-block | `4` | Scan recently finalized blocks for updated KVs, then run `check-blob` on them | High | Ensure newly updated blobs are fetched and verified within the Beacon node retention window | | ||
|
|
||
| ### More choices | ||
|
|
||
| You can combine modes by summing/OR-ing them to get mixed behavior and balance precision, coverage vs performance: | ||
|
|
||
| - `3` = `1 + 2` = meta + blob | ||
| - `5` = `1 + 4` = meta + block | ||
| - `6` = `2 + 4` = blob + block | ||
| - `7` = meta + blob + block | ||
|
|
||
|
|
||
| > [!TIP] | ||
| > `--scanner.batch-size` and `--scanner.interval.*` control the batch size and frequency of each scan mode, so you can tune the performance impact further based on the amount of data and hardware resources. | ||
|
|
||
| > [!NOTE] | ||
| > `--scanner.batch-size` only affects `check-meta` and `check-blob` modes, not `check-block`. | ||
|
|
||
| > [!WARNING] | ||
| > If `--scanner.batch-size` is set higher than the default, it may cause `out of gas` error while querying meta data from the L1 contract. | ||
|
|
||
| ## Status tracking | ||
|
|
||
| When es-node starts, the scanner only starts after the node finishes syncing all shards from the P2P network. | ||
|
|
||
| After it starts, the scanner periodically logs summaries and statistics (mismatched/unfixed counts). These counts are also exposed in the node state as `scan_stats`. | ||
|
|
||
| ## Repair behavior | ||
|
|
||
| A background repair loop periodically retries/fixes mismatched KVs by fetching blobs from the p2p network and rewriting them locally. | ||
|
|
||
| - If mismatches are detected for the first time, the KV is marked as `pending`, meaning it is scheduled for repair. Sometimes the mismatch is transient (e.g., due to download latency) and may be recovered automatically by the downloader. | ||
| - If the KV is repaired successfully or recovered, it is removed from the mismatch list. | ||
| - If the repair fails, it remains in the mismatch list and is marked as `failed` for future retries. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your recommended mode for our mainnet miner nodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't have many blobs yet, I'd rather use mode 6 to check both all and the most recent ones. Should we update the shells to make it the default?