From 4743ea732c35b90d86f39cad8abafeab9bfdde26 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 6 Jul 2024 20:35:52 -0400 Subject: [PATCH] Fix weight estimation for RctType::ClsagBulletproof TXs --- .github/workflows/monero-tests.yaml | 1 - coins/monero/wallet/src/send/mod.rs | 1 + coins/monero/wallet/src/send/tx.rs | 9 ++++++++- coins/monero/wallet/tests/runner/mod.rs | 4 ++-- orchestration/dev/coins/monero/run.sh | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/monero-tests.yaml b/.github/workflows/monero-tests.yaml index 96c175f1e..c558d04f1 100644 --- a/.github/workflows/monero-tests.yaml +++ b/.github/workflows/monero-tests.yaml @@ -42,7 +42,6 @@ jobs: GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-seed --lib GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package polyseed --lib GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-wallet-util --lib - GITHUB_CI=true RUST_BACKTRACE=1 cargo test --package monero-serai-verify-chain --lib # Doesn't run unit tests with features as the tests workflow will diff --git a/coins/monero/wallet/src/send/mod.rs b/coins/monero/wallet/src/send/mod.rs index b7c8712af..c477d3e7d 100644 --- a/coins/monero/wallet/src/send/mod.rs +++ b/coins/monero/wallet/src/send/mod.rs @@ -251,6 +251,7 @@ impl SignableTransaction { Err(SendError::NoInputs)?; } for (_, decoys) in &self.inputs { + // TODO: Add a function for the ring length if decoys.len() != match self.rct_type { RctType::ClsagBulletproof => 11, diff --git a/coins/monero/wallet/src/send/tx.rs b/coins/monero/wallet/src/send/tx.rs index e46cc9096..c7b4988f7 100644 --- a/coins/monero/wallet/src/send/tx.rs +++ b/coins/monero/wallet/src/send/tx.rs @@ -122,7 +122,14 @@ impl SignableTransaction { key_images.push(ED25519_BASEPOINT_POINT); clsags.push(Clsag { D: ED25519_BASEPOINT_POINT, - s: vec![Scalar::ZERO; 16], + s: vec![ + Scalar::ZERO; + match self.rct_type { + RctType::ClsagBulletproof => 11, + RctType::ClsagBulletproofPlus => 16, + _ => unreachable!("unsupported RCT type"), + } + ], c1: Scalar::ZERO, }); pseudo_outs.push(ED25519_BASEPOINT_POINT); diff --git a/coins/monero/wallet/tests/runner/mod.rs b/coins/monero/wallet/tests/runner/mod.rs index 11351033d..ba59beccc 100644 --- a/coins/monero/wallet/tests/runner/mod.rs +++ b/coins/monero/wallet/tests/runner/mod.rs @@ -126,7 +126,7 @@ pub async fn rpc() -> SimpleRequestRpc { SimpleRequestRpc::new("http://serai:seraidex@127.0.0.1:18081".to_string()).await.unwrap(); // Only run once - if rpc.get_height().await.unwrap() < 100 { + if rpc.get_height().await.unwrap() < 120 { return rpc; } @@ -138,7 +138,7 @@ pub async fn rpc() -> SimpleRequestRpc { ); // Mine 100 blocks to ensure decoy availability - rpc.generate_blocks(&addr, 100).await.unwrap(); + rpc.generate_blocks(&addr, 120).await.unwrap(); rpc } diff --git a/orchestration/dev/coins/monero/run.sh b/orchestration/dev/coins/monero/run.sh index 675d44382..75a93e464 100755 --- a/orchestration/dev/coins/monero/run.sh +++ b/orchestration/dev/coins/monero/run.sh @@ -7,5 +7,5 @@ RPC_PASS="${RPC_PASS:=seraidex}" monerod --non-interactive --regtest --offline --fixed-difficulty=1 \ --no-zmq --rpc-bind-ip=0.0.0.0 --rpc-bind-port=18081 --confirm-external-bind \ --rpc-access-control-origins "*" --disable-rpc-ban \ - --rpc-login=$RPC_USER:$RPC_PASS \ + --rpc-login=$RPC_USER:$RPC_PASS --log-level 2 \ $1