Skip to content

Commit

Permalink
tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
rus-alex committed Aug 15, 2023
1 parent 5af2739 commit 7c960b8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions cmd/opera/launcher/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func exportRLP(w io.Writer, gdb *gossip.Store, from, to idx.Epoch) (err error) {
// exportDOT writer the active chain.
func exportDOT(writer io.Writer, gdb *gossip.Store, cfg *config, from, to idx.Epoch) (err error) {
consensusCfg := integration.Configs{
Opera: cfg.Opera,
Lachesis: cfg.Lachesis,
VectorClock: cfg.VectorClock,
}
Expand Down
27 changes: 17 additions & 10 deletions utils/dag/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/Fantom-foundation/lachesis-base/inter/dag"
"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/Fantom-foundation/lachesis-base/inter/pos"
"github.com/Fantom-foundation/lachesis-base/kvdb/memorydb"
"github.com/ethereum/go-ethereum/log"
"gonum.org/v1/gonum/graph"

Expand Down Expand Up @@ -49,9 +50,10 @@ func newDagLoader(gdb *gossip.Store, cfg integration.Configs, from, to idx.Epoch
cfg.Lachesis)

var (
epoch idx.Epoch
vv = make(pos.ValidatorsBuilder, 60)
ee = make(map[hash.Event]dag.Event, 1000)
epoch idx.Epoch
vv pos.ValidatorsBuilder // = make(pos.ValidatorsBuilder, 60)
ee map[hash.Event]dag.Event // = make(map[hash.Event]dag.Event, 1000)
processed map[hash.Event]dag.Event // = make(map[hash.Event]dag.Event, 1000)
)
err := orderer.Bootstrap(abft.OrdererCallbacks{
ApplyAtropos: func(decidedFrame idx.Frame, atropos hash.Event) (sealEpoch *pos.Validators) {
Expand All @@ -65,7 +67,7 @@ func newDagLoader(gdb *gossip.Store, cfg integration.Configs, from, to idx.Epoch
cfg.Opera.Protocol.DagProcessor.EventsBufferLimit,
dagordering.Callback{
Process: func(e dag.Event) error {
fmt.Printf("<<< E(%d - %d) %s \n", e.Epoch(), e.Frame(), e.ID().String())
processed[e.ID()] = e
err = dagIndexer.Add(e)
if err != nil {
panic(err)
Expand All @@ -79,24 +81,26 @@ func newDagLoader(gdb *gossip.Store, cfg integration.Configs, from, to idx.Epoch
id: int64(id),
hash: e.ID(),
parents: e.Parents(),
frame: e.Frame(),
}
return nil
},
Released: func(e dag.Event, peer string, err error) {
// panic(err)
if err != nil {
panic(err)
}
},
Get: func(id hash.Event) dag.Event {
return ee[id]
return processed[id]
},
Exists: func(id hash.Event) bool {
_, ok := ee[id]
_, ok := processed[id]
return ok
},
})

gdb.ForEachEvent(from, func(e *inter.EventPayload) bool {
// current epoch is finished
// , so process accumulated events
// current epoch is finished, so process accumulated events
if epoch < e.Epoch() {
epoch = e.Epoch()

Expand All @@ -105,9 +109,11 @@ func newDagLoader(gdb *gossip.Store, cfg integration.Configs, from, to idx.Epoch
if err != nil {
panic(err)
}
dagIndexer.Reset(validators, memorydb.New(), func(id hash.Event) dag.Event {
return gdb.GetEvent(id)
})

for _, e := range ee {
fmt.Printf(">>> E(%d - %d) %s \n", e.Epoch(), e.Frame(), e.ID().String())
buffer.PushEvent(e, "")
}

Expand All @@ -121,6 +127,7 @@ func newDagLoader(gdb *gossip.Store, cfg integration.Configs, from, to idx.Epoch
// reset
vv = make(pos.ValidatorsBuilder, 60)
ee = make(map[hash.Event]dag.Event, 1000)
processed = make(map[hash.Event]dag.Event, 1000)
}
// break after last epoch
if to >= from && e.Epoch() > to {
Expand Down
16 changes: 8 additions & 8 deletions utils/dag/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dag

import (
"github.com/Fantom-foundation/lachesis-base/hash"
"github.com/Fantom-foundation/lachesis-base/inter/idx"
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/encoding"
)
Expand Down Expand Up @@ -37,6 +38,7 @@ type dagNode struct {
id int64
hash hash.Event
parents hash.Events
frame idx.Frame
isRoot bool
isAtropos bool
}
Expand All @@ -53,20 +55,18 @@ func (n *dagNode) Attributes() []encoding.Attribute {
},
}

var role string
if n.isRoot {
aa = append(aa,
encoding.Attribute{
Key: "role",
Value: "Root",
},
)
role = "Root"
}

if n.isAtropos {
role = "Atropos"
}
if len(role) > 0 {
aa = append(aa,
encoding.Attribute{
Key: "xlabel",
Value: "Atropos",
Value: role,
},
)
}
Expand Down

0 comments on commit 7c960b8

Please sign in to comment.