Skip to content

Conversation

@constwz
Copy link
Owner

@constwz constwz commented Jun 21, 2024

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:

  • add each change in a bullet point here
  • ...

`,
},
{
Name: "traverse-var",

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?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

},
{
Name: "traverse-var",
Usage: "Dump a specific block from storage (same as 'geth dump' but using snapshots)",

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

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@constwz constwz force-pushed the feat-data-analysis branch from 0158894 to f4b9d05 Compare June 21, 2024 11:16
defer close(pool)
waitGroup := &sync.WaitGroup{}

it := db.NewIterator(nil, nil)

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.

// todo: record account by write file
return
}
if common.Bytes2Hex(slimAccount.CodeHash) == common.HexToHash("").String() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EmptyCodeHash I suspect.

key := it.Key()
switch {
case bytes.HasPrefix(key, rawdb.SnapshotAccountPrefix) && len(key) == (len(rawdb.SnapshotAccountPrefix)+common.HashLength):
accountAddress := common.BytesToAddress(key)

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.

@constwz constwz force-pushed the feat-data-analysis branch from 8d7121c to 469a0c5 Compare June 24, 2024 03:03
},
{
Name: "inspect-storage",
Usage: "Statistical variable data for all contracts",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArgsUsage is invalid.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

log.Error("failed to DecodeBytes", "addrHash", key[1:])
continue
}
if common.Bytes2Hex(account.CodeHash) == types.EmptyCodeHash.String() {

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?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// cpu count
CPUCountFlag = &cli.Int64Flag{
Name: "cpu",
Usage: "The count of cpu",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count -> core number

Copy link
Owner Author

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))

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?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept

if bytes.Equal(account.CodeHash, types.EmptyCodeHash.Bytes()) {
continue
}
fmt.Printf("add task: %d\n", idx)

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)?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

} else {
emptyKeyCount++
}
if emptyKeyCount == 20 {

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.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

defer storageIt.Release()

storageKeyCount := uint64(0)
for storageIt.Next() {

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)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants