Skip to content

Commit

Permalink
fix: supported in epoch added
Browse files Browse the repository at this point in the history
  • Loading branch information
fess-v committed Apr 10, 2024
1 parent a91581d commit 8df5b31
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
30 changes: 30 additions & 0 deletions stackslib/src/chainstate/stacks/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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]
Expand Down
35 changes: 4 additions & 31 deletions stackslib/src/chainstate/stacks/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8df5b31

Please sign in to comment.