Skip to content

Commit 170e403

Browse files
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into feat/variable-lookup-by-ref
2 parents 9c8b966 + 962e7ab commit 170e403

File tree

52 files changed

+6550
-3636
lines changed

Some content is hidden

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

52 files changed

+6550
-3636
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,21 @@ jobs:
234234
- create-cache
235235
- check-release
236236
uses: ./.github/workflows/epoch-tests.yml
237+
238+
## Trigger Codecov report manually once all tests are done
239+
## This is done in concert with codecov.yml having notify: manual_trigger: true set
240+
## See: https://docs.codecov.com/docs/notifications#preventing-notifications-until-youre-ready-to-send-notifications
241+
trigger-codecov-report:
242+
if: ${{ always() && !cancelled() }}
243+
name: Trigger Codecov Report
244+
runs-on: ubuntu-latest
245+
needs:
246+
- stacks-core-tests
247+
- bitcoin-tests
248+
- p2p-tests
249+
- epoch-tests
250+
steps:
251+
- name: Codecov Send Notifications
252+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
253+
with:
254+
run_command: "send-notifications"

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ 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]
8+
## [3.3.0.0.6]
99

1010
### Added
1111

@@ -16,13 +16,15 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1616
- Added `marf_compress` as a node configuration parameter to enable MARF compression feature ([#6811](https://github.com/stacks-network/stacks-core/pull/6811))
1717
- Effective in epoch 3.4 `contract-call?`s can accept a constant as the contract to be called
1818
- Added post-condition enhancements for epoch 3.4 (SIP-040): `Originator` post-condition mode (`0x03`) and NFT `MAY SEND` condition code (`0x12`), including serialization support and epoch-gated validation/enforcement.
19+
- Disabled `at-block` starting from Epoch 3.4 (see SIP-042). New contracts referencing `at-block` are rejected during static analysis. Existing contracts that invoke it will fail at runtime with an `AtBlockUnavailable` error.
1920

2021
### Fixed
2122

2223
- Improved the cost-tracking for `from-consensus-buff?`, effective in epoch 3.4, so that when an empty buffer is passed, users will see a `none` result, rather than a confusing runtime error.
2324
- Resolved several cases where a mock-miner would stop mining
2425
- /v2/pox endpoint now returns the `pox_ustx_threshold` stored in the reward set instead of a live computed value, which incorrectly accounts for STX locked during the prepare phase, after the reward set has been set.
2526
- Signer protocol version negotiation now properly handles downgrades based on majority consensus, not just upgrades
27+
- The sortition DB now tracks canonical Stacks tip by its burn view, allowing it to recover from a chain freeze if the Bitcoin block upon which the ongoing tenure is based is orphened before the last tenure block is processed.
2628

2729
### Changed
2830

clarity-types/src/errors/analysis.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ pub enum StaticCheckErrorKind {
498498
WriteAttemptedInReadOnly,
499499
/// `at-block` closure must be read-only but contains write operations.
500500
AtBlockClosureMustBeReadOnly,
501+
/// `at-block` is not available in this epoch.
502+
AtBlockUnavailable,
501503

502504
// contract post-conditions
503505
/// Post-condition expects a list of asset allowances but received invalid input.
@@ -611,13 +613,25 @@ pub enum RuntimeCheckErrorKind {
611613
/// Referenced function is not defined in the current scope.
612614
/// The `String` wraps the non-existent function name.
613615
UndefinedFunction(String),
616+
/// `at-block` is not available in this epoch.
617+
AtBlockUnavailable,
614618

615619
// Argument counts
616620
/// Incorrect number of arguments provided to a function.
617621
/// The first `usize` represents the expected count, and the second represents the actual count.
618622
IncorrectArgumentCount(usize, usize),
619623

620624
// Traits
625+
/// Referenced trait is not defined or cannot be found.
626+
/// The `String` wraps the non-existent trait name.
627+
/// This is only reachable at runtime via contracts deployed with Clarity 1 as its
628+
/// static analysis is not as strict as later clarity versions.
629+
TraitReferenceUnknown(String),
630+
/// Referenced method does not exist in the specified trait.
631+
/// The first `String` wraps the trait name, and the second wraps the method name.
632+
/// This is only reachable at runtime via contracts deployed with Clarity 1 as its
633+
/// static analysis is not as strict as later clarity versions.
634+
TraitMethodUnknown(String, String),
621635
/// Invalid implementation of a trait method.
622636
/// The first `String` wraps the trait name, and the second wraps the method name.
623637
BadTraitImplementation(String, String),
@@ -1175,6 +1189,7 @@ impl DiagnosableError for StaticCheckErrorKind {
11751189
StaticCheckErrorKind::TooManyFunctionParameters(found, allowed) => format!("too many function parameters specified: found {found}, the maximum is {allowed}"),
11761190
StaticCheckErrorKind::WriteAttemptedInReadOnly => "expecting read-only statements, detected a writing operation".into(),
11771191
StaticCheckErrorKind::AtBlockClosureMustBeReadOnly => "(at-block ...) closures expect read-only statements, but detected a writing operation".into(),
1192+
StaticCheckErrorKind::AtBlockUnavailable => "(at-block ...) is not available in this epoch".into(),
11781193
StaticCheckErrorKind::BadTokenName => "expecting an token name as an argument".into(),
11791194
StaticCheckErrorKind::DefineNFTBadSignature => "(define-asset ...) expects an asset name and an asset identifier type signature as arguments".into(),
11801195
StaticCheckErrorKind::NoSuchNFT(asset_name) => format!("tried to use asset function with a undefined asset ('{asset_name}')"),

clarity/fuzz/fuzz_targets/fuzz_sanitize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub fn strict_admits(me: &TypeSignature, x: &ClarityValue) -> Result<bool, Runti
245245
}
246246
TypeSignature::CallableType(_)
247247
| TypeSignature::ListUnionType(_)
248-
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::Unreachable(
248+
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::TraitReferenceUnknown(
249249
"Trait reference unknown".into(),
250250
)),
251251
}

clarity/fuzz/fuzz_targets/fuzz_value_sanitize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub fn strict_admits(me: &TypeSignature, x: &ClarityValue) -> Result<bool, Runti
251251
}
252252
TypeSignature::CallableType(_)
253253
| TypeSignature::ListUnionType(_)
254-
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::Unreachable(
254+
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::TraitReferenceUnknown(
255255
"Trait reference unknown".into(),
256256
)),
257257
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ fn check_special_at_block(
132132
context: &TypingContext,
133133
) -> Result<TypeSignature, StaticCheckError> {
134134
check_argument_count(2, args)?;
135+
if !checker.epoch.supports_at_block() {
136+
return Err(StaticCheckErrorKind::AtBlockUnavailable.into());
137+
}
135138
checker.type_check_expects(&args[0], context, &TypeSignature::BUFFER_32)?;
136139
checker.type_check(&args[1], context)
137140
}

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,51 @@ fn test_at_block() {
927927
for (good_test, expected) in good.iter() {
928928
assert_eq!(
929929
expected,
930-
&format!("{}", type_check_helper(good_test).unwrap())
930+
&format!(
931+
"{}",
932+
type_check_helper_version(
933+
good_test,
934+
ClarityVersion::Clarity4,
935+
StacksEpochId::Epoch33
936+
)
937+
.unwrap()
938+
)
931939
);
932940
}
933941

934942
for (bad_test, expected) in bad.iter() {
935-
assert_eq!(*expected, *type_check_helper(bad_test).unwrap_err().err);
943+
assert_eq!(
944+
*expected,
945+
*type_check_helper_version(bad_test, ClarityVersion::Clarity4, StacksEpochId::Epoch33)
946+
.unwrap_err()
947+
.err
948+
);
949+
}
950+
951+
assert_eq!(
952+
StaticCheckErrorKind::AtBlockUnavailable,
953+
*type_check_helper_version(
954+
"(at-block (sha256 u0) u1)",
955+
ClarityVersion::Clarity4,
956+
StacksEpochId::Epoch34
957+
)
958+
.unwrap_err()
959+
.err
960+
);
961+
962+
let mut versions_gt_clarity4 = ClarityVersion::ALL.to_vec();
963+
versions_gt_clarity4.retain(|version| *version > ClarityVersion::Clarity4);
964+
for version in versions_gt_clarity4 {
965+
assert_eq!(
966+
StaticCheckErrorKind::UnknownFunction("at-block".to_string()),
967+
*type_check_helper_version(
968+
"(at-block (sha256 u0) u1)",
969+
version,
970+
StacksEpochId::latest()
971+
)
972+
.unwrap_err()
973+
.err
974+
);
936975
}
937976
}
938977

clarity/src/vm/callables.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,16 @@ impl DefinedFunction {
342342
let trait_name = trait_identifier.name.to_string();
343343
let constraining_trait = contract_defining_trait
344344
.lookup_trait_definition(&trait_name)
345-
.ok_or(RuntimeCheckErrorKind::Unreachable(format!(
346-
"Trait reference unknown: {trait_name}"
347-
)))?;
345+
.ok_or(RuntimeCheckErrorKind::TraitReferenceUnknown(
346+
trait_name.to_string(),
347+
))?;
348348
let expected_sig =
349349
constraining_trait
350350
.get(&self.name)
351-
.ok_or(RuntimeCheckErrorKind::Unreachable(format!(
352-
"Trait method unknown: {trait_name}.{}",
353-
self.name
354-
)))?;
351+
.ok_or(RuntimeCheckErrorKind::TraitMethodUnknown(
352+
trait_name.to_string(),
353+
self.name.to_string(),
354+
))?;
355355

356356
let args = self.arg_types.to_vec();
357357
if !expected_sig.check_args_trait_compliance(epoch, args)? {

clarity/src/vm/docs/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,9 @@ const AT_BLOCK: SpecialAPI = SpecialAPI {
14701470
snippet: "at-block ${1:id-header-hash} ${2:expr}",
14711471
output_type: "A",
14721472
signature: "(at-block id-block-hash expr)",
1473-
description: "The `at-block` function evaluates the expression `expr` _as if_ it were evaluated at the end of the
1473+
description: "Removed in Epoch 3.4 (see SIP-042).
1474+
1475+
The `at-block` function evaluates the expression `expr` _as if_ it were evaluated at the end of the
14741476
block indicated by the _block-hash_ argument. The `expr` closure must be read-only.
14751477
14761478
Note: The block identifying hash must be a hash returned by the `id-header-hash` block information

clarity/src/vm/functions/database.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ pub fn special_contract_call(
188188
.into());
189189
}
190190

191+
// If this check succeeds, the subsequent trait reference and method checks cannot fail
191192
function_to_check.check_trait_expectations(
192193
exec_state.epoch(),
193194
&contract_context_defining_trait,
@@ -545,6 +546,9 @@ pub fn special_at_block(
545546
invoke_ctx: &InvocationContext,
546547
context: &LocalContext,
547548
) -> Result<Value, VmExecutionError> {
549+
if !exec_state.epoch().supports_at_block() {
550+
return Err(RuntimeCheckErrorKind::AtBlockUnavailable.into());
551+
}
548552
check_argument_count(2, args)?;
549553

550554
runtime_cost(ClarityCostFunction::AtBlock, exec_state, 0)?;

0 commit comments

Comments
 (0)