mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-24 09:48:24 +00:00
enable chronicles runtime filtering of t8n and evmstate tools
This commit is contained in:
parent
ced7db901b
commit
c3e8f951b2
2
Makefile
2
Makefile
@ -251,7 +251,7 @@ t8n_test: | build deps t8n
|
||||
|
||||
# builds evm state test tool
|
||||
evmstate: | build deps
|
||||
$(ENV_SCRIPT) nim c $(NIM_PARAMS) -d:chronicles_enabled=off "tools/evmstate/$@.nim"
|
||||
$(ENV_SCRIPT) nim c $(NIM_PARAMS) "tools/evmstate/$@.nim"
|
||||
|
||||
# builds and runs evm state tool test suite
|
||||
evmstate_test: | build deps evmstate
|
||||
|
@ -59,6 +59,8 @@ type
|
||||
|
||||
verbosity* {.
|
||||
desc: "sets the verbosity level"
|
||||
longDesc:
|
||||
"0 = silent, 1 = error, 2 = warn, 3 = info, 4 = debug, 5 = detail"
|
||||
defaultValue: 0
|
||||
name: "verbosity" }: int
|
||||
|
||||
|
1
tools/evmstate/config.nims
Normal file
1
tools/evmstate/config.nims
Normal file
@ -0,0 +1 @@
|
||||
switch("define", "chronicles_runtime_filtering=on")
|
@ -1,5 +1,6 @@
|
||||
import
|
||||
std/[json, strutils, sets, tables, options],
|
||||
chronicles,
|
||||
eth/[common, keys],
|
||||
stew/[results, byteutils],
|
||||
stint,
|
||||
@ -300,8 +301,24 @@ proc prepareAndRun(ctx: var StateContext, conf: StateConf): bool =
|
||||
writeResultToStdout(stateRes)
|
||||
not hasError
|
||||
|
||||
when defined(chronicles_runtime_filtering):
|
||||
proc toLogLevel(v: int): LogLevel =
|
||||
case v
|
||||
of 1: LogLevel.ERROR
|
||||
of 2: LogLevel.WARN
|
||||
of 3: LogLevel.INFO
|
||||
of 4: LogLevel.DEBUG
|
||||
of 5: LogLevel.TRACE
|
||||
else: LogLevel.NONE
|
||||
|
||||
proc setVerbosity(v: int) =
|
||||
let level = v.toLogLevel
|
||||
setLogLevel(level)
|
||||
|
||||
proc main() =
|
||||
let conf = StateConf.init()
|
||||
when defined(chronicles_runtime_filtering):
|
||||
setVerbosity(conf.verbosity)
|
||||
var ctx: StateContext
|
||||
if not ctx.prepareAndRun(conf):
|
||||
quit(QuitFailure)
|
||||
|
@ -9,13 +9,13 @@ There are few options to build `evmstate` tool like any other nimbus tools.
|
||||
1. Use nimble to install dependencies and your system Nim compiler(version <= 1.6.0).
|
||||
```
|
||||
$> nimble install -y --depsOnly
|
||||
$> nim c -d:release -d:chronicles_enabled=off tools/evmstate/evmstate
|
||||
$> nim c -d:release tools/evmstate/evmstate
|
||||
$> nim c -r -d:release tools/evmstate/evmstate_test
|
||||
```
|
||||
2. Use nimbus shipped Nim compiler and dependencies.
|
||||
```
|
||||
$> make update
|
||||
$> ./env.sh nim c -d:release -d:chronicles_enabled=off tools/evmstate/evmstate
|
||||
$> ./env.sh nim c -d:release tools/evmstate/evmstate
|
||||
$> ./env.sh nim c -r -d:release tools/evmstate/evmstate_test
|
||||
```
|
||||
3. Use nimbus makefile.
|
||||
@ -48,5 +48,5 @@ The following options are available:
|
||||
--index if index is unset, all subtest in the fork will be tested [=none(int)].
|
||||
--pretty pretty print the trace result [=false].
|
||||
--verbosity sets the verbosity level [=0].
|
||||
|
||||
0 = silent, 1 = error, 2 = warn, 3 = info, 4 = debug, 5 = detail.
|
||||
```
|
||||
|
@ -1 +1,2 @@
|
||||
switch("define", "chronicles_default_output_device=stderr")
|
||||
switch("define", "chronicles_runtime_filtering=on")
|
||||
|
@ -1,5 +1,10 @@
|
||||
import
|
||||
"."/[config, transition, types]
|
||||
chronicles,
|
||||
"."/[config, transition]
|
||||
|
||||
# we are using chronicles LogLevel
|
||||
# instead of our LogLevel
|
||||
import types except LogLevel
|
||||
|
||||
template wrapException(body) =
|
||||
when wrapExceptionEnabled:
|
||||
@ -15,9 +20,25 @@ template wrapException(body) =
|
||||
else:
|
||||
body
|
||||
|
||||
when defined(chronicles_runtime_filtering):
|
||||
proc toLogLevel(v: int): LogLevel =
|
||||
case v
|
||||
of 1: LogLevel.ERROR
|
||||
of 2: LogLevel.WARN
|
||||
of 3: LogLevel.INFO
|
||||
of 4: LogLevel.DEBUG
|
||||
of 5: LogLevel.TRACE
|
||||
else: LogLevel.NONE
|
||||
|
||||
proc setVerbosity(v: int) =
|
||||
let level = v.toLogLevel
|
||||
setLogLevel(level)
|
||||
|
||||
proc main() =
|
||||
wrapException:
|
||||
let conf = T8NConf.init()
|
||||
when defined(chronicles_runtime_filtering):
|
||||
setVerbosity(conf.verbosity)
|
||||
var ctx = TransContext()
|
||||
ctx.transitionAction(conf)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user