diff --git a/nimbus/compile_info.nim b/nimbus/compile_info.nim index 14a0e6c57..d740925c6 100644 --- a/nimbus/compile_info.nim +++ b/nimbus/compile_info.nim @@ -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 diff --git a/nimbus/db/aristo/aristo_api.nim b/nimbus/db/aristo/aristo_api.nim index be1f1208b..135051b0d 100644 --- a/nimbus/db/aristo/aristo_api.nim +++ b/nimbus/db/aristo/aristo_api.nim @@ -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 = diff --git a/nimbus/db/aristo/aristo_desc/desc_structural.nim b/nimbus/db/aristo/aristo_desc/desc_structural.nim index 7e3fef54b..49648ad89 100644 --- a/nimbus/db/aristo/aristo_desc/desc_structural.nim +++ b/nimbus/db/aristo/aristo_desc/desc_structural.nim @@ -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 # ---------------------- diff --git a/nimbus/db/aristo/aristo_fetch.nim b/nimbus/db/aristo/aristo_fetch.nim index 9f1b6db10..4fc8403eb 100644 --- a/nimbus/db/aristo/aristo_fetch.nim +++ b/nimbus/db/aristo/aristo_fetch.nim @@ -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 diff --git a/nimbus/db/core_db/base.nim b/nimbus/db/core_db/base.nim index 4e00a5c5f..7da24100b 100644 --- a/nimbus/db/core_db/base.nim +++ b/nimbus/db/core_db/base.nim @@ -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: "" else: "" 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] = diff --git a/nimbus/db/core_db/base/base_config.nim b/nimbus/db/core_db/base/base_config.nim index 7b27a750f..d5936738b 100644 --- a/nimbus/db/core_db/base/base_config.nim +++ b/nimbus/db/core_db/base/base_config.nim @@ -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 diff --git a/nimbus/db/ledger/base.nim b/nimbus/db/ledger/base.nim index 44ea2b85a..ed7298c4b 100644 --- a/nimbus/db/ledger/base.nim +++ b/nimbus/db/ledger/base.nim @@ -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 diff --git a/nimbus/db/ledger/base/base_config.nim b/nimbus/db/ledger/base/base_config.nim index f9aeb086e..07ba08d0d 100644 --- a/nimbus/db/ledger/base/base_config.nim +++ b/nimbus/db/ledger/base/base_config.nim @@ -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 diff --git a/nimbus/db/ledger/base/base_helpers.nim b/nimbus/db/ledger/base/base_helpers.nim index ad77ee8c0..7ae7d09d0 100644 --- a/nimbus/db/ledger/base/base_helpers.nim +++ b/nimbus/db/ledger/base/base_helpers.nim @@ -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