Skip to content

Commit

Permalink
Move visual inside cmd/pics (#11543)
Browse files Browse the repository at this point in the history
and also move `design` into `docs` in order to reduce the number of
top-level directories
  • Loading branch information
yperbasis authored Aug 9, 2024
1 parent 2a98f6a commit ff2130d
Show file tree
Hide file tree
Showing 30 changed files with 2 additions and 686 deletions.
230 changes: 1 addition & 229 deletions cmd/pics/pics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ import (
"sort"
"strconv"

libcommon "github.com/erigontech/erigon-lib/common"

"github.com/erigontech/erigon/cmd/pics/visual"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/turbo/trie"
"github.com/erigontech/erigon/visual"
)

var pic = flag.String("pic", "", "specifies picture to regenerate")
Expand Down Expand Up @@ -203,221 +200,6 @@ q_%x->q_%x;
}
}

func prefixGroups4() {
fmt.Printf("Prefix groups 4\n")
filename := "prefix_groups_4.dot"
f, err := os.Create(filename)
if err != nil {
panic(err)
}
keys := generatePrefixGroups()
sort.Strings(keys)
tr := trie.New(libcommon.Hash{})
var hightlights = make([][]byte, 0, len(keys))
for i, key := range keys {
hexKey := make([]byte, len(key)/2)
for j := 0; j < len(hexKey); j++ {
hexKey[j] = key[2*j+1] | (key[2*j] << 4)
}
vs := strconv.Itoa(i)
tr.Update(hexKey, []byte(vs))
hightlights = append(hightlights, []byte(key))
}
visual.StartGraph(f, false)
trie.Visual(tr, f, &trie.VisualOpts{
Highlights: hightlights,
IndexColors: visual.QuadIndexColors,
FontColors: visual.QuadFontColors,
Values: true,
SameLevel: true,
})
visual.EndGraph(f)
if err := f.Close(); err != nil {
panic(err)
}
//nolint:gosec
cmd := exec.Command("dot", "-Tpng:gd", "-o"+dot2png(filename), filename)
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("error: %v, output: %s\n", err, output)
}
}

func prefixGroups5() {
fmt.Printf("Prefix groups 5\n")
filename := "prefix_groups_5.dot"
f, err := os.Create(filename)
if err != nil {
panic(err)
}
keys := generatePrefixGroups()
sort.Strings(keys)
tr := trie.New(libcommon.Hash{})
var hightlights = make([][]byte, 0, len(keys))
var folds = make([][]byte, 0, len(keys))
for i, key := range keys {
hexKey := make([]byte, len(key)/2)
for j := 0; j < len(hexKey); j++ {
hexKey[j] = key[2*j+1] | (key[2*j] << 4)
}
vs := strconv.Itoa(i)
tr.Update(hexKey, []byte(vs))
hightlights = append(hightlights, []byte(key))
folds = append(folds, hexKey)
}
tr.Fold(folds[:8])
visual.StartGraph(f, false)
trie.Visual(tr, f, &trie.VisualOpts{
Highlights: hightlights,
IndexColors: visual.QuadIndexColors,
FontColors: visual.QuadFontColors,
Values: true,
SameLevel: true,
})
visual.EndGraph(f)
if err := f.Close(); err != nil {
panic(err)
}
//nolint:gosec
cmd := exec.Command("dot", "-Tpng:gd", "-o"+dot2png(filename), filename)
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("error: %v, output: %s\n", err, output)
}
}

func prefixGroups6() {
fmt.Printf("Prefix groups 6\n")
filename := "prefix_groups_6.dot"
f, err := os.Create(filename)
if err != nil {
panic(err)
}
keys := generatePrefixGroups()
sort.Strings(keys)
tr := trie.New(libcommon.Hash{})
var hightlights = make([][]byte, 0, len(keys))
var folds = make([][]byte, 0, len(keys))
for i, key := range keys {
hexKey := make([]byte, len(key)/2)
for j := 0; j < len(hexKey); j++ {
hexKey[j] = key[2*j+1] | (key[2*j] << 4)
}
vs := strconv.Itoa(i)
tr.Update(hexKey, []byte(vs))
hightlights = append(hightlights, []byte(key))
folds = append(folds, hexKey)
}
tr.Fold(folds[:8])
tr.Fold(folds[8:16])
visual.StartGraph(f, false)
trie.Visual(tr, f, &trie.VisualOpts{
Highlights: hightlights,
IndexColors: visual.QuadIndexColors,
FontColors: visual.QuadFontColors,
Values: true,
SameLevel: true,
})
visual.EndGraph(f)
if err := f.Close(); err != nil {
panic(err)
}
//nolint:gosec
cmd := exec.Command("dot", "-Tpng:gd", "-o"+dot2png(filename), filename)
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("error: %v, output: %s\n", err, output)
}
}

func prefixGroups7() {
fmt.Printf("Prefix groups 7\n")
filename := "prefix_groups_7.dot"
f, err := os.Create(filename)
if err != nil {
panic(err)
}
keys := generatePrefixGroups()
sort.Strings(keys)
tr := trie.New(libcommon.Hash{})
var hightlights = make([][]byte, 0, len(keys))
var folds = make([][]byte, 0, len(keys))
for i, key := range keys {
hexKey := make([]byte, len(key)/2)
for j := 0; j < len(hexKey); j++ {
hexKey[j] = key[2*j+1] | (key[2*j] << 4)
}
vs := strconv.Itoa(i)
tr.Update(hexKey, []byte(vs))
hightlights = append(hightlights, []byte(key))
folds = append(folds, hexKey)
}
tr.Fold(folds[:8])
tr.Fold(folds[8:16])
tr.Fold(folds[16:24])
tr.Fold(folds[24:])
visual.StartGraph(f, false)
trie.Visual(tr, f, &trie.VisualOpts{
Highlights: hightlights,
IndexColors: visual.QuadIndexColors,
FontColors: visual.QuadFontColors,
Values: true,
SameLevel: true,
})
visual.EndGraph(f)
if err := f.Close(); err != nil {
panic(err)
}
//nolint:gosec
cmd := exec.Command("dot", "-Tpng:gd", "-o"+dot2png(filename), filename)
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("error: %v, output: %s\n", err, output)
}
}

func prefixGroups8() {
fmt.Printf("Prefix groups 8\n")
filename := "prefix_groups_8.dot"
f, err := os.Create(filename)
if err != nil {
panic(err)
}
keys := generatePrefixGroups()
sort.Strings(keys)
tr := trie.New(libcommon.Hash{})
var hightlights = make([][]byte, 0, len(keys))
var folds [][]byte
for i, key := range keys {
hexKey := make([]byte, len(key)/2)
for j := 0; j < len(hexKey); j++ {
hexKey[j] = key[2*j+1] | (key[2*j] << 4)
}
vs := strconv.Itoa(i)
tr.Update(hexKey, []byte(vs))
hightlights = append(hightlights, []byte(key))
switch i {
case 3, 8, 22, 23:
default:
folds = append(folds, hexKey)
}
}
tr.Fold(folds)
visual.StartGraph(f, false)
trie.Visual(tr, f, &trie.VisualOpts{
Highlights: hightlights,
IndexColors: visual.QuadIndexColors,
FontColors: visual.QuadFontColors,
Values: true,
SameLevel: true,
})
visual.EndGraph(f)
if err := f.Close(); err != nil {
panic(err)
}
//nolint:gosec
cmd := exec.Command("dot", "-Tpng:gd", "-o"+dot2png(filename), filename)
if output, err := cmd.CombinedOutput(); err != nil {
fmt.Printf("error: %v, output: %s\n", err, output)
}
}

func main() {
flag.Parse()
switch *pic {
Expand All @@ -427,16 +209,6 @@ func main() {
prefixGroups2()
case "prefix_groups_3":
prefixGroups3()
case "prefix_groups_4":
prefixGroups4()
case "prefix_groups_5":
prefixGroups5()
case "prefix_groups_6":
prefixGroups6()
case "prefix_groups_7":
prefixGroups7()
case "prefix_groups_8":
prefixGroups8()
case "initial_state_1":
if err := initialState1(); err != nil {
fmt.Printf("%v\n", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pics/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ import (
"github.com/erigontech/erigon/accounts/abi/bind"
"github.com/erigontech/erigon/accounts/abi/bind/backends"
"github.com/erigontech/erigon/cmd/pics/contracts"
"github.com/erigontech/erigon/cmd/pics/visual"
"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/core"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/crypto"
"github.com/erigontech/erigon/params"
"github.com/erigontech/erigon/turbo/stages/mock"
"github.com/erigontech/erigon/turbo/trie"
"github.com/erigontech/erigon/visual"
)

/*func statePicture(t *trie.Trie, number int, keyCompression int, codeCompressed bool, valCompressed bool,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion design/logos/Illustrator/readme.md

This file was deleted.

1 change: 0 additions & 1 deletion design/logos/png/readme.md

This file was deleted.

1 change: 0 additions & 1 deletion design/logos/svg/readme.md

This file was deleted.

1 change: 0 additions & 1 deletion design/logos/test

This file was deleted.

1 change: 0 additions & 1 deletion design/wallpapers/readme.md

This file was deleted.

File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Loading

0 comments on commit ff2130d

Please sign in to comment.