Skip to content

Commit

Permalink
Merge pull request #343 from uprendis/feature/optimization-pack
Browse files Browse the repository at this point in the history
Optimization package
  • Loading branch information
uprendis authored Aug 1, 2022
2 parents 59e2aac + 53eddab commit 11c9b85
Show file tree
Hide file tree
Showing 67 changed files with 2,196 additions and 1,158 deletions.
12 changes: 3 additions & 9 deletions cmd/opera/launcher/check.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package launcher

import (
"path"
"time"

"github.com/Fantom-foundation/lachesis-base/inter/idx"
Expand All @@ -10,7 +9,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"

"github.com/Fantom-foundation/go-opera/integration"
"github.com/Fantom-foundation/go-opera/inter"
)

Expand All @@ -21,11 +19,8 @@ func checkEvm(ctx *cli.Context) error {

cfg := makeAllConfigs(ctx)

rawProducer := integration.DBProducer(path.Join(cfg.Node.DataDir, "chaindata"), cfg.cachescale)
gdb, err := makeRawGossipStore(rawProducer, cfg)
if err != nil {
log.Crit("DB opening error", "datadir", cfg.Node.DataDir, "err", err)
}
rawDbs := makeDirectDBsProducer(cfg)
gdb := makeGossipStore(rawDbs, cfg)
defer gdb.Close()
evms := gdb.EvmStore()

Expand Down Expand Up @@ -62,8 +57,7 @@ func checkEvm(ctx *cli.Context) error {
})
}

err = evms.CheckEvm(checkBlocks)
if err != nil {
if err := evms.CheckEvm(checkBlocks); err != nil {
return err
}
log.Info("EVM storage is verified", "last", prevPoint, "elapsed", common.PrettyDuration(time.Since(start)))
Expand Down
15 changes: 13 additions & 2 deletions cmd/opera/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type config struct {
Lachesis abft.Config
LachesisStore abft.StoreConfig
VectorClock vecmt.IndexConfig
cachescale cachescale.Func
DBs integration.DBsConfig
}

func (c *config) AppConfigs() integration.Configs {
Expand All @@ -158,6 +158,7 @@ func (c *config) AppConfigs() integration.Configs {
Lachesis: c.Lachesis,
LachesisStore: c.LachesisStore,
VectorClock: c.VectorClock,
DBs: c.DBs,
}
}

Expand Down Expand Up @@ -369,7 +370,6 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) {
Lachesis: abft.DefaultConfig(),
LachesisStore: abft.DefaultStoreConfig(cacheRatio),
VectorClock: vecmt.DefaultConfig(cacheRatio),
cachescale: cacheRatio,
}

if ctx.GlobalIsSet(FakeNetFlag.Name) {
Expand All @@ -388,6 +388,17 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) {
return &cfg, err
}
}
// apply default for DB config if it wasn't touched by config file
dbDefault := integration.DefaultDBsConfig(cacheRatio.U64, uint64(utils.MakeDatabaseHandles()))
if len(cfg.DBs.Routing.Table) == 0 {
cfg.DBs.Routing = dbDefault.Routing
}
if len(cfg.DBs.GenesisCache.Table) == 0 {
cfg.DBs.GenesisCache = dbDefault.GenesisCache
}
if len(cfg.DBs.RuntimeCache.Table) == 0 {
cfg.DBs.RuntimeCache = dbDefault.RuntimeCache
}

// Apply flags (high priority)
var err error
Expand Down
1 change: 0 additions & 1 deletion cmd/opera/launcher/config_custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestConfigFile(t *testing.T) {
Lachesis: abft.DefaultConfig(),
LachesisStore: abft.DefaultStoreConfig(cacheRatio),
VectorClock: vecmt.DefaultConfig(cacheRatio),
cachescale: cacheRatio,
}

canonical := func(nn []*enode.Node) []*enode.Node {
Expand Down
2 changes: 1 addition & 1 deletion cmd/opera/launcher/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
// Tests that a node embedded within a console can be started up properly and
// then terminated by closing the input stream.
func TestConsoleWelcome(t *testing.T) {
// Start a opera console, make sure it's cleaned up and terminate the console
// Start an opera console, make sure it's cleaned up and terminate the console
cli := exec(t,
"--fakenet", "0/1", "--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"console")
Expand Down
Loading

0 comments on commit 11c9b85

Please sign in to comment.