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

feat: run clarity-wasm in a separate session #1330

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 47 additions & 2 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use clarity_repl::clarity::vm::analysis::AnalysisDatabase;
use clarity_repl::clarity::vm::costs::LimitedCostTracker;
use clarity_repl::clarity::vm::types::QualifiedContractIdentifier;
use clarity_repl::clarity::ClarityVersion;
use clarity_repl::frontend::terminal::print_clarity_wasm_warning;
use clarity_repl::repl::diagnostic::output_diagnostic;
use clarity_repl::repl::{ClarityCodeSource, ClarityContract, ContractDeployer, DEFAULT_EPOCH};
use clarity_repl::{analysis, repl, Terminal};
Expand Down Expand Up @@ -397,6 +398,9 @@ struct Console {
conflicts_with = "use_on_disk_deployment_plan"
)]
pub use_computed_deployment_plan: bool,
/// Prevent the Clarity Wasm preview from running in parallel of the Clarity interpreter
#[clap(long = "disable-clarity-wasm")]
pub disable_clarity_wasm: bool,
}

#[derive(Parser, PartialEq, Clone, Debug)]
Expand Down Expand Up @@ -1022,9 +1026,50 @@ pub fn main() {
std::process::exit(1);
}

Terminal::load(artifacts.session)
if cmd.disable_clarity_wasm {
Terminal::load(artifacts.session, None)
} else {
let mut manifest_wasm = manifest.clone();
manifest_wasm.repl_settings.clarity_wasm_mode = true;
let (_, _, artifacts_wasm) = load_deployment_and_artifacts_or_exit(
&manifest_wasm,
&cmd.deployment_plan_path,
cmd.use_on_disk_deployment_plan,
cmd.use_computed_deployment_plan,
);
if artifacts.success != artifacts_wasm.success {
for contract in deployment.contracts.keys() {
let empty_diag = vec![];
let diag = artifacts
.diags
.get(contract)
.unwrap_or(empty_diag.as_ref());
let diag_wasm = artifacts_wasm
.diags
.get(contract)
.unwrap_or(empty_diag.as_ref());

if diag.len() != diag_wasm.len() {
dbg!(&diag);
dbg!(&diag_wasm);
}
}
print_clarity_wasm_warning();
}

Terminal::load(artifacts.session, Some(artifacts_wasm.session))
}
}
None => {
let settings = repl::SessionSettings::default();
if cmd.disable_clarity_wasm {
Terminal::new(settings, None)
} else {
let mut settings_wasm = repl::SessionSettings::default();
settings_wasm.repl_settings.clarity_wasm_mode = true;
Terminal::new(settings, Some(settings_wasm))
}
}
None => Terminal::new(repl::SessionSettings::default()),
};
let reload = terminal.start();

Expand Down
2 changes: 1 addition & 1 deletion components/clarinet-deployments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn update_session_with_contracts_executions(
for (_, (boot_contract, ast)) in boot_contracts_data {
session
.interpreter
.run(&boot_contract, &mut Some(ast), false, None)
.run_interpreter(&boot_contract, &mut Some(ast), false, None)
.expect("failed to interprete boot contract");
}

Expand Down
68 changes: 16 additions & 52 deletions components/clarity-repl/src/analysis/call_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,8 @@ mod tests {
)
"
.to_string();
match session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
Err(output) => {
match session.formatted_interpretation(snippet, Some("checker".to_string()), false, None) {
Err((output, _)) => {
assert_eq!(output.len(), 3);
assert_eq!(
output[0],
Expand Down Expand Up @@ -259,14 +253,8 @@ mod tests {
)
"
.to_string();
match session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
Err(output) => {
match session.formatted_interpretation(snippet, Some("checker".to_string()), false, None) {
Err((output, _)) => {
assert_eq!(output.len(), 3);
assert_eq!(
output[0],
Expand Down Expand Up @@ -297,14 +285,8 @@ mod tests {
)
"
.to_string();
match session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
Err(output) => {
match session.formatted_interpretation(snippet, Some("checker".to_string()), false, None) {
Err((output, _)) => {
assert_eq!(output.len(), 3);
assert_eq!(
output[0],
Expand Down Expand Up @@ -335,13 +317,7 @@ mod tests {
)
"
.to_string();
match session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
match session.formatted_interpretation(snippet, Some("checker".to_string()), false, None) {
Ok((_, result)) => {
assert_eq!(result.diagnostics.len(), 0);
}
Expand All @@ -358,13 +334,9 @@ mod tests {
(define-private (kv-set (key int) (value int))
(map-set kv-store { key: key } { value: value } {value: 0}))"
.to_string();
if let Err(err_output) = session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
if let Err((err_output, _)) =
session.formatted_interpretation(snippet, Some("checker".to_string()), false, None)
{
assert_eq!(
err_output[0],
format!(
Expand All @@ -384,13 +356,9 @@ mod tests {
(define-private (kv-add (key int) (value int))
(map-insert kv-store { key: key } { value: value } { value: 0}))"
.to_string();
if let Err(err_output) = session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
if let Err((err_output, _)) =
session.formatted_interpretation(snippet, Some("checker".to_string()), false, None)
{
assert_eq!(
err_output[0],
format!(
Expand All @@ -410,13 +378,9 @@ mod tests {
(define-private (kv-del (key int))
(map-delete kv-store { key: 1 } {value: 0}))"
.to_string();
if let Err(err_output) = session.formatted_interpretation(
snippet,
Some("checker".to_string()),
false,
None,
None,
) {
if let Err((err_output, _)) =
session.formatted_interpretation(snippet, Some("checker".to_string()), false, None)
{
assert_eq!(
err_output[0],
format!(
Expand Down
Loading
Loading