diff --git a/cross-chain-airdrop/Cargo.lock b/cross-chain-airdrop/Cargo.lock index 5712edbca..e66e3c410 100644 --- a/cross-chain-airdrop/Cargo.lock +++ b/cross-chain-airdrop/Cargo.lock @@ -1558,15 +1558,6 @@ dependencies = [ "thiserror-impl 1.0.69", ] -[[package]] -name = "thiserror" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" -dependencies = [ - "thiserror-impl 2.0.18", -] - [[package]] name = "thiserror-impl" version = "2.0.18" diff --git a/miners/rust/Cargo.toml b/miners/rust/Cargo.toml index b9f61f5fa..fb5ddf9a2 100644 --- a/miners/rust/Cargo.toml +++ b/miners/rust/Cargo.toml @@ -12,7 +12,7 @@ name = "rustchain-miner" path = "src/main.rs" [dependencies] -reqwest = { version = "0.13", features = ["json", "rustls-tls"], default-features = false } +reqwest = { version = "0.13", features = ["json", "rustls"], default-features = false } serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "0.11" diff --git a/node/airdrop_v2.py b/node/airdrop_v2.py index 5052a8376..a5107b1cc 100644 --- a/node/airdrop_v2.py +++ b/node/airdrop_v2.py @@ -648,9 +648,9 @@ def _determine_tier( "Accept": "application/vnd.github.cloak-preview", }, params={ - "q": f"author:{github_username} merged:true", - "per_page": 1, - }, + "q": f"author:{github_username} repo:Scottcjn/Rustchain merged:true", + "per_page": 1, + }, timeout=10, ) diff --git a/node/rustchain_p2p_gossip.py b/node/rustchain_p2p_gossip.py index 757babe51..f64546bba 100644 --- a/node/rustchain_p2p_gossip.py +++ b/node/rustchain_p2p_gossip.py @@ -1823,6 +1823,10 @@ def receive_gossip(): if not _gossip_rate_check(remote_ip): return jsonify({"error": "rate_limited", "limit": f"{GOSSIP_RATE_LIMIT}/{GOSSIP_RATE_WINDOW_S}s"}), 429 + auth_error = _require_p2p_read_auth() + if auth_error: + return auth_error + if ( request.content_length is not None and request.content_length > MAX_GOSSIP_REQUEST_BYTES diff --git a/node/utxo_db.py b/node/utxo_db.py index 6cd2d719e..dd80cdd75 100644 --- a/node/utxo_db.py +++ b/node/utxo_db.py @@ -1535,9 +1535,16 @@ def mempool_get_block_candidates(self, max_count: int = 100) -> List[dict]: conn.close() def mempool_clear_expired(self) -> int: - """Remove expired transactions from mempool. Returns count removed.""" + """Remove expired transactions from mempool. Returns count removed. + + Uses BEGIN IMMEDIATE to ensure the SELECT-then-DELETE sequence is + atomic. Without it, a concurrent mempool_add() or apply_transaction() + can interleave between the SELECT and the DELETEs, causing mempool + state corruption / double-spend (B2, issue #8176). + """ conn = self._conn() try: + conn.execute("BEGIN IMMEDIATE") now = int(time.time()) try: expired = conn.execute( @@ -1546,22 +1553,29 @@ def mempool_clear_expired(self) -> int: ).fetchall() except sqlite3.OperationalError as exc: if "no such table" in str(exc).lower(): + conn.execute("ROLLBACK") return 0 + conn.execute("ROLLBACK") raise - else: - count = 0 - for row in expired: - conn.execute( - "DELETE FROM utxo_mempool_inputs WHERE tx_id = ?", - (row['tx_id'],), - ) - conn.execute( - "DELETE FROM utxo_mempool WHERE tx_id = ?", - (row['tx_id'],), - ) - count += 1 - conn.commit() - return count + count = 0 + for row in expired: + conn.execute( + "DELETE FROM utxo_mempool_inputs WHERE tx_id = ?", + (row['tx_id'],), + ) + conn.execute( + "DELETE FROM utxo_mempool WHERE tx_id = ?", + (row['tx_id'],), + ) + count += 1 + conn.commit() + return count + except Exception: + try: + conn.execute("ROLLBACK") + except Exception: + pass + raise finally: conn.close() diff --git a/rips/benches/entropy_bench.rs b/rips/benches/entropy_bench.rs new file mode 100644 index 000000000..e71cf4176 --- /dev/null +++ b/rips/benches/entropy_bench.rs @@ -0,0 +1,10 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +fn entropy_benchmark(c: &mut Criterion) { + c.bench_function("entropy", |b| b.iter(|| { + black_box(42u64) + })); +} + +criterion_group!(benches, entropy_benchmark); +criterion_main!(benches); \ No newline at end of file diff --git a/rust-tools/examples/cli-wallet/src/main.rs b/rust-tools/examples/cli-wallet/src/main.rs new file mode 100644 index 000000000..fbedd9205 --- /dev/null +++ b/rust-tools/examples/cli-wallet/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} \ No newline at end of file diff --git a/rust-tools/examples/rustchain-sdk/Cargo.toml b/rust-tools/examples/rustchain-sdk/Cargo.toml index f7a6a2121..16333e1cf 100644 --- a/rust-tools/examples/rustchain-sdk/Cargo.toml +++ b/rust-tools/examples/rustchain-sdk/Cargo.toml @@ -24,6 +24,9 @@ chrono = { version = "0.4", features = ["serde"] } uuid = { version = "1.0", features = ["v4", "serde"] } base64 = "0.21" hex = "0.4" +# Optional wallet dependencies +bip39 = { version = "2.0", optional = true } +ed25519-dalek = { version = "2.0", optional = true } [dev-dependencies] tokio-test = "0.4" @@ -31,6 +34,4 @@ wiremock = "0.5" [features] default = [] -wallet = ["bip39", "ed25519-dalek"] -bip39 = { version = "2.0", optional = true } -ed25519-dalek = { version = "2.0", optional = true } \ No newline at end of file +wallet = ["bip39", "ed25519-dalek"] \ No newline at end of file diff --git a/rust-tools/examples/rustchain-sdk/src/lib.rs b/rust-tools/examples/rustchain-sdk/src/lib.rs new file mode 100644 index 000000000..2a86110c3 --- /dev/null +++ b/rust-tools/examples/rustchain-sdk/src/lib.rs @@ -0,0 +1 @@ +// RustChain SDK — example crate. \ No newline at end of file diff --git a/rust-tools/sdk/Cargo.toml b/rust-tools/sdk/Cargo.toml new file mode 100644 index 000000000..ffba4ea0c --- /dev/null +++ b/rust-tools/sdk/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "rustchain-sdk" +version = "0.1.0" +edition = "2021" + +[dependencies] \ No newline at end of file diff --git a/rust-tools/sdk/src/lib.rs b/rust-tools/sdk/src/lib.rs new file mode 100644 index 000000000..b768136fa --- /dev/null +++ b/rust-tools/sdk/src/lib.rs @@ -0,0 +1 @@ +// RustChain SDK library. \ No newline at end of file diff --git a/rustchain-miner/Cargo.toml b/rustchain-miner/Cargo.toml index 2d2cce34c..444d2858b 100644 --- a/rustchain-miner/Cargo.toml +++ b/rustchain-miner/Cargo.toml @@ -23,7 +23,7 @@ clap = { version = "4.4", features = ["derive", "env"] } tokio = { version = "1.35", features = ["full"] } # HTTP/HTTPS (reqwest with rustls TLS) -reqwest = { version = "0.13", features = ["json", "rustls-tls"], default-features = false } +reqwest = { version = "0.13", features = ["json", "rustls"], default-features = false } # Error handling thiserror = "2.0"