Repository navigation
fix(p2p): judge ipv4-mapped addresses by their embedded ipv4 form #2144
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
Changes from all commits
5d73115
e645c64
0f16b35
2a0bd9d
22c6b46
35f5e14
3f023bc
0675d14
0e72b1e
1cce2d8
4168ab9
d88a80c
a56d180
09ec47b
5f9f166
a7c9b45
e92126c
41009f7
51034ee
2c85f1e
34da41b
cbdd411
ab7cc9e
5633ad6
80caa41
544a5da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,19 @@ impl LoadedStorage { | |
| } | ||
|
|
||
| fn load_storage_v3<S: PeerDbStorage>(storage: &S) -> crate::Result<LoadedStorage> { | ||
| { | ||
| // Rewrite any rows written by an older version under the mapped spelling of an | ||
| // IPv4 address, so the stored keys match the canonical form used at runtime. | ||
| let mut write_tx = storage.transaction_rw()?; | ||
|
Comment on lines
+87
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the strict behavior here: a corrupt value fails the whole load anyway through the normal read path (e.g. |
||
| // Commit only when rows were actually rewritten, so the common case of an | ||
| // already-canonical database stays read-only. | ||
| if write_tx.normalize_legacy_mapped_address_keys()? { | ||
| write_tx.commit()?; | ||
| } | ||
| // TODO: once older databases are no longer expected, replace this | ||
| // every-startup scan with a one-time versioned migration or a stored marker. | ||
| } | ||
|
|
||
| let tx = storage.transaction_ro()?; | ||
|
|
||
| let known_addresses = tx.get_known_addresses()?.into_iter().collect::<BTreeMap<_, _>>(); | ||
|
|
||
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.
Error handling is inconsistent between corrupt keys and corrupt values: a key that no longer parses is dropped with a warning specifically so it cannot 'fail the startup on every run', but a value that fails to decode aborts the entire migration (and thus startup) with
InvalidStorageState, reproducing exactly the same permanent-startup-failure scenario this function was written to avoid. A single corrupt row value in a legacy mapped-key row will wedge every subsequent startup. Consider dropping such rows (with an error-level log) for consistency with the key-drop policy, or at least documenting why value corruption is treated as unrecoverable while key corruption is not.Suggestion: