|
|
@@ -221,12 +221,12 @@ impl Faucetd {
|
|
|
blockchain.contracts.lookup(&blockchain.sled_db, &cid, SMART_CONTRACT_ZKAS_DB_NAME)?;
|
|
|
|
|
|
let Some(mint_zkbytes) = db_handle.get(serialize(&MONEY_CONTRACT_ZKAS_MINT_NS_V1))? else {
|
|
|
- error!("{} zkas bincode not found in sled database", MONEY_CONTRACT_ZKAS_MINT_NS_V1);
|
|
|
+ error!(target: "faucetd", "{} zkas bincode not found in sled database", MONEY_CONTRACT_ZKAS_MINT_NS_V1);
|
|
|
return Err(Error::ZkasBincodeNotFound)
|
|
|
};
|
|
|
|
|
|
let Some(burn_zkbytes) = db_handle.get(serialize(&MONEY_CONTRACT_ZKAS_BURN_NS_V1))? else {
|
|
|
- error!("{} zkas bincode not found in sled database", MONEY_CONTRACT_ZKAS_BURN_NS_V1);
|
|
|
+ error!(target: "faucetd", "{} zkas bincode not found in sled database", MONEY_CONTRACT_ZKAS_BURN_NS_V1);
|
|
|
return Err(Error::ZkasBincodeNotFound)
|
|
|
};
|
|
|
|
|
|
@@ -239,9 +239,9 @@ impl Faucetd {
|
|
|
let burn_zkbin = ZkBinary::decode(&burn_zkbin)?;
|
|
|
let burn_circuit = ZkCircuit::new(empty_witnesses(&burn_zkbin)?, &burn_zkbin);
|
|
|
|
|
|
- info!("Creating mint circuit proving key");
|
|
|
+ info!(target: "faucetd", "Creating mint circuit proving key");
|
|
|
let mint_provingkey = ProvingKey::build(mint_zkbin.k, &mint_circuit);
|
|
|
- info!("Creating burn circuit proving key");
|
|
|
+ info!(target: "faucetd", "Creating burn circuit proving key");
|
|
|
let burn_provingkey = ProvingKey::build(burn_zkbin.k, &burn_circuit);
|
|
|
|
|
|
{
|
|
|
@@ -256,7 +256,7 @@ impl Faucetd {
|
|
|
|
|
|
// Get or create an initial keypair for signing transactions
|
|
|
let keypair = Self::initialize_keypair(wallet.clone()).await?;
|
|
|
- info!("Faucet pubkey: {}", keypair.public);
|
|
|
+ info!(target: "faucetd", "Faucet pubkey: {}", keypair.public);
|
|
|
|
|
|
let faucetd = Self {
|
|
|
synced: Mutex::new(false),
|
|
|
@@ -280,10 +280,10 @@ impl Faucetd {
|
|
|
let wallet_schema = include_str!("../../../src/contract/money/wallet.sql");
|
|
|
|
|
|
// Get a wallet connection
|
|
|
- info!("Acquiring wallet connection");
|
|
|
+ info!(target: "faucetd", "Acquiring wallet connection");
|
|
|
let conn = wallet.conn.lock().await;
|
|
|
|
|
|
- info!("Initializing wallet schema");
|
|
|
+ info!(target: "faucetd", "Initializing wallet schema");
|
|
|
conn.execute(wallet_schema, rusqlite::params![])?;
|
|
|
|
|
|
let query = format!("SELECT * FROM {}", MONEY_TREE_COL_TREE);
|
|
|
@@ -294,7 +294,7 @@ impl Faucetd {
|
|
|
|
|
|
let merkle_tree = match merkle_tree {
|
|
|
Ok(v) => {
|
|
|
- info!("Merkle tree already exists");
|
|
|
+ info!(target: "faucetd", "Merkle tree already exists");
|
|
|
v
|
|
|
}
|
|
|
|
|
|
@@ -308,7 +308,7 @@ impl Faucetd {
|
|
|
);
|
|
|
|
|
|
conn.execute(&query, rusqlite::params![tree_bytes])?;
|
|
|
- info!("Successfully initialized Merkle tree");
|
|
|
+ info!(target: "faucetd", "Successfully initialized Merkle tree");
|
|
|
tree
|
|
|
}
|
|
|
};
|
|
|
@@ -351,7 +351,7 @@ impl Faucetd {
|
|
|
);
|
|
|
|
|
|
conn.execute(&query, rusqlite::params![is_default, public_bytes, secret_bytes])?;
|
|
|
- info!("Wrote keypair to wallet");
|
|
|
+ info!(target: "faucetd", "Wrote keypair to wallet");
|
|
|
keypair
|
|
|
}
|
|
|
};
|
|
|
@@ -382,7 +382,7 @@ impl Faucetd {
|
|
|
}
|
|
|
|
|
|
if !(*self.synced.lock().await) {
|
|
|
- error!("challenge(): Blockchain is not yet synced");
|
|
|
+ error!(target: "faucetd", "challenge(): Blockchain is not yet synced");
|
|
|
return JsonError::new(InternalError, None, id).into()
|
|
|
}
|
|
|
|
|
|
@@ -390,7 +390,7 @@ impl Faucetd {
|
|
|
let pubkey = match PublicKey::from_str(pubkey) {
|
|
|
Ok(v) => v,
|
|
|
Err(e) => {
|
|
|
- error!("challenge(): Failed parsing PublicKey from String: {}", e);
|
|
|
+ error!(target: "faucetd", "challenge(): Failed parsing PublicKey from String: {}", e);
|
|
|
return server_error(RpcError::ParseError, id)
|
|
|
}
|
|
|
};
|
|
|
@@ -444,7 +444,7 @@ impl Faucetd {
|
|
|
}
|
|
|
|
|
|
if !(*self.synced.lock().await) {
|
|
|
- error!("airdrop(): Blockchain is not yet synced");
|
|
|
+ error!(target: "faucetd", "airdrop(): Blockchain is not yet synced");
|
|
|
return JsonError::new(InternalError, None, id).into()
|
|
|
}
|
|
|
|
|
|
@@ -453,7 +453,7 @@ impl Faucetd {
|
|
|
let pubkey = match PublicKey::from_str(pubkey) {
|
|
|
Ok(v) => v,
|
|
|
Err(e) => {
|
|
|
- error!("airdrop(): Failed parsing PublicKey from String: {}", e);
|
|
|
+ error!(target: "faucetd", "airdrop(): Failed parsing PublicKey from String: {}", e);
|
|
|
return server_error(RpcError::ParseError, id)
|
|
|
}
|
|
|
};
|
|
|
@@ -463,7 +463,7 @@ impl Faucetd {
|
|
|
let amount = match decode_base10(&amount, 8, true) {
|
|
|
Ok(v) => v,
|
|
|
Err(_) => {
|
|
|
- error!("airdrop(): Failed parsing amount from string");
|
|
|
+ error!(target: "faucetd", "airdrop(): Failed parsing amount from string");
|
|
|
return server_error(RpcError::ParseError, id)
|
|
|
}
|
|
|
};
|
|
|
@@ -475,7 +475,7 @@ impl Faucetd {
|
|
|
// Decode VDF witness
|
|
|
let witness = params[2].get::<String>().unwrap();
|
|
|
let Ok(witness) = BigUint::from_str_radix(witness, 16) else {
|
|
|
- error!("airdrop(): Failed parsing VDF witness from string");
|
|
|
+ error!(target: "faucetd", "airdrop(): Failed parsing VDF witness from string");
|
|
|
return server_error(RpcError::ParseError, id)
|
|
|
};
|
|
|
|
|
|
@@ -484,7 +484,7 @@ impl Faucetd {
|
|
|
let map = self.airdrop_map.lock().await;
|
|
|
if let Some(last_airdrop) = map.get(&pubkey.to_bytes()) {
|
|
|
if now - last_airdrop <= self.airdrop_timeout {
|
|
|
- error!("airdrop(): Time limit reached for {}", pubkey);
|
|
|
+ error!(target: "faucetd", "airdrop(): Time limit reached for {}", pubkey);
|
|
|
return server_error(RpcError::TimeLimitReached, id)
|
|
|
}
|
|
|
};
|
|
|
@@ -493,15 +493,15 @@ impl Faucetd {
|
|
|
// Check if a VDF challenge exists
|
|
|
let map = self.challenge_map.lock().await;
|
|
|
let Some((challenge, n_steps)) = map.get(&pubkey.to_bytes()).cloned() else {
|
|
|
- error!("airdrop(): No VDF challenge found for {}", pubkey);
|
|
|
+ error!(target: "faucetd", "airdrop(): No VDF challenge found for {}", pubkey);
|
|
|
return server_error(RpcError::NoVdfChallenge, id)
|
|
|
};
|
|
|
drop(map);
|
|
|
|
|
|
// Verify the VDF
|
|
|
- info!("airdrop(): Verifying VDF for {}...", pubkey);
|
|
|
+ info!(target: "faucetd", "airdrop(): Verifying VDF for {}...", pubkey);
|
|
|
if !mimc_vdf::verify(&challenge, n_steps, &witness) {
|
|
|
- error!("airdrop(): VDF verification failed for {}", pubkey);
|
|
|
+ error!(target: "faucetd", "airdrop(): VDF verification failed for {}", pubkey);
|
|
|
return server_error(RpcError::VdfVerifyFailed, id)
|
|
|
}
|
|
|
|
|
|
@@ -516,17 +516,17 @@ impl Faucetd {
|
|
|
let (mint_zkbin, mint_pk, burn_zkbin, burn_pk) = {
|
|
|
let proving_keys_r = self.proving_keys.read().await;
|
|
|
let Some(arr) = proving_keys_r.get(&cid.to_bytes()) else {
|
|
|
- error!("Contract ID {} not found in proving keys hashmap", cid);
|
|
|
+ error!(target: "faucetd", "Contract ID {} not found in proving keys hashmap", cid);
|
|
|
return server_error(RpcError::InternalError, id)
|
|
|
};
|
|
|
|
|
|
let Some(mint_data) = arr.iter().find(|x| x.0 == MONEY_CONTRACT_ZKAS_MINT_NS_V1) else {
|
|
|
- error!("{} proof data not found in vector", MONEY_CONTRACT_ZKAS_MINT_NS_V1);
|
|
|
+ error!(target: "faucetd", "{} proof data not found in vector", MONEY_CONTRACT_ZKAS_MINT_NS_V1);
|
|
|
return server_error(RpcError::InternalError, id)
|
|
|
};
|
|
|
|
|
|
let Some(burn_data) = arr.iter().find(|x| x.0 == MONEY_CONTRACT_ZKAS_BURN_NS_V1) else {
|
|
|
- error!("{} proof data not found in vector", MONEY_CONTRACT_ZKAS_BURN_NS_V1);
|
|
|
+ error!(target: "faucetd", "{} proof data not found in vector", MONEY_CONTRACT_ZKAS_BURN_NS_V1);
|
|
|
return server_error(RpcError::InternalError, id)
|
|
|
};
|
|
|
|
|
|
@@ -557,7 +557,7 @@ impl Faucetd {
|
|
|
let debris = match builder.build() {
|
|
|
Ok(v) => v,
|
|
|
Err(e) => {
|
|
|
- error!("Failed to build transfer tx params: {}", e);
|
|
|
+ error!(target: "faucetd", "Failed to build transfer tx params: {}", e);
|
|
|
return server_error(RpcError::InternalError, id)
|
|
|
}
|
|
|
};
|
|
|
@@ -575,7 +575,7 @@ impl Faucetd {
|
|
|
let lock = self.validator_state.read().await;
|
|
|
let current_slot = lock.consensus.time_keeper.current_slot();
|
|
|
if let Err(e) = lock.verify_transactions(&[tx.clone()], current_slot, false).await {
|
|
|
- error!("airdrop(): Failed to verify transaction before broadcasting: {}", e);
|
|
|
+ error!(target: "faucetd", "airdrop(): Failed to verify transaction before broadcasting: {}", e);
|
|
|
return JsonError::new(InternalError, None, id).into()
|
|
|
}
|
|
|
|
|
|
@@ -599,7 +599,7 @@ async fn prune_airdrop_maps(
|
|
|
) -> Result<()> {
|
|
|
loop {
|
|
|
sleep(timeout as u64).await;
|
|
|
- debug!("Pruning airdrop maps");
|
|
|
+ debug!(target: "faucetd", "Pruning airdrop maps");
|
|
|
|
|
|
let now = Utc::now().timestamp();
|
|
|
|
|
|
@@ -651,7 +651,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|
|
*TESTNET_INITIAL_DISTRIBUTION,
|
|
|
),
|
|
|
x => {
|
|
|
- error!("Unsupported chain `{}`", x);
|
|
|
+ error!(target: "faucetd", "Unsupported chain `{}`", x);
|
|
|
return Err(Error::UnsupportedChain)
|
|
|
}
|
|
|
};
|
|
|
@@ -699,7 +699,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|
|
let sync_p2p = net::P2p::new(network_settings).await;
|
|
|
let registry = sync_p2p.protocol_registry();
|
|
|
|
|
|
- info!("Registering block sync P2P protocols...");
|
|
|
+ info!(target: "faucetd", "Registering block sync P2P protocols...");
|
|
|
let _state = state.clone();
|
|
|
registry
|
|
|
.register(net::SESSION_ALL, move |channel, p2p| {
|
|
|
@@ -749,7 +749,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|
|
);
|
|
|
|
|
|
// JSON-RPC server
|
|
|
- info!("Starting JSON-RPC server");
|
|
|
+ info!(target: "faucetd", "Starting JSON-RPC server");
|
|
|
let rpc_task = StoppableTask::new();
|
|
|
rpc_task.clone().start(
|
|
|
listen_and_serve(args.rpc_listen, faucetd.clone(), ex.clone()),
|
|
|
@@ -763,7 +763,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|
|
ex.clone(),
|
|
|
);
|
|
|
|
|
|
- info!("Starting sync P2P network");
|
|
|
+ info!(target: "faucetd", "Starting sync P2P network");
|
|
|
sync_p2p.clone().start(ex.clone()).await?;
|
|
|
StoppableTask::new().start(
|
|
|
sync_p2p.clone().run(ex.clone()),
|
|
|
@@ -783,13 +783,13 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|
|
|
|
|
match block_sync_task(sync_p2p.clone(), state.clone()).await {
|
|
|
Ok(()) => *faucetd.synced.lock().await = true,
|
|
|
- Err(e) => error!("Failed syncing blockchain: {}", e),
|
|
|
+ Err(e) => error!(target: "faucetd", "Failed syncing blockchain: {}", e),
|
|
|
}
|
|
|
|
|
|
// Signal handling for graceful termination.
|
|
|
let (signals_handler, signals_task) = SignalHandler::new()?;
|
|
|
signals_handler.wait_termination(signals_task).await?;
|
|
|
- info!("Caught termination signal, cleaning up and exiting...");
|
|
|
+ info!(target: "faucetd", "Caught termination signal, cleaning up and exiting...");
|
|
|
|
|
|
info!(target: "faucetd", "Stopping JSON-RPC server...");
|
|
|
rpc_task.stop().await;
|
|
|
@@ -800,9 +800,9 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'_>>) -> Result<()> {
|
|
|
info!(target: "faucetd", "Stopping syncing P2P network...");
|
|
|
sync_p2p.stop().await;
|
|
|
|
|
|
- info!("Flushing database...");
|
|
|
+ info!(target: "faucetd", "Flushing database...");
|
|
|
let flushed_bytes = sled_db.flush_async().await?;
|
|
|
- info!("Flushed {} bytes", flushed_bytes);
|
|
|
+ info!(target: "faucetd", "Flushed {} bytes", flushed_bytes);
|
|
|
|
|
|
Ok(())
|
|
|
}
|