summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine A <>2023-10-05 00:45:03 +0200
committerAntoine A <>2023-10-05 00:45:03 +0200
commit2e685701559118da856a0cde10849d82a112c9c7 (patch)
treef30d0bd02d43e45f14b68469d80090aab3688366
parentb898b96922ac80325d6371c0aafa3ee55c2c21b2 (diff)
downloaddepolymerization-2e685701559118da856a0cde10849d82a112c9c7.tar.gz
depolymerization-2e685701559118da856a0cde10849d82a112c9c7.tar.bz2
depolymerization-2e685701559118da856a0cde10849d82a112c9c7.zip
Test support for bitcoind 24.1 and small improvements
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml3
-rw-r--r--README.md4
-rw-r--r--btc-wire/src/rpc.rs7
-rw-r--r--common/Cargo.toml2
-rw-r--r--common/src/reconnect.rs11
-rw-r--r--instrumentation/Cargo.toml3
-rw-r--r--instrumentation/src/btc.rs18
-rw-r--r--makefile2
-rwxr-xr-xscript/prepare.sh8
10 files changed, 43 insertions, 25 deletions
diff --git a/Cargo.lock b/Cargo.lock
index dd57cc0..d81fc47 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -365,6 +365,7 @@ name = "common"
version = "0.1.0"
dependencies = [
"base32",
+ "exponential-backoff",
"flexi_logger",
"log",
"postgres",
@@ -749,6 +750,15 @@ dependencies = [
]
[[package]]
+name = "exponential-backoff"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47f78d87d930eee4b5686a2ab032de499c72bd1e954b84262bb03492a0f932cd"
+dependencies = [
+ "rand",
+]
+
+[[package]]
name = "fallible-iterator"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 842c0ac..bbe5454 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,3 +8,6 @@ members = [
"common",
"instrumentation"
]
+
+[profile.dev]
+debug = true \ No newline at end of file
diff --git a/README.md b/README.md
index 0885a8e..1de3ec5 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@
## Install from source
-Cargo version 1.66.1 or above is required. You can get cargo from your
+Cargo version 1.70.0 or above is required. You can get cargo from your
distribution package manager or from [rustup.rs](https://rustup.rs/).
```
@@ -37,7 +37,7 @@ Depolymerizer require:
#### Bitcoin
-[Bitcoind](https://bitcoincore.org/) version 24.0 is expected
+[Bitcoind](https://bitcoincore.org/) version 24.1 is expected
#### Ethereum
diff --git a/btc-wire/src/rpc.rs b/btc-wire/src/rpc.rs
index d63b2f6..711cb39 100644
--- a/btc-wire/src/rpc.rs
+++ b/btc-wire/src/rpc.rs
@@ -403,6 +403,13 @@ impl Rpc {
pub fn disconnect_node(&mut self, addr: &str) -> Result<()> {
expect_null(self.call("disconnectnode", &(addr, ())))
}
+
+ /* ----- Control ------ */
+
+ /// Request a graceful shutdown
+ pub fn stop(&mut self) -> Result<String> {
+ self.call("stop", &())
+ }
}
#[derive(Debug, serde::Deserialize)]
diff --git a/common/Cargo.toml b/common/Cargo.toml
index 5b9f4ef..0c165de 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -33,3 +33,5 @@ rand = { version = "0.8.5", features = ["getrandom"] }
zeroize = "1.6.0"
# Optimized uri binary format
uri-pack = { path = "../uri-pack" }
+# Exponential backoff generator
+exponential-backoff = "1.2.0"
diff --git a/common/src/reconnect.rs b/common/src/reconnect.rs
index f569fc9..f2892f5 100644
--- a/common/src/reconnect.rs
+++ b/common/src/reconnect.rs
@@ -15,10 +15,13 @@
*/
use std::time::Duration;
+use exponential_backoff::Backoff;
use log::error;
use postgres::{Client, NoTls};
-const RECONNECT_DELAY: Duration = Duration::from_secs(5);
+const MIN_RECONNECT_DELAY: Duration = Duration::from_millis(300);
+const MAX_RECONNECT_DELAY: Duration = Duration::from_secs(10);
+const VALID_DELAY: Duration = Duration::from_secs(3);
pub struct AutoReconnect<S, C> {
config: S,
@@ -39,10 +42,12 @@ impl<S, C> AutoReconnect<S, C> {
/// Create a new client, loop on error
fn connect(config: &S, connect: fn(&S) -> Option<C>) -> C {
+ let backoff = Backoff::new(8, MIN_RECONNECT_DELAY, MAX_RECONNECT_DELAY);
+ let mut iter = backoff.iter();
loop {
match connect(config) {
Some(new) => return new,
- None => std::thread::sleep(RECONNECT_DELAY),
+ None => std::thread::sleep(iter.next().unwrap_or(MAX_RECONNECT_DELAY)),
}
}
}
@@ -67,6 +72,6 @@ pub fn auto_reconnect_db(config: postgres::Config) -> AutoReconnectDb {
.map_err(|err| error!("connect DB: {}", err))
.ok()
},
- |client| client.is_valid(RECONNECT_DELAY).is_err(),
+ |client| client.is_valid(VALID_DELAY).is_err(),
)
}
diff --git a/instrumentation/Cargo.toml b/instrumentation/Cargo.toml
index 4bc5432..984650a 100644
--- a/instrumentation/Cargo.toml
+++ b/instrumentation/Cargo.toml
@@ -37,6 +37,5 @@ rust-ini = "0.19.0"
indicatif = "0.17.7"
thread-local-panic-hook = "0.1.0"
-
[build-dependencies]
-clap_mangen = "0.2.5"
+clap_mangen = "0.2.14"
diff --git a/instrumentation/src/btc.rs b/instrumentation/src/btc.rs
index 5add69b..964f302 100644
--- a/instrumentation/src/btc.rs
+++ b/instrumentation/src/btc.rs
@@ -388,16 +388,8 @@ impl BtcCtx {
pub fn stop_node(&mut self) {
// We need to kill bitcoin gracefully to avoid corruption
- #[cfg(unix)]
- {
- cmd_redirect_ok(
- "kill",
- &[&self.btc_node.0.id().to_string()],
- "/dev/null",
- "fill btc node",
- );
- self.btc_node.0.wait().unwrap();
- }
+ self.common_rpc.stop().unwrap();
+ self.btc_node.0.wait().unwrap();
}
pub fn cluster_deco(&mut self) {
@@ -1105,11 +1097,11 @@ pub fn maxfee(ctx: TestCtx) {
total_amount += amount;
ctx.debit(amount, rand_slice());
}
- sleep(Duration::from_secs(3));
+ ctx.mine(2);
// Check no transaction happen
- ctx.expect_wire_balance(wire, true);
- ctx.expect_client_balance(client, true);
+ ctx.expect_wire_balance(wire, false);
+ ctx.expect_client_balance(client, false);
}
ctx.step("Good feed");
diff --git a/makefile b/makefile
index b0c381e..96970e0 100644
--- a/makefile
+++ b/makefile
@@ -7,7 +7,7 @@ segwit_demo:
cargo run --release --bin segwit-demo
test:
- RUST_BACKTRACE=full cargo run -r --bin instrumentation -- offline
+ RUST_BACKTRACE=full cargo run --profile dev --bin instrumentation -- offline
msrv:
cargo msrv --min 1.70.0 --max 1.70.0 --linear \ No newline at end of file
diff --git a/script/prepare.sh b/script/prepare.sh
index d95d9d7..72adb5d 100755
--- a/script/prepare.sh
+++ b/script/prepare.sh
@@ -20,15 +20,15 @@ echo "Ⅰ - Find installed postgres version"
PG_VER=`pg_config --version | egrep -o '[0-9]{1,}' | head -1`
echo "Found version $PG_VER"
-echo "Ⅱ - Install bitcoind version 0.23"
+echo "Ⅱ - Install bitcoind version 24.1"
cd $DIR
-curl -L https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz -o btc.tar.gz
+curl -L https://bitcoincore.org/bin/bitcoin-core-24.1/bitcoin-24.1-x86_64-linux-gnu.tar.gz -o btc.tar.gz
tar xvzf btc.tar.gz
rm -rfv ~/bitcoin
mkdir -pv ~/bitcoin
-mv -v bitcoin-24.0.1/* ~/bitcoin
+mv -v bitcoin-24.1/* ~/bitcoin
-echo "Ⅲ - Install Go Ethereum (Geth) v1.10.24"
+echo "Ⅲ - Install Go Ethereum (Geth) v1.10.26"
cd $DIR
curl -L https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.10.26-e5eb32ac.tar.gz -o geth.tar.gz
tar xvzf geth.tar.gz