diff --git a/cmd/hack/hack.go b/cmd/hack/hack.go index 94b03b553..4ede9ae7b 100644 --- a/cmd/hack/hack.go +++ b/cmd/hack/hack.go @@ -2030,6 +2030,44 @@ func trimTxs(chaindata string) error { return nil } +func scanTxs(chaindata string) error { + db := kv2.MustOpen(chaindata).RwKV() + defer db.Close() + tx, err := db.BeginRo(context.Background()) + if err != nil { + return err + } + defer tx.Rollback() + c, err := tx.Cursor(dbutils.EthTx) + if err != nil { + return err + } + defer c.Close() + trTypes := make(map[byte]int) + trTypesAl := make(map[byte]int) + for k, v, err := c.First(); k != nil; k, v, err = c.Next() { + if err != nil { + return err + } + var tr types.Transaction + if tr, err = types.DecodeTransaction(rlp.NewStream(bytes.NewReader(v), 0)); err != nil { + return err + } + if _, ok := trTypes[tr.Type()]; !ok { + fmt.Printf("Example for type %d:\n%x\n", tr.Type(), v) + } + trTypes[tr.Type()]++ + if tr.GetAccessList().StorageKeys() > 0 { + if _, ok := trTypesAl[tr.Type()]; !ok { + fmt.Printf("Example for type %d with AL:\n%x\n", tr.Type(), v) + } + trTypesAl[tr.Type()]++ + } + } + fmt.Printf("Transaction types: %v\n", trTypes) + return nil +} + func scanReceipts(chaindata string) error { dbdb := kv2.MustOpen(chaindata).RwKV() defer dbdb.Close() @@ -2266,6 +2304,9 @@ func main() { case "trimTxs": err = trimTxs(*chaindata) + case "scanTxs": + err = scanTxs(*chaindata) + case "scanReceipts": err = scanReceipts(*chaindata) }