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

feat: add enable-debug flag #791

Closed
wants to merge 4 commits into from
Closed
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
7 changes: 5 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func New(
enableReqLogger bool,
enableMetrics bool,
logsLimit uint64,
enableAPIDebug bool,
) (http.HandlerFunc, func()) {
origins := strings.Split(strings.TrimSpace(allowedOrigins), ",")
for i, o := range origins {
Expand Down Expand Up @@ -82,8 +83,10 @@ func New(
Mount(router, "/blocks")
transactions.New(repo, txPool).
Mount(router, "/transactions")
debug.New(repo, stater, forkConfig, callGasLimit, allowCustomTracer, bft).
Mount(router, "/debug")
if enableAPIDebug {
debug.New(repo, stater, forkConfig, callGasLimit, allowCustomTracer, bft).
Mount(router, "/debug")
}
node.New(nw).
Mount(router, "/node")
subs := subscriptions.New(repo, origins, backtraceLimit, txPool)
Expand Down
4 changes: 4 additions & 0 deletions cmd/thor/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ var (
Value: "localhost:2112",
Usage: "metrics service listening address",
}
enableAPIDebug = cli.BoolFlag{
Name: "enable-api-debug",
Usage: "enable `/debug` endpoint on the node",
}

// solo mode only flags
onDemandFlag = cli.BoolFlag{
Expand Down
4 changes: 4 additions & 0 deletions cmd/thor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func main() {
disablePrunerFlag,
enableMetricsFlag,
metricsAddrFlag,
enableAPIDebug,
},
Action: defaultAction,
Commands: []cli.Command{
Expand Down Expand Up @@ -125,6 +126,7 @@ func main() {
disablePrunerFlag,
enableMetricsFlag,
metricsAddrFlag,
enableAPIDebug,
},
Action: soloAction,
},
Expand Down Expand Up @@ -242,6 +244,7 @@ func defaultAction(ctx *cli.Context) error {
ctx.Bool(enableAPILogsFlag.Name),
ctx.Bool(enableMetricsFlag.Name),
ctx.Uint64(apiLogsLimitFlag.Name),
ctx.Bool(enableAPIDebug.Name),
)
defer func() { log.Info("closing API..."); apiCloser() }()

Expand Down Expand Up @@ -380,6 +383,7 @@ func soloAction(ctx *cli.Context) error {
ctx.Bool(enableAPILogsFlag.Name),
ctx.Bool(enableMetricsFlag.Name),
ctx.Uint64(apiLogsLimitFlag.Name),
ctx.Bool(enableAPIDebug.Name),
)
defer func() { log.Info("closing API..."); apiCloser() }()

Expand Down
1 change: 1 addition & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ bin/thor -h
| `--cache` | Megabytes of RAM allocated to trie nodes cache (default: 4096) |
| `--disable-pruner` | Disable state pruner to keep all history |
| `--enable-metrics` | Enables the metrics server |
| `--enable-api-debug` | Enables the /debug endpoint |
| `--metrics-addr` | Metrics service listening address |
| `--help, -h` | Show help |
| `--version, -v` | Print the version |
Expand Down
Loading