Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mode to produce block snapshots #9053

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions erigon-lib/common/dbg/dbg_env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package dbg

import (
"fmt"
"os"
"strconv"

"github.com/c2h5oh/datasize"
)

func EnvString(envVarName string, defaultVal string) string {
v, _ := os.LookupEnv(envVarName)
if v != "" {
fmt.Printf("[dbg] env %s=%s\n", envVarName, v)
return v
}
return defaultVal
}
func EnvBool(envVarName string, defaultVal bool) bool {
v, _ := os.LookupEnv(envVarName)
if v == "true" {
fmt.Printf("[dbg] env %s=%t\n", envVarName, true)
return true
}
if v == "false" {
fmt.Printf("[dbg] env %s=%t\n", envVarName, false)
return false
}
return defaultVal
}
func EnvInt(envVarName string, defaultVal int) int {
v, _ := os.LookupEnv(envVarName)
if v != "" {
i, err := strconv.Atoi(v)
if err != nil {
panic(err)
}
if i < 0 || i > 4 {
panic(i)
}
fmt.Printf("[dbg] env %s=%d\n", envVarName, i)
return i
}
return defaultVal
}
func EnvDataSize(envVarName string, defaultVal datasize.ByteSize) datasize.ByteSize {
v, _ := os.LookupEnv(envVarName)
if v != "" {
val, err := datasize.ParseString(v)
if err != nil {
panic(err)
}
fmt.Printf("[dbg] env %s=%s\n", envVarName, val)
return val
}
return defaultVal
}
2 changes: 2 additions & 0 deletions erigon-lib/common/dbg/experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"github.com/ledgerwatch/log/v3"
)

var StagesOnlyBlocks = EnvBool("STAGES_ONLY_BLOCKS", false)

var doMemstat = true

func init() {
Expand Down
15 changes: 9 additions & 6 deletions eth/stagedsync/default_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package stagedsync
import (
"context"

"github.com/ledgerwatch/erigon-lib/common/dbg"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/eth/ethconfig"
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
Expand Down Expand Up @@ -116,6 +117,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.Execution,
Description: "Execute blocks w/o hash checks",
Disabled: dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnExecuteBlocksStage(s, u, tx, 0, ctx, exec, firstCycle, logger)
},
Expand All @@ -129,7 +131,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.HashState,
Description: "Hash the key in the state",
Disabled: bodies.historyV3 && ethconfig.EnableHistoryV4InTest,
Disabled: bodies.historyV3 || ethconfig.EnableHistoryV4InTest || dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnHashStateStage(s, tx, hashState, ctx, logger)
},
Expand All @@ -143,7 +145,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.IntermediateHashes,
Description: "Generate intermediate hashes and computing state root",
Disabled: bodies.historyV3 && ethconfig.EnableHistoryV4InTest,
Disabled: bodies.historyV3 || ethconfig.EnableHistoryV4InTest || dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
if exec.chainConfig.IsPrague(0) {
_, err := SpawnVerkleTrie(s, u, tx, trieCfg, ctx, logger)
Expand All @@ -166,7 +168,7 @@ func DefaultStages(ctx context.Context,
ID: stages.CallTraces,
Description: "Generate call traces index",
DisabledDescription: "Work In Progress",
Disabled: bodies.historyV3,
Disabled: bodies.historyV3 || dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnCallTraces(s, tx, callTraces, ctx, logger)
},
Expand All @@ -180,7 +182,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.AccountHistoryIndex,
Description: "Generate account history index",
Disabled: bodies.historyV3,
Disabled: bodies.historyV3 || dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnAccountHistoryIndex(s, tx, history, ctx, logger)
},
Expand All @@ -194,7 +196,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.StorageHistoryIndex,
Description: "Generate storage history index",
Disabled: bodies.historyV3,
Disabled: bodies.historyV3 || dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnStorageHistoryIndex(s, tx, history, ctx, logger)
},
Expand All @@ -208,7 +210,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.LogIndex,
Description: "Generate receipt logs index",
Disabled: bodies.historyV3,
Disabled: bodies.historyV3 || dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnLogIndex(s, tx, logIndex, ctx, 0, logger)
},
Expand All @@ -222,6 +224,7 @@ func DefaultStages(ctx context.Context,
{
ID: stages.TxLookup,
Description: "Generate tx lookup index",
Disabled: dbg.StagesOnlyBlocks,
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnTxLookup(s, tx, 0 /* toBlock */, txLookup, ctx, logger)
},
Expand Down
Loading