Skip to content

Commit 4376278

Browse files
authored
Logging cleanups (#3643)
Remove unnecessary logging intermediate include and make sure the right serializers are available
1 parent a7ac803 commit 4376278

File tree

11 files changed

+58
-43
lines changed

11 files changed

+58
-43
lines changed

execution_chain/beacon/api_handler/api_forkchoice.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import
1111
std/[typetraits],
1212
results,
1313
chronos,
14-
eth/common/[headers, hashes, times],
15-
web3/execution_types,
14+
eth/common/[eth_types_json_serialization, headers, hashes, times],
15+
web3/[conversions, execution_types],
1616
json_rpc/errors,
1717
chronicles,
1818
../../core/tx_pool,

execution_chain/common/chain_config.nim

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import
1515
eth/common/eth_types_rlp,
1616
stint, stew/[byteutils],
1717
json_serialization, chronicles,
18-
json_serialization/stew/results,
18+
json_serialization/pkg/results,
19+
json_serialization/std/tables,
1920
json_serialization/lexer,
2021
./[genesis_alloc, hardforks]
2122

@@ -674,3 +675,29 @@ func `==`*(a, b: ChainConfig): bool =
674675
if a.isNil and not b.isNil: return false
675676
if not a.isNil and b.isNil: return false
676677
a[] == b[]
678+
679+
template toLog(it: Genesis): auto =
680+
# Avoid logging entire genesis allocation table
681+
(
682+
nonce: it.nonce,
683+
timestamp: it.timestamp,
684+
extraData: it.extraData,
685+
gasLimit: it.gasLimit,
686+
difficulty: it.difficulty,
687+
mixHash: it.mixHash,
688+
coinbase: it.coinbase,
689+
alloc: it.alloc.len,
690+
number: it.number,
691+
gasUser: it.gasUser,
692+
parentHash: it.parentHash,
693+
baseFeePerGas: it.baseFeePerGas,
694+
blobGasUsed: it.blobGasUsed,
695+
excessBlobGas: it.excessBlobGas,
696+
parentBeaconBlockRoot: it.parentBeaconBlockRoot,
697+
)
698+
699+
# TODO formatIt doesn't work for nested Json objects
700+
chronicles.formatIt(Genesis):
701+
toLog(it)
702+
proc writeValue*(w: var JsonWriter, value: Genesis) {.raises: [IOError].} =
703+
w.writeValue(toLog(value))

execution_chain/common/common.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import
1313
chronicles,
14-
logging,
14+
eth/common/eth_types_json_serialization,
1515
../db/[core_db, ledger, storage_types, fcu_db],
1616
../utils/[utils],
1717
".."/[constants, errors, version_info],
@@ -23,12 +23,12 @@ export
2323
core_db,
2424
constants,
2525
errors,
26+
eth_types_json_serialization,
2627
evmforks,
27-
hardforks,
2828
genesis,
29-
utils,
29+
hardforks,
3030
taskpools,
31-
logging
31+
utils
3232

3333
type
3434
HeaderChainUpdateCB* = proc(hdr: Header; fin: Hash32) {.gcsafe, raises: [].}

execution_chain/common/logging.nim

Lines changed: 0 additions & 25 deletions
This file was deleted.

execution_chain/config.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import
2323
confutils/defs,
2424
confutils/std/net as confnet,
2525
confutils/toml/defs as tomldefs,
26+
confutils/json/defs as jsdefs,
2627
json_serialization/std/net as jsnet,
2728
toml_serialization/std/net as tomlnet,
2829
results,
@@ -36,7 +37,8 @@ import
3637
./common/chain_config,
3738
./db/opts
3839

39-
export net, defs, jsnet, nimbus_binary_common
40+
export net, defs, jsdefs, jsnet, nimbus_binary_common
41+
4042
const
4143

4244
# e.g.:

execution_chain/networking/discoveryv4/enode.nim

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import
1313
std/[uri, strutils, net],
1414
pkg/chronicles,
15-
eth/common/keys
15+
eth/common/keys,
16+
json_serialization/writer
1617

17-
export keys
18+
export keys, writeValue
1819

1920
type
2021
ENodeError* = enum
@@ -34,7 +35,10 @@ type
3435
tcpPort*: Port ## TCP port number
3536

3637
ENode* = object
37-
## ENode object
38+
## ENode is a legacy URL-style identifier for Ethereum node that supports
39+
## a pubkey, IP address/port and an optional discovery port - it has mostly
40+
## been superseded by ENR.
41+
## https://ethereum.org/en/developers/docs/networking-layer/network-addresses/#enode
3842
pubkey*: PublicKey ## Node public key
3943
address*: Address ## Node address
4044

@@ -134,5 +138,8 @@ proc `$`*(a: Address): string =
134138
result.add(":" & $a.udpPort)
135139
result.add(":" & $a.tcpPort)
136140

137-
chronicles.formatIt(Address): $it
138-
chronicles.formatIt(ENode): $it
141+
proc writeValue*(w: var JsonWriter, a: Address) {.raises: [IOError].} =
142+
w.writeValue $a
143+
144+
proc writeValue*(w: var JsonWriter, a: ENode) {.raises: [IOError].} =
145+
w.writeValue $a

execution_chain/networking/discoveryv4/kademlia.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import
1414
eth/common/keys, eth/p2p/discoveryv5/random2,
1515
./enode
1616

17-
export sets # TODO: This should not be needed, but compilation fails otherwise
17+
export enode, sets
1818

1919
declareGauge discv4_routing_table_nodes,
2020
"Discovery v4 routing table nodes"

execution_chain/networking/p2p_peers.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import
1313
std/sequtils,
1414
chronos,
15+
chronicles/formats as chronicles,
1516
results,
1617
./p2p_enums,
1718
./p2p_protocols,
@@ -80,6 +81,9 @@ func id*(peer: PeerRef): NodeId =
8081
func `$`*(peer: PeerRef): string =
8182
$peer.remote
8283

84+
chronicles.formatIt(PeerRef):
85+
$it
86+
8387
func `$`*(x: DisconnectPeer): string =
8488
if x.isNil: "DisconnectPeer(nil)"
8589
else: "DisconnectPeer(cb)"

execution_chain/networking/p2p_types.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import
1515
./rlpx/rlpxtransport,
1616
./discoveryv4/[enode, kademlia],
1717
./p2p_peers,
18-
./peer_pool
18+
./peer_pool,
19+
json_serialization/std/net as jsnet
1920

2021
export
2122
base.NetworkId, rlpxtransport, kademlia,
22-
p2p_peers
23+
p2p_peers, jsnet
2324

2425
type
2526
Peer* = PeerRef[EthereumNode]

execution_chain/sync/wire_protocol/responder.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import
1818
./broadcast,
1919
./trace_config,
2020
../../utils/utils,
21-
../../common/logging,
2221
../../core/pooled_txs_rlp,
2322
../../networking/p2p_types
2423

0 commit comments

Comments
 (0)