Conversation
cmd/geth/snapshot.go
Outdated
| `, | ||
| }, | ||
| { | ||
| Name: "traverse-var", |
There was a problem hiding this comment.
How about inspect-storage something like that?
cmd/geth/snapshot.go
Outdated
| }, | ||
| { | ||
| Name: "traverse-var", | ||
| Usage: "Dump a specific block from storage (same as 'geth dump' but using snapshots)", |
There was a problem hiding this comment.
- Fix usage/description
- Remove unneeded flags
0158894 to
f4b9d05
Compare
cmd/geth/snapshot.go
Outdated
| defer close(pool) | ||
| waitGroup := &sync.WaitGroup{} | ||
|
|
||
| it := db.NewIterator(nil, nil) |
There was a problem hiding this comment.
When creating iterator, we can pass the SnapshotAccountPrefix as a prefix, then we can only iterate the keys we need.
cmd/geth/snapshot.go
Outdated
| // todo: record account by write file | ||
| return | ||
| } | ||
| if common.Bytes2Hex(slimAccount.CodeHash) == common.HexToHash("").String() { |
cmd/geth/snapshot.go
Outdated
| key := it.Key() | ||
| switch { | ||
| case bytes.HasPrefix(key, rawdb.SnapshotAccountPrefix) && len(key) == (len(rawdb.SnapshotAccountPrefix)+common.HashLength): | ||
| accountAddress := common.BytesToAddress(key) |
There was a problem hiding this comment.
The key should not be address directly.
8d7121c to
469a0c5
Compare
cmd/geth/snapshot.go
Outdated
| }, | ||
| { | ||
| Name: "inspect-storage", | ||
| Usage: "Statistical variable data for all contracts", |
cmd/geth/snapshot.go
Outdated
| log.Error("failed to DecodeBytes", "addrHash", key[1:]) | ||
| continue | ||
| } | ||
| if common.Bytes2Hex(account.CodeHash) == types.EmptyCodeHash.String() { |
There was a problem hiding this comment.
Why convert to string before compare? Can we just compare using bytes?
cmd/utils/flags.go
Outdated
| // cpu count | ||
| CPUCountFlag = &cli.Int64Flag{ | ||
| Name: "cpu", | ||
| Usage: "The count of cpu", |
| func (pool *routinePool) worker(snap snapshot.Snapshot, keySet []common.Hash) { | ||
| for addrHash := range pool.taskQueue { | ||
| arrCount, arrItemCount, varCount := traversalContract(snap, addrHash, keySet) | ||
| pool.arrCount.Add(uint64(arrCount)) |
There was a problem hiding this comment.
We also have to 统计切片的一般长度.
Can we save the arrCount, arrItemCount, varCount to a file/log, so that we can do the analysis?
cmd/geth/snapshot.go
Outdated
| if bytes.Equal(account.CodeHash, types.EmptyCodeHash.Bytes()) { | ||
| continue | ||
| } | ||
| fmt.Printf("add task: %d\n", idx) |
There was a problem hiding this comment.
I think no need to print each time, just print if (idx % 10000 == 0)?
cmd/geth/snapshot.go
Outdated
| } else { | ||
| emptyKeyCount++ | ||
| } | ||
| if emptyKeyCount == 20 { |
feat: slot number
| defer storageIt.Release() | ||
|
|
||
| storageKeyCount := uint64(0) | ||
| for storageIt.Next() { |
There was a problem hiding this comment.
please add this condition len(key) == (len(SnapshotStoragePrefix)+2*common.HashLength)
Description
add a description of your changes here...
Rationale
tell us why we need these changes...
Example
add an example CLI or API response...
Changes
Notable changes: