Skip to content

[ETCM-125] Fix faucet logging issue #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
}