Skip to content

Commit da3ea6f

Browse files
authored
Merge pull request #6091 from stacks-network/release/3.1.0.0.9
Merge release/3.1.0.0.9 to master
2 parents 91c18cb + cbb22d6 commit da3ea6f

Some content is hidden

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

87 files changed

+6414
-1194
lines changed

.github/workflows/clarity-js-sdk-pr.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ 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+
## [3.1.0.0.9]
9+
10+
### Added
11+
12+
- Added field `vm_error` to EventObserver transaction outputs
13+
- Added new `ValidateRejectCode` values to the `/v3/block_proposal` endpoint
14+
- Added `StateMachineUpdateContent::V1` to support a vector of `StacksTransaction` expected to be replayed in subsequent Stacks blocks
15+
- Include a reason string in the transaction receipt when a transaction is rolled back due to a post-condition. This should help users in understanding what went wrong.
16+
17+
### Changed
18+
19+
- Reduce the default `block_rejection_timeout_steps` configuration so that miners will retry faster when blocks fail to reach 70% approved or 30% rejected.
20+
- Added index for `next_ready_nakamoto_block()` which improves block processing performance.
21+
- Added a new field, `parent_burn_block_hash`, to the payload that is included in the `/new_burn_block` event observer payload.
22+
23+
### Fixed
24+
25+
- Fix regression in mock-mining, allowing the mock miner to continue mining blocks throughout a tenure instead of failing after mining the tenure change block.
26+
827
## [3.1.0.0.8]
928

1029
### Added
@@ -19,7 +38,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1938

2039
- When a miner times out waiting for signatures, it will re-propose the same block instead of building a new block ([#5877](https://github.com/stacks-network/stacks-core/pull/5877))
2140
- Improve tenure downloader trace verbosity applying proper logging level depending on the tenure state ("debug" if unconfirmed, "info" otherwise) ([#5871](https://github.com/stacks-network/stacks-core/issues/5871))
22-
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
41+
- Remove warning log about missing UTXOs when a node is configured as `miner` with `mock_mining` mode enabled ([#5841](https://github.com/stacks-network/stacks-core/issues/5841))
2342
- Deprecated the `wait_on_interim_blocks` option in the miner config file. This option is no longer needed, as the miner will always wait for interim blocks to be processed before mining a new block. To wait extra time in between blocks, use the `min_time_between_blocks_ms` option instead. ([#5979](https://github.com/stacks-network/stacks-core/pull/5979))
2443
- Added `empty_mempool_sleep_ms` to the miner config file to control the time to wait in between mining attempts when the mempool is empty. If not set, the default sleep time is 2.5s. ([#5997](https://github.com/stacks-network/stacks-core/pull/5997))
2544

CONTRIBUTING.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,31 @@ A non-exhaustive list of examples of consensus-critical changes include:
361361

362362
- Every consensus-critical change needs an integration test to verify that the feature activates only when the hard fork activates.
363363

364-
PRs must include test coverage. However, if your PR includes large tests or tests which cannot run in parallel
364+
- PRs must include test coverage. However, if your PR includes large tests or tests which cannot run in parallel
365365
(which is the default operation of the `cargo test` command), these tests should be decorated with `#[ignore]`.
366-
367366
A test should be marked `#[ignore]` if:
368367

369-
1. It does not _always_ pass `cargo test` in a vanilla environment
368+
1. It does not _always_ pass `cargo test` in a vanilla environment
370369
(i.e., it does not need to run with `--test-threads 1`).
371370

372-
2. Or, it runs for over a minute via a normal `cargo test` execution
371+
2. Or, it runs for over a minute via a normal `cargo test` execution
373372
(the `cargo test` command will warn if this is not the case).
374373

374+
- **Integration tests need to be properly tagged** using [pinny-rs](https://github.com/BitcoinL2-Labs/pinny-rs/) crate. Tagging requires two fundamental steps:
375+
1. Define allowed tags in the package `Cargo.toml` file (if needed).
376+
2. Apply relevant tags to the tests, picking from the allowed set.
377+
378+
Then it will be possible to run tests with filtering based on the tags using `cargo test` and `cargo nextest` runner.
379+
> For more information and examples on how tagging works, refer to the [pinny-rs](https://github.com/BitcoinL2-Labs/pinny-rs/) readme.
380+
381+
Below the tag set currently defined with related purpose:
382+
383+
| Tag | Description |
384+
|-----------------|----------------------------------------------|
385+
| `slow` | tests running over a minute |
386+
| `bitcoind` | tests requiring bitcoin daemon |
387+
| `flaky` | tests that exhibit flaky behavior |
388+
375389
## Formatting
376390

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

Cargo.lock

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clarity/src/vm/clarity.rs

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,30 @@ pub enum Error {
2020
Interpreter(InterpreterError),
2121
BadTransaction(String),
2222
CostError(ExecutionCost, ExecutionCost),
23-
AbortedByCallback(Option<Value>, AssetMap, Vec<StacksTransactionEvent>),
23+
AbortedByCallback {
24+
/// What the output value of the transaction would have been.
25+
/// This will be a Some for contract-calls, and None for contract initialization txs.
26+
output: Option<Value>,
27+
/// The asset map which was evaluated by the abort callback
28+
assets_modified: AssetMap,
29+
/// The events from the transaction processing
30+
tx_events: Vec<StacksTransactionEvent>,
31+
/// A human-readable explanation for aborting the transaction
32+
reason: String,
33+
},
2434
}
2535

2636
impl fmt::Display for Error {
2737
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28-
match *self {
38+
match self {
2939
Error::CostError(ref a, ref b) => {
30-
write!(f, "Cost Error: {} cost exceeded budget of {} cost", a, b)
40+
write!(f, "Cost Error: {a} cost exceeded budget of {b} cost")
3141
}
3242
Error::Analysis(ref e) => fmt::Display::fmt(e, f),
3343
Error::Parse(ref e) => fmt::Display::fmt(e, f),
34-
Error::AbortedByCallback(..) => write!(f, "Post condition aborted transaction"),
44+
Error::AbortedByCallback { reason, .. } => {
45+
write!(f, "Post condition aborted transaction: {reason}")
46+
}
3547
Error::Interpreter(ref e) => fmt::Display::fmt(e, f),
3648
Error::BadTransaction(ref s) => fmt::Display::fmt(s, f),
3749
}
@@ -42,7 +54,7 @@ impl std::error::Error for Error {
4254
fn cause(&self) -> Option<&dyn std::error::Error> {
4355
match *self {
4456
Error::CostError(ref _a, ref _b) => None,
45-
Error::AbortedByCallback(..) => None,
57+
Error::AbortedByCallback { .. } => None,
4658
Error::Analysis(ref e) => Some(e),
4759
Error::Parse(ref e) => Some(e),
4860
Error::Interpreter(ref e) => Some(e),
@@ -168,16 +180,17 @@ pub trait TransactionConnection: ClarityConnection {
168180
/// * the asset changes during `to_do` in an `AssetMap`
169181
/// * the Stacks events during the transaction
170182
///
171-
/// and a `bool` value which is `true` if the `abort_call_back` caused the changes to abort.
183+
/// and an optional string value which is the result of `abort_call_back`,
184+
/// containing a human-readable reason for aborting the transaction.
172185
///
173186
/// If `to_do` returns an `Err` variant, then the changes are aborted.
174187
fn with_abort_callback<F, A, R, E>(
175188
&mut self,
176189
to_do: F,
177190
abort_call_back: A,
178-
) -> Result<(R, AssetMap, Vec<StacksTransactionEvent>, bool), E>
191+
) -> Result<(R, AssetMap, Vec<StacksTransactionEvent>, Option<String>), E>
179192
where
180-
A: FnOnce(&AssetMap, &mut ClarityDatabase) -> bool,
193+
A: FnOnce(&AssetMap, &mut ClarityDatabase) -> Option<String>,
181194
F: FnOnce(&mut OwnedEnvironment) -> Result<(R, AssetMap, Vec<StacksTransactionEvent>), E>,
182195
E: From<InterpreterError>;
183196

@@ -283,16 +296,16 @@ pub trait TransactionConnection: ClarityConnection {
283296
.stx_transfer(from, to, amount, memo)
284297
.map_err(Error::from)
285298
},
286-
|_, _| false,
299+
|_, _| None,
287300
)
288301
.map(|(value, assets, events, _)| (value, assets, events))
289302
}
290303

291304
/// Execute a contract call in the current block.
292-
/// If an error occurs while processing the transaction, its modifications will be rolled back.
293-
/// abort_call_back is called with an AssetMap and a ClarityDatabase reference,
294-
/// if abort_call_back returns true, all modifications from this transaction will be rolled back.
295-
/// otherwise, they will be committed (though they may later be rolled back if the block itself is rolled back).
305+
/// If an error occurs while processing the transaction, its modifications will be rolled back.
306+
/// `abort_call_back` is called with an `AssetMap` and a `ClarityDatabase` reference,
307+
/// If `abort_call_back` returns `Some(reason)`, all modifications from this transaction will be rolled back.
308+
/// Otherwise, they will be committed (though they may later be rolled back if the block itself is rolled back).
296309
#[allow(clippy::too_many_arguments)]
297310
fn run_contract_call<F>(
298311
&mut self,
@@ -305,7 +318,7 @@ pub trait TransactionConnection: ClarityConnection {
305318
max_execution_time: Option<std::time::Duration>,
306319
) -> Result<(Value, AssetMap, Vec<StacksTransactionEvent>), Error>
307320
where
308-
F: FnOnce(&AssetMap, &mut ClarityDatabase) -> bool,
321+
F: FnOnce(&AssetMap, &mut ClarityDatabase) -> Option<String>,
309322
{
310323
let expr_args: Vec<_> = args
311324
.iter()
@@ -331,20 +344,25 @@ pub trait TransactionConnection: ClarityConnection {
331344
},
332345
abort_call_back,
333346
)
334-
.and_then(|(value, assets, events, aborted)| {
335-
if aborted {
336-
Err(Error::AbortedByCallback(Some(value), assets, events))
347+
.and_then(|(value, assets_modified, tx_events, reason)| {
348+
if let Some(reason) = reason {
349+
Err(Error::AbortedByCallback {
350+
output: Some(value),
351+
assets_modified,
352+
tx_events,
353+
reason,
354+
})
337355
} else {
338-
Ok((value, assets, events))
356+
Ok((value, assets_modified, tx_events))
339357
}
340358
})
341359
}
342360

343361
/// Initialize a contract in the current block.
344362
/// If an error occurs while processing the initialization, it's modifications will be rolled back.
345-
/// abort_call_back is called with an AssetMap and a ClarityDatabase reference,
346-
/// if abort_call_back returns true, all modifications from this transaction will be rolled back.
347-
/// otherwise, they will be committed (though they may later be rolled back if the block itself is rolled back).
363+
/// `abort_call_back` is called with an `AssetMap` and a `ClarityDatabase` reference,
364+
/// If `abort_call_back` returns `Some(reason)`, all modifications from this transaction will be rolled back.
365+
/// Otherwise, they will be committed (though they may later be rolled back if the block itself is rolled back).
348366
#[allow(clippy::too_many_arguments)]
349367
fn initialize_smart_contract<F>(
350368
&mut self,
@@ -357,9 +375,9 @@ pub trait TransactionConnection: ClarityConnection {
357375
max_execution_time: Option<std::time::Duration>,
358376
) -> Result<(AssetMap, Vec<StacksTransactionEvent>), Error>
359377
where
360-
F: FnOnce(&AssetMap, &mut ClarityDatabase) -> bool,
378+
F: FnOnce(&AssetMap, &mut ClarityDatabase) -> Option<String>,
361379
{
362-
let (_, asset_map, events, aborted) = self.with_abort_callback(
380+
let (_, assets_modified, tx_events, reason) = self.with_abort_callback(
363381
|vm_env| {
364382
if let Some(max_execution_time_duration) = max_execution_time {
365383
vm_env
@@ -378,10 +396,15 @@ pub trait TransactionConnection: ClarityConnection {
378396
},
379397
abort_call_back,
380398
)?;
381-
if aborted {
382-
Err(Error::AbortedByCallback(None, asset_map, events))
399+
if let Some(reason) = reason {
400+
Err(Error::AbortedByCallback {
401+
output: None,
402+
assets_modified,
403+
tx_events,
404+
reason,
405+
})
383406
} else {
384-
Ok((asset_map, events))
407+
Ok((assets_modified, tx_events))
385408
}
386409
}
387410
}

0 commit comments

Comments
 (0)