Skip to content

Commit b8adef4

Browse files
author
Michał Mrożek
authored
[ETCM-125] Fix faucet logging issue (#693)
1 parent 1668edf commit b8adef4

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

src/main/resources/application.conf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -519,17 +519,6 @@ mantis {
519519
port = 13798
520520
}
521521

522-
logging {
523-
# Flag used to switch logs to the JSON format
524-
json-output = false
525-
526-
# Logs directory
527-
logs-dir = ${mantis.datadir}"/logs"
528-
529-
# Logs filename
530-
logs-file = "mantis"
531-
}
532-
533522
async {
534523
dispatchers {
535524
block-forger {
@@ -596,3 +585,14 @@ validation-context {
596585
}
597586
throughput = 1
598587
}
588+
589+
logging {
590+
# Flag used to switch logs to the JSON format
591+
json-output = false
592+
593+
# Logs directory
594+
logs-dir = ${mantis.datadir}"/logs"
595+
596+
# Logs filename
597+
logs-file = "mantis"
598+
}

src/main/resources/logback.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
<!--read properties from application.conf-->
77
<newRule pattern="*/load" actionClass="io.iohk.ethereum.utils.LoadFromApplicationConfiguration"/>
8-
<load key="mantis.logging.json-output" as="ASJSON"/>
9-
<load key="mantis.logging.logs-dir" as="LOGSDIR"/>
10-
<load key="mantis.logging.logs-file" as="LOGSFILENAME"/>
8+
<load key="logging.json-output" as="ASJSON"/>
9+
<load key="logging.logs-dir" as="LOGSDIR"/>
10+
<load key="logging.logs-file" as="LOGSFILENAME"/>
1111

1212
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
1313
<encoder>

src/main/scala/io/iohk/ethereum/faucet/FaucetApi.scala

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@ import io.iohk.ethereum.rlp
1717
import io.iohk.ethereum.network.p2p.messages.CommonMessages.SignedTransactions.SignedTransactionEnc
1818
import org.bouncycastle.util.encoders.Hex
1919

20-
class FaucetApi(
21-
rpcClient: RpcClient,
22-
keyStore: KeyStore,
23-
config: FaucetConfig,
24-
clock: Clock = Clock.systemUTC())
25-
extends Logger {
20+
class FaucetApi(rpcClient: RpcClient, keyStore: KeyStore, config: FaucetConfig, clock: Clock = Clock.systemUTC())
21+
extends Logger {
2622

2723
private val latestRequestTimestamps = new LruMap[RemoteAddress, Long](config.latestTimestampCacheSize)
2824

2925
private val wallet = keyStore.unlockAccount(config.walletAddress, config.walletPassword) match {
3026
case Right(w) => w
31-
case Left(err) => throw new RuntimeException(s"Cannot unlock wallet for use in faucet (${config.walletAddress}), because of $err")
27+
case Left(err) =>
28+
log.info("accounts " + keyStore.listAccounts().right.get.mkString(", "))
29+
throw new RuntimeException(s"Cannot unlock wallet for use in faucet (${config.walletAddress}), because of $err")
3230
}
3331

3432
private val corsSettings = CorsSettings.defaultSettings
@@ -67,13 +65,8 @@ class FaucetApi(
6765
}
6866

6967
private def prepareTx(targetAddress: Address, nonce: BigInt): ByteString = {
70-
val transaction = Transaction(
71-
nonce,
72-
config.txGasPrice,
73-
config.txGasLimit,
74-
Some(targetAddress),
75-
config.txValue,
76-
ByteString())
68+
val transaction =
69+
Transaction(nonce, config.txGasPrice, config.txGasLimit, Some(targetAddress), config.txValue, ByteString())
7770

7871
val stx = wallet.signTx(transaction, None)
7972
ByteString(rlp.encode(stx.tx.toRLPEncodable))

src/universal/conf/faucet.conf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
faucet {
2+
3+
# Base directory where all the data used by the fauced is stored
4+
datadir = ${user.home}"/.mantis-faucet"
5+
26
# Wallet address used to send transactions from
37
wallet-address = "0x00"
48

59
# Password to unlock faucet wallet
610
wallet-password = ""
711

812
# Path to directory where wallet key is stored
9-
keystore-dir = "~/.mantis-faucet-keystore"
13+
keystore-dir = ${faucet.datadir}"/keystore"
1014

1115
# Transaction gas price
1216
tx-gas-price = 20000000000
@@ -35,3 +39,14 @@ faucet {
3539
# How many ip addr -> timestamp entries to store
3640
latest-timestamp-cache-size = 1024
3741
}
42+
43+
logging {
44+
# Flag used to switch logs to the JSON format
45+
json-output = false
46+
47+
# Logs directory
48+
logs-dir = ${faucet.datadir}"/logs"
49+
50+
# Logs filename
51+
logs-file = "faucet"
52+
}

src/universal/conf/logging.conf

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
mantis {
2-
logging {
3-
# Flag used to switch logs to the JSON format
4-
# json-output = false
1+
logging {
2+
# Flag used to switch logs to the JSON format
3+
# json-output = false
54

6-
# Logs directory
7-
# logs-dir = ${mantis.datadir}"/logs"
5+
# Logs directory
6+
# logs-dir = ${mantis.datadir}"/logs"
87

9-
# Logs filename
10-
# logs-file = "mantis"
11-
}
8+
# Logs filename
9+
# logs-file = "mantis"
1210
}

0 commit comments

Comments
 (0)