Skip to content

Commit

Permalink
[ETCM-125] Fix faucet logging issue (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Mrożek committed Sep 23, 2020
1 parent 1668edf commit b8adef4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 38 deletions.
22 changes: 11 additions & 11 deletions src/main/resources/application.conf
Expand Up @@ -519,17 +519,6 @@ mantis {
port = 13798
}

logging {
# Flag used to switch logs to the JSON format
json-output = false

# Logs directory
logs-dir = ${mantis.datadir}"/logs"

# Logs filename
logs-file = "mantis"
}

async {
dispatchers {
block-forger {
Expand Down Expand Up @@ -596,3 +585,14 @@ validation-context {
}
throughput = 1
}

logging {
# Flag used to switch logs to the JSON format
json-output = false

# Logs directory
logs-dir = ${mantis.datadir}"/logs"

# Logs filename
logs-file = "mantis"
}
6 changes: 3 additions & 3 deletions src/main/resources/logback.xml
Expand Up @@ -5,9 +5,9 @@

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

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
Expand Down
21 changes: 7 additions & 14 deletions src/main/scala/io/iohk/ethereum/faucet/FaucetApi.scala
Expand Up @@ -17,18 +17,16 @@ import io.iohk.ethereum.rlp
import io.iohk.ethereum.network.p2p.messages.CommonMessages.SignedTransactions.SignedTransactionEnc
import org.bouncycastle.util.encoders.Hex

class FaucetApi(
rpcClient: RpcClient,
keyStore: KeyStore,
config: FaucetConfig,
clock: Clock = Clock.systemUTC())
extends Logger {
class FaucetApi(rpcClient: RpcClient, keyStore: KeyStore, config: FaucetConfig, clock: Clock = Clock.systemUTC())
extends Logger {

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

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

private val corsSettings = CorsSettings.defaultSettings
Expand Down Expand Up @@ -67,13 +65,8 @@ class FaucetApi(
}

private def prepareTx(targetAddress: Address, nonce: BigInt): ByteString = {
val transaction = Transaction(
nonce,
config.txGasPrice,
config.txGasLimit,
Some(targetAddress),
config.txValue,
ByteString())
val transaction =
Transaction(nonce, config.txGasPrice, config.txGasLimit, Some(targetAddress), config.txValue, ByteString())

val stx = wallet.signTx(transaction, None)
ByteString(rlp.encode(stx.tx.toRLPEncodable))
Expand Down
17 changes: 16 additions & 1 deletion src/universal/conf/faucet.conf
@@ -1,12 +1,16 @@
faucet {

# Base directory where all the data used by the fauced is stored
datadir = ${user.home}"/.mantis-faucet"

# Wallet address used to send transactions from
wallet-address = "0x00"

# Password to unlock faucet wallet
wallet-password = ""

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

# Transaction gas price
tx-gas-price = 20000000000
Expand Down Expand Up @@ -35,3 +39,14 @@ faucet {
# How many ip addr -> timestamp entries to store
latest-timestamp-cache-size = 1024
}

logging {
# Flag used to switch logs to the JSON format
json-output = false

# Logs directory
logs-dir = ${faucet.datadir}"/logs"

# Logs filename
logs-file = "faucet"
}
16 changes: 7 additions & 9 deletions src/universal/conf/logging.conf
@@ -1,12 +1,10 @@
mantis {
logging {
# Flag used to switch logs to the JSON format
# json-output = false
logging {
# Flag used to switch logs to the JSON format
# json-output = false

# Logs directory
# logs-dir = ${mantis.datadir}"/logs"
# Logs directory
# logs-dir = ${mantis.datadir}"/logs"

# Logs filename
# logs-file = "mantis"
}
# Logs filename
# logs-file = "mantis"
}

0 comments on commit b8adef4

Please sign in to comment.