Skip to content

Commit

Permalink
Merge pull request #6 from jbencin/multisig-order-independence
Browse files Browse the repository at this point in the history
Multisig order independence
  • Loading branch information
fess-v authored Apr 30, 2024
2 parents fa95032 + be71ee8 commit cfdc8f1
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 102 deletions.
14 changes: 7 additions & 7 deletions stackslib/src/chainstate/stacks/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,11 @@ impl TransactionSpendingCondition {

Some(TransactionSpendingCondition::Singlesig(
SinglesigSpendingCondition {
signer: signer_addr.bytes.clone(),
signer: signer_addr.bytes,
nonce: 0,
tx_fee: 0,
hash_mode: SinglesigHashMode::P2PKH,
key_encoding: key_encoding,
key_encoding,
signature: MessageSignature::empty(),
},
))
Expand All @@ -730,7 +730,7 @@ impl TransactionSpendingCondition {

Some(TransactionSpendingCondition::Singlesig(
SinglesigSpendingCondition {
signer: signer_addr.bytes.clone(),
signer: signer_addr.bytes,
nonce: 0,
tx_fee: 0,
hash_mode: SinglesigHashMode::P2WPKH,
Expand All @@ -753,7 +753,7 @@ impl TransactionSpendingCondition {

Some(TransactionSpendingCondition::Multisig(
MultisigSpendingCondition {
signer: signer_addr.bytes.clone(),
signer: signer_addr.bytes,
nonce: 0,
tx_fee: 0,
hash_mode: MultisigHashMode::P2SH,
Expand All @@ -776,7 +776,7 @@ impl TransactionSpendingCondition {

Some(TransactionSpendingCondition::OrderIndependentMultisig(
OrderIndependentMultisigSpendingCondition {
signer: signer_addr.bytes.clone(),
signer: signer_addr.bytes,
nonce: 0,
tx_fee: 0,
hash_mode: OrderIndependentMultisigHashMode::P2SH,
Expand All @@ -799,7 +799,7 @@ impl TransactionSpendingCondition {

Some(TransactionSpendingCondition::OrderIndependentMultisig(
OrderIndependentMultisigSpendingCondition {
signer: signer_addr.bytes.clone(),
signer: signer_addr.bytes,
nonce: 0,
tx_fee: 0,
hash_mode: OrderIndependentMultisigHashMode::P2WSH,
Expand All @@ -822,7 +822,7 @@ impl TransactionSpendingCondition {

Some(TransactionSpendingCondition::Multisig(
MultisigSpendingCondition {
signer: signer_addr.bytes.clone(),
signer: signer_addr.bytes,
nonce: 0,
tx_fee: 0,
hash_mode: MultisigHashMode::P2WSH,
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/chainstate/stacks/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ impl StacksBlock {
}
}
if !tx.auth.is_supported_in_epoch(epoch_id) {
error!("Order independent multisig transactions not supported before Stacks 3.0");
error!("Authentication mode not supported in Epoch {epoch_id}");
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions stackslib/src/chainstate/stacks/db/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6650,7 +6650,9 @@ impl StacksChainState {
// 1: must parse (done)

// 2: it must be validly signed.
StacksChainState::process_transaction_precheck(&chainstate_config, &tx)
let epoch = clarity_connection.get_epoch().clone();

StacksChainState::process_transaction_precheck(&chainstate_config, &tx, epoch)
.map_err(|e| MemPoolRejection::FailedToValidate(e))?;

// 3: it must pay a tx fee
Expand All @@ -6664,8 +6666,6 @@ impl StacksChainState {
}

// 4: check if transaction is valid in the current epoch
let epoch = clarity_connection.get_epoch().clone();

if !StacksBlock::validate_transactions_static_epoch(&[tx.clone()], epoch) {
return Err(MemPoolRejection::Other(
"Transaction is not supported in this epoch".to_string(),
Expand Down
Loading

0 comments on commit cfdc8f1

Please sign in to comment.