diff --git a/Cargo.lock b/Cargo.lock index 2957c55..1c1492d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,9 +57,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" [[package]] name = "ark-ff" @@ -297,9 +297,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -330,9 +330,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.2" +version = "1.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b37dae8c8ded08d5ec72caa1b4204a5344047cd4a2c7387e3d150020abfbc1c9" +checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" dependencies = [ "cfg-if", "cpufeatures", @@ -792,6 +792,7 @@ dependencies = [ [[package]] name = "inkwell" version = "0.4.0" +source = "git+https://github.com/TheDan64/inkwell.git#69c5a3fcc3e8b997c36e20021c52adcff664d746" dependencies = [ "either", "inkwell_internals", @@ -805,6 +806,7 @@ dependencies = [ [[package]] name = "inkwell_internals" version = "0.9.0" +source = "git+https://github.com/TheDan64/inkwell.git#69c5a3fcc3e8b997c36e20021c52adcff664d746" dependencies = [ "proc-macro2", "quote", @@ -1110,7 +1112,7 @@ dependencies = [ [[package]] name = "polkavm" version = "0.9.3" -source = "git+https://github.com/koute/polkavm.git#658b2a612e966c5dde0860e7d95d57ffe87a0fdf" +source = "git+https://github.com/koute/polkavm.git#e278c34af27cf2c32fc44bcbfe2b17333312eb02" dependencies = [ "libc", "log", @@ -1122,7 +1124,7 @@ dependencies = [ [[package]] name = "polkavm-assembler" version = "0.9.0" -source = "git+https://github.com/koute/polkavm.git#658b2a612e966c5dde0860e7d95d57ffe87a0fdf" +source = "git+https://github.com/koute/polkavm.git#e278c34af27cf2c32fc44bcbfe2b17333312eb02" dependencies = [ "log", ] @@ -1130,7 +1132,7 @@ dependencies = [ [[package]] name = "polkavm-common" version = "0.9.0" -source = "git+https://github.com/koute/polkavm.git#658b2a612e966c5dde0860e7d95d57ffe87a0fdf" +source = "git+https://github.com/koute/polkavm.git#e278c34af27cf2c32fc44bcbfe2b17333312eb02" dependencies = [ "log", ] @@ -1138,7 +1140,7 @@ dependencies = [ [[package]] name = "polkavm-linker" version = "0.9.2" -source = "git+https://github.com/koute/polkavm.git#658b2a612e966c5dde0860e7d95d57ffe87a0fdf" +source = "git+https://github.com/koute/polkavm.git#e278c34af27cf2c32fc44bcbfe2b17333312eb02" dependencies = [ "gimli", "hashbrown 0.14.3", @@ -1152,7 +1154,7 @@ dependencies = [ [[package]] name = "polkavm-linux-raw" version = "0.9.0" -source = "git+https://github.com/koute/polkavm.git#658b2a612e966c5dde0860e7d95d57ffe87a0fdf" +source = "git+https://github.com/koute/polkavm.git#e278c34af27cf2c32fc44bcbfe2b17333312eb02" [[package]] name = "ppv-lite86" @@ -1209,9 +1211,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -1799,18 +1801,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 4ebe0fd..79dcb9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,8 +8,6 @@ petgraph = "0.6" cc = "1.0" libc = "0.2" tempfile = "3.8" -#inkwell = { version = "0.4.0", default-features = false, features = ["llvm16-0", "no-libffi-linking", "target-riscv"] } -inkwell = { path = "../inkwell", default-features = false, features = ["serde", "llvm16-0", "no-libffi-linking", "target-riscv"] } anyhow = "1.0" semver = { version = "1.0", features = [ "serde" ] } itertools = "0.12" @@ -33,3 +31,9 @@ polkavm-linker = { git = "https://github.com/koute/polkavm.git" } polkavm = { git = "https://github.com/koute/polkavm.git" } parity-scale-codec = "3.6" alloy-primitives = "0.6" + +[workspace.dependencies.inkwell] +git = "https://github.com/TheDan64/inkwell.git" +commit = "69c5a3f" +default-features = false +features = ["serde", "llvm16-0", "no-libffi-linking", "target-riscv"] diff --git a/README.md b/README.md index 4c8afb8..b7c3671 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,16 @@ YUL and EVM bytecode recompiler to LLVM, targetting RISC-V on PolkaVM. Code bases of [frontend](https://github.com/matter-labs/era-compiler-solidity) and [code generator](https://github.com/matter-labs/era-compiler-llvm-context) are forked adapted from ZKSync `zksolc`. -Primary goal of this codebase currently is to allow for benchmarks comparing runtime performance against ink!, solang and EVM interpreters. +# Status + +Currently, primary goal of this codebase is to allow for benchmarks comparing performance against ink! and solang artifacts as well as EVM interpreters. # TODO -The project is in a very early PoC phase; at this stage don't expect the produced code to be working nor to be correct for anything more than a basic flipper contract yet. +The project is in a very early PoC phase. Don't yet expect the produced code to be working nor to be correct for anything more than a basic flipper contract at the current stage. - [ ] Efficient implementations of byte swaps, memset, memmove and the like -- [ ] Use drink! for integration tests once we have 64bit support in PolkaVM +- [ ] Use `drink` for integration tests once we have 64bit support in PolkaVM - [ ] Exercice `schlau` and possibly `smart-bench` benchmark cases - [ ] Tests currently rely on the binary being in $PATH, which is very annoying and requires `cargo install` all the times - [ ] Define how to do deployments @@ -25,8 +27,8 @@ The project is in a very early PoC phase; at this stage don't expect the produce - [ ] Debug information - [ ] Look for and implement further optimizations - [ ] Differential testing against EVM -- [ ] Switch to LLVM 18 which has RV{32,64}E upstream -- [ ] Minimize scope of "stdlib", favorably implement it in high level language instead of LLVM IR. +- [ ] Switch to LLVM 18 which has `RV{32,64}E` targets upstream +- [ ] Minimize scope of "stdlib" - [ ] Document differences from EVM - [ ] Audit for bugs and correctness - [ ] Rebranding diff --git a/crates/lld-sys/Cargo.toml b/crates/lld-sys/Cargo.toml index 6a742ec..d7eb136 100644 --- a/crates/lld-sys/Cargo.toml +++ b/crates/lld-sys/Cargo.toml @@ -11,4 +11,10 @@ build = "build.rs" libc = { workspace = true } [build-dependencies] -cc = { workspace = true } \ No newline at end of file +cc = { workspace = true } + +[target.aarch64-apple-darwin] +rustflags = [ + "-C", "link-arg=-undefined", + "-C", "link-arg=dynamic_lookup", +] diff --git a/crates/llvm-context/Cargo.toml b/crates/llvm-context/Cargo.toml index d10e08b..33348dd 100644 --- a/crates/llvm-context/Cargo.toml +++ b/crates/llvm-context/Cargo.toml @@ -3,6 +3,7 @@ name = "era-compiler-llvm-context" version = "1.4.1" authors = [ "Oleksandr Zarudnyi ", + "Cyrill Leutwiler ", ] license = "MIT OR Apache-2.0" edition = "2021" diff --git a/crates/llvm-context/src/eravm/context/function/runtime/default_call.rs b/crates/llvm-context/src/eravm/context/function/runtime/default_call.rs index ac91ec6..6d0f803 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/default_call.rs +++ b/crates/llvm-context/src/eravm/context/function/runtime/default_call.rs @@ -3,13 +3,10 @@ //! use inkwell::types::BasicType; -use inkwell::values::BasicValue; -use crate::eravm::context::address_space::AddressSpace; use crate::eravm::context::function::declaration::Declaration as FunctionDeclaration; use crate::eravm::context::function::llvm_runtime::LLVMRuntime; use crate::eravm::context::function::Function; -use crate::eravm::context::pointer::Pointer; use crate::eravm::context::Context; use crate::eravm::Dependency; use crate::eravm::WriteLLVM; @@ -27,6 +24,7 @@ pub struct DefaultCall { name: String, } +#[allow(unused)] impl DefaultCall { /// The gas argument index. pub const ARGUMENT_INDEX_GAS: usize = 0; diff --git a/crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs b/crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs index 219d302..9cfbcce 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs +++ b/crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs @@ -3,7 +3,6 @@ //! use inkwell::types::BasicType; -use inkwell::values::BasicValue; use crate::eravm::context::address_space::AddressSpace; use crate::eravm::context::function::Function; @@ -121,7 +120,7 @@ where let value_join_block = context.append_basic_block("deployer_call_value_join_block"); context.set_basic_block(context.current_function().borrow().entry_block()); - let abi_data = crate::eravm::utils::abi_data( + let _abi_data = crate::eravm::utils::abi_data( context, input_offset, input_length, diff --git a/crates/llvm-context/src/eravm/context/tests.rs b/crates/llvm-context/src/eravm/context/tests.rs index 0b36759..998709c 100644 --- a/crates/llvm-context/src/eravm/context/tests.rs +++ b/crates/llvm-context/src/eravm/context/tests.rs @@ -17,7 +17,7 @@ pub fn create_context( let module = llvm.create_module("test"); let optimizer = Optimizer::new(optimizer_settings); - Context::::new(&llvm, module, optimizer, None, true, None) + Context::::new(llvm, module, optimizer, None, true, None) } #[test] diff --git a/crates/llvm-context/src/eravm/evm/crypto.rs b/crates/llvm-context/src/eravm/evm/crypto.rs index 70575c4..97761b3 100644 --- a/crates/llvm-context/src/eravm/evm/crypto.rs +++ b/crates/llvm-context/src/eravm/evm/crypto.rs @@ -2,10 +2,6 @@ //! Translates the cryptographic operations. //! -use inkwell::values::BasicValue; - -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::function::Function as EraVMFunction; use crate::eravm::context::Context; use crate::eravm::Dependency; @@ -13,37 +9,12 @@ use crate::eravm::Dependency; /// Translates the `sha3` instruction. /// pub fn sha3<'ctx, D>( - context: &mut Context<'ctx, D>, - offset: inkwell::values::IntValue<'ctx>, - length: inkwell::values::IntValue<'ctx>, + _context: &mut Context<'ctx, D>, + _offset: inkwell::values::IntValue<'ctx>, + _length: inkwell::values::IntValue<'ctx>, ) -> anyhow::Result> where D: Dependency + Clone, { - Ok(offset.into()) - /* - let offset_pointer = context.builder().build_int_to_ptr( - offset, - context.byte_type().ptr_type(AddressSpace::Heap.into()), - "sha3_offset_pointer", - )?; - - Ok(context - .build_invoke( - context.llvm_runtime().sha3, - &[ - offset_pointer.as_basic_value_enum(), - length.as_basic_value_enum(), - context - .bool_const( - context - .get_function(EraVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER) - .is_some(), - ) - .as_basic_value_enum(), - ], - "sha3_call", - ) - .expect("Always exists")) - */ + todo!() } diff --git a/crates/llvm-context/src/eravm/evm/event.rs b/crates/llvm-context/src/eravm/evm/event.rs index 898d591..2f2ecfd 100644 --- a/crates/llvm-context/src/eravm/evm/event.rs +++ b/crates/llvm-context/src/eravm/evm/event.rs @@ -2,9 +2,6 @@ //! Translates a log or event call. //! -use inkwell::values::BasicValue; - -use crate::eravm::context::address_space::AddressSpace; use crate::eravm::context::Context; use crate::eravm::Dependency; @@ -18,10 +15,10 @@ use crate::eravm::Dependency; /// accept two at once. /// pub fn log<'ctx, D>( - context: &mut Context<'ctx, D>, - input_offset: inkwell::values::IntValue<'ctx>, - input_length: inkwell::values::IntValue<'ctx>, - topics: Vec>, + _context: &mut Context<'ctx, D>, + _input_offset: inkwell::values::IntValue<'ctx>, + _input_length: inkwell::values::IntValue<'ctx>, + _topics: Vec>, ) -> anyhow::Result<()> where D: Dependency + Clone, diff --git a/crates/llvm-context/src/target_machine/mod.rs b/crates/llvm-context/src/target_machine/mod.rs index a044dfc..8790a7b 100644 --- a/crates/llvm-context/src/target_machine/mod.rs +++ b/crates/llvm-context/src/target_machine/mod.rs @@ -64,15 +64,6 @@ impl TargetMachine { /// pub fn set_target_data(&self, module: &inkwell::module::Module) { module.set_triple(&self.target_machine.get_triple()); - let data_layout = self - .target_machine - .get_target_data() - .get_data_layout() - .as_str() - .to_str() - .expect("datalayout sting should be valid") - .to_owned(); - module.set_data_layout(&self.target_machine.get_target_data().get_data_layout()); } diff --git a/crates/solidity/Cargo.toml b/crates/solidity/Cargo.toml index 2984918..6ce1371 100644 --- a/crates/solidity/Cargo.toml +++ b/crates/solidity/Cargo.toml @@ -3,6 +3,7 @@ name = "revive-solidity" version = "1.4.0" authors = [ "Oleksandr Zarudnyi ", + "Cyrill Leutwiler ", ] license = "MIT OR Apache-2.0" edition = "2021" diff --git a/crates/solidity/src/evmla/ethereal_ir/function/block/element/mod.rs b/crates/solidity/src/evmla/ethereal_ir/function/block/element/mod.rs index b30e5bd..fae2e7c 100644 --- a/crates/solidity/src/evmla/ethereal_ir/function/block/element/mod.rs +++ b/crates/solidity/src/evmla/ethereal_ir/function/block/element/mod.rs @@ -1041,13 +1041,13 @@ where InstructionName::CALL => { let mut arguments = self.pop_arguments_llvm(context); - let gas = arguments.remove(0).into_int_value(); - let address = arguments.remove(0).into_int_value(); - let value = arguments.remove(0).into_int_value(); - let input_offset = arguments.remove(0).into_int_value(); - let input_size = arguments.remove(0).into_int_value(); - let output_offset = arguments.remove(0).into_int_value(); - let output_size = arguments.remove(0).into_int_value(); + let _gas = arguments.remove(0).into_int_value(); + let _address = arguments.remove(0).into_int_value(); + let _value = arguments.remove(0).into_int_value(); + let _input_offset = arguments.remove(0).into_int_value(); + let _input_size = arguments.remove(0).into_int_value(); + let _output_offset = arguments.remove(0).into_int_value(); + let _output_size = arguments.remove(0).into_int_value(); todo!() /* diff --git a/crates/solidity/src/yul/parser/statement/expression/function_call/mod.rs b/crates/solidity/src/yul/parser/statement/expression/function_call/mod.rs index c7ef2f3..55ae3dc 100644 --- a/crates/solidity/src/yul/parser/statement/expression/function_call/mod.rs +++ b/crates/solidity/src/yul/parser/statement/expression/function_call/mod.rs @@ -748,15 +748,15 @@ impl FunctionCall { Name::Call => { let arguments = self.pop_arguments::(context)?; - let gas = arguments[0].value.into_int_value(); - let address = arguments[1].value.into_int_value(); - let value = arguments[2].value.into_int_value(); - let input_offset = arguments[3].value.into_int_value(); - let input_size = arguments[4].value.into_int_value(); - let output_offset = arguments[5].value.into_int_value(); - let output_size = arguments[6].value.into_int_value(); + let _gas = arguments[0].value.into_int_value(); + let _address = arguments[1].value.into_int_value(); + let _value = arguments[2].value.into_int_value(); + let _input_offset = arguments[3].value.into_int_value(); + let _input_size = arguments[4].value.into_int_value(); + let _output_offset = arguments[5].value.into_int_value(); + let _output_size = arguments[6].value.into_int_value(); - let simulation_address: Vec> = arguments + let _simulation_address: Vec> = arguments .into_iter() .map(|mut argument| argument.constant.take()) .collect(); diff --git a/crates/solidity/src/yul/parser/statement/expression/function_call/verbatim.rs b/crates/solidity/src/yul/parser/statement/expression/function_call/verbatim.rs index f8a0c69..1ec24df 100644 --- a/crates/solidity/src/yul/parser/statement/expression/function_call/verbatim.rs +++ b/crates/solidity/src/yul/parser/statement/expression/function_call/verbatim.rs @@ -218,7 +218,7 @@ where ); } - let arguments = call.pop_arguments_llvm::(context)?; + let _arguments = call.pop_arguments_llvm::(context)?; todo!() //era_compiler_llvm_context::eravm_call::raw_far( // context, @@ -255,7 +255,7 @@ where ) .map(Some) } - identifier @ "system_call" => { + _identifier @ "system_call" => { unimplemented!() } identifier @ "system_call_byref" => {