Skip to content

Commit

Permalink
Change error name
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-roberts committed Nov 25, 2024
1 parent 30cedc8 commit 678f4bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion packages/engine/src/errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub mod Error {
pub const UNSATISFIED_LOCKTIME: felt252 = 'Unsatisfied locktime';
pub const SCRIPT_STRICT_MULTISIG: felt252 = 'OP_CHECKMULTISIG invalid dummy';
pub const FINALIZED_TX_CLTV: felt252 = 'Finalized tx in OP_CLTV';
pub const INVALID_TX_VERSION: felt252 = 'Invalid transaction version';
pub const SCRIPT_INVALID: felt252 = 'Invalid script data';
pub const INVALID_COINBASE: felt252 = 'Invalid coinbase transaction';
pub const SIG_NULLFAIL: felt252 = 'Sig non-zero on failed checksig';
Expand Down
16 changes: 8 additions & 8 deletions packages/engine/src/opcodes/locktime.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ pub fn opcode_checksequenceverify<
return Result::Ok(());
}

// Prevent trigger OP_CHECKSEQUENCEVERIFY before tx version 2
let version = EngineTransactionTrait::<
T, I, O, IEngineTransactionInputTrait, IEngineTransactionOutputTrait
>::get_version(engine.transaction);
if version < 2 {
return Result::Err(Error::UNSATISFIED_LOCKTIME);
}

let transaction_input = EngineTransactionTrait::<
T, I, O, IEngineTransactionInputTrait, IEngineTransactionOutputTrait
>::get_transaction_inputs(engine.transaction)
Expand All @@ -129,14 +137,6 @@ pub fn opcode_checksequenceverify<
return Result::Err(Error::UNSATISFIED_LOCKTIME);
}

// Prevent trigger OP_CHECKSEQUENCEVERIFY before tx version 2
let version = EngineTransactionTrait::<
T, I, O, IEngineTransactionInputTrait, IEngineTransactionOutputTrait
>::get_version(engine.transaction);
if version < 2 {
return Result::Err(Error::INVALID_TX_VERSION);
}

// Mask off non-consensus bits before comparisons
let locktime_mask = SEQUENCE_LOCKTIME_IS_SECOND | SEQUENCE_LOCKTIME_MASK;
verify_locktime(
Expand Down
3 changes: 1 addition & 2 deletions packages/tests/src/tests/opcodes/test_locktime.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ fn test_opcode_checksequence_as_op_nop_fail() {
}

#[test]
#[ignore]
fn test_opcode_checksequence_tx_version_fail() {
let mut program =
"OP_DATA_4 0x40000000 OP_CHECKSEQUENCEVERIFY"; // 0x40000000 == 64 in ScriptNum
Expand All @@ -157,7 +156,7 @@ fn test_opcode_checksequence_tx_version_fail() {
// Running with tx v1
let flags: u32 = ScriptFlags::ScriptVerifyCheckSequenceVerify.into();
let mut engine = utils::test_compile_and_run_with_tx_flags_err(
program, tx, flags, Error::INVALID_TX_VERSION
program, tx, flags, Error::UNSATISFIED_LOCKTIME
);
utils::check_dstack_size(ref engine, 1);
}
Expand Down

0 comments on commit 678f4bd

Please sign in to comment.