Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions clarity-types/src/types/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ impl TypeSignature {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => self.admits_type_v2_1(other),
| StacksEpochId::Epoch33
| StacksEpochId::Epoch34 => self.admits_type_v2_1(other),
StacksEpochId::Epoch10 => Err(CommonCheckErrorKind::Expects(
"epoch 1.0 not supported".into(),
)),
Expand Down Expand Up @@ -669,7 +670,8 @@ impl TypeSignature {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => self.canonicalize_v2_1(),
| StacksEpochId::Epoch33
| StacksEpochId::Epoch34 => self.canonicalize_v2_1(),
}
}

Expand Down Expand Up @@ -1008,7 +1010,8 @@ impl TypeSignature {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => Self::least_supertype_v2_1(a, b),
| StacksEpochId::Epoch33
| StacksEpochId::Epoch34 => Self::least_supertype_v2_1(a, b),
StacksEpochId::Epoch10 => Err(CommonCheckErrorKind::Expects(
"epoch 1.0 not supported".into(),
)),
Expand Down
3 changes: 2 additions & 1 deletion clarity/src/vm/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ pub fn run_analysis(
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => {
| StacksEpochId::Epoch33
| StacksEpochId::Epoch34 => {
TypeChecker2_1::run_pass(&epoch, &mut contract_analysis, db, build_type_map)
}
StacksEpochId::Epoch10 => {
Expand Down
10 changes: 7 additions & 3 deletions clarity/src/vm/analysis/type_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl FunctionType {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => self.check_args_2_1(accounting, args, clarity_version),
| StacksEpochId::Epoch33
| StacksEpochId::Epoch34 => self.check_args_2_1(accounting, args, clarity_version),
StacksEpochId::Epoch10 => {
Err(StaticCheckErrorKind::Expects("Epoch10 is not supported".into()).into())
}
Expand All @@ -73,7 +74,8 @@ impl FunctionType {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => {
| StacksEpochId::Epoch33
| StacksEpochId::Epoch34 => {
self.check_args_by_allowing_trait_cast_2_1(db, clarity_version, func_args)
}
StacksEpochId::Epoch10 => {
Expand All @@ -94,6 +96,8 @@ fn is_reserved_word_v3(word: &str) -> bool {
pub fn is_reserved_word(word: &str, version: ClarityVersion) -> bool {
match version {
ClarityVersion::Clarity1 | ClarityVersion::Clarity2 => false,
ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => is_reserved_word_v3(word),
ClarityVersion::Clarity3 | ClarityVersion::Clarity4 | ClarityVersion::Clarity5 => {
is_reserved_word_v3(word)
}
}
}
13 changes: 7 additions & 6 deletions clarity/src/vm/analysis/type_checker/v2_1/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ impl TraitContext {
pub fn new(clarity_version: ClarityVersion) -> TraitContext {
match clarity_version {
ClarityVersion::Clarity1 => Self::Clarity1(HashMap::new()),
ClarityVersion::Clarity2 | ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => {
Self::Clarity2 {
defined: HashSet::new(),
all: HashMap::new(),
}
}
ClarityVersion::Clarity2
| ClarityVersion::Clarity3
| ClarityVersion::Clarity4
| ClarityVersion::Clarity5 => Self::Clarity2 {
defined: HashSet::new(),
all: HashMap::new(),
},
}
}

Expand Down
10 changes: 8 additions & 2 deletions clarity/src/vm/analysis/type_checker/v2_1/tests/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,10 @@ fn clarity_trait_experiments_downcast_literal_2(
})
.unwrap_err();
match version {
ClarityVersion::Clarity2 | ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => {
ClarityVersion::Clarity2
| ClarityVersion::Clarity3
| ClarityVersion::Clarity4
| ClarityVersion::Clarity5 => {
assert!(err.starts_with("ExpectedCallableType(PrincipalType)"))
}
ClarityVersion::Clarity1 => {
Expand Down Expand Up @@ -2749,7 +2752,10 @@ fn clarity_trait_experiments_trait_cast_incompatible(
assert!(err.starts_with("TypeError(CallableType(Trait(TraitIdentifier"))
}
}
ClarityVersion::Clarity2 | ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => {
ClarityVersion::Clarity2
| ClarityVersion::Clarity3
| ClarityVersion::Clarity4
| ClarityVersion::Clarity5 => {
assert!(err.starts_with("IncompatibleTrait"))
}
}
Expand Down
26 changes: 13 additions & 13 deletions clarity/src/vm/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ mod test {
write_length: u64::MAX,
runtime: 1,
};
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::Epoch33, limit);
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::latest(), limit);

let err = build_ast(
&QualifiedContractIdentifier::transient(),
"(define-constant my-const u1)",
&mut tracker,
ClarityVersion::Clarity4,
StacksEpochId::Epoch33,
ClarityVersion::latest(),
StacksEpochId::latest(),
)
.unwrap_err();

Expand All @@ -488,14 +488,14 @@ mod test {
write_length: u64::MAX,
runtime: expected_ast_parse_cost,
};
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::Epoch33, limit);
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::latest(), limit);

let err = build_ast(
&QualifiedContractIdentifier::transient(),
"(define-constant a 0)(define-constant b 1)", // no dependency = 0 graph edge
&mut tracker,
ClarityVersion::Clarity4,
StacksEpochId::Epoch33,
ClarityVersion::latest(),
StacksEpochId::latest(),
)
.expect_err("Expected parse error, but found success!");

Expand All @@ -520,14 +520,14 @@ mod test {
write_length: u64::MAX,
runtime: expected_ast_parse_cost,
};
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::Epoch33, limit);
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::latest(), limit);

let err = build_ast(
&QualifiedContractIdentifier::transient(),
"(define-constant a 0)(define-constant b a)", // 1 dependency = 1 graph edge
&mut tracker,
ClarityVersion::Clarity4,
StacksEpochId::Epoch33,
ClarityVersion::latest(),
StacksEpochId::latest(),
)
.expect_err("Expected parse error, but found success!");

Expand All @@ -553,8 +553,8 @@ mod test {
&QualifiedContractIdentifier::transient(),
&contract,
&mut (),
ClarityVersion::Clarity4,
StacksEpochId::Epoch33,
ClarityVersion::latest(),
StacksEpochId::latest(),
)
.expect_err("Expected parse error, but found success!");

Expand All @@ -575,8 +575,8 @@ mod test {
&QualifiedContractIdentifier::transient(),
&contract,
&mut (),
ClarityVersion::Clarity4,
StacksEpochId::Epoch33,
ClarityVersion::latest(),
StacksEpochId::latest(),
)
.expect_err("Expected parse error, but found success!");

Expand Down
2 changes: 1 addition & 1 deletion clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ impl LimitedCostTracker {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32 => COSTS_3_NAME.to_string(),
StacksEpochId::Epoch33 => COSTS_4_NAME.to_string(),
StacksEpochId::Epoch33 | StacksEpochId::Epoch34 => COSTS_4_NAME.to_string(),
};
Ok(result)
}
Expand Down
2 changes: 2 additions & 0 deletions clarity/src/vm/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ macro_rules! switch_on_global_epoch {
StacksEpochId::Epoch32 => $Epoch205Version(args, env, context),
// Note: We reuse 2.05 for 3.3.
StacksEpochId::Epoch33 => $Epoch205Version(args, env, context),
// Note: We reuse 2.05 for 3.4.
StacksEpochId::Epoch34 => $Epoch205Version(args, env, context),
}
}
};
Expand Down
18 changes: 3 additions & 15 deletions clarity/src/vm/test_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,10 @@ pub const TEST_BURN_STATE_DB_21: UnitTestBurnStateDB = UnitTestBurnStateDB {
};

pub fn generate_test_burn_state_db(epoch_id: StacksEpochId) -> UnitTestBurnStateDB {
match epoch_id {
StacksEpochId::Epoch10 => {
panic!("Epoch 1.0 not testable");
}
StacksEpochId::Epoch20
| StacksEpochId::Epoch2_05
| StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31
| StacksEpochId::Epoch32
| StacksEpochId::Epoch33 => UnitTestBurnStateDB { epoch_id },
if matches!(epoch_id, StacksEpochId::Epoch10) {
panic!("Epoch 1.0 not testable");
}
UnitTestBurnStateDB { epoch_id }
}

pub fn execute(s: &str) -> Value {
Expand Down
6 changes: 3 additions & 3 deletions clarity/src/vm/tests/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ fn test_to_ascii(version: ClarityVersion, epoch: StacksEpochId) {
}

fn evaluate_to_ascii(snippet: &str) -> Value {
execute_versioned(snippet, ClarityVersion::Clarity4)
execute_versioned(snippet, ClarityVersion::latest())
.unwrap_or_else(|e| panic!("Execution failed for snippet `{snippet}`: {e:?}"))
.unwrap_or_else(|| panic!("Execution returned no value for snippet `{snippet}`"))
}
Expand Down Expand Up @@ -690,7 +690,7 @@ proptest! {
let evaluation = evaluate_to_ascii(&snippet);

let ascii_snippet = &utf8_string[1..]; // Remove the u prefix
let expected_inner = execute_versioned(ascii_snippet, ClarityVersion::Clarity4)
let expected_inner = execute_versioned(ascii_snippet, ClarityVersion::latest())
.unwrap_or_else(|e| panic!("Execution failed for `{ascii_snippet}`: {e:?}"))
.unwrap_or_else(|| panic!("Execution returned no value for `{ascii_snippet}`"));
let expected = Value::okay(expected_inner).expect("response wrapping should succeed");
Expand All @@ -703,7 +703,7 @@ proptest! {
let snippet = format!("(to-ascii? {utf8_string})");
let evaluation = evaluate_to_ascii(&snippet);

let literal_value = execute_versioned(&utf8_string, ClarityVersion::Clarity4)
let literal_value = execute_versioned(&utf8_string, ClarityVersion::latest())
.unwrap_or_else(|e| panic!("Execution failed for literal `{utf8_string}`: {e:?}"))
.unwrap_or_else(|| panic!("Execution returned no value for literal `{utf8_string}`"));

Expand Down
Loading
Loading