Skip to content

Commit

Permalink
Version bump the remaining crate dependencies (#6579)
Browse files Browse the repository at this point in the history
## Description

As part of #6179, this PR updates the remaining quick-fix crates to
their latest X.Y versions. Code fixes were needed to get compilation
working and tests passing.

Issue #6536 lists the crates that will need a bit more work to get
working and passing.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
alfiedotwtf authored Sep 23, 2024
1 parent 3f163c7 commit e1546f6
Show file tree
Hide file tree
Showing 11 changed files with 613 additions and 192 deletions.
663 changes: 540 additions & 123 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ mdbook = { version = "0.4", default-features = false }
miden = "0.3"
miden-core = "0.3"
minifier = "0.3"
notify = "5.0"
notify-debouncer-mini = "0.2"
notify = "6.1"
notify-debouncer-mini = "0.4"
num-bigint = "0.4"
num-traits = "0.2"
object = "0.36"
Expand All @@ -189,7 +189,7 @@ rayon = "1.7"
rayon-cond = "0.3"
regex = "1.10"
reqwest = "0.12"
revm = "2.3"
revm = "14.0"
ropey = "1.5"
rpassword = "7.2"
rustc-hash = "1.1"
Expand All @@ -207,18 +207,18 @@ slotmap = "1.0"
smallvec = "1.7"
strsim = "0.11"
strum = "0.26"
syn = "1.0"
syn = "2.0"
taplo = "0.13"
tar = "0.4"
tempfile = "3"
term-table = "1.3"
termion = "4.0"
textwrap = "0.16"
thiserror = "1.0"
tikv-jemallocator = "0.5"
tikv-jemallocator = "0.6"
tokio = "1.12"
toml = "0.8"
toml_edit = "0.21"
toml_edit = "0.22"
tower = { version = "0.5", default-features = false }
tower-lsp = "0.20"
tracing = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-client/src/util/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn update_proxy_address_in_manifest(
let mut toml = String::new();
let mut file = File::open(manifest.path())?;
file.read_to_string(&mut toml)?;
let mut manifest_toml = toml.parse::<toml_edit::Document>()?;
let mut manifest_toml = toml.parse::<toml_edit::DocumentMut>()?;
if manifest.proxy().is_some() {
manifest_toml["proxy"]["address"] = toml_edit::value(address);
let mut file = std::fs::OpenOptions::new()
Expand Down
6 changes: 3 additions & 3 deletions forc-plugins/forc-client/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{
str::FromStr,
};
use tempfile::tempdir;
use toml_edit::{value, Document, InlineTable, Item, Table, Value};
use toml_edit::{value, DocumentMut, InlineTable, Item, Table, Value};

fn get_workspace_root() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
Expand Down Expand Up @@ -75,7 +75,7 @@ fn patch_manifest_file_with_path_std(manifest_dir: &Path) -> anyhow::Result<()>
let toml_path = manifest_dir.join(sway_utils::constants::MANIFEST_FILE_NAME);
let toml_content = fs::read_to_string(&toml_path).unwrap();

let mut doc = toml_content.parse::<Document>().unwrap();
let mut doc = toml_content.parse::<DocumentMut>().unwrap();
let new_std_path = get_workspace_root().join("sway-lib-std");

let mut std_dependency = InlineTable::new();
Expand All @@ -89,7 +89,7 @@ fn patch_manifest_file_with_path_std(manifest_dir: &Path) -> anyhow::Result<()>
fn patch_manifest_file_with_proxy_table(manifest_dir: &Path, proxy: Proxy) -> anyhow::Result<()> {
let toml_path = manifest_dir.join(sway_utils::constants::MANIFEST_FILE_NAME);
let toml_content = fs::read_to_string(&toml_path)?;
let mut doc = toml_content.parse::<Document>()?;
let mut doc = toml_content.parse::<DocumentMut>()?;

let proxy_table = doc.entry("proxy").or_insert(Item::Table(Table::new()));
let proxy_table = proxy_table.as_table_mut().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions forc/src/ops/forc_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn edit_forc_toml(out_dir: &Path, project_name: &str, real_name: &str) -> Result
let mut file = File::open(out_dir.join(constants::MANIFEST_FILE_NAME))?;
let mut toml = String::new();
file.read_to_string(&mut toml)?;
let mut manifest_toml = toml.parse::<toml_edit::Document>()?;
let mut manifest_toml = toml.parse::<toml_edit::DocumentMut>()?;

let mut authors = Vec::new();
let forc_toml: toml::Value = toml::de::from_str(&toml)?;
Expand Down Expand Up @@ -144,7 +144,7 @@ fn edit_cargo_toml(out_dir: &Path, project_name: &str, real_name: &str) -> Resul
}
updated_authors.push(real_name);

let mut manifest_toml = toml.parse::<toml_edit::Document>()?;
let mut manifest_toml = toml.parse::<toml_edit::DocumentMut>()?;
manifest_toml["package"]["authors"] = toml_edit::value(updated_authors);
manifest_toml["package"]["name"] = toml_edit::value(project_name);

Expand Down
30 changes: 13 additions & 17 deletions sway-ir/sway-ir-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
quote::{format_ident, quote},
syn::{
parse_macro_input, Attribute, Data, DeriveInput, Fields, FieldsNamed, FieldsUnnamed, Ident,
Meta, NestedMeta, Variant,
Variant,
},
};

Expand Down Expand Up @@ -170,7 +170,7 @@ fn pass_through_context(field_name: &Ident, attrs: &[Attribute]) -> proc_macro2:
attrs
.iter()
.filter_map(|attr| {
let attr_name = attr.path.get_ident()?;
let attr_name = attr.path().get_ident()?;
if attr_name != "in_context" {
return None;
}
Expand Down Expand Up @@ -199,20 +199,16 @@ fn pass_through_context(field_name: &Ident, attrs: &[Attribute]) -> proc_macro2:
}

fn try_parse_context_field_from_attr(attr: &Attribute) -> Option<Ident> {
let meta = attr.parse_meta().ok()?;
let Meta::List(meta_list) = meta else {
return None;
};
if meta_list.nested.len() != 1 {
return None;
let mut context_fields = Vec::new();

let _ = attr.parse_nested_meta(|nested_meta| {
context_fields.push(nested_meta.path.get_ident().unwrap().clone());
Ok(())
});

if context_fields.len() != 1 {
None
} else {
context_fields.pop()
}
let nested_meta = meta_list.nested.first()?;
let NestedMeta::Meta(inner_meta) = nested_meta else {
return None;
};
let Meta::Path(path) = inner_meta else {
return None;
};
let context_field_name = path.get_ident()?.clone();
Some(context_field_name)
}
2 changes: 1 addition & 1 deletion sway-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pretty_assertions = "1.4.0"
rand = "0.8"
regex = "^1.10.2"
sway-lsp-test-utils = { path = "tests/utils" }
tikv-jemallocator = "0.5"
tikv-jemallocator = "0.6"
tower = { version = "0.4.12", default-features = false, features = ["util"] }

[[bench]]
Expand Down
15 changes: 7 additions & 8 deletions sway-lsp/src/core/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,12 @@ impl SyncWorkspace {
let handle = tokio::spawn(async move {
let (tx, mut rx) = tokio::sync::mpsc::channel(10);
// Setup debouncer. No specific tickrate, max debounce time 2 seconds
let mut debouncer =
new_debouncer(Duration::from_secs(1), None, move |event| {
if let Ok(e) = event {
let _ = tx.blocking_send(e);
}
})
.unwrap();
let mut debouncer = new_debouncer(Duration::from_secs(1), move |event| {
if let Ok(e) = event {
let _ = tx.blocking_send(e);
}
})
.unwrap();

debouncer
.watcher()
Expand Down Expand Up @@ -286,7 +285,7 @@ pub(crate) fn edit_manifest_dependency_paths(
if let Ok(mut file) = File::open(manifest.path()) {
let mut toml = String::new();
let _ = file.read_to_string(&mut toml);
if let Ok(mut manifest_toml) = toml.parse::<toml_edit::Document>() {
if let Ok(mut manifest_toml) = toml.parse::<toml_edit::DocumentMut>() {
for (name, abs_path) in dependency_map {
manifest_toml["dependencies"][&name]["path"] =
toml_edit::value(abs_path.display().to_string());
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/utils/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ impl KeywordDocs {
let name = ident.trim_end_matches("_keyword").to_owned();
let mut documentation = String::new();
keyword.attrs.iter().for_each(|attr| {
let tokens = attr.tokens.to_token_stream();
let tokens = attr.meta.clone().to_token_stream();
let lit = extract_lit(tokens);
writeln!(documentation, "{lit}").unwrap();
});
Expand Down
51 changes: 29 additions & 22 deletions test/src/e2e_vm_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub(crate) async fn runs_on_node(

pub(crate) enum VMExecutionResult {
Fuel(ProgramState, Vec<Receipt>),
Evm(revm::ExecutionResult),
Evm(revm::primitives::result::ExecutionResult),
MidenVM(miden::ExecutionTrace),
}

Expand Down Expand Up @@ -214,31 +214,38 @@ pub(crate) fn runs_in_vm(
))
}
BuildTarget::EVM => {
let mut evm = revm::new();
evm.database(revm::InMemoryDB::default());
evm.env = revm::Env::default();
let mut evm = revm::EvmBuilder::default()
.with_db(revm::InMemoryDB::default())
.with_clear_env()
.build();

// Transaction to create the smart contract
evm.env.tx.transact_to = revm::TransactTo::create();
evm.env.tx.data = bytes::Bytes::from(script.bytecode.bytes.into_boxed_slice());
let result = evm.transact_commit();

match result.out {
revm::TransactOut::None => Err(anyhow!("Could not create smart contract")),
revm::TransactOut::Call(_) => todo!(),
revm::TransactOut::Create(ref _bytes, account_opt) => {
match account_opt {
Some(account) => {
evm.env.tx.transact_to = revm::TransactTo::Call(account);

// Now issue a call.
//evm.env.tx. = bytes::Bytes::from(script.bytecode.into_boxed_slice());
let result = evm.transact_commit();
Ok(VMExecutionResult::Evm(result))
let result = evm
.transact_commit()
.map_err(|e| anyhow::anyhow!("Could not create smart contract on EVM: {e:?}"))?;

match result {
revm::primitives::ExecutionResult::Revert { .. }
| revm::primitives::ExecutionResult::Halt { .. } => todo!(),
revm::primitives::ExecutionResult::Success { ref output, .. } => match output {
revm::primitives::result::Output::Call(_) => todo!(),
revm::primitives::result::Output::Create(_bytes, address_opt) => {
match address_opt {
None => todo!(),
Some(address) => {
evm.tx_mut().data = script.bytecode.bytes.into();
evm.tx_mut().transact_to =
revm::interpreter::primitives::TransactTo::Call(*address);

let result = evm
.transact_commit()
.map_err(|e| anyhow::anyhow!("Failed call on EVM: {e:?}"))?;

Ok(VMExecutionResult::Evm(result))
}
}
None => todo!(),
}
}
},
}
}
BuildTarget::MidenVM => {
Expand Down
18 changes: 10 additions & 8 deletions test/src/e2e_vm_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,16 @@ impl TestContext {
}
}
}
harness::VMExecutionResult::Evm(state) => match state.exit_reason {
revm::Return::Continue => todo!(),
revm::Return::Stop => TestResult::Result(0),
revm::Return::Return => todo!(),
revm::Return::SelfDestruct => todo!(),
revm::Return::Revert => TestResult::Revert(0),
_ => {
panic!("EVM exited with unhandled reason: {:?}", state.exit_reason);
harness::VMExecutionResult::Evm(state) => match state {
revm::primitives::ExecutionResult::Success { reason, .. } => match reason {
revm::primitives::SuccessReason::Stop => TestResult::Result(0),
revm::primitives::SuccessReason::Return => todo!(),
revm::primitives::SuccessReason::SelfDestruct => todo!(),
revm::primitives::SuccessReason::EofReturnContract => todo!(),
},
revm::primitives::ExecutionResult::Revert { .. } => TestResult::Result(0),
revm::primitives::ExecutionResult::Halt { reason, .. } => {
panic!("EVM exited with unhandled reason: {:?}", reason);
}
},
harness::VMExecutionResult::MidenVM(trace) => {
Expand Down

0 comments on commit e1546f6

Please sign in to comment.