Skip to content

Commit dc66d07

Browse files
author
Aaron Blankstein
authored
Merge pull request #2490 from blockstack/fix/analysis-db-storage
Fix: improved analysis db storage
2 parents 7b61252 + a18792f commit dc66d07

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ 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 [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.8] - 2021-03-02
9+
10+
This is a hotfix release for improved handling of static analysis storage and
11+
improved `at-block` behavior. The chainstate directory of 2.0.8 is compatible with
12+
the 2.0.7 chainstate.
13+
14+
## Fixed
15+
16+
- Improved static analysis storage
17+
- `at-block` behavior in `clarity-cli` and unit tests (no changes in `stacks-node`
18+
behavior).
19+
820
## [2.0.7] - 2021-02-26
921

1022
This is an emergency hotfix that prevents the node from accidentally deleting

src/chainstate/stacks/db/transactions.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,13 @@ impl StacksChainState {
10391039
.expect("BUG: total block cost decreased");
10401040

10411041
let (asset_map, events) = match initialize_resp {
1042-
Ok(x) => x,
1042+
Ok(x) => {
1043+
// store analysis -- if this fails, then the have some pretty bad problems
1044+
clarity_tx
1045+
.save_analysis(&contract_id, &contract_analysis)
1046+
.expect("FATAL: failed to store contract analysis");
1047+
x
1048+
}
10431049
Err(e) => match handle_clarity_runtime_error(e) {
10441050
ClarityRuntimeTxError::Acceptable { error, err_type } => {
10451051
info!("Smart-contract processed with {}", err_type;
@@ -1076,11 +1082,6 @@ impl StacksChainState {
10761082
},
10771083
};
10781084

1079-
// store analysis -- if this fails, then the have some pretty bad problems
1080-
clarity_tx
1081-
.save_analysis(&contract_id, &contract_analysis)
1082-
.expect("FATAL: failed to store contract analysis");
1083-
10841085
let receipt = StacksTransactionReceipt::from_smart_contract(
10851086
tx.clone(),
10861087
events,

src/vm/database/key_value_wrapper.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,14 @@ impl<'a> RollbackWrapper<'a> {
310310
bhh: StacksBlockId,
311311
query_pending_data: bool,
312312
) -> Result<StacksBlockId> {
313-
self.query_pending_data = query_pending_data;
314-
self.store.set_block_hash(bhh)
313+
self.store.set_block_hash(bhh).and_then(|x| {
314+
// use and_then so that query_pending_data is only set once set_block_hash succeeds
315+
// this doesn't matter in practice, because a set_block_hash failure always aborts
316+
// the transaction with a runtime error (destroying its environment), but it's much
317+
// better practice to do this, especially if the abort behavior changes in the future.
318+
self.query_pending_data = query_pending_data;
319+
Ok(x)
320+
})
315321
}
316322

317323
/// this function will only return commitment proofs for values _already_ materialized

0 commit comments

Comments
 (0)