-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
cmd/geth: add db cmd to show metadata #23900
Conversation
cmd/geth/dbcmd.go
Outdated
data = append(data, [][]string{{"frozen", fmt.Sprintf("%v", ancients)}, | ||
{"lastPivotNumber", pp(rawdb.ReadLastPivotNumber(db))}, | ||
{"snapshotSyncStatus", fmt.Sprintf("%d bytes", len(rawdb.ReadSnapshotSyncStatus(db)))}, | ||
{"snapshotGenerator", fmt.Sprintf("%x", rawdb.ReadSnapshotGenerator(db))}, |
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.
It doesn't make sense to show the byte format generator. Maybe we can decode the content and show the real info? We can define a public function to decode the generator in the snapshot package I think.
@rjl493456442 something like this?
|
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.
Nitpicks, otherwise lgtm
cmd/geth/dbcmd.go
Outdated
@@ -20,6 +20,7 @@ import ( | |||
"bytes" | |||
"errors" | |||
"fmt" | |||
"github.com/ethereum/go-ethereum/core/state/snapshot" |
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.
Please fix the imports
core/state/snapshot/journal.go
Outdated
log.Warn("failed to decode snapshot generator", "err", err) | ||
return "" | ||
} | ||
return fmt.Sprintf(`Wiping: %v, Done: %v, Accounts: %d, Slots: %d, Storage: %d, Marker: %x`, |
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.
Nitpick:
- we don't have the wiping notion anymore. Wiping will never happen again. I would prefer to not show this info.
- generation marker can indicate to a storage position, which is 2 * 32 bytes length. I would prefer to interpret it a bit further, e.g.
// Figure out whether we're after or within an account
switch len(marker) {
case common.HashLength:
ctx = append(ctx, []interface{}{"at", common.BytesToHash(marker)}...)
case 2 * common.HashLength:
ctx = append(ctx, []interface{}{
"in", common.BytesToHash(marker[:common.HashLength]),
"at", common.BytesToHash(marker[common.HashLength:]),
}...)
}
Co-authored-by: Sina Mahmoodi <[email protected]>
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.
LGTM
* cmd/geth: add db cmd to show metadata * cmd/geth: better output generator status Co-authored-by: Sina Mahmoodi <[email protected]> * cmd: minor Co-authored-by: Sina Mahmoodi <[email protected]> Co-authored-by: Sina Mahmoodi <[email protected]>
* cmd/geth: add db cmd to show metadata * cmd/geth: better output generator status Co-authored-by: Sina Mahmoodi <[email protected]> * cmd: minor Co-authored-by: Sina Mahmoodi <[email protected]> Co-authored-by: Sina Mahmoodi <[email protected]>
Example with a quirky (broken) datadir, where some things don't match up -- both header hashes/number as well as the frozen-count, which is off.