Skip to content
Draft
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
ddb4779
collecting information
Nov 8, 2022
bbc07cc
some updates, had a lot of problems with just passing flags...
Nov 11, 2022
dc4b1d5
passing method calls and verification items to ide
Nov 22, 2022
dc079fa
fixed duplicate method calls
Dec 4, 2022
c1d86d2
Fixed the issue of no_verify causing subsequent verifications to fail…
Dec 4, 2022
207a4ad
now finding correct defpath for function calls and also handling bino…
Dec 10, 2022
4636373
Fixed a bug for calls where the DefId can not be found apparently.
Dec 11, 2022
e311df9
fixed minor bug and formatting
Dec 12, 2022
3780ce1
now finding defpath's for MethodCalls too
Dec 12, 2022
e518ef4
Figured out how to resolve MethodCalls, but we are still in trouble..
Dec 19, 2022
295040c
Commit finally to own fork
Dec 19, 2022
7adf64e
Finally catching all relevant method calls as far as I can tell..
Dec 29, 2022
4943255
initial quantifier instantiations working
Jan 3, 2023
0bd03b9
generating signatures correctly in some cases, struggling with traitb…
Jan 5, 2023
fe577dc
successfully resolving projections (it seems)
Jan 5, 2023
dedc17b
started on generating external specs for traits
Jan 6, 2023
8812f3d
WIP: stream messages from server to client
Jan 8, 2023
c1cbde9
Managed to subst EarlyBinders
Jan 19, 2023
b4f93ae
Merge remote-tracking branch 'upstream/master'
Jan 19, 2023
41e1964
Merge branch 'master' into proto-extspec
Jan 19, 2023
6facfce
upgraded my parts to current rust version
Jan 19, 2023
3ac17ee
Asynchronously report messages from the server to the client via WebS…
Jan 31, 2023
24ad838
refactored extern spec generation to try and make it more readable.
Feb 4, 2023
5d141eb
renamed stuff
Feb 7, 2023
95b78ca
Merge branch 'joseph_quant' into proto-extspec
Feb 7, 2023
9b0b5ad
Merge remote-tracking branch 'upstream/master' into proto-extspec
Feb 7, 2023
bb6ddb2
Adjusted viper VerificationResult so we can passe times, and whether …
Feb 8, 2023
a4dce76
WIP: restructure the process verification a bit
Feb 8, 2023
f84219c
Fixed warnings and a bug.
Feb 8, 2023
d9e067c
renamed a file and adjusted text for IDE information output
Feb 12, 2023
a069cef
Finish process_verification restructuring. Add a parameter for qi.pro…
Feb 12, 2023
92c92c3
Merge remote-tracking branch 'cedric/proto-extspec' into quant
Feb 12, 2023
ca86115
Changed message for fake errors and adjusted names of CompilerInfo pr…
Feb 13, 2023
4e1a547
Merge remote-tracking branch 'jthomme1/quant' into proto-extspec
Feb 15, 2023
26ea0af
Add QuantifierChosenTriggersMessage reporting
Feb 15, 2023
872b3c1
Merge remote-tracking branch 'cedric/proto-extspec' into quant
Feb 15, 2023
2cbc865
passing information about specifications of calls to IDE now, called …
Feb 16, 2023
c3a2c6f
WIP: async processing of verification info
Feb 16, 2023
5ed232e
(IDE) Contract Spans are now also collected for pedges and termatinat…
Feb 19, 2023
91b91c4
Cleaning up unused imports and debugging print statements
Feb 19, 2023
ba54ed7
Some minor output changes
Feb 20, 2023
e4810ec
Merge cedric's branch
Feb 20, 2023
f886f8b
Minor fixes
Feb 20, 2023
93a78c7
Merge remote-tracking branch 'upstream/master' into quant
Feb 20, 2023
9ef451a
give spans of pledges to IDE and filter out trusted methods and predi…
Feb 21, 2023
5df2a04
Merge remote-tracking branch 'joseph/quant' into proto-extspec
Feb 21, 2023
b6ba6f6
updated ide-parts to new compiler version
Feb 21, 2023
f27499c
Emit everything in a compiler note/message
Feb 21, 2023
cf53b8e
Make every token CamelCase
Feb 21, 2023
158b9ad
Set config variable for viper message reporting to default false.
Feb 21, 2023
195af4d
Proper camelCase messages
Feb 22, 2023
91f4ff9
Can not automatically generate extern_specs for local methods anymore
Feb 22, 2023
82e6063
Fix GlobalRef detaching warning. Add a few comments. Remove some debu…
Feb 22, 2023
849b18d
Better comment for the VerificationRequestProcessing global variable.
Feb 22, 2023
33a2e63
Remove leftover comment.
Feb 22, 2023
ed8b1b6
Merge remote-tracking branch 'jthomme1/quant'
Feb 22, 2023
1b1242d
Correct formatting and removed all clippy warnings except for 2
Feb 22, 2023
ebfdd1b
Fix last 2 clippy warnings
Feb 22, 2023
ca1d9d6
Updated viper-toolchain, added various comments / documentation, addr…
Feb 22, 2023
137f9a2
corrected tag for recent viper-ide nightly release
Feb 22, 2023
f79e966
updated viper-toolchain again, this time to a compatible version
Feb 23, 2023
f2fa93a
fixed error due to new scala version
Feb 23, 2023
5600499
made testcases compile at least, but one is hard to update to new str…
Feb 23, 2023
7e6ceaf
Fixed prusti-server test. Why do we get a 255 exit code on a successf…
Feb 23, 2023
e8bddf0
Adjusted ui testcase that has additional note about existential quant…
Feb 23, 2023
ede8451
Bugfixes for 2 testcases. All tests should be passing now
Feb 23, 2023
3572fea
Add debug output
Feb 24, 2023
be04342
Merge remote-tracking branch 'cedric/master' into quant
Feb 24, 2023
7d434b5
Merge remote-tracking branch 'jthomme1/quant'
Feb 24, 2023
bac27bf
Make cache save when not using a server
Feb 25, 2023
9ca7602
Merge remote-tracking branch 'jthomme1/quant'
Feb 25, 2023
b373c14
Gracefully close also the receiving end of the websocket.
Feb 25, 2023
e84688f
Close the websocket connection correctly
Feb 25, 2023
2cc9233
Merge remote-tracking branch 'jthomme1/quant'
Feb 25, 2023
c39ece5
Fix bug where successful selective verification is still cached
Feb 25, 2023
f83a088
Fix bug in translation of spans to vscode-spans
Feb 27, 2023
8b4563f
Bump prusti version to 0.3.0
Mar 1, 2023
eaeef45
Update viper-toolchain version
Mar 4, 2023
82b0eb8
Implement some comments (untested)
Mar 5, 2023
a492472
Fix Z3 arguments
Mar 5, 2023
f50a367
Fix test and formatting error
Mar 5, 2023
a1e6d9f
Refactor / Fix according to code reviews
Mar 5, 2023
b144843
Format and move old comment to right location
Mar 5, 2023
aaa3ea5
Address reviews and add comments
Mar 5, 2023
dc6ead0
Merge remote-tracking branch 'upstream/master'
Mar 6, 2023
1f0ae07
Improve displaying of generated extern spec block for trait
Mar 7, 2023
e562bca
Fix some quantifier reporting weirdness
Mar 7, 2023
65c99d9
Make QI etc. also work for existential quantifiers
Mar 8, 2023
a299c14
Check if current package is primary package before throwing fake_error
Mar 9, 2023
eb05efc
Separate trait bounds from generic args and handle bad case
Mar 13, 2023
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
499 changes: 326 additions & 173 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions prusti-common/src/vir/program_normalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use crate::vir::{program::Program, Position};
use log::{debug, trace};
use rustc_hash::{FxHashMap, FxHashSet};
use viper::VerificationResult;
use viper::VerificationResultKind;

#[derive(Clone)]
pub enum NormalizationInfo {
LegacyProgram { original_position_ids: Vec<u64> },
LowProgram,
Expand Down Expand Up @@ -80,7 +81,7 @@ impl NormalizationInfo {
)
}

/// Denormalize the verification result.
/// Denormalize the program
pub fn denormalize_program(&self, program: &mut Program) {
match program {
Program::Low(_) => debug!("No denormalization is done for vir::low programs."),
Expand All @@ -101,8 +102,8 @@ impl NormalizationInfo {
}

/// Denormalize a verification result.
pub fn denormalize_result(&self, result: &mut VerificationResult) {
if let VerificationResult::Failure(ref mut ver_errors) = result {
pub fn denormalize_result(&self, result: &mut VerificationResultKind) {
if let VerificationResultKind::Failure(ref mut ver_errors) = result {
ver_errors.iter_mut().for_each(|ver_error| {
if let Some(pos) = ver_error.pos_id.as_mut() {
self.denormalize_position_string(pos);
Expand Down
5 changes: 5 additions & 0 deletions prusti-interface/src/environment/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ impl<'tcx> EnvDiagnostic<'tcx> {
diagnostic.buffer(&mut self.warn_buffer.borrow_mut());
}

/// Emits a note
pub fn span_note<S: Into<MultiSpan> + Clone>(&self, sp: S, msg: &str) {
self.tcx.sess.span_note_without_error(sp, msg);
}

/// Returns true if an error has been emitted
pub fn has_errors(&self) -> bool {
self.tcx.sess.has_errors().is_some()
Expand Down
10 changes: 10 additions & 0 deletions prusti-interface/src/prusti_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum PrustiErrorKind {
Warning,
/// A warning which is only shown if at least one error is emitted.
WarningOnError,
Message,
Comment thread
cedihegi marked this conversation as resolved.
}

impl PartialOrd for PrustiError {
Expand Down Expand Up @@ -146,6 +147,14 @@ impl PrustiError {
error
}

/// Report a message
pub fn message<S: ToString>(message: S, span: MultiSpan) -> Self {
check_message(message.to_string());
let mut msg = PrustiError::new(message.to_string(), span);
msg.kind = PrustiErrorKind::Message;
msg
}

/// Set that this Prusti error should be reported as a warning to the user
pub fn set_warning(&mut self) {
self.kind = PrustiErrorKind::Warning;
Expand Down Expand Up @@ -203,6 +212,7 @@ impl PrustiError {
&self.help,
&self.notes,
),
PrustiErrorKind::Message => env_diagnostic.span_note(*self.span, &self.message),
};
}

Expand Down
11 changes: 10 additions & 1 deletion prusti-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ doctest = false
[dependencies]
log = { version = "0.4", features = ["release_max_level_info"] }
viper = { path = "../viper" }
viper-sys = { path = "../viper-sys" }
prusti-common = { path = "../prusti-common" }
prusti-utils = { path = "../prusti-utils" }
env_logger = "0.10"
Expand All @@ -27,9 +28,17 @@ bincode = "1.0"
url = "2.2.2"
num_cpus = "1.14"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
tokio = "1.20"
jni = { version = "0.20", features = ["invocation"] }
# the tungstenite version used by warp 0.3
tokio-tungstenite = "0.13"
futures = "0.3.25"
futures-util = "0.3.25"
async-stream = "0.3.3"
once_cell = "1.17.0"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
warp = "0.3"
tokio = "1.20"
rustc-hash = "1.1.0"

[dev-dependencies]
Expand Down
104 changes: 61 additions & 43 deletions prusti-server/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,76 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use crate::VerificationRequest;
use crate::{ServerMessage, VerificationRequest};
use futures_util::{
sink::SinkExt,
stream::{Stream, StreamExt},
};
use prusti_common::config;
use reqwest::Client;
use url::{ParseError, Url};
use viper::VerificationResult;
use tokio_tungstenite::{
connect_async,
tungstenite::{error::Error, Message},
};
use url::Url;

pub struct PrustiClient {
client: Client,
server_url: Url,
}
pub struct PrustiClient;

impl PrustiClient {
pub fn new<S: ToString>(server_address: S) -> Result<Self, ParseError> {
pub async fn verify<S: ToString>(
server_address: S,
request: VerificationRequest,
) -> impl Stream<Item = ServerMessage> {
// TODO: do proper error handling

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How "improper" is it? For example, is it just resilience against the server unexpectedly quitting? If we panic in such a case that might be ok.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atm, we panic if the server address is invalid and if the connection is torn down/fails somehow unexpectedly. However, this was basically the same before: just that there this method returned a result which was .expected.

let mut address = server_address.to_string();
if !address.starts_with("http") {
address = format!("http://{address}");
if !address.starts_with("ws") {
address = format!("ws://{address}");
}
Ok(Self {
client: Client::new(),
server_url: Url::parse(address.as_str())?,
})
}

pub async fn verify(
&self,
request: VerificationRequest,
) -> reqwest::Result<VerificationResult> {
let server_url = Url::parse(address.as_str()).unwrap();

let use_json = config::json_communication();
let base = self.client.post(
self.server_url
.join(if use_json { "json/" } else { "bincode/" })
.unwrap()
.join("verify/")
.unwrap(),
);
let response = if use_json {
base.json(&request)
.send()
.await?
.error_for_status()?
.json()
.await?

let uri = server_url
.join(if use_json { "json/" } else { "bincode/" })
.unwrap()
.join("verify/")
.unwrap();
let (mut socket, _) = connect_async(uri).await.unwrap();
let msg = if use_json {
Message::text(
serde_json::to_string(&request)
.expect("error encoding verification request in json"),
)
} else {
let bytes = base
.body(bincode::serialize(&request).expect("error encoding verification request"))
.send()
.await?
.error_for_status()?
.bytes()
.await?;
bincode::deserialize(&bytes).expect("error decoding verification result")
Message::binary(
bincode::serialize(&request)
.expect("error encoding verification request as binary"),
)
};
socket.send(msg).await.unwrap();
let json_map = |ws_msg| {
if let Message::Text(json) = ws_msg {
serde_json::from_str(&json).expect("error decoding verification result from json")
} else {
panic!("Invalid response from the server.");
}
};
let bin_map = |ws_msg| {
if let Message::Binary(bytes) = ws_msg {
bincode::deserialize(&bytes).expect("error decoding verification result")
} else {
panic!("Invalid response from the server.");
}
};
let filter_close = |msg_result: Result<Message, Error>| async {
let msg = msg_result.unwrap();
match msg {
Message::Close(_) => None,
_ => Some(msg),
}
};
Ok(response)
socket
.filter_map(filter_close)
.map(if use_json { json_map } else { bin_map })
}
}
2 changes: 2 additions & 0 deletions prusti-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
mod client;
mod process_verification;
mod server;
mod server_message;
mod verification_request;

pub use client::*;
pub use process_verification::*;
pub use server::*;
pub use server_message::*;
pub use verification_request::*;

// Futures returned by `Client` need to be executed in a compatible tokio runtime.
Expand Down
Loading