Skip to content

Commit 6c715b5

Browse files
authored
Merge pull request #5902 from hugocaillard/refactor/wasm-target-conditional-compilation
refactor: rename `clarity/canonical` cargo feature to `rusqlite`
2 parents 1f33bd0 + 07ecfbb commit 6c715b5

File tree

13 files changed

+32
-33
lines changed

13 files changed

+32
-33
lines changed

clarity/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ regex = "1"
2727
lazy_static = "1.4.0"
2828
integer-sqrt = "0.1.3"
2929
slog = { version = "2.5.2", features = [ "max_level_trace" ] }
30-
stacks_common = { package = "stacks-common", path = "../stacks-common", optional = true, default-features = false }
30+
stacks_common = { package = "stacks-common", path = "../stacks-common", default-features = false }
3131
rstest = "0.17.0"
3232
rstest_reuse = "0.5.0"
3333
hashbrown = { workspace = true }
34-
rusqlite = { workspace = true, optional = true}
34+
rusqlite = { workspace = true, optional = true }
3535

3636
[dependencies.serde_json]
3737
version = "1.0"
@@ -49,11 +49,11 @@ mutants = "0.0.3"
4949
# criterion = "0.3"
5050

5151
[features]
52-
default = ["canonical"]
53-
canonical = ["rusqlite", "stacks_common/canonical"]
52+
default = ["rusqlite"]
5453
developer-mode = ["stacks_common/developer-mode"]
5554
slog_json = ["stacks_common/slog_json"]
56-
testing = ["canonical"]
55+
rusqlite = ["stacks_common/rusqlite", "dep:rusqlite"]
56+
testing = []
5757
devtools = []
5858
rollback_value_check = []
5959
disable-costs = []

clarity/src/vm/analysis/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ use self::type_checker::v2_1::TypeChecker as TypeChecker2_1;
3636
pub use self::types::{AnalysisPass, ContractAnalysis};
3737
use crate::vm::ast::{build_ast_with_rules, ASTRules};
3838
use crate::vm::costs::LimitedCostTracker;
39-
#[cfg(feature = "canonical")]
39+
#[cfg(feature = "rusqlite")]
4040
use crate::vm::database::MemoryBackingStore;
4141
use crate::vm::database::STORE_CONTRACT_SRC_INTERFACE;
4242
use crate::vm::representations::SymbolicExpression;
4343
use crate::vm::types::{QualifiedContractIdentifier, TypeSignature};
4444
use crate::vm::ClarityVersion;
4545

4646
/// Used by CLI tools like the docs generator. Not used in production
47-
#[cfg(feature = "canonical")]
47+
#[cfg(feature = "rusqlite")]
4848
pub fn mem_type_check(
4949
snippet: &str,
5050
version: ClarityVersion,

clarity/src/vm/database/clarity_store.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
#[cfg(feature = "canonical")]
17+
#[cfg(feature = "rusqlite")]
1818
use rusqlite::Connection;
1919
use stacks_common::types::chainstate::{StacksBlockId, TrieHash};
2020
use stacks_common::util::hash::{hex_bytes, to_hex, Sha512Trunc256Sum};
2121

2222
use crate::vm::analysis::AnalysisDatabase;
2323
use crate::vm::contexts::GlobalContext;
24-
#[cfg(feature = "canonical")]
2524
use crate::vm::database::{
2625
ClarityDatabase, ClarityDeserializable, ClaritySerializable, NULL_BURN_STATE_DB, NULL_HEADER_DB,
2726
};
@@ -85,7 +84,7 @@ pub trait ClarityBackingStore {
8584
fn get_open_chain_tip_height(&mut self) -> u32;
8685
fn get_open_chain_tip(&mut self) -> StacksBlockId;
8786

88-
#[cfg(feature = "canonical")]
87+
#[cfg(feature = "rusqlite")]
8988
fn get_side_store(&mut self) -> &Connection;
9089

9190
fn get_cc_special_cases_handler(&self) -> Option<SpecialCaseHandler> {
@@ -222,7 +221,7 @@ impl ClarityBackingStore for NullBackingStore {
222221
panic!("NullBackingStore can't retrieve data")
223222
}
224223

225-
#[cfg(feature = "canonical")]
224+
#[cfg(feature = "rusqlite")]
226225
fn get_side_store(&mut self) -> &Connection {
227226
panic!("NullBackingStore has no side store")
228227
}

clarity/src/vm/database/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
#[cfg(feature = "canonical")]
16+
#[cfg(feature = "rusqlite")]
1717
pub use sqlite::MemoryBackingStore;
1818

1919
pub use self::clarity_db::{
@@ -22,7 +22,7 @@ pub use self::clarity_db::{
2222
};
2323
pub use self::clarity_store::{ClarityBackingStore, SpecialCaseHandler};
2424
pub use self::key_value_wrapper::{RollbackWrapper, RollbackWrapperPersistedLog};
25-
#[cfg(feature = "canonical")]
25+
#[cfg(feature = "rusqlite")]
2626
pub use self::sqlite::SqliteConnection;
2727
pub use self::structures::{
2828
ClarityDeserializable, ClaritySerializable, DataMapMetadata, DataVariableMetadata,
@@ -32,6 +32,6 @@ pub use self::structures::{
3232
pub mod clarity_db;
3333
pub mod clarity_store;
3434
mod key_value_wrapper;
35-
#[cfg(feature = "canonical")]
35+
#[cfg(feature = "rusqlite")]
3636
pub mod sqlite;
3737
mod structures;

clarity/src/vm/docs/contracts.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use hashbrown::{HashMap, HashSet};
44
use stacks_common::consts::CHAIN_ID_TESTNET;
55
use stacks_common::types::StacksEpochId;
66

7-
#[cfg(feature = "canonical")]
7+
#[cfg(feature = "rusqlite")]
88
use crate::vm::analysis::mem_type_check;
99
use crate::vm::analysis::ContractAnalysis;
1010
use crate::vm::ast::{build_ast_with_rules, ASTRules};
1111
use crate::vm::contexts::GlobalContext;
1212
use crate::vm::costs::LimitedCostTracker;
13-
#[cfg(feature = "canonical")]
13+
#[cfg(feature = "rusqlite")]
1414
use crate::vm::database::MemoryBackingStore;
1515
use crate::vm::docs::{get_input_type_string, get_output_type_string, get_signature};
1616
use crate::vm::types::{FunctionType, QualifiedContractIdentifier, Value};
@@ -63,7 +63,7 @@ fn make_func_ref(func_name: &str, func_type: &FunctionType, description: &str) -
6363
}
6464
}
6565

66-
#[cfg(feature = "canonical")]
66+
#[cfg(feature = "rusqlite")]
6767
#[allow(clippy::expect_used)]
6868
fn get_constant_value(var_name: &str, contract_content: &str) -> Value {
6969
let to_eval = format!("{}\n{}", contract_content, var_name);
@@ -72,7 +72,7 @@ fn get_constant_value(var_name: &str, contract_content: &str) -> Value {
7272
.expect("BUG: failed to return constant value")
7373
}
7474

75-
#[cfg(feature = "canonical")]
75+
#[cfg(feature = "rusqlite")]
7676
fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
7777
let contract_id = QualifiedContractIdentifier::transient();
7878
let mut contract_context = ContractContext::new(contract_id.clone(), ClarityVersion::Clarity2);
@@ -99,7 +99,7 @@ fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
9999
})
100100
}
101101

102-
#[cfg(feature = "canonical")]
102+
#[cfg(feature = "rusqlite")]
103103
#[allow(clippy::expect_used)]
104104
pub fn make_docs(
105105
content: &str,
@@ -185,7 +185,7 @@ pub fn make_docs(
185185

186186
/// Produce a set of documents for multiple contracts, supplied as a list of `(contract_name, contract_content)` pairs,
187187
/// and a map from `contract_name` to corresponding `ContractSupportDocs`
188-
#[cfg(feature = "canonical")]
188+
#[cfg(feature = "rusqlite")]
189189
pub fn produce_docs_refs<A: AsRef<str>, B: AsRef<str>>(
190190
contracts: &[(A, B)],
191191
support_docs: &HashMap<&str, ContractSupportDocs>,

clarity/src/vm/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use std::{error, fmt};
1818

19-
#[cfg(feature = "canonical")]
19+
#[cfg(feature = "rusqlite")]
2020
use rusqlite::Error as SqliteError;
2121
use serde_json::Error as SerdeJSONErr;
2222
use stacks_common::types::chainstate::BlockHeaderHash;
@@ -57,7 +57,7 @@ pub enum InterpreterError {
5757
UninitializedPersistedVariable,
5858
FailedToConstructAssetTable,
5959
FailedToConstructEventBatch,
60-
#[cfg(feature = "canonical")]
60+
#[cfg(feature = "rusqlite")]
6161
SqliteError(IncomparableError<SqliteError>),
6262
BadFileName,
6363
FailedToCreateDataDirectory,
@@ -241,7 +241,7 @@ mod test {
241241
fn error_formats() {
242242
let t = "(/ 10 0)";
243243
let expected = "DivisionByZero
244-
Stack Trace:
244+
Stack Trace:
245245
_native_:native_div
246246
";
247247

clarity/src/vm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub mod coverage;
4242

4343
pub mod events;
4444

45-
#[cfg(feature = "canonical")]
45+
#[cfg(feature = "rusqlite")]
4646
pub mod tooling;
4747

4848
#[cfg(any(test, feature = "testing"))]

stacks-common/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ features = ["std"]
6565
rand_core = { workspace = true }
6666

6767
[features]
68-
default = ["canonical", "developer-mode"]
69-
canonical = ["rusqlite"]
68+
default = ["developer-mode"]
7069
developer-mode = []
7170
slog_json = ["slog-json"]
72-
testing = ["canonical"]
71+
rusqlite = ["dep:rusqlite"]
72+
testing = []
7373
serde = []
7474
bech32_std = []
7575
bech32_strict = []

stacks-common/src/bitvec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
#[cfg(feature = "canonical")]
17+
#[cfg(feature = "rusqlite")]
1818
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef};
1919
use serde::{Deserialize, Serialize};
2020

@@ -106,7 +106,7 @@ impl<'de, const MAX_SIZE: u16> Deserialize<'de> for BitVec<MAX_SIZE> {
106106
}
107107
}
108108

109-
#[cfg(feature = "canonical")]
109+
#[cfg(feature = "rusqlite")]
110110
impl<const MAX_SIZE: u16> FromSql for BitVec<MAX_SIZE> {
111111
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self> {
112112
let bytes = hex_bytes(value.as_str()?).map_err(|e| FromSqlError::Other(Box::new(e)))?;
@@ -115,7 +115,7 @@ impl<const MAX_SIZE: u16> FromSql for BitVec<MAX_SIZE> {
115115
}
116116
}
117117

118-
#[cfg(feature = "canonical")]
118+
#[cfg(feature = "rusqlite")]
119119
impl<const MAX_SIZE: u16> ToSql for BitVec<MAX_SIZE> {
120120
fn to_sql(&self) -> rusqlite::Result<ToSqlOutput<'_>> {
121121
let hex = bytes_to_hex(self.serialize_to_vec().as_slice());

stacks-common/src/deps_common/bitcoin/util/hash.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ impl_array_newtype!(Ripemd160Hash, u8, 20);
5050
/// A Bitcoin hash160, 20-bytes, computed from x as RIPEMD160(SHA256(x))
5151
pub struct Hash160([u8; 20]);
5252
impl_array_newtype!(Hash160, u8, 20);
53-
impl_byte_array_rusqlite_only!(Hash160);
5453

5554
impl Hash160 {
5655
/// Convert the Hash160 inner bytes to a non-prefixed hex string

0 commit comments

Comments
 (0)