gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-depolymerization] branch master updated (328d775 -> 5db4ac3)


From: gnunet
Subject: [taler-depolymerization] branch master updated (328d775 -> 5db4ac3)
Date: Sun, 06 Feb 2022 19:39:35 +0100

This is an automated email from the git hooks/post-receive script.

antoine pushed a change to branch master
in repository depolymerization.

    from 328d775  eth-wire: support lifetime and bounce
     new 79f0adf  Improve tests
     new 5db4ac3  Update dependencies and use taler-config to parse 
configuration

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Cargo.lock                         | 80 +++++++++++++++++++-------------------
 btc-wire/Cargo.toml                |  1 +
 btc-wire/src/bin/btc-wire-cli.rs   | 14 +++----
 btc-wire/src/bin/btc-wire-utils.rs | 48 ++++++++++++++---------
 btc-wire/src/config.rs             |  4 +-
 btc-wire/src/loops/worker.rs       | 40 +++++++------------
 btc-wire/src/main.rs               |  2 +-
 btc-wire/src/rpc.rs                |  4 ++
 common/Cargo.toml                  |  1 +
 common/src/config.rs               | 32 +++++++++------
 eth-wire/Cargo.toml                |  3 +-
 eth-wire/src/bin/eth-wire-cli.rs   |  5 ++-
 eth-wire/src/bin/eth-wire-utils.rs |  3 +-
 eth-wire/src/loops/worker.rs       |  2 +-
 eth-wire/src/main.rs               |  2 +-
 test/btc/reconnect.sh              |  2 +-
 test/btc/stress.sh                 | 10 +++--
 test/common.sh                     | 25 ++++++------
 wire-gateway/Cargo.toml            |  4 +-
 wire-gateway/src/main.rs           | 31 ++++++++-------
 20 files changed, 166 insertions(+), 147 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index e845d2b..30c1a6d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -127,9 +127,9 @@ checksum = 
"bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
 [[package]]
 name = "block-buffer"
-version = "0.10.0"
+version = "0.10.1"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95"
+checksum = "03588e54c62ae6d763e2a80090d50353b785795361b4ff5b3bf0a5097fc31c0b"
 dependencies = [
  "generic-array",
 ]
@@ -312,9 +312,9 @@ dependencies = [
 
 [[package]]
 name = "crossbeam-epoch"
-version = "0.9.6"
+version = "0.9.7"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762"
+checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
 dependencies = [
  "cfg-if",
  "crossbeam-utils",
@@ -325,9 +325,9 @@ dependencies = [
 
 [[package]]
 name = "crossbeam-utils"
-version = "0.8.6"
+version = "0.8.7"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
+checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
 dependencies = [
  "cfg-if",
  "lazy_static",
@@ -492,9 +492,9 @@ dependencies = [
 
 [[package]]
 name = "ethbloom"
-version = "0.11.1"
+version = "0.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8"
+checksum = "c927489503a5d331fdb25a3ac8d80e433ee6aa96951c99346d66e7be2b0400a0"
 dependencies = [
  "crunchy",
  "fixed-hash",
@@ -504,9 +504,9 @@ dependencies = [
 
 [[package]]
 name = "ethereum-types"
-version = "0.12.1"
+version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf"
+checksum = "6e6307a3fa100563ce323e6b654c5935c8d919aeee56b0ccef1c65c5ecd2ecf6"
 dependencies = [
  "ethbloom",
  "fixed-hash",
@@ -574,9 +574,9 @@ dependencies = [
 
 [[package]]
 name = "futures"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4"
+checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e"
 dependencies = [
  "futures-channel",
  "futures-core",
@@ -589,9 +589,9 @@ dependencies = [
 
 [[package]]
 name = "futures-channel"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b"
+checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010"
 dependencies = [
  "futures-core",
  "futures-sink",
@@ -599,15 +599,15 @@ dependencies = [
 
 [[package]]
 name = "futures-core"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7"
+checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
 
 [[package]]
 name = "futures-executor"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a"
+checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6"
 dependencies = [
  "futures-core",
  "futures-task",
@@ -616,15 +616,15 @@ dependencies = [
 
 [[package]]
 name = "futures-io"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2"
+checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
 
 [[package]]
 name = "futures-macro"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c"
+checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -633,21 +633,21 @@ dependencies = [
 
 [[package]]
 name = "futures-sink"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508"
+checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868"
 
 [[package]]
 name = "futures-task"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72"
+checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a"
 
 [[package]]
 name = "futures-util"
-version = "0.3.19"
+version = "0.3.21"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164"
+checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a"
 dependencies = [
  "futures-channel",
  "futures-core",
@@ -879,9 +879,9 @@ checksum = 
"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.116"
+version = "0.2.117"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74"
+checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
 
 [[package]]
 name = "listenfd"
@@ -1196,9 +1196,9 @@ checksum = 
"eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
 
 [[package]]
 name = "primitive-types"
-version = "0.10.1"
+version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373"
+checksum = "db5a3482110d085cee2a284278b42a4361bc611d008eddfbf04fd84735ae521f"
 dependencies = [
  "fixed-hash",
  "impl-serde",
@@ -1415,9 +1415,9 @@ dependencies = [
 
 [[package]]
 name = "semver"
-version = "1.0.4"
+version = "1.0.5"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
+checksum = "0486718e92ec9a68fbed73bb5ef687d71103b142595b406835649bebd33f72c7"
 
 [[package]]
 name = "serde"
@@ -1737,9 +1737,9 @@ checksum = 
"360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
 
 [[package]]
 name = "tracing"
-version = "0.1.29"
+version = "0.1.30"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
+checksum = "2d8d93354fe2a8e50d5953f5ae2e47a3fc2ef03292e7ea46e3cc38f549525fb9"
 dependencies = [
  "cfg-if",
  "pin-project-lite",
@@ -1748,9 +1748,9 @@ dependencies = [
 
 [[package]]
 name = "tracing-core"
-version = "0.1.21"
+version = "0.1.22"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
+checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23"
 dependencies = [
  "lazy_static",
 ]
@@ -1769,9 +1769,9 @@ checksum = 
"dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
 
 [[package]]
 name = "uint"
-version = "0.9.2"
+version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1b1b413ebfe8c2c74a69ff124699dd156a7fa41cb1d09ba6df94aa2f2b0a4a3a"
+checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0"
 dependencies = [
  "byteorder",
  "crunchy",
diff --git a/btc-wire/Cargo.toml b/btc-wire/Cargo.toml
index a7606ae..9d3a9aa 100644
--- a/btc-wire/Cargo.toml
+++ b/btc-wire/Cargo.toml
@@ -3,6 +3,7 @@ name = "btc-wire"
 version = "0.1.0"
 edition = "2021"
 license = "AGPL-3.0-or-later"
+rust-version = "1.56.1"
 
 [features]
 # Enable random failures
diff --git a/btc-wire/src/bin/btc-wire-cli.rs b/btc-wire/src/bin/btc-wire-cli.rs
index c070006..9438230 100644
--- a/btc-wire/src/bin/btc-wire-cli.rs
+++ b/btc-wire/src/bin/btc-wire-cli.rs
@@ -15,18 +15,20 @@
 */
 use btc_wire::{
     config::{BitcoinConfig, WIRE_WALLET_NAME},
-    rpc::{Rpc, Error, ErrorCode},
+    rpc::{Error, ErrorCode, Rpc},
     rpc_utils::default_data_dir,
 };
 use common::{
     config::{Config, CoreConfig},
+    log::init,
     postgres::{Client, NoTls},
 };
 
 fn main() {
+    init();
     let args: Vec<_> = std::env::args().collect();
     // Parse taler config
-    let config = CoreConfig::load_from_file(&args[2]);
+    let config = CoreConfig::load_taler_config(Some(&args[2]));
     assert_eq!(config.currency, "BTC");
     // Connect to database
     let mut db = Client::connect(&config.db_url, NoTls).expect("Failed to 
connect to database");
@@ -47,12 +49,10 @@ fn main() {
         }
         "initwallet" => {
             // Parse bitcoin config
-            let btc_conf =
-                
BitcoinConfig::load(config.data_dir.unwrap_or_else(default_data_dir))
-                    .expect("Failed to load bitcoin configuration");
+            let btc_conf = 
BitcoinConfig::load(config.data_dir.unwrap_or_else(default_data_dir))
+                .expect("Failed to load bitcoin configuration");
             // Connect to bitcoin node
-            let mut rpc =
-                Rpc::common(&btc_conf).expect("Failed to connect to bitcoin 
RPC server");
+            let mut rpc = Rpc::common(&btc_conf).expect("Failed to connect to 
bitcoin RPC server");
 
             // Skip previous blocks
             let info = rpc
diff --git a/btc-wire/src/bin/btc-wire-utils.rs 
b/btc-wire/src/bin/btc-wire-utils.rs
index bbda3f4..c69ae45 100644
--- a/btc-wire/src/bin/btc-wire-utils.rs
+++ b/btc-wire/src/bin/btc-wire-utils.rs
@@ -15,16 +15,16 @@
 */
 use std::path::PathBuf;
 
-use bitcoin::{Address, Amount, Network};
+use bitcoin::{Address, Amount, BlockHash, Network};
 use btc_wire::{
     config::BitcoinConfig,
-    rpc::{Rpc, Category, Error, ErrorCode},
+    rpc::{Category, Error, ErrorCode, Rpc},
     rpc_utils::default_data_dir,
 };
 use common::{
     config::{Config, CoreConfig},
     postgres::{Client, NoTls},
-    rand_slice,
+    rand_slice, log::init,
 };
 
 #[derive(argh::FromArgs)]
@@ -43,7 +43,7 @@ enum Cmd {
     Transfer(TransferCmd),
     NextBlock(NextBlockCmd),
     Abandon(AbandonCmd),
-    ClearDB(ClearCmd),
+    ResetDB(ResetCmd),
 }
 
 #[derive(argh::FromArgs)]
@@ -82,9 +82,9 @@ struct AbandonCmd {
 }
 
 #[derive(argh::FromArgs)]
-#[argh(subcommand, name = "cleardb")]
+#[argh(subcommand, name = "resetdb")]
 /// Clear database
-struct ClearCmd {
+struct ResetCmd {
     #[argh(positional)]
     /// taler config
     config: String,
@@ -92,7 +92,7 @@ struct ClearCmd {
 
 struct App {
     config: BitcoinConfig,
-    client: Rpc,
+    rpc: Rpc,
 }
 
 impl App {
@@ -101,12 +101,15 @@ impl App {
         let config = BitcoinConfig::load(data_dir).unwrap();
         let client = Rpc::common(&config).unwrap();
 
-        Self { config, client }
+        Self {
+            config,
+            rpc: client,
+        }
     }
 
     pub fn auto_wallet(&mut self, name: &str) -> (Rpc, Address) {
         // Auto load
-        if let Err(err) = self.client.load_wallet(name) {
+        if let Err(err) = self.rpc.load_wallet(name) {
             match err {
                 Error::RPC { code, .. } if code == 
ErrorCode::RpcWalletAlreadyLoaded => {}
                 e => Err(e).unwrap(),
@@ -124,21 +127,22 @@ impl App {
             Network::Regtest => {
                 // Manually mine a block
                 let (_, addr) = self.auto_wallet(wallet);
-                self.client.generate(1, &addr).unwrap();
+                self.rpc.generate(1, &addr).unwrap();
             }
             _ => {
                 // Wait for next network block
-                self.client.wait_for_new_block(0).ok();
+                self.rpc.wait_for_new_block(0).ok();
             }
         }
     }
 }
 
 fn main() {
+    init();
     let args: Args = argh::from_env();
+    let mut app = App::start(args.datadir);
     match args.cmd {
         Cmd::Transfer(TransferCmd { from, to, amount }) => {
-            let mut app = App::start(args.datadir);
             let (mut client, _) = app.auto_wallet(&from);
             let (_, to) = app.auto_wallet(&to);
             let tx = client
@@ -147,11 +151,9 @@ fn main() {
             println!("{}", tx);
         }
         Cmd::NextBlock(NextBlockCmd { to }) => {
-            let mut app = App::start(args.datadir);
             app.next_block(&to);
         }
         Cmd::Abandon(AbandonCmd { from }) => {
-            let mut app = App::start(args.datadir);
             let (mut wire, _) = app.auto_wallet(&from);
             let list = wire.list_since_block(None, 1, false).unwrap();
             for tx in list.transactions {
@@ -160,11 +162,21 @@ fn main() {
                 }
             }
         }
-        Cmd::ClearDB(ClearCmd { config }) => {
-            let config = CoreConfig::load_from_file(&config);
+        Cmd::ResetDB(ResetCmd { config }) => {
+            let config = CoreConfig::load_taler_config(Some(&config));
+            let hash: BlockHash = app.rpc.get_block_hash(0).unwrap();
             let mut db = Client::connect(&config.db_url, NoTls).unwrap();
-            db.execute("DROP TABLE IF EXISTS state, tx_in, tx_out, bounce", 
&[])
-                .unwrap();
+            let mut tx = db.transaction().unwrap();
+            // Clear transaction tables and reset state
+            tx.execute("DELETE FROM tx_in", &[]).unwrap();
+            tx.execute("DELETE FROM tx_out", &[]).unwrap();
+            tx.execute("DELETE FROM bounce", &[]).unwrap();
+            tx.execute(
+                "UPDATE state SET value=$1 WHERE name='last_hash'",
+                &[&hash.as_ref()],
+            )
+            .unwrap();
+            tx.commit().unwrap();
         }
     }
 }
diff --git a/btc-wire/src/config.rs b/btc-wire/src/config.rs
index 5f1cf7d..4560fcc 100644
--- a/btc-wire/src/config.rs
+++ b/btc-wire/src/config.rs
@@ -69,12 +69,12 @@ impl BitcoinConfig {
         let main = conf.general_section();
 
         if !main.contains_key("txindex") {
-            error!("btc_wire require a bitcoin core node running with 
'txindex' option");
+            error!("require a bitcoind node running with 'txindex' option");
             exit(1);
         }
 
         if !main.contains_key("maxtxfee") {
-            error!("btc_wire require a bitcoin core node running with 
'maxtxfee' option");
+            error!("require a bitcoind node running with 'maxtxfee' option");
             exit(1);
         }
 
diff --git a/btc-wire/src/loops/worker.rs b/btc-wire/src/loops/worker.rs
index b8593e2..a84e373 100644
--- a/btc-wire/src/loops/worker.rs
+++ b/btc-wire/src/loops/worker.rs
@@ -155,7 +155,7 @@ fn withdraw(db: &mut Client, rpc: &mut Rpc) -> 
LoopResult<bool> {
     Ok(row.is_some())
 }
 
-/// Bounce a transaction on the blockchain, return false if nor more requested 
transaction are found
+/// Bounce a transaction on the blockchain, return false if no more requested 
transaction are found
 fn bounce(db: &mut Client, rpc: &mut Rpc, fee: &BtcAmount) -> LoopResult<bool> 
{
     // We rely on the advisory lock to ensure we are the only one sending 
transactions
     let row = db.query_opt(
@@ -195,10 +195,9 @@ fn bounce(db: &mut Client, rpc: &mut Rpc, fee: &BtcAmount) 
-> LoopResult<bool> {
 }
 
 /// Retrieve last stored hash
-fn last_hash(db: &mut Client) -> Result<Option<BlockHash>, postgres::Error> {
-    Ok(db
-        .query_opt("SELECT value FROM state WHERE name='last_hash'", &[])?
-        .map(|r| BlockHash::from_slice(r.get(0)).unwrap()))
+fn last_hash(db: &mut Client) -> Result<BlockHash, postgres::Error> {
+    let row = db.query_one("SELECT value FROM state WHERE name='last_hash'", 
&[])?;
+    Ok(BlockHash::from_slice(row.get(0)).unwrap())
 }
 
 /// Parse new transactions, return true if the database is up to date with the 
latest mined block
@@ -215,7 +214,7 @@ fn sync_chain(
     // Get a set of transactions ids to parse
     let (txs, removed, lastblock): (HashMap<Txid, (Category, i32)>, 
HashSet<Txid>, BlockHash) = {
         // Get all transactions made since this block
-        let list = rpc.list_since_block(last_hash.as_ref(), min_confirmations, 
true)?;
+        let list = rpc.list_since_block(Some(&last_hash), min_confirmations, 
true)?;
         // Only keep ids and category
         let txs = list
             .transactions
@@ -254,9 +253,6 @@ fn sync_chain(
             Category::Receive if confirmations >= min_confirmations as i32 => {
                 sync_chain_incoming_confirmed(&id, rpc, db)?
             }
-            Category::Receive if confirmations < 0 => {
-                panic!("receive conflict {} {}", id, confirmations)
-            }
             _ => {
                 // Ignore coinbase and unconfirmed send transactions
             }
@@ -264,23 +260,13 @@ fn sync_chain(
     }
 
     // Move last_hash forward
-    {
-        let nb_row = if let Some(hash) = &last_hash {
-            db.execute(
-                "UPDATE state SET value=$1 WHERE name='last_hash' AND 
value=$2",
-                &[&lastblock.as_ref(), &hash.as_ref()],
-            )?
-        } else {
-            db.execute(
-        "INSERT INTO state (name, value) VALUES ('last_hash', $1) ON CONFLICT 
(name) DO NOTHING",
+    db.execute(
+        "UPDATE state SET value=$1 WHERE name='last_hash'",
         &[&lastblock.as_ref()],
-            )?
-        };
+    )?;
 
-        if nb_row == 0 {
-            error!("watcher: hash state collision, database have been altered 
by another process");
-        }
-    }
+    
+    dbg!(last_hash, lastblock);
     Ok(true)
 }
 
@@ -372,9 +358,7 @@ fn sync_chain_outgoing(
             OutMetadata::Withdraw { wtid, .. } => {
                 sync_chain_withdraw(id, &full, &wtid, rpc, db, confirmations, 
state)?
             }
-            OutMetadata::Bounce { bounced } => {
-                sync_chain_bounce(id, &bounced, db, confirmations)?
-            }
+            OutMetadata::Bounce { bounced } => sync_chain_bounce(id, &bounced, 
db, confirmations)?,
         },
         Ok((_, Err(e))) => warn!("send: decode-info {} - {}", id, e),
         Err(e) => match e {
@@ -563,6 +547,7 @@ fn sync_chain_bounce(
             }
         }
     }
+
     Ok(())
 }
 
@@ -572,6 +557,7 @@ fn sync_chain_incoming_confirmed(
     rpc: &mut Rpc,
     db: &mut Client,
 ) -> Result<(), LoopError> {
+    dbg!(id);
     match rpc.get_tx_segwit_key(id) {
         Ok((full, reserve_pub)) => {
             // Store transactions in database
diff --git a/btc-wire/src/main.rs b/btc-wire/src/main.rs
index 5107f4f..7d22b0e 100644
--- a/btc-wire/src/main.rs
+++ b/btc-wire/src/main.rs
@@ -43,7 +43,7 @@ pub struct WireState {
 fn main() {
     common::log::init();
 
-    let config = load_btc_config(std::env::args_os().nth(1).expect("Missing 
conf path arg"));
+    let config = load_btc_config(Some(&std::env::args().nth(1).expect("Missing 
conf path arg")));
     let data_dir = config
         .core
         .data_dir
diff --git a/btc-wire/src/rpc.rs b/btc-wire/src/rpc.rs
index 9ef0ae4..aa25f1b 100644
--- a/btc-wire/src/rpc.rs
+++ b/btc-wire/src/rpc.rs
@@ -210,6 +210,10 @@ impl Rpc {
         self.call("generatetoaddress", &(nb, address))
     }
 
+    pub fn get_block_hash(&mut self, height: u32) -> Result<BlockHash> {
+        self.call("getblockhash", &[height])
+    }
+
     pub fn wait_for_new_block(&mut self, timeout: u64) -> Result<Nothing> {
         self.call("waitfornewblock", &[timeout])
     }
diff --git a/common/Cargo.toml b/common/Cargo.toml
index da28284..fe14107 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -3,6 +3,7 @@ name = "common"
 version = "0.1.0"
 edition = "2021"
 license = "AGPL-3.0-or-later"
+rust-version = "1.56.1"
 
 # See more keys and their definitions at 
https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/common/src/config.rs b/common/src/config.rs
index 0aefa35..00bcf62 100644
--- a/common/src/config.rs
+++ b/common/src/config.rs
@@ -14,16 +14,26 @@
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
 use ini::{Ini, Properties};
-use std::{
-    path::{Path, PathBuf},
-    str::FromStr,
-};
+use std::{path::PathBuf, process::Command, str::FromStr};
 use url::Url;
 
 pub trait Config: Sized {
-    /// Load from a file
-    fn load_from_file(config_file: impl AsRef<Path>) -> Self {
-        let conf = ini::Ini::load_from_file(config_file).expect("Failed to 
open the config file");
+    /// Load using taler-config
+    fn load_taler_config(file: Option<&str>) -> Self {
+        let mut cmd = Command::new("taler-config");
+        cmd.arg("-d");
+        if let Some(path) = file {
+            cmd.args(["-c", path]);
+        }
+        let output = cmd.output().expect("Failed to execute taler-config");
+        if !output.status.success() {
+            panic!(
+                "taler-config failure:\n{}",
+                String::from_utf8_lossy(&output.stderr)
+            );
+        }
+        let conf = 
ini::Ini::load_from_str(&String::from_utf8_lossy(&output.stdout))
+            .expect("Failed to parse config");
         let taler = section(&conf, "taler");
         let currency = require(taler, "CURRENCY", string);
         let section_name = match currency.as_str() {
@@ -115,16 +125,16 @@ impl<const DEFAULT_FEE: u64, const DEFAULT_CONFIRMATION: 
u16> Config
 
 pub type BtcConfig = WireConfig<1000, 6>;
 
-pub fn load_btc_config(path: impl AsRef<Path>) -> BtcConfig {
-    let config = WireConfig::load_from_file(path);
+pub fn load_btc_config(path: Option<&str>) -> BtcConfig {
+    let config = WireConfig::load_taler_config(path);
     assert_eq!(config.core.currency, "BTC");
     return config;
 }
 
 pub type EthConfig = WireConfig<1000000, 24>;
 
-pub fn load_eth_config(path: impl AsRef<Path>) -> EthConfig {
-    let config = WireConfig::load_from_file(path);
+pub fn load_eth_config(path: Option<&str>) -> EthConfig {
+    let config = WireConfig::load_taler_config(path);
     assert_eq!(config.core.currency, "ETH");
     return config;
 }
diff --git a/eth-wire/Cargo.toml b/eth-wire/Cargo.toml
index c0ca0c6..9b507f2 100644
--- a/eth-wire/Cargo.toml
+++ b/eth-wire/Cargo.toml
@@ -3,6 +3,7 @@ name = "eth-wire"
 version = "0.1.0"
 edition = "2021"
 license = "AGPL-3.0-or-later"
+rust-version = "1.56.1"
 
 [dependencies]
 # Cli args 
@@ -13,7 +14,7 @@ serde_json = "1.0.78"
 serde_repr = "0.1.7"
 hex = "0.4.3"
 # Ethereum serializable types
-ethereum-types = { version = "0.12.1", default-features = false, features = [
+ethereum-types = { version = "0.13.0", default-features = false, features = [
     "serialize",
 ] }
 # Error macros
diff --git a/eth-wire/src/bin/eth-wire-cli.rs b/eth-wire/src/bin/eth-wire-cli.rs
index 94149a1..e638157 100644
--- a/eth-wire/src/bin/eth-wire-cli.rs
+++ b/eth-wire/src/bin/eth-wire-cli.rs
@@ -18,12 +18,13 @@ use eth_wire::{rpc::Rpc, BlockState};
 use ethereum_types::H160;
 use common::{
     config::{Config, CoreConfig},
-    postgres::{Client, NoTls},
+    postgres::{Client, NoTls}, log::init,
 };
 
 fn main() {
+    init();
     let args: Vec<_> = std::env::args().collect();
-    let config = CoreConfig::load_from_file(&args[2]);
+    let config = CoreConfig::load_taler_config(Some(&args[2]));
     assert_eq!(config.currency, "ETH");
     let mut db = Client::connect(&config.db_url, NoTls).expect("Failed to 
connect to database");
 
diff --git a/eth-wire/src/bin/eth-wire-utils.rs 
b/eth-wire/src/bin/eth-wire-utils.rs
index 500e6f3..cb15d45 100644
--- a/eth-wire/src/bin/eth-wire-utils.rs
+++ b/eth-wire/src/bin/eth-wire-utils.rs
@@ -15,7 +15,7 @@
 */
 use std::{path::PathBuf, str::FromStr};
 
-use common::{api_common::Amount, rand_slice};
+use common::{api_common::Amount, rand_slice, log::init};
 use eth_wire::{
     rpc::{hex::Hex, Rpc, TransactionRequest},
     taler_util::taler_to_eth,
@@ -115,6 +115,7 @@ struct BalanceCmd {
 }
 
 fn main() {
+    init();
     let args: Args = argh::from_env();
     match args.cmd {
         Cmd::Deposit(DepositCmd {
diff --git a/eth-wire/src/loops/worker.rs b/eth-wire/src/loops/worker.rs
index ef1be19..b1962a5 100644
--- a/eth-wire/src/loops/worker.rs
+++ b/eth-wire/src/loops/worker.rs
@@ -207,7 +207,7 @@ fn withdraw(db: &mut Client, rpc: &mut Rpc, state: 
&WireState) -> LoopResult<boo
     Ok(row.is_some())
 }
 
-/// Bounce a transaction on the blockchain, return false if nor more requested 
transaction are found
+/// Bounce a transaction on the blockchain, return false if no more requested 
transaction are found
 fn bounce(db: &mut Client, rpc: &mut Rpc, fee: U256) -> LoopResult<bool> {
     // We rely on the advisory lock to ensure we are the only one sending 
transactions
     let row = db.query_opt(
diff --git a/eth-wire/src/main.rs b/eth-wire/src/main.rs
index de76e33..8165c4a 100644
--- a/eth-wire/src/main.rs
+++ b/eth-wire/src/main.rs
@@ -54,7 +54,7 @@ fn main() {
     common::log::init();
 
     let path = std::env::args().nth(1).unwrap();
-    let config = load_eth_config(path);
+    let config = load_eth_config(Some(&path));
 
     let state: &'static WireState = Box::leak(Box::new(WireState {
         confirmation: AtomicU16::new(config.confirmation),
diff --git a/test/btc/reconnect.sh b/test/btc/reconnect.sh
index fb65882..275af14 100644
--- a/test/btc/reconnect.sh
+++ b/test/btc/reconnect.sh
@@ -71,7 +71,7 @@ echo " OK"
 echo "----- Recover DB -----"
 
 echo "Reset database"
-reset_db # Clear database tables
+reset_db
 mine_btc # Trigger worker
 sleep 2
 
diff --git a/test/btc/stress.sh b/test/btc/stress.sh
index 83a34a8..e5bf0fa 100644
--- a/test/btc/stress.sh
+++ b/test/btc/stress.sh
@@ -68,9 +68,10 @@ next_btc # Mine transactions
 echo "----- Recover DB -----"
 
 echo "Reset database"
-reset_db # Clear database tables
-mine_btc # Trigger worker
 sleep 5
+reset_db
+mine_btc # Trigger worker
+sleep 10
 
 echo -n "Requesting exchange incoming transaction list:"
 check_delta "incoming?delta=-100" "$SEQ" "0.000"
@@ -109,9 +110,10 @@ echo " OK"
 echo "----- Recover DB -----"
 
 echo "Reset database"
-reset_db # Clear database tables
-mine_btc # Trigger worker
 sleep 5
+reset_db
+mine_btc # Trigger worker
+sleep 10
 
 echo -n "Requesting exchange incoming transaction list:"
 check_delta "incoming?delta=-100" "$SEQ" "0.000"
diff --git a/test/common.sh b/test/common.sh
index e7481ac..ccf2546 100644
--- a/test/common.sh
+++ b/test/common.sh
@@ -45,11 +45,11 @@ function load_config() {
     source <(grep = $CONF | sed 's/ *= */=/' | sed 's/=\(.*\)/="\1"/g1')
     BANK_ENDPOINT=http://127.0.0.1:$PORT/
     if [ "$CURRENCY" == "BTC" ]; then
-        WIRE_CLI=btc-wire-cli
-        WIRE_UTILS=btc-wire-utils
+        WIRE_CLI="btc-wire-cli"
+        WIRE_UTILS="btc-wire-utils -d $WIRE_DIR"
     else
-        WIRE_CLI=eth-wire-cli
-        WIRE_UTILS=eth-wire-utils
+        WIRE_CLI="eth-wire-cli"
+        WIRE_UTILS="eth-wire-utils -d $WIRE_DIR"
     fi
 }
 
@@ -84,8 +84,7 @@ function setup_db() {
 
 # Erase database
 function reset_db() {
-    $WIRE_UTILS cleardb $CONF
-    $WIRE_CLI initdb $CONF
+    $WIRE_UTILS resetdb $CONF
 }
 
 # ----- Bitcoin node ----- #
@@ -196,15 +195,15 @@ function check_balance() {
 # Start btc-wire
 function btc_wire() {    
     cargo build --bin btc-wire --release &> log/cargo.log
-    target/release/btc-wire $CONF &> log/btc_wire.log &
+    target/release/btc-wire $CONF &> log/wire.log &
     WIRE_PID="$!"
 }
 
 # Start multiple btc_wire with random failures in parallel
 function stress_btc_wire() {
    cargo build --bin btc-wire --release --features fail &> log/cargo.log
-   target/release/btc-wire $CONF &> log/btc_wire.log & 
-   target/release/btc-wire $CONF &> log/btc_wire1.log & 
+   target/release/btc-wire $CONF &> log/wire.log & 
+   target/release/btc-wire $CONF &> log/wire.log & 
 }
 
 # ----- Ethereum node ----- #
@@ -252,8 +251,8 @@ function init_eth() {
 
 # Check client and wire balance
 function check_balance_eth() {
-    local CLIENT_BALANCE=`eth-wire-utils -d $WIRE_DIR balance $CLIENT`
-    local WIRE_BALANCE=`eth-wire-utils -d $WIRE_DIR balance $WIRE`
+    local CLIENT_BALANCE=`$WIRE_UTILS balance $CLIENT`
+    local WIRE_BALANCE=`$WIRE_UTILS balance $WIRE`
     local CLIENT="${1:-*}"
     if [ "$1" == "*" ]; then
         local CLIENT="$CLIENT_BALANCE"
@@ -270,13 +269,13 @@ function check_balance_eth() {
 # Start eth-wire
 function eth_wire() {
     cargo build --bin eth-wire --release &> log/cargo.log
-    target/release/eth-wire $CONF &> log/eth_wire.log &
+    target/release/eth-wire $CONF &> log/wire.log &
     WIRE_PID="$!"
 }
 
 # Mine ethereum blocks
 function mine_eth() {
-    eth-wire-utils -d $WIRE_DIR mine $RESERVE ${1:-}
+    $WIRE_UTILS mine $RESERVE ${1:-}
 }
 
 # Mine previous transactions
diff --git a/wire-gateway/Cargo.toml b/wire-gateway/Cargo.toml
index 40e8878..480a3ea 100644
--- a/wire-gateway/Cargo.toml
+++ b/wire-gateway/Cargo.toml
@@ -3,7 +3,7 @@ name = "wire-gateway"
 version = "0.1.0"
 edition = "2021"
 license = "AGPL-3.0-or-later"
-
+rust-version = "1.56.1"
 
 [dependencies]
 # Http library
@@ -34,7 +34,7 @@ common = { path = "../common" }
 # Bitcoin types
 bitcoin = { version = "0.27.1", optional = true }
 # Euthereum types
-ethereum-types = { version = "0.12.1", default-features = false, optional = 
true }
+ethereum-types = { version = "0.13.0", default-features = false, optional = 
true }
 
 
 [features]
diff --git a/wire-gateway/src/main.rs b/wire-gateway/src/main.rs
index 62e0aa2..1a1b02d 100644
--- a/wire-gateway/src/main.rs
+++ b/wire-gateway/src/main.rs
@@ -13,6 +13,19 @@
   You should have received a copy of the GNU Affero General Public License 
along with
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
+use common::{
+    api_common::{ShortHashCode, Timestamp},
+    api_wire::{
+        HistoryParams, IncomingBankTransaction, IncomingHistory, 
OutgoingBankTransaction,
+        OutgoingHistory, TransferRequest, TransferResponse,
+    },
+    config::{Config, GatewayConfig},
+    error_codes::ErrorCode,
+    log::log::{error, info, log, Level},
+    postgres::{fallible_iterator::FallibleIterator, Client},
+    sql::{sql_amount, sql_array, sql_safe_u64, sql_url},
+    url::Url,
+};
 use deadpool_postgres::{Pool, Runtime};
 use error::{CatchResult, ServerError};
 use hyper::{
@@ -28,19 +41,6 @@ use std::{
     sync::atomic::{AtomicBool, AtomicU32, Ordering},
     time::{Duration, Instant},
 };
-use common::{
-    api_common::{ShortHashCode, Timestamp},
-    api_wire::{
-        HistoryParams, IncomingBankTransaction, IncomingHistory, 
OutgoingBankTransaction,
-        OutgoingHistory, TransferRequest, TransferResponse,
-    },
-    config::{Config, GatewayConfig},
-    error_codes::ErrorCode,
-    log::log::{error, info, log, Level},
-    postgres::{fallible_iterator::FallibleIterator, Client},
-    sql::{sql_amount, sql_array, sql_safe_u64, sql_url},
-    url::Url,
-};
 use tokio::sync::Notify;
 use tokio_postgres::{config::Host, NoTls};
 
@@ -88,8 +88,9 @@ impl ServerState {
 async fn main() {
     common::log::init();
 
-    let conf =
-        
GatewayConfig::load_from_file(std::env::args_os().nth(1).expect("Missing conf 
path arg"));
+    let conf = GatewayConfig::load_taler_config(Some(
+        &std::env::args().nth(1).expect("Missing conf path arg"),
+    ));
 
     #[cfg(feature = "test")]
     common::log::log::warn!("Running with test admin endpoint unsuitable for 
production");

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]