Skip to content

Commit

Permalink
Add log-level to launcher + fix trace debug (#1757)
Browse files Browse the repository at this point in the history
* Add log-level to launcher + fix trace debug

* Update testnet/launcher/cmd/cli.go

* pr comments
  • Loading branch information
otherview authored Jan 24, 2024
1 parent 2019eac commit 9c81010
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions go/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func (cf *ChainFork) IsFork() bool {
}

func (cf *ChainFork) String() string {
if cf == nil {
return ""
}
return fmt.Sprintf("ChainFork{NewCanonical: %s, OldCanonical: %s, CommonAncestor: %s, CanonicalPath: %s, NonCanonicalPath: %s}",
cf.NewCanonical.Hash(), cf.OldCanonical.Hash(), cf.CommonAncestor.Hash(), cf.CanonicalPath, cf.NonCanonicalPath)
}
3 changes: 3 additions & 0 deletions testnet/launcher/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type TestnetConfigCLI struct {
contractDeployerDockerImage string
contractDeployerDebug bool
isSGXEnabled bool
logLevel int
}

// ParseConfigCLI returns a NodeConfigCLI based the cli params and defaults.
Expand All @@ -27,6 +28,7 @@ func ParseConfigCLI() *TestnetConfigCLI {
contractDeployerDockerImage := flag.String(contractDeployerDockerImageFlag, "testnetobscuronet.azurecr.io/obscuronet/hardhatdeployer:latest", flagUsageMap[contractDeployerDockerImageFlag])
contractDeployerDebug := flag.Bool(contractDeployerDebugFlag, false, flagUsageMap[contractDeployerDebugFlag])
isSGXEnabled := flag.Bool(isSGXEnabledFlag, false, flagUsageMap[isSGXEnabledFlag])
logLevel := flag.Int(logLevelFlag, 4, flagUsageMap[logLevelFlag])
flag.Parse()

cfg.validatorEnclaveDockerImage = *validatorEnclaveDockerImage
Expand All @@ -36,6 +38,7 @@ func ParseConfigCLI() *TestnetConfigCLI {
cfg.contractDeployerDebug = *contractDeployerDebug
cfg.contractDeployerDockerImage = *contractDeployerDockerImage
cfg.isSGXEnabled = *isSGXEnabled
cfg.logLevel = *logLevel

return cfg
}
2 changes: 2 additions & 0 deletions testnet/launcher/cmd/cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
contractDeployerDockerImageFlag = "contract-deployer-docker-image"
contractDeployerDebugFlag = "contract-deployer-debug"
isSGXEnabledFlag = "is-sgx-enabled"
logLevelFlag = "log-level"
)

// Returns a map of the flag usages.
Expand All @@ -22,5 +23,6 @@ func getFlagUsageMap() map[string]string {
contractDeployerDockerImageFlag: "The docker image that runs the contract deployer",
contractDeployerDebugFlag: "Enables the use of node inspector to debug the contract deployer",
isSGXEnabledFlag: "Enables the SGX usage",
logLevelFlag: "Log level for all network",
}
}
1 change: 1 addition & 0 deletions testnet/launcher/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func main() {
launcher.WithContractDeployerDebug(cliConfig.contractDeployerDebug),
launcher.WithContractDeployerDockerImage(cliConfig.contractDeployerDockerImage),
launcher.WithSGXEnabled(cliConfig.isSGXEnabled),
launcher.WithLogLevel(cliConfig.logLevel),
),
)
err := testnet.Start()
Expand Down
8 changes: 8 additions & 0 deletions testnet/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type Config struct {
contractDeployerDebug bool

isSGXEnabled bool

logLevel int
}

func NewTestnetConfig(opts ...Option) *Config {
Expand Down Expand Up @@ -68,3 +70,9 @@ func WithContractDeployerDebug(b bool) Option {
c.contractDeployerDebug = b
}
}

func WithLogLevel(i int) Option {
return func(c *Config) {
c.logLevel = i
}
}
4 changes: 2 additions & 2 deletions testnet/launcher/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (t *Testnet) Start() error {
node.WithL1Start(networkConfig.L1StartHash),
node.WithInMemoryHostDB(true),
node.WithDebugNamespaceEnabled(true),
node.WithLogLevel(4),
node.WithLogLevel(t.cfg.logLevel),
node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
)

Expand Down Expand Up @@ -102,7 +102,7 @@ func (t *Testnet) Start() error {
node.WithL1Start(networkConfig.L1StartHash),
node.WithInMemoryHostDB(true),
node.WithDebugNamespaceEnabled(true),
node.WithLogLevel(4),
node.WithLogLevel(t.cfg.logLevel),
node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
)

Expand Down

0 comments on commit 9c81010

Please sign in to comment.