Skip to content

Commit 19c4b0e

Browse files
committed
Merge remote-tracking branch 'stacks-network/develop' into feat/shadow-marf
2 parents fba48a0 + 87c4373 commit 19c4b0e

File tree

118 files changed

+5463
-3234
lines changed

Some content is hidden

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

118 files changed

+5463
-3234
lines changed

.github/workflows/clippy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ jobs:
4242
- name: Clippy
4343
id: clippy
4444
run: cargo clippy-stacks
45+
46+
- name: Clippy Stackslib
47+
id: clippy-stackslib
48+
run: cargo clippy-stackslib

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1212
- Renamed `clarity-serialization` to `clarity-types`.
1313
- Add `stackerdb_timeout_secs` to miner config for limiting duration of StackerDB HTTP requests.
1414
- When determining a global transaction replay set, the state evaluator now uses a longest-common-prefix algorithm to find a replay set in the case where a single replay set has less than 70% of signer weight.
15-
- New endpoint /v3/tenures/blocks/ allowing retrieving the list of stacks blocks from a burn block
15+
- New endpoints /v3/tenures/blocks/, /v3/tenures/blocks/hash, /v3/tenures/blocks/height allowing retrieving the list of stacks blocks from a burn block
1616
- Creates epoch 3.3 and costs-4 in preparation for a hardfork to activate Clarity 4
1717
- Adds support for new Clarity 4 builtins (not activated until epoch 3.3):
1818
- `contract-hash?`
19+
- `current-contract`
20+
- `block-time`
1921
- `to-ascii?`
2022
- Added `contract_cost_limit_percentage` to the miner config file — sets the percentage of a block’s execution cost at which, if a large non-boot contract call would cause a BlockTooBigError, the miner will stop adding further non-boot contract calls and only include STX transfers and boot contract calls for the remainder of the block.
2123

@@ -25,8 +27,9 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
2527
expressive (#6337)
2628
- Removed affirmation maps logic throughout, upgrading chainstate DB schema to 11 and burnchain DB schema to 3 (#6314)
2729

28-
### Changed
30+
### Fixed
2931

32+
- When running `stacks-inspect decode-tx`, print the correct version of the address (mainnet or testnet) based on the transaction passed in
3033
- When a contract deploy is analyzed, it will no longer throw a `CostError` when the contract contains an undefined top-level variable. Instead, it will throw a `UndefinedVariable` error.
3134

3235
## [3.2.0.0.1]

CONTRIBUTING.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ For an example of this process, see PRs
5656
test, module, function, etc.), each should be documented according
5757
to our [coding guidelines](#Coding-Guidelines).
5858

59-
> [*] The Changelog focuses on product changes. A "major change" refers to updates that have a direct impact on the end user, such as introducing new features, modifying existing functionality, or optimizing runtime performance.
59+
> [*] The Changelog focuses on product changes. A "major change" refers to updates that have a direct impact on the end user, such as introducing new features, modifying existing functionality, or optimizing runtime performance.
6060
On the other hand, changes that do not need to be reflected in the Changelog include code refactoring, writing tests, or automating processes, as these do not directly affect the user experience.
6161

6262
## Git Commit Messages
@@ -374,10 +374,10 @@ A test should be marked `#[ignore]` if:
374374
- **Integration tests need to be properly tagged** using [pinny-rs](https://github.com/BitcoinL2-Labs/pinny-rs/) crate. Tagging requires two fundamental steps:
375375
1. Define allowed tags in the package `Cargo.toml` file (if needed).
376376
2. Apply relevant tags to the tests, picking from the allowed set.
377-
377+
378378
Then it will be possible to run tests with filtering based on the tags using `cargo test` and `cargo nextest` runner.
379379
> For more information and examples on how tagging works, refer to the [pinny-rs](https://github.com/BitcoinL2-Labs/pinny-rs/) readme.
380-
380+
381381
Below the tag set currently defined with related purpose:
382382

383383
| Tag | Description |
@@ -406,16 +406,26 @@ cargo fmt-stacks
406406

407407
## Clippy Warnings
408408

409-
PRs will be checked against `clippy` and will _fail_ if any clippy warnings are generated.
410-
Unfortunately, not all existing clippy warnings have been addressed throughout stacks-core, so arguments must be passed via the command line.
411-
Therefore, we handle `clippy` configurations using a Cargo alias: `cargo clippy-stacks`
409+
All PRs are checked with `clippy`, and the CI will **fail** if any warnings are raised.
410+
Because not all existing clippy warnings in `stacks-core` have been addressed, we use Cargo aliases to standardize how clippy is run across different parts of the codebase.
411+
412+
Two commands are available:
412413

413-
You can check what warnings need to be addressed locally via:
414+
- `cargo clippy-stacks`
415+
Runs clippy across the core packages of the repository (e.g. `stx-genesis`, `clarity`, `stacks-signer`, etc.).
416+
417+
- `cargo clippy-stackslib`
418+
Runs clippy specifically on the `stackslib` package, with a different configuration.
419+
420+
To check warnings locally, run:
414421

415422
```bash
416423
cargo clippy-stacks
424+
cargo clippy-stackslib
417425
```
418426

427+
Make sure both commands pass before opening a pull request.
428+
419429
## Comments
420430

421431
Comments are very important for the readability and correctness of the codebase. The purpose of comments is:
@@ -491,7 +501,7 @@ impl<'a, 'b> ReadOnlyChecker<'a, 'b> {
491501
/// - Returns CheckErrors::WriteAttemptedInReadOnly if there is a read-only
492502
/// violation, i.e. if some function marked read-only attempts to modify
493503
/// the chainstate.
494-
pub fn run(&mut self, contract_analysis: &ContractAnalysis) -> CheckResult<()>
504+
pub fn run(&mut self, contract_analysis: &ContractAnalysis) -> Result<(), CheckError>
495505
```
496506

497507
This comment is considered positive because it explains the contract of the function in pseudo-code. Someone who understands the constructs mentioned could, e.g., write a test for this method from this description.

Cargo.lock

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clarity-types/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ lazy_static = { workspace = true }
1414
regex = { version = "1", default-features = false }
1515
rusqlite = { workspace = true, optional = true }
1616
serde = { workspace = true }
17-
serde_json = { version = "1.0", default-features = false }
17+
serde_json = { version = "1.0", default-features = false, optional = true }
1818
serde_derive = { workspace = true }
1919
slog = { workspace = true }
2020
stacks_common = { package = "stacks-common", path = "../stacks-common", default-features = false }
@@ -28,7 +28,7 @@ default = []
2828
testing = []
2929
developer-mode = ["stacks_common/developer-mode"]
3030
slog_json = ["stacks_common/slog_json"]
31-
rusqlite = ["stacks_common/rusqlite", "dep:rusqlite"]
31+
rusqlite = ["stacks_common/rusqlite", "dep:rusqlite", "dep:serde_json"]
3232

3333
# Wasm-specific features for easier configuration
3434
wasm-web = ["stacks_common/wasm-web"]

clarity-types/src/errors/analysis.rs

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use crate::execution_cost::ExecutionCost;
2121
use crate::representations::SymbolicExpression;
2222
use crate::types::{TraitIdentifier, TupleTypeSignature, TypeSignature, Value};
2323

24-
pub type CheckResult<T> = Result<T, CheckError>;
25-
2624
/// What kind of syntax binding was found to be in error?
2725
#[derive(Debug, PartialEq, Clone, Copy)]
2826
pub enum SyntaxBindingErrorType {
@@ -164,50 +162,44 @@ pub enum CheckErrors {
164162
// match errors
165163
BadMatchOptionSyntax(Box<CheckErrors>),
166164
BadMatchResponseSyntax(Box<CheckErrors>),
167-
BadMatchInput(TypeSignature),
165+
BadMatchInput(Box<TypeSignature>),
168166

169167
// list typing errors
170-
UnknownListConstructionFailure,
171168
ListTypesMustMatch,
172169
ConstructedListTooLarge,
173170

174171
// simple type expectation mismatch
175-
TypeError(TypeSignature, TypeSignature),
176-
TypeLiteralError(TypeSignature, TypeSignature),
177-
TypeValueError(TypeSignature, Value),
172+
TypeError(Box<TypeSignature>, Box<TypeSignature>),
173+
TypeValueError(Box<TypeSignature>, Box<Value>),
178174

179-
NoSuperType(TypeSignature, TypeSignature),
180175
InvalidTypeDescription,
181176
UnknownTypeName(String),
182177

183178
// union type mismatch
184-
UnionTypeError(Vec<TypeSignature>, TypeSignature),
185-
UnionTypeValueError(Vec<TypeSignature>, Value),
186-
187-
ExpectedLiteral,
188-
ExpectedOptionalType(TypeSignature),
189-
ExpectedResponseType(TypeSignature),
190-
ExpectedOptionalOrResponseType(TypeSignature),
191-
ExpectedOptionalValue(Value),
192-
ExpectedResponseValue(Value),
193-
ExpectedOptionalOrResponseValue(Value),
179+
UnionTypeError(Vec<TypeSignature>, Box<TypeSignature>),
180+
UnionTypeValueError(Vec<TypeSignature>, Box<Value>),
181+
182+
ExpectedOptionalType(Box<TypeSignature>),
183+
ExpectedResponseType(Box<TypeSignature>),
184+
ExpectedOptionalOrResponseType(Box<TypeSignature>),
185+
ExpectedOptionalValue(Box<Value>),
186+
ExpectedResponseValue(Box<Value>),
187+
ExpectedOptionalOrResponseValue(Box<Value>),
194188
CouldNotDetermineResponseOkType,
195189
CouldNotDetermineResponseErrType,
196190
CouldNotDetermineSerializationType,
197191
UncheckedIntermediaryResponses,
198-
ExpectedContractPrincipalValue(Value),
192+
ExpectedContractPrincipalValue(Box<Value>),
199193

200194
CouldNotDetermineMatchTypes,
201195
CouldNotDetermineType,
202196

203197
// Checker runtime failures
204198
TypeAlreadyAnnotatedFailure,
205-
TypeAnnotationExpectedFailure,
206199
CheckerImplementationFailure,
207200

208201
// Assets
209202
BadTokenName,
210-
DefineFTBadSignature,
211203
DefineNFTBadSignature,
212204
NoSuchNFT(String),
213205
NoSuchFT(String),
@@ -220,7 +212,7 @@ pub enum CheckErrors {
220212

221213
// tuples
222214
BadTupleFieldName,
223-
ExpectedTuple(TypeSignature),
215+
ExpectedTuple(Box<TypeSignature>),
224216
NoSuchTupleField(String, TupleTypeSignature),
225217
EmptyTuplesNotAllowed,
226218
BadTupleConstruction(String),
@@ -236,9 +228,9 @@ pub enum CheckErrors {
236228
DefineFunctionBadSignature,
237229
BadFunctionName,
238230
BadMapTypeDefinition,
239-
PublicFunctionMustReturnResponse(TypeSignature),
231+
PublicFunctionMustReturnResponse(Box<TypeSignature>),
240232
DefineVariableBadSignature,
241-
ReturnTypesMustMatch(TypeSignature, TypeSignature),
233+
ReturnTypesMustMatch(Box<TypeSignature>, Box<TypeSignature>),
242234

243235
CircularReference(Vec<String>),
244236

@@ -248,7 +240,7 @@ pub enum CheckErrors {
248240
PublicFunctionNotReadOnly(String, String),
249241
ContractAlreadyExists(String),
250242
ContractCallExpectName,
251-
ExpectedCallableType(TypeSignature),
243+
ExpectedCallableType(Box<TypeSignature>),
252244

253245
// get-block-info? errors
254246
NoSuchBlockInfoProperty(String),
@@ -266,7 +258,7 @@ pub enum CheckErrors {
266258
// expect a function, or applying a function to a list
267259
NonFunctionApplication,
268260
ExpectedListApplication,
269-
ExpectedSequence(TypeSignature),
261+
ExpectedSequence(Box<TypeSignature>),
270262
MaxLengthOverflow,
271263

272264
// let syntax
@@ -283,10 +275,9 @@ pub enum CheckErrors {
283275
RequiresAtLeastArguments(usize, usize),
284276
RequiresAtMostArguments(usize, usize),
285277
IncorrectArgumentCount(usize, usize),
286-
IfArmsMustMatch(TypeSignature, TypeSignature),
287-
MatchArmsMustMatch(TypeSignature, TypeSignature),
288-
DefaultTypesMustMatch(TypeSignature, TypeSignature),
289-
TooManyExpressions,
278+
IfArmsMustMatch(Box<TypeSignature>, Box<TypeSignature>),
279+
MatchArmsMustMatch(Box<TypeSignature>, Box<TypeSignature>),
280+
DefaultTypesMustMatch(Box<TypeSignature>, Box<TypeSignature>),
290281
IllegalOrUnknownFunctionApplication(String),
291282
UnknownFunction(String),
292283

@@ -295,15 +286,14 @@ pub enum CheckErrors {
295286
TraitReferenceUnknown(String),
296287
TraitMethodUnknown(String, String),
297288
ExpectedTraitIdentifier,
298-
ImportTraitBadSignature,
299289
TraitReferenceNotAllowed,
300290
BadTraitImplementation(String, String),
301291
DefineTraitBadSignature,
302292
DefineTraitDuplicateMethod(String),
303293
UnexpectedTraitOrFieldReference,
304294
TraitBasedContractCallInReadOnly,
305295
ContractOfExpectsTrait,
306-
IncompatibleTrait(TraitIdentifier, TraitIdentifier),
296+
IncompatibleTrait(Box<TraitIdentifier>, Box<TraitIdentifier>),
307297

308298
// strings
309299
InvalidCharactersDetected,
@@ -321,7 +311,7 @@ pub enum CheckErrors {
321311

322312
#[derive(Debug, PartialEq)]
323313
pub struct CheckError {
324-
pub err: CheckErrors,
314+
pub err: Box<CheckErrors>,
325315
pub expressions: Option<Vec<SymbolicExpression>>,
326316
pub diagnostic: Diagnostic,
327317
}
@@ -341,7 +331,7 @@ impl CheckError {
341331
pub fn new(err: CheckErrors) -> CheckError {
342332
let diagnostic = Diagnostic::err(&err);
343333
CheckError {
344-
err,
334+
err: Box::new(err),
345335
expressions: None,
346336
diagnostic,
347337
}
@@ -456,7 +446,6 @@ impl From<CheckErrors> for String {
456446
}
457447
}
458448

459-
#[allow(clippy::result_large_err)]
460449
pub fn check_argument_count<T>(expected: usize, args: &[T]) -> Result<(), CheckErrors> {
461450
if args.len() != expected {
462451
Err(CheckErrors::IncorrectArgumentCount(expected, args.len()))
@@ -465,7 +454,6 @@ pub fn check_argument_count<T>(expected: usize, args: &[T]) -> Result<(), CheckE
465454
}
466455
}
467456

468-
#[allow(clippy::result_large_err)]
469457
pub fn check_arguments_at_least<T>(expected: usize, args: &[T]) -> Result<(), CheckErrors> {
470458
if args.len() < expected {
471459
Err(CheckErrors::RequiresAtLeastArguments(expected, args.len()))
@@ -474,7 +462,6 @@ pub fn check_arguments_at_least<T>(expected: usize, args: &[T]) -> Result<(), Ch
474462
}
475463
}
476464

477-
#[allow(clippy::result_large_err)]
478465
pub fn check_arguments_at_most<T>(expected: usize, args: &[T]) -> Result<(), CheckErrors> {
479466
if args.len() > expected {
480467
Err(CheckErrors::RequiresAtMostArguments(expected, args.len()))
@@ -501,7 +488,6 @@ fn formatted_expected_types(expected_types: &[TypeSignature]) -> String {
501488
impl DiagnosableError for CheckErrors {
502489
fn message(&self) -> String {
503490
match &self {
504-
CheckErrors::ExpectedLiteral => "expected a literal argument".into(),
505491
CheckErrors::SupertypeTooLarge => "supertype of two types is too large".into(),
506492
CheckErrors::Expects(s) => format!("unexpected interpreter behavior: {s}"),
507493
CheckErrors::BadMatchOptionSyntax(source) =>
@@ -512,7 +498,6 @@ impl DiagnosableError for CheckErrors {
512498
source.message()),
513499
CheckErrors::BadMatchInput(t) =>
514500
format!("match requires an input of either a response or optional, found input: '{t}'"),
515-
CheckErrors::TypeAnnotationExpectedFailure => "analysis expected type to already be annotated for expression".into(),
516501
CheckErrors::CostOverflow => "contract execution cost overflowed cost counter".into(),
517502
CheckErrors::CostBalanceExceeded(a, b) => format!("contract execution cost exceeded budget: {a:?} > {b:?}"),
518503
CheckErrors::MemoryBalanceExceeded(a, b) => format!("contract execution cost exceeded memory budget: {a:?} > {b:?}"),
@@ -523,12 +508,9 @@ impl DiagnosableError for CheckErrors {
523508
CheckErrors::ValueOutOfBounds => "created a type which value size was out of defined bounds".into(),
524509
CheckErrors::TypeSignatureTooDeep => "created a type which was deeper than maximum allowed type depth".into(),
525510
CheckErrors::ExpectedName => "expected a name argument to this function".into(),
526-
CheckErrors::NoSuperType(a, b) => format!("unable to create a supertype for the two types: '{a}' and '{b}'"),
527-
CheckErrors::UnknownListConstructionFailure => "invalid syntax for list definition".into(),
528511
CheckErrors::ListTypesMustMatch => "expecting elements of same type in a list".into(),
529512
CheckErrors::ConstructedListTooLarge => "reached limit of elements in a sequence".into(),
530513
CheckErrors::TypeError(expected_type, found_type) => format!("expecting expression of type '{expected_type}', found '{found_type}'"),
531-
CheckErrors::TypeLiteralError(expected_type, found_type) => format!("expecting a literal of type '{expected_type}', found '{found_type}'"),
532514
CheckErrors::TypeValueError(expected_type, found_value) => format!("expecting expression of type '{expected_type}', found '{found_value}'"),
533515
CheckErrors::UnionTypeError(expected_types, found_type) => format!("expecting expression of type {}, found '{}'", formatted_expected_types(expected_types), found_type),
534516
CheckErrors::UnionTypeValueError(expected_types, found_type) => format!("expecting expression of type {}, found '{}'", formatted_expected_types(expected_types), found_type),
@@ -593,21 +575,18 @@ impl DiagnosableError for CheckErrors {
593575
CheckErrors::IfArmsMustMatch(type_1, type_2) => format!("expression types returned by the arms of 'if' must match (got '{type_1}' and '{type_2}')"),
594576
CheckErrors::MatchArmsMustMatch(type_1, type_2) => format!("expression types returned by the arms of 'match' must match (got '{type_1}' and '{type_2}')"),
595577
CheckErrors::DefaultTypesMustMatch(type_1, type_2) => format!("expression types passed in 'default-to' must match (got '{type_1}' and '{type_2}')"),
596-
CheckErrors::TooManyExpressions => "reached limit of expressions".into(),
597578
CheckErrors::IllegalOrUnknownFunctionApplication(function_name) => format!("use of illegal / unresolved function '{function_name}"),
598579
CheckErrors::UnknownFunction(function_name) => format!("use of unresolved function '{function_name}'"),
599580
CheckErrors::TraitBasedContractCallInReadOnly => "use of trait based contract calls are not allowed in read-only context".into(),
600581
CheckErrors::WriteAttemptedInReadOnly => "expecting read-only statements, detected a writing operation".into(),
601582
CheckErrors::AtBlockClosureMustBeReadOnly => "(at-block ...) closures expect read-only statements, but detected a writing operation".into(),
602583
CheckErrors::BadTokenName => "expecting an token name as an argument".into(),
603-
CheckErrors::DefineFTBadSignature => "(define-token ...) expects a token name as an argument".into(),
604584
CheckErrors::DefineNFTBadSignature => "(define-asset ...) expects an asset name and an asset identifier type signature as arguments".into(),
605585
CheckErrors::NoSuchNFT(asset_name) => format!("tried to use asset function with a undefined asset ('{asset_name}')"),
606586
CheckErrors::NoSuchFT(asset_name) => format!("tried to use token function with a undefined token ('{asset_name}')"),
607587
CheckErrors::NoSuchTrait(contract_name, trait_name) => format!("use of unresolved trait {contract_name}.{trait_name}"),
608588
CheckErrors::TraitReferenceUnknown(trait_name) => format!("use of undeclared trait <{trait_name}>"),
609589
CheckErrors::TraitMethodUnknown(trait_name, func_name) => format!("method '{func_name}' unspecified in trait <{trait_name}>"),
610-
CheckErrors::ImportTraitBadSignature => "(use-trait ...) expects a trait name and a trait identifier".into(),
611590
CheckErrors::BadTraitImplementation(trait_name, func_name) => format!("invalid signature for method '{func_name}' regarding trait's specification <{trait_name}>"),
612591
CheckErrors::ExpectedTraitIdentifier => "expecting expression of type trait identifier".into(),
613592
CheckErrors::UnexpectedTraitOrFieldReference => "unexpected use of trait reference or field".into(),

0 commit comments

Comments
 (0)