diff --git a/cl/phase1/stages/clstages.go b/cl/phase1/stages/clstages.go index 9901e0c67b6..ce02d39b47a 100644 --- a/cl/phase1/stages/clstages.go +++ b/cl/phase1/stages/clstages.go @@ -5,6 +5,7 @@ import ( "errors" "time" + "github.com/ledgerwatch/erigon-lib/common/datadir" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/clstages" "github.com/ledgerwatch/erigon/cl/cltypes" @@ -30,6 +31,7 @@ type Cfg struct { gossipManager *network2.GossipManager forkChoice *forkchoice.ForkChoiceStore beaconDB persistence.BeaconChainDatabase + dirs datadir.Dirs } type Args struct { @@ -48,6 +50,7 @@ func ClStagesCfg( gossipManager *network2.GossipManager, forkChoice *forkchoice.ForkChoiceStore, beaconDB persistence.BeaconChainDatabase, + dirs datadir.Dirs, ) *Cfg { return &Cfg{ rpc: rpc, @@ -58,6 +61,7 @@ func ClStagesCfg( gossipManager: gossipManager, forkChoice: forkChoice, beaconDB: beaconDB, + dirs: dirs, } } @@ -235,7 +239,7 @@ func ConsensusClStages(ctx context.Context, startingSlot := cfg.state.LatestBlockHeader().Slot downloader := network2.NewBackwardBeaconDownloader(ctx, cfg.rpc) - return SpawnStageHistoryDownload(StageHistoryReconstruction(downloader, cfg.beaconDB, cfg.executionClient, cfg.genesisCfg, cfg.beaconCfg, 0, startingRoot, startingSlot, "/tmp", logger), ctx, logger) + return SpawnStageHistoryDownload(StageHistoryReconstruction(downloader, cfg.beaconDB, cfg.executionClient, cfg.genesisCfg, cfg.beaconCfg, 0, startingRoot, startingSlot, cfg.dirs.Tmp, logger), ctx, logger) }, }, CatchUpEpochs: { diff --git a/cmd/caplin-phase1/caplin1/run.go b/cmd/caplin-phase1/caplin1/run.go index ebe00e03b53..9e1e497b8c3 100644 --- a/cmd/caplin-phase1/caplin1/run.go +++ b/cmd/caplin-phase1/caplin1/run.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/ledgerwatch/erigon-lib/common/datadir" "github.com/ledgerwatch/erigon/cl/cltypes/solid" "github.com/ledgerwatch/erigon/cl/freezer" "github.com/ledgerwatch/erigon/cl/persistence" @@ -24,7 +25,7 @@ import ( func RunCaplinPhase1(ctx context.Context, sentinel sentinel.SentinelClient, beaconConfig *clparams.BeaconChainConfig, genesisConfig *clparams.GenesisConfig, engine execution_client.ExecutionEngine, state *state.CachingBeaconState, - caplinFreezer freezer.Freezer, datadir string) error { + caplinFreezer freezer.Freezer, dirs datadir.Dirs) error { ctx, cn := context.WithCancel(ctx) defer cn() @@ -51,7 +52,7 @@ func RunCaplinPhase1(ctx context.Context, sentinel sentinel.SentinelClient, return true }) gossipManager := network.NewGossipReceiver(sentinel, forkChoice, beaconConfig, genesisConfig, caplinFreezer) - dataDirFs := afero.NewBasePathFs(afero.NewOsFs(), datadir) + dataDirFs := afero.NewBasePathFs(afero.NewOsFs(), dirs.DataDir) { // start the gossip manager go gossipManager.Start(ctx) @@ -87,8 +88,8 @@ func RunCaplinPhase1(ctx context.Context, sentinel sentinel.SentinelClient, } }() } - beaconDB := persistence.NewbeaconChainDatabaseFilesystem(afero.NewBasePathFs(dataDirFs, datadir), beaconConfig) - stageCfg := stages.ClStagesCfg(beaconRpc, genesisConfig, beaconConfig, state, engine, gossipManager, forkChoice, beaconDB) + beaconDB := persistence.NewbeaconChainDatabaseFilesystem(afero.NewBasePathFs(dataDirFs, dirs.DataDir), beaconConfig) + stageCfg := stages.ClStagesCfg(beaconRpc, genesisConfig, beaconConfig, state, engine, gossipManager, forkChoice, beaconDB, dirs) sync := stages.ConsensusClStages(ctx, stageCfg) logger.Info("[caplin] starting clstages loop") diff --git a/cmd/caplin-phase1/main.go b/cmd/caplin-phase1/main.go index b14c0399f75..50e1b5a2e5f 100644 --- a/cmd/caplin-phase1/main.go +++ b/cmd/caplin-phase1/main.go @@ -135,5 +135,5 @@ func runCaplinNode(cliCtx *cli.Context) error { } } - return caplin1.RunCaplinPhase1(ctx, sentinel, cfg.BeaconCfg, cfg.GenesisCfg, executionEngine, state, caplinFreezer, cfg.DataDir) + return caplin1.RunCaplinPhase1(ctx, sentinel, cfg.BeaconCfg, cfg.GenesisCfg, executionEngine, state, caplinFreezer, cfg.Dirs) } diff --git a/cmd/sentinel/cli/cliSettings.go b/cmd/sentinel/cli/cliSettings.go index 8c40a0fd025..12ab7ad1ba0 100644 --- a/cmd/sentinel/cli/cliSettings.go +++ b/cmd/sentinel/cli/cliSettings.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/ledgerwatch/erigon-lib/common/datadir" "github.com/ledgerwatch/erigon/cl/phase1/core/rawdb" "github.com/ledgerwatch/erigon/cl/phase1/core/state" "github.com/ledgerwatch/erigon/common" @@ -54,6 +55,7 @@ type ConsensusClientCliCfg struct { JwtSecret []byte InitalState *state.CachingBeaconState + Dirs datadir.Dirs } func SetupConsensusClientCfg(ctx *cli.Context) (*ConsensusClientCliCfg, error) { @@ -97,6 +99,7 @@ func SetupConsensusClientCfg(ctx *cli.Context) (*ConsensusClientCliCfg, error) { cfg.RecordMode = ctx.Bool(flags.RecordModeFlag.Name) cfg.RecordDir = ctx.String(flags.RecordModeDir.Name) cfg.DataDir = ctx.String(utils.DataDirFlag.Name) + cfg.Dirs = datadir.New(cfg.DataDir) cfg.RunEngineAPI = ctx.Bool(flags.RunEngineAPI.Name) cfg.EngineAPIAddr = ctx.String(flags.EngineApiHostFlag.Name) diff --git a/eth/backend.go b/eth/backend.go index 51adb2ddc03..6ad8fbace5a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -748,7 +748,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere return nil, err } fmt.Println(engine) - go caplin1.RunCaplinPhase1(ctx, client, beaconCfg, genesisCfg, engine, state, nil, dirs.DataDir) + go caplin1.RunCaplinPhase1(ctx, client, beaconCfg, genesisCfg, engine, state, nil, dirs) } return backend, nil