Skip to content

Commit b792655

Browse files
authored
Merge pull request #6802 from brice-stacks/feat/clarity-5
feat: add epoch 3.4 and Clarity5
2 parents 50c1927 + 7794552 commit b792655

File tree

246 files changed

+62600
-187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+62600
-187
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Setup for epoch 3.4 and Clarity version 5. Epoch 3.4 is currently set to activate at Bitcoin height 3,400,000 (very far in the future) until an activation height is selected. Clarity will activate with epoch 3.4.
13+
814
## [3.3.0.0.4]
915

1016
### Added

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,25 @@ A test should be marked `#[ignore]` if:
386386
| `bitcoind` | tests requiring bitcoin daemon |
387387
| `flaky` | tests that exhibit flaky behavior |
388388

389+
- **Consensus tests use `insta` to record snapshots** and then compare results across runs to ensure that there are no accidental consensus changes.
390+
1. Install `insta`:
391+
392+
```bash
393+
cargo install cargo-insta
394+
```
395+
396+
2. Run snapshot tests with `insta`:
397+
398+
```bash
399+
cargo insta test -p stackslib --unreferenced=delete -- chainstate::tests --include-ignored
400+
```
401+
402+
3. Review/accept snapshot updates:
403+
404+
```bash
405+
cargo insta review
406+
```
407+
389408
## Formatting
390409

391410
PRs will be checked against `rustfmt` and will _fail_ if not properly formatted.

clarity-types/src/types/signatures.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ impl TypeSignature {
455455
| StacksEpochId::Epoch30
456456
| StacksEpochId::Epoch31
457457
| StacksEpochId::Epoch32
458-
| StacksEpochId::Epoch33 => self.admits_type_v2_1(other),
458+
| StacksEpochId::Epoch33
459+
| StacksEpochId::Epoch34 => self.admits_type_v2_1(other),
459460
StacksEpochId::Epoch10 => Err(ClarityTypeError::UnsupportedEpoch(*epoch)),
460461
}
461462
}
@@ -663,7 +664,8 @@ impl TypeSignature {
663664
| StacksEpochId::Epoch30
664665
| StacksEpochId::Epoch31
665666
| StacksEpochId::Epoch32
666-
| StacksEpochId::Epoch33 => self.canonicalize_v2_1(),
667+
| StacksEpochId::Epoch33
668+
| StacksEpochId::Epoch34 => self.canonicalize_v2_1(),
667669
}
668670
}
669671

@@ -1002,7 +1004,8 @@ impl TypeSignature {
10021004
| StacksEpochId::Epoch30
10031005
| StacksEpochId::Epoch31
10041006
| StacksEpochId::Epoch32
1005-
| StacksEpochId::Epoch33 => Self::least_supertype_v2_1(a, b),
1007+
| StacksEpochId::Epoch33
1008+
| StacksEpochId::Epoch34 => Self::least_supertype_v2_1(a, b),
10061009
StacksEpochId::Epoch10 => Err(ClarityTypeError::UnsupportedEpoch(*epoch)),
10071010
}
10081011
}

clarity/src/vm/analysis/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ pub fn run_analysis(
150150
| StacksEpochId::Epoch30
151151
| StacksEpochId::Epoch31
152152
| StacksEpochId::Epoch32
153-
| StacksEpochId::Epoch33 => {
153+
| StacksEpochId::Epoch33
154+
| StacksEpochId::Epoch34 => {
154155
TypeChecker2_1::run_pass(&epoch, &mut contract_analysis, db, build_type_map)
155156
}
156157
StacksEpochId::Epoch10 => {

clarity/src/vm/analysis/type_checker/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ impl FunctionType {
4747
| StacksEpochId::Epoch30
4848
| StacksEpochId::Epoch31
4949
| StacksEpochId::Epoch32
50-
| StacksEpochId::Epoch33 => self.check_args_2_1(accounting, args, clarity_version),
50+
| StacksEpochId::Epoch33
51+
| StacksEpochId::Epoch34 => self.check_args_2_1(accounting, args, clarity_version),
5152
StacksEpochId::Epoch10 => Err(StaticCheckErrorKind::ExpectsRejectable(
5253
"Epoch10 is not supported".into(),
5354
)
@@ -74,7 +75,8 @@ impl FunctionType {
7475
| StacksEpochId::Epoch30
7576
| StacksEpochId::Epoch31
7677
| StacksEpochId::Epoch32
77-
| StacksEpochId::Epoch33 => {
78+
| StacksEpochId::Epoch33
79+
| StacksEpochId::Epoch34 => {
7880
self.check_args_by_allowing_trait_cast_2_1(db, clarity_version, func_args)
7981
}
8082
StacksEpochId::Epoch10 => Err(StaticCheckErrorKind::ExpectsRejectable(
@@ -96,6 +98,8 @@ fn is_reserved_word_v3(word: &str) -> bool {
9698
pub fn is_reserved_word(word: &str, version: ClarityVersion) -> bool {
9799
match version {
98100
ClarityVersion::Clarity1 | ClarityVersion::Clarity2 => false,
99-
ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => is_reserved_word_v3(word),
101+
ClarityVersion::Clarity3 | ClarityVersion::Clarity4 | ClarityVersion::Clarity5 => {
102+
is_reserved_word_v3(word)
103+
}
100104
}
101105
}

clarity/src/vm/analysis/type_checker/v2_1/contexts.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ impl TraitContext {
4040
pub fn new(clarity_version: ClarityVersion) -> TraitContext {
4141
match clarity_version {
4242
ClarityVersion::Clarity1 => Self::Clarity1(HashMap::new()),
43-
ClarityVersion::Clarity2 | ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => {
44-
Self::Clarity2 {
45-
defined: HashSet::new(),
46-
all: HashMap::new(),
47-
}
48-
}
43+
ClarityVersion::Clarity2
44+
| ClarityVersion::Clarity3
45+
| ClarityVersion::Clarity4
46+
| ClarityVersion::Clarity5 => Self::Clarity2 {
47+
defined: HashSet::new(),
48+
all: HashMap::new(),
49+
},
4950
}
5051
}
5152

clarity/src/vm/analysis/type_checker/v2_1/tests/contracts.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,7 +2545,10 @@ fn clarity_trait_experiments_downcast_literal_2(
25452545
})
25462546
.unwrap_err();
25472547
match version {
2548-
ClarityVersion::Clarity2 | ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => {
2548+
ClarityVersion::Clarity2
2549+
| ClarityVersion::Clarity3
2550+
| ClarityVersion::Clarity4
2551+
| ClarityVersion::Clarity5 => {
25492552
assert!(err.starts_with("ExpectedCallableType(PrincipalType)"))
25502553
}
25512554
ClarityVersion::Clarity1 => {
@@ -2747,7 +2750,10 @@ fn clarity_trait_experiments_trait_cast_incompatible(
27472750
assert!(err.starts_with("TypeError(CallableType(Trait(TraitIdentifier"))
27482751
}
27492752
}
2750-
ClarityVersion::Clarity2 | ClarityVersion::Clarity3 | ClarityVersion::Clarity4 => {
2753+
ClarityVersion::Clarity2
2754+
| ClarityVersion::Clarity3
2755+
| ClarityVersion::Clarity4
2756+
| ClarityVersion::Clarity5 => {
27512757
assert!(err.starts_with("IncompatibleTrait"))
27522758
}
27532759
}

clarity/src/vm/ast/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,14 @@ mod test {
478478
write_length: u64::MAX,
479479
runtime: 1,
480480
};
481-
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::Epoch33, limit);
481+
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::latest(), limit);
482482

483483
let err = build_ast(
484484
&QualifiedContractIdentifier::transient(),
485485
"(define-constant my-const u1)",
486486
&mut tracker,
487-
ClarityVersion::Clarity4,
488-
StacksEpochId::Epoch33,
487+
ClarityVersion::latest(),
488+
StacksEpochId::latest(),
489489
)
490490
.unwrap_err();
491491

@@ -508,14 +508,14 @@ mod test {
508508
write_length: u64::MAX,
509509
runtime: expected_ast_parse_cost,
510510
};
511-
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::Epoch33, limit);
511+
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::latest(), limit);
512512

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

@@ -540,14 +540,14 @@ mod test {
540540
write_length: u64::MAX,
541541
runtime: expected_ast_parse_cost,
542542
};
543-
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::Epoch33, limit);
543+
let mut tracker = LimitedCostTracker::new_with_limit(StacksEpochId::latest(), limit);
544544

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

@@ -573,8 +573,8 @@ mod test {
573573
&QualifiedContractIdentifier::transient(),
574574
&contract,
575575
&mut (),
576-
ClarityVersion::Clarity4,
577-
StacksEpochId::Epoch33,
576+
ClarityVersion::latest(),
577+
StacksEpochId::latest(),
578578
)
579579
.expect_err("Expected parse error, but found success!");
580580

@@ -595,8 +595,8 @@ mod test {
595595
&QualifiedContractIdentifier::transient(),
596596
&contract,
597597
&mut (),
598-
ClarityVersion::Clarity4,
599-
StacksEpochId::Epoch33,
598+
ClarityVersion::latest(),
599+
StacksEpochId::latest(),
600600
)
601601
.expect_err("Expected parse error, but found success!");
602602

clarity/src/vm/costs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ impl LimitedCostTracker {
851851
| StacksEpochId::Epoch30
852852
| StacksEpochId::Epoch31
853853
| StacksEpochId::Epoch32 => COSTS_3_NAME.to_string(),
854-
StacksEpochId::Epoch33 => COSTS_4_NAME.to_string(),
854+
StacksEpochId::Epoch33 | StacksEpochId::Epoch34 => COSTS_4_NAME.to_string(),
855855
};
856856
Ok(result)
857857
}

clarity/src/vm/functions/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ macro_rules! switch_on_global_epoch {
6161
StacksEpochId::Epoch32 => $Epoch205Version(args, env, context),
6262
// Note: We reuse 2.05 for 3.3.
6363
StacksEpochId::Epoch33 => $Epoch205Version(args, env, context),
64+
// Note: We reuse 2.05 for 3.4.
65+
StacksEpochId::Epoch34 => $Epoch205Version(args, env, context),
6466
}
6567
}
6668
};

0 commit comments

Comments
 (0)