-
Notifications
You must be signed in to change notification settings - Fork 0
feat: data analysis #1
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
base: master
Are you sure you want to change the base?
Conversation
cmd/geth/snapshot.go
Outdated
| `, | ||
| }, | ||
| { | ||
| Name: "traverse-var", |
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.
How about inspect-storage something like that?
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.
fixed
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix usage/description
- Remove unneeded flags
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.
fixed
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() { |
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.
EmptyCodeHash I suspect.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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", |
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.
ArgsUsage is invalid.
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.
fixed
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why convert to string before compare? Can we just compare using bytes?
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.
fixed
cmd/utils/flags.go
Outdated
| // cpu count | ||
| CPUCountFlag = &cli.Int64Flag{ | ||
| Name: "cpu", | ||
| Usage: "The count of cpu", |
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.
count -> core number
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.
fixed
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have to 统计切片的一般长度.
Can we save the arrCount, arrItemCount, varCount to a file/log, so that we can do the analysis?
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.
accept
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think no need to print each time, just print if (idx % 10000 == 0)?
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.
fixed
cmd/geth/snapshot.go
Outdated
| } else { | ||
| emptyKeyCount++ | ||
| } | ||
| if emptyKeyCount == 20 { |
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.
can we change 20 to 100.
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.
fixed
feat: slot number
| defer storageIt.Release() | ||
|
|
||
| storageKeyCount := uint64(0) | ||
| for storageIt.Next() { |
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 add this condition len(key) == (len(SnapshotStoragePrefix)+2*common.HashLength)
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.
fixed
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: