Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Refactor of Clarity storage (iteration 1) #4437

Draft
wants to merge 24 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
65a6dc8
working on introducing new storage for clarity contracts and analyses
cylewitruk Feb 15, 2024
8a45a36
further work on improving clarity contract storage
cylewitruk Feb 16, 2024
fa05257
rename of put/get to put_data/get_data for clarity. further work on c…
cylewitruk Feb 16, 2024
dc6e953
added 'fake' and implementations for faking structs for tests
cylewitruk Feb 17, 2024
3e2c045
further work on fakes for signatures/representations
cylewitruk Feb 17, 2024
ddb0c98
further work on tests for new db paths
cylewitruk Feb 17, 2024
a1b5012
fixed bug with pending contracts in kv store, all clarity tests passi…
cylewitruk Feb 17, 2024
dca20a2
logging tweaks
cylewitruk Feb 18, 2024
d05f850
cargo fmt
cylewitruk Feb 18, 2024
a0fc6cd
refactoring of results/errors after rebase on next
cylewitruk Feb 18, 2024
59b65fd
trying to fix failing tests
cylewitruk Feb 19, 2024
2a8883b
fixing issues with failing tests
cylewitruk Feb 20, 2024
47b9f95
revert cargo.toml release profile settings
cylewitruk Feb 20, 2024
a23a34d
refactoring of contract analysis storage
cylewitruk Feb 25, 2024
546afe2
working on fixes for failing tests
cylewitruk Feb 25, 2024
bad0886
wip: all tests pass
cylewitruk Feb 26, 2024
a85eac7
wip: documentation
cylewitruk Feb 26, 2024
f23e001
wip: documentation
cylewitruk Feb 26, 2024
dff3c68
wip: documentation
cylewitruk Feb 26, 2024
97e8089
improvement: use a more performant option for checking contract exist…
cylewitruk Feb 27, 2024
2e851ff
chore: remove unneeded parameter from
cylewitruk Feb 27, 2024
2a35ea1
wip: rename functions with '2' suffix, cargo fmt and other small things
cylewitruk Feb 27, 2024
e4fd282
chore: restore changed logging levels
cylewitruk Feb 28, 2024
ed6615e
chore: regenerate broken cargo.lock after rebase
cylewitruk Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
416 changes: 283 additions & 133 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion clarity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,26 @@ stacks_common = { package = "stacks-common", path = "../stacks-common" }
rstest = "0.17.0"
rstest_reuse = "0.5.0"
hashbrown = { workspace = true }
lru = "0.12.2"
lz4_flex = "0.11.2"
speedy = "0.8.7"
fake = { version = "2.9.2", features = ["derive"] }

[dependencies.serde_json]
version = "1.0"
features = ["arbitrary_precision", "unbounded_depth"]

[dependencies.rusqlite]
version = "=0.24.2"
features = ["blob", "serde_json", "i128_blob", "bundled", "trace"]
features = ["blob", "serde_json", "i128_blob", "bundled", "trace", "array"]

[dependencies.time]
version = "0.2.23"
features = ["std"]

[dev-dependencies]
assert-json-diff = "1.0.0"
randomizer = "0.1.2"
# a nightly rustc regression (35dbef235 2021-03-02) prevents criterion from compiling
# but it isn't necessary for tests: only benchmarks. therefore, commenting out for now.
# criterion = "0.3"
Expand Down
239 changes: 0 additions & 239 deletions clarity/src/vm/analysis/analysis_db.rs

This file was deleted.

1 change: 0 additions & 1 deletion clarity/src/vm/analysis/arithmetic_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use hashbrown::HashMap;
pub use super::errors::{
check_argument_count, check_arguments_at_least, CheckError, CheckErrors, CheckResult,
};
use super::AnalysisDatabase;
use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis};
use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed};
use crate::vm::functions::{tuples, NativeFunctions};
Expand Down
25 changes: 13 additions & 12 deletions clarity/src/vm/analysis/contract_interface_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use std::collections::{BTreeMap, BTreeSet};

use speedy::{Readable, Writable};
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::types::ContractAnalysis;
Expand Down Expand Up @@ -105,21 +106,21 @@ pub fn build_contract_interface(
Ok(contract_interface)
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub enum ContractInterfaceFunctionAccess {
private,
public,
read_only,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceTupleEntryType {
pub name: String,
#[serde(rename = "type")]
pub type_f: ContractInterfaceAtomType,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub enum ContractInterfaceAtomType {
none,
int128,
Expand Down Expand Up @@ -151,12 +152,12 @@ pub enum ContractInterfaceAtomType {
trait_reference,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceFungibleTokens {
pub name: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceNonFungibleTokens {
pub name: String,
#[serde(rename = "type")]
Expand Down Expand Up @@ -228,7 +229,7 @@ impl ContractInterfaceAtomType {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceFunctionArg {
pub name: String,
#[serde(rename = "type")]
Expand All @@ -247,13 +248,13 @@ impl ContractInterfaceFunctionArg {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceFunctionOutput {
#[serde(rename = "type")]
pub type_f: ContractInterfaceAtomType,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceFunction {
pub name: String,
pub access: ContractInterfaceFunctionAccess,
Expand Down Expand Up @@ -301,13 +302,13 @@ impl ContractInterfaceFunction {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub enum ContractInterfaceVariableAccess {
constant,
variable,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceVariable {
pub name: String,
#[serde(rename = "type")]
Expand Down Expand Up @@ -353,7 +354,7 @@ impl ContractInterfaceVariable {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterfaceMap {
pub name: String,
pub key: ContractInterfaceAtomType,
Expand All @@ -374,7 +375,7 @@ impl ContractInterfaceMap {
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Writable, Readable)]
pub struct ContractInterface {
pub functions: Vec<ContractInterfaceFunction>,
pub variables: Vec<ContractInterfaceVariable>,
Expand Down