]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove global availability logic for testing async signing
authorAlec Chen <alecchendev@gmail.com>
Tue, 11 Jun 2024 00:18:52 +0000 (17:18 -0700)
committerAlec Chen <alecchendev@gmail.com>
Mon, 17 Jun 2024 23:34:56 +0000 (16:34 -0700)
lightning/src/chain/channelmonitor.rs
lightning/src/ln/channel.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/util/test_channel_signer.rs
lightning/src/util/test_utils.rs

index 5cc8030a6a1dc33b8ad58c1bb877ee808f34a6a0..a037a965a8fbaac1f5419ed5acc41bb83617a594 100644 (file)
@@ -1923,12 +1923,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
                self.inner.lock().unwrap().counterparty_payment_script = script;
        }
 
-       #[cfg(test)]
-       pub fn do_signer_call<F: FnMut(&Signer) -> ()>(&self, mut f: F) {
-               let inner = self.inner.lock().unwrap();
-               f(&inner.onchain_tx_handler.signer);
-       }
-
        #[cfg(test)]
        pub fn do_mut_signer_call<F: FnMut(&mut Signer) -> ()>(&self, mut f: F) {
                let mut inner = self.inner.lock().unwrap();
index b6004debd7aabb3404991d4f6de9b86414269ee8..4dfe970304cc8dfb168fc1dfe0f02ecc2daf3c0b 100644 (file)
@@ -2116,12 +2116,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider  {
                self.outbound_scid_alias
        }
 
-       /// Returns the holder signer for this channel.
-       #[cfg(test)]
-       pub fn get_signer(&self) -> &ChannelSignerType<SP> {
-               return &self.holder_signer
-       }
-
        /// Returns the holder signer for this channel.
        #[cfg(test)]
        pub fn get_mut_signer(&mut self) -> &mut ChannelSignerType<SP> {
index d46588b105ade84cb22c4f1620c4c5c03fead11f..8c08d37f5f6193e2d1fc932a90e547f9e5593d90 100644 (file)
@@ -484,47 +484,6 @@ impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
        pub fn get_block_header(&self, height: u32) -> Header {
                self.blocks.lock().unwrap()[height as usize].0.header
        }
-       /// Changes the channel signer's availability for the specified peer and channel.
-       ///
-       /// When `available` is set to `true`, the channel signer will behave normally. When set to
-       /// `false`, the channel signer will act like an off-line remote signer and will return `Err` for
-       /// several of the signing methods. Currently, only `get_per_commitment_point` and
-       /// `release_commitment_secret` are affected by this setting.
-       #[cfg(test)]
-       pub fn set_channel_signer_available(&self, peer_id: &PublicKey, chan_id: &ChannelId, available: bool) {
-               use crate::sign::ChannelSigner;
-               log_debug!(self.logger, "Setting channel signer for {} as available={}", chan_id, available);
-
-               let per_peer_state = self.node.per_peer_state.read().unwrap();
-               let chan_lock = per_peer_state.get(peer_id).unwrap().lock().unwrap();
-
-               let mut channel_keys_id = None;
-               if let Some(chan) = chan_lock.channel_by_id.get(chan_id).map(|phase| phase.context()) {
-                       chan.get_signer().as_ecdsa().unwrap().set_available(available);
-                       channel_keys_id = Some(chan.channel_keys_id);
-               }
-
-               let mut monitor = None;
-               for (funding_txo, channel_id) in self.chain_monitor.chain_monitor.list_monitors() {
-                       if *chan_id == channel_id {
-                               monitor = self.chain_monitor.chain_monitor.get_monitor(funding_txo).ok();
-                       }
-               }
-               if let Some(monitor) = monitor {
-                       monitor.do_signer_call(|signer| {
-                               channel_keys_id = channel_keys_id.or(Some(signer.inner.channel_keys_id()));
-                               signer.set_available(available)
-                       });
-               }
-
-               if available {
-                       self.keys_manager.unavailable_signers.lock().unwrap()
-                               .remove(channel_keys_id.as_ref().unwrap());
-               } else {
-                       self.keys_manager.unavailable_signers.lock().unwrap()
-                               .insert(channel_keys_id.unwrap());
-               }
-       }
 
        /// Toggles this node's signer to be available for the given signer operation.
        /// This is useful for testing behavior for restoring an async signer that previously
index 5f509f7752dc3523002bd3b4e9ceb5ad08021c9e..884acc2c2eac1835ca07f6949afd172effe2e62e 100644 (file)
@@ -71,9 +71,6 @@ pub struct TestChannelSigner {
        /// Channel state used for policy enforcement
        pub state: Arc<Mutex<EnforcementState>>,
        pub disable_revocation_policy_check: bool,
-       /// When `true` (the default), the signer will respond immediately with signatures. When `false`,
-       /// the signer will return an error indicating that it is unavailable.
-       pub available: Arc<Mutex<bool>>,
        /// Set of signer operations that are disabled. If an operation is disabled,
        /// the signer will return `Err` when the corresponding method is called.
        pub disabled_signer_ops: Arc<Mutex<HashSet<SignerOp>>>,
@@ -130,7 +127,6 @@ impl TestChannelSigner {
                        inner,
                        state,
                        disable_revocation_policy_check: false,
-                       available: Arc::new(Mutex::new(true)),
                        disabled_signer_ops: Arc::new(Mutex::new(new_hash_set())),
                }
        }
@@ -145,7 +141,6 @@ impl TestChannelSigner {
                        inner,
                        state,
                        disable_revocation_policy_check,
-                       available: Arc::new(Mutex::new(true)),
                        disabled_signer_ops: Arc::new(Mutex::new(new_hash_set())),
                }
        }
@@ -157,15 +152,6 @@ impl TestChannelSigner {
                self.state.lock().unwrap()
        }
 
-       /// Marks the signer's availability.
-       ///
-       /// When `true`, methods are forwarded to the underlying signer as normal. When `false`, some
-       /// methods will return `Err` indicating that the signer is unavailable. Intended to be used for
-       /// testing asynchronous signing.
-       pub fn set_available(&self, available: bool) {
-               *self.available.lock().unwrap() = available;
-       }
-
        pub fn enable_op(&mut self, signer_op: SignerOp) {
                self.disabled_signer_ops.lock().unwrap().remove(&signer_op);
        }
index afdcbbac370eb37cb76cbd896b6c069d20c6c6e2..2a11a91f29480675ea585badb8ed40068de28658 100644 (file)
@@ -1277,9 +1277,6 @@ impl SignerProvider for TestKeysInterface {
                let keys = self.backing.derive_channel_signer(channel_value_satoshis, channel_keys_id);
                let state = self.make_enforcement_state_cell(keys.commitment_seed);
                let mut signer = TestChannelSigner::new_with_revoked(keys, state, self.disable_revocation_policy_check);
-               if self.unavailable_signers.lock().unwrap().contains(&channel_keys_id) {
-                       signer.set_available(false);
-               }
                if let Some(ops) = self.unavailable_signers_ops.lock().unwrap().get(&channel_keys_id) {
                        for &op in ops {
                                signer.disable_op(op);