Misc updates (#2513)

* Update config for Ledger and CoreDb

why:
  Prepare for tracer which depends on the API jump table (as well as
  the profiler.) The API jump table is now enabled in unit/integration
  test mode piggybacking on the `unittest2DisableParamFiltering`
  compiler flag or on an extra compiler flag `dbjapi_enabled`.

* No deed for error field in `NodeRef`

why:
  Was opnly needed by proof nodes pre-loader which will be re-implemented

* Cosmetics
This commit is contained in:
Jordan Hrycaj 2024-07-22 18:10:04 +00:00 committed by GitHub
parent 45d85aa3b5
commit 1452e7b1c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 100 additions and 38 deletions

View File

@ -8,6 +8,10 @@
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
import
./db/core_db/base/base_config,
./db/ledger/base/base_config
func vmName(): string =
when defined(evmc_enabled):
"evmc"
@ -23,6 +27,10 @@ const
rc &= ", chunked-rlpx"
when defined(boehmgc):
rc &= ", boehm/gc"
when 0 < coreDbBaseConfigExtras.len:
rc &= ", " & coreDbBaseConfigExtras
when 0 < ledgerBaseConfigExtras.len:
rc &= ", " & ledgerBaseConfigExtras
rc &= " enabled"
rc

View File

@ -851,9 +851,9 @@ func init*(
result = api.pathAsBlob(a)
profApi.persist =
proc(a: AristoDbRef; b = 0u64; c = false): auto =
proc(a: AristoDbRef; b = 0u64): auto =
AristoApiProfPersistFn.profileRunner:
result = api.persist(a, b, c)
result = api.persist(a, b)
profApi.reCentre =
proc(a: AristoDbRef): auto =

View File

@ -18,7 +18,7 @@ import
std/[hashes, tables],
stint,
eth/common,
"."/[desc_error, desc_identifiers]
./desc_identifiers
export stint
@ -74,7 +74,6 @@ type
NodeRef* = ref object of VertexRef
## Combined record for a *traditional* ``Merkle Patricia Tree` node merged
## with a structural `VertexRef` type object.
error*: AristoError ## Used for error signalling in RLP decoder
key*: array[16,HashKey] ## Merkle hash/es for vertices
# ----------------------

View File

@ -129,7 +129,7 @@ proc hasAccountPayload(
proc fetchAccountHike*(
db: AristoDbRef; # Database
accPath: Hash256; # Implies a storage ID (if any)
accPath: Hash256; # Implies a storage ID (if any)
): Result[Hike,AristoError] =
## Verify that the `accPath` argument properly referres to a storage root
## vertex ID. The function will reset the keys along the `accPath` for

View File

@ -15,14 +15,13 @@ import
eth/common,
"../.."/[constants, errors],
".."/[kvt, aristo],
./backend/aristo_db,
./base/[api_tracking, base_config, base_desc, base_helpers]
export
CoreDbAccRef,
CoreDbAccount,
CoreDbApiError,
#CoreDbCaptFlags,
#CoreDbCaptRef,
CoreDbCtxRef,
CoreDbErrorCode,
CoreDbError,
@ -34,7 +33,6 @@ export
CoreDbType
when CoreDbEnableApiTracking:
{.warning: "*** Provided API logging for CoreDB (disabled by default)".}
import
chronicles
logScope:
@ -42,16 +40,18 @@ when CoreDbEnableApiTracking:
const
logTxt = "API"
when CoreDbEnableProfiling:
{.warning: "*** Enabled profiling for CoreDB (also tracer API available)".}
export
CoreDbFnInx,
CoreDbProfListRef
when CoreDbEnableApiJumpTable:
discard
when CoreDbEnableCaptJournal and false:
import
./backend/aristo_trace
type
CoreDbCaptRef* = distinct TraceLogInstRef
func `$`(p: CoreDbCaptRef): string =
if p.distinctBase.isNil: "<nil>" else: "<capt>"
else:
import
../aristo/[
@ -714,7 +714,7 @@ proc dispose*(tx: CoreDbTxRef) =
# Public tracer methods
# ------------------------------------------------------------------------------
when false: # currently disabled
when CoreDbEnableCaptJournal and false: # currently disabled
proc newCapture*(
db: CoreDbRef;
): CoreDbRc[CoreDbCaptRef] =

View File

@ -20,38 +20,78 @@ const
## Tracking noise is then enabled by setting the flag `trackCoreDbApi` to
## `true` in the `CoreDbRef` descriptor.
EnableProfiling = false
## Enables profiling of the backend. If the flag `EnableApiTracking` is
## also set the API will also be subject to profiling.
AutoValidateDescriptors = defined(release).not or
defined(unittest2DisableParamFiltering)
## No validatinon needed for production suite.
##
## The `unittest2DisableParamFiltering` flag is coincidentally used by
## unit/integration tests which makes it convenient to piggyback on that
## for enabling debugging checks.
EnableCaptJournal = defined(release).not
## Enables the tracer facility. If set `true` capture journal directives
## like `newCapture()` will be available.
NoisyCaptJournal = true
## Provide extra logging with the tracer facility if available.
EnableApiJumpTable = false
EnableApiJumpTable = defined(dbjapi_enabled) or
defined(unittest2DisableParamFiltering)
## This flag enables the functions jump table even if `EnableApiProfiling`
## and `EnableCaptJournal` is set `false` in realease mode. This setting
## should be used for debugging, only.
##
## The `unittest2DisableParamFiltering` flag is coincidentally used by
## unit/integration tests which makes it convenient to piggyback on that
## for providing API jump tables.
EnableProfiling = false
## Enables profiling of the backend if the flags ` EnableApiJumpTable`
## and `EnableApiTracking` are also set. Profiling will then be enabled
## with the flag `trackCoreDbApi` (which also enables extra logging.)
EnableCaptJournal = true
## Enables the tracer facility if the flag ` EnableApiJumpTable` is
## also set. In that case the capture journal directives like
## `newCapture()` will be available.
NoisyCaptJournal = true
## Provide extra logging with the tracer facility if available.
AutoValidateDescriptors = defined(release).not
## No validatinon needed for production suite.
# Exportable constants (leave alone this section)
const
CoreDbEnableApiTracking* = EnableApiTracking
CoreDbEnableProfiling* = EnableProfiling
CoreDbEnableCaptJournal* = EnableCaptJournal
CoreDbNoisyCaptJournal* = CoreDbEnableCaptJournal and NoisyCaptJournal
CoreDbEnableApiJumpTable* =
CoreDbEnableProfiling or CoreDbEnableCaptJournal or EnableApiJumpTable
CoreDbAutoValidateDescriptors* = AutoValidateDescriptors
# Api jump table dependent settings:
CoreDbEnableApiJumpTable* = EnableApiJumpTable
CoreDbEnableProfiling* = EnableProfiling and CoreDbEnableApiJumpTable
CoreDbEnableCaptJournal* = EnableCaptJournal and CoreDbEnableApiJumpTable
CoreDbNoisyCaptJournal* = NoisyCaptJournal and CoreDbEnableCaptJournal
# Support warning about extra compile time options. For production, non of
# the above features should be enabled.
import strutils
const coreDbBaseConfigExtras* = block:
var s: seq[string]
when CoreDbEnableApiTracking:
s.add "logging"
when CoreDbAutoValidateDescriptors:
s.add "validate"
when CoreDbEnableProfiling:
s.add "profiling"
when CoreDbEnableCaptJournal:
when CoreDbNoisyCaptJournal:
s.add "noisy tracer"
else:
s.add "tracer"
when CoreDbEnableApiJumpTable and
not CoreDbEnableProfiling and
not CoreDbEnableCaptJournal:
s.add "Api jump table"
if s.len == 0:
""
else:
"CoreDb(" & s.join(", ") & ")"
# End

View File

@ -33,7 +33,6 @@ export
# ------------------------------------------------------------------------------
when LedgerEnableApiTracking:
{.warning: "*** Provided API logging for Ledger (disabled by default)".}
import
std/times,
chronicles
@ -43,7 +42,6 @@ when LedgerEnableApiTracking:
apiTxt = "API"
when LedgerEnableApiProfiling:
{.warning: "*** Provided API profiling for Ledger (disabled by default)".}
export
LedgerFnInx,
LedgerProfListRef

View File

@ -30,4 +30,19 @@ const
LedgerEnableApiTracking* = EnableApiTracking and CoreDbEnableApiTracking
LedgerEnableApiProfiling* = EnableApiProfiling and CoreDbEnableApiJumpTable
# Support warning about extra compile time options. For production, non of
# the above features should be enabled.
import strutils
const ledgerBaseConfigExtras* = block:
var s: seq[string]
when LedgerEnableApiTracking:
s.add "logging"
when LedgerEnableApiProfiling:
s.add "profiling"
if s.len == 0:
""
else:
"Ledger(" & s.join(", ") & ")"
# End

View File

@ -17,6 +17,8 @@ import
# ------------------------------------------------------------------------------
when LedgerEnableApiProfiling:
import api_tracking
proc ldgProfData*(db: CoreDbRef): LedgerProfListRef =
## Return profiling data table (only available in profiling mode). If
## available (i.e. non-nil), result data can be organised by the functions