@@ -1560,13 +1560,14 @@ impl StacksChainState {
15601560
15611561 // what version of Clarity did the transaction caller want? And, is it valid now?
15621562 let clarity_version = StacksChainState :: get_tx_clarity_version ( clarity_block, tx) ?;
1563- if clarity_version == ClarityVersion :: Clarity2 {
1564- // requires 2.1 and higher
1565- if clarity_block. get_epoch ( ) < StacksEpochId :: Epoch21 {
1566- let msg = format ! ( "Invalid transaction {}: asks for Clarity2, but not in Stacks epoch 2.1 or later" , tx. txid( ) ) ;
1567- info ! ( "{}" , & msg) ;
1568- return Err ( Error :: InvalidStacksTransaction ( msg, false ) ) ;
1569- }
1563+ if clarity_version > ClarityVersion :: default_for_epoch ( epoch) {
1564+ let msg = format ! (
1565+ "Invalid transaction {}: asks for {clarity_version}, but current epoch {epoch} only supports up to {}" ,
1566+ tx. txid( ) ,
1567+ ClarityVersion :: default_for_epoch( epoch)
1568+ ) ;
1569+ info ! ( "{msg}" ) ;
1570+ return Err ( Error :: InvalidStacksTransaction ( msg, false ) ) ;
15701571 }
15711572
15721573 let mut transaction = clarity_block. connection ( ) . start_transaction_processing ( ) ;
@@ -8668,7 +8669,9 @@ pub mod test {
86688669 if let Err ( Error :: InvalidStacksTransaction ( msg, ..) ) =
86698670 StacksChainState :: process_transaction ( & mut conn, & smart_contract_v2, false , None )
86708671 {
8671- assert ! ( msg. find( "not in Stacks epoch 2.1 or later" ) . is_some( ) ) ;
8672+ assert ! ( msg
8673+ . find( "asks for Clarity 2, but current epoch 2.05 only supports up to Clarity 1" )
8674+ . is_some( ) ) ;
86728675 } else {
86738676 panic ! ( "FATAL: did not recieve the appropriate error in processing a clarity2 tx in pre-2.1 epoch" ) ;
86748677 }
0 commit comments