From 8df5b318a8c3014a48a94e7b42e42bfd68033674 Mon Sep 17 00:00:00 2001 From: Fess Date: Wed, 10 Apr 2024 14:06:58 +0400 Subject: [PATCH] fix: supported in epoch added --- stackslib/src/chainstate/stacks/auth.rs | 30 ++++++++++++++++++++ stackslib/src/chainstate/stacks/block.rs | 35 +++--------------------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/stackslib/src/chainstate/stacks/auth.rs b/stackslib/src/chainstate/stacks/auth.rs index 5ba40fceea..e2f2654efc 100644 --- a/stackslib/src/chainstate/stacks/auth.rs +++ b/stackslib/src/chainstate/stacks/auth.rs @@ -27,6 +27,7 @@ use stacks_common::types::StacksPublicKeyBuffer; use stacks_common::util::hash::{to_hex, Hash160, Sha512Trunc256Sum}; use stacks_common::util::retry::{BoundReader, RetryReader}; use stacks_common::util::secp256k1::{MessageSignature, MESSAGE_SIGNATURE_ENCODED_SIZE}; +use stacks_common::types::StacksEpochId; use crate::burnchains::{PrivateKey, PublicKey, Txid}; use crate::chainstate::stacks::{ @@ -1387,6 +1388,35 @@ impl TransactionAuth { } } } + + pub fn is_supported_in_epoch( + &self, + epoch_id: StacksEpochId, + ) -> bool { + match &self { + TransactionAuth::Sponsored(ref origin, ref sponsor) => { + let origin_supported = match origin { + TransactionSpendingCondition::OrderIndependentMultisig(..) => { + epoch_id >= StacksEpochId::Epoch30 + }, + _ => true, + }; + let sponsor_supported = match sponsor { + TransactionSpendingCondition::OrderIndependentMultisig(..) => { + epoch_id >= StacksEpochId::Epoch30 + }, + _ => true, + }; + origin_supported && sponsor_supported + }, + TransactionAuth::Standard(ref origin) => match origin { + TransactionSpendingCondition::OrderIndependentMultisig(..) => { + epoch_id >= StacksEpochId::Epoch30 + }, + _ => true, + }, + } + } } #[rustfmt::skip] diff --git a/stackslib/src/chainstate/stacks/block.rs b/stackslib/src/chainstate/stacks/block.rs index 6126dfcfc4..97c64f35f8 100644 --- a/stackslib/src/chainstate/stacks/block.rs +++ b/stackslib/src/chainstate/stacks/block.rs @@ -600,37 +600,10 @@ impl StacksBlock { return false; } } - match &tx.auth { - TransactionAuth::Sponsored(ref origin, ref sponsor) => { - match origin { - TransactionSpendingCondition::OrderIndependentMultisig(..) => { - if epoch_id < StacksEpochId::Epoch30 { - error!("Order independent multisig transactions not supported before Stacks 3.0"); - return false; - } - } - _ => (), - } - match sponsor { - TransactionSpendingCondition::OrderIndependentMultisig(..) => { - if epoch_id < StacksEpochId::Epoch30 { - error!("Order independent multisig transactions not supported before Stacks 3.0"); - return false; - } - } - _ => (), - } - } - TransactionAuth::Standard(ref origin) => match origin { - TransactionSpendingCondition::OrderIndependentMultisig(..) => { - if epoch_id < StacksEpochId::Epoch30 { - error!("Order independent multisig transactions not supported before Stacks 3.0"); - return false; - } - } - _ => (), - }, - }; + if !tx.auth.is_supported_in_epoch(epoch_id) { + error!("Order independent multisig transactions not supported before Stacks 3.0"); + return false; + } } return true; }