diff --git a/crates/common/src/eravm/address.rs b/crates/common/src/eravm/address.rs deleted file mode 100644 index 9da5f4a..0000000 --- a/crates/common/src/eravm/address.rs +++ /dev/null @@ -1,115 +0,0 @@ -//! The EraVM address constants. - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_TO_L1: u16 = 0xFFFF; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_PRECOMPILE: u16 = 0xFFFD; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_META: u16 = 0xFFFC; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_MIMIC_CALL: u16 = 0xFFFB; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_SYSTEM_MIMIC_CALL: u16 = 0xFFFA; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_MIMIC_CALL_BYREF: u16 = 0xFFF9; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_SYSTEM_MIMIC_CALL_BYREF: u16 = 0xFFF8; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_RAW_FAR_CALL: u16 = 0xFFF7; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_RAW_FAR_CALL_BYREF: u16 = 0xFFF6; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_SYSTEM_CALL: u16 = 0xFFF5; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_SYSTEM_CALL_BYREF: u16 = 0xFFF4; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_SET_CONTEXT_VALUE_CALL: u16 = 0xFFF3; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_SET_PUBDATA_PRICE: u16 = 0xFFF2; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_INCREMENT_TX_COUNTER: u16 = 0xFFF1; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_GET_GLOBAL_PTR_CALLDATA: u16 = 0xFFF0; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_GET_GLOBAL_CALL_FLAGS: u16 = 0xFFEF; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_GET_GLOBAL_PTR_RETURN_DATA: u16 = 0xFFEE; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_EVENT_INITIALIZE: u16 = 0xFFED; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_EVENT_WRITE: u16 = 0xFFEC; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_LOAD_CALLDATA: u16 = 0xFFEB; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_LOAD_RETURN_DATA: u16 = 0xFFEA; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_ADD: u16 = 0xFFE9; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_SHRINK: u16 = 0xFFE8; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_PACK: u16 = 0xFFE7; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_MULTIPLICATION_HIGH_REGISTER: u16 = 0xFFE6; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_GET_GLOBAL_EXTRA_ABI_DATA: u16 = 0xFFE5; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_DATA_LOAD: u16 = 0xFFE4; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_DATA_COPY: u16 = 0xFFE3; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_DATA_SIZE: u16 = 0xFFE2; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_CONST_ARRAY_DECLARE: u16 = 0xFFE1; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_CONST_ARRAY_SET: u16 = 0xFFE0; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_CONST_ARRAY_FINALIZE: u16 = 0xFFDF; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_CONST_ARRAY_GET: u16 = 0xFFDE; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_DECOMMIT: u16 = 0xFFDD; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_LOAD_DECOMMIT: u16 = 0xFFDC; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_RETURN_FORWARD: u16 = 0xFFDB; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_REVERT_FORWARD: u16 = 0xFFDA; - -/// The corresponding simulation predefined address. -pub const ERAVM_ADDRESS_ACTIVE_PTR_SWAP: u16 = 0xFFD9; diff --git a/crates/common/src/eravm/mod.rs b/crates/common/src/eravm/mod.rs deleted file mode 100644 index 05eb1ec..0000000 --- a/crates/common/src/eravm/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! -//! The EraVM constants. -//! - -pub mod address; diff --git a/crates/common/src/extension.rs b/crates/common/src/extension.rs index 5dca06b..8cbaa87 100644 --- a/crates/common/src/extension.rs +++ b/crates/common/src/extension.rs @@ -39,8 +39,8 @@ pub static EXTENSION_LLVM_SOURCE: &str = "ll"; /// The LLVM bitcode file extension. pub static EXTENSION_LLVM_BINARY: &str = "bc"; -/// The EraVM assembly file extension. -pub static EXTENSION_ERAVM_ASSEMBLY: &str = "zasm"; +/// The PolkaVM assembly file extension. +pub static EXTENSION_POLKAVM_ASSEMBLY: &str = "zasm"; -/// The EraVM bytecode file extension. -pub static EXTENSION_ERAVM_BINARY: &str = "zbin"; +/// The PolkaVM bytecode file extension. +pub static EXTENSION_POLKAVM_BINARY: &str = "zbin"; diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index ac70220..350dde6 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -3,17 +3,17 @@ pub(crate) mod base; pub(crate) mod bit_length; pub(crate) mod byte_length; -pub(crate) mod eravm; pub(crate) mod evm_version; pub(crate) mod exit_code; pub(crate) mod extension; +pub(crate) mod polkavm; pub(crate) mod utils; pub use self::base::*; pub use self::bit_length::*; pub use self::byte_length::*; -pub use self::eravm::address::*; pub use self::evm_version::EVMVersion; pub use self::exit_code::*; pub use self::extension::*; +pub use self::polkavm::address::*; pub use self::utils::*; diff --git a/crates/common/src/polkavm/address.rs b/crates/common/src/polkavm/address.rs new file mode 100644 index 0000000..2e500df --- /dev/null +++ b/crates/common/src/polkavm/address.rs @@ -0,0 +1,115 @@ +//! The PolkaVM address constants. + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_TO_L1: u16 = 0xFFFF; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_PRECOMPILE: u16 = 0xFFFD; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_META: u16 = 0xFFFC; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_MIMIC_CALL: u16 = 0xFFFB; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_SYSTEM_MIMIC_CALL: u16 = 0xFFFA; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_MIMIC_CALL_BYREF: u16 = 0xFFF9; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_SYSTEM_MIMIC_CALL_BYREF: u16 = 0xFFF8; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_RAW_FAR_CALL: u16 = 0xFFF7; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_RAW_FAR_CALL_BYREF: u16 = 0xFFF6; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_SYSTEM_CALL: u16 = 0xFFF5; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_SYSTEM_CALL_BYREF: u16 = 0xFFF4; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_SET_CONTEXT_VALUE_CALL: u16 = 0xFFF3; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_SET_PUBDATA_PRICE: u16 = 0xFFF2; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_INCREMENT_TX_COUNTER: u16 = 0xFFF1; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_GET_GLOBAL_PTR_CALLDATA: u16 = 0xFFF0; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_GET_GLOBAL_CALL_FLAGS: u16 = 0xFFEF; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_GET_GLOBAL_PTR_RETURN_DATA: u16 = 0xFFEE; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_EVENT_INITIALIZE: u16 = 0xFFED; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_EVENT_WRITE: u16 = 0xFFEC; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_LOAD_CALLDATA: u16 = 0xFFEB; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_LOAD_RETURN_DATA: u16 = 0xFFEA; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_ADD: u16 = 0xFFE9; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_SHRINK: u16 = 0xFFE8; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_PACK: u16 = 0xFFE7; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_MULTIPLICATION_HIGH_REGISTER: u16 = 0xFFE6; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_GET_GLOBAL_EXTRA_ABI_DATA: u16 = 0xFFE5; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_DATA_LOAD: u16 = 0xFFE4; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_DATA_COPY: u16 = 0xFFE3; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_DATA_SIZE: u16 = 0xFFE2; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_CONST_ARRAY_DECLARE: u16 = 0xFFE1; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_CONST_ARRAY_SET: u16 = 0xFFE0; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_CONST_ARRAY_FINALIZE: u16 = 0xFFDF; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_CONST_ARRAY_GET: u16 = 0xFFDE; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_DECOMMIT: u16 = 0xFFDD; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_LOAD_DECOMMIT: u16 = 0xFFDC; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_RETURN_FORWARD: u16 = 0xFFDB; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_REVERT_FORWARD: u16 = 0xFFDA; + +/// The corresponding simulation predefined address. +pub const POLKAVM_ADDRESS_ACTIVE_PTR_SWAP: u16 = 0xFFD9; diff --git a/crates/common/src/polkavm/mod.rs b/crates/common/src/polkavm/mod.rs new file mode 100644 index 0000000..093d451 --- /dev/null +++ b/crates/common/src/polkavm/mod.rs @@ -0,0 +1,5 @@ +//! +//! The PolkaVM constants. +//! + +pub mod address; diff --git a/crates/integration/codesize.json b/crates/integration/codesize.json index b799d3a..efad337 100644 --- a/crates/integration/codesize.json +++ b/crates/integration/codesize.json @@ -1,7 +1,7 @@ { - "Computation": 7380, - "Baseline": 3912, - "Flipper": 4354, "Fibonacci": 5971, - "ERC20": 53186 + "Baseline": 3912, + "ERC20": 53186, + "Flipper": 4354, + "Computation": 7380 } \ No newline at end of file diff --git a/crates/llvm-context/Cargo.toml b/crates/llvm-context/Cargo.toml index f60bedf..347f92b 100644 --- a/crates/llvm-context/Cargo.toml +++ b/crates/llvm-context/Cargo.toml @@ -7,7 +7,7 @@ authors = [ ] license = "MIT OR Apache-2.0" edition = "2021" -description = "Shared front end code of the EraVM compilers" +description = "Shared front end code of the revive PolkaVM compilers" [lib] doctest = false diff --git a/crates/llvm-context/src/debug_config/ir_type.rs b/crates/llvm-context/src/debug_config/ir_type.rs index 8541b5c..6ad11ed 100644 --- a/crates/llvm-context/src/debug_config/ir_type.rs +++ b/crates/llvm-context/src/debug_config/ir_type.rs @@ -28,7 +28,7 @@ impl IRType { Self::EVMLA => revive_common::EXTENSION_EVMLA, Self::LLL => revive_common::EXTENSION_LLL, Self::LLVM => revive_common::EXTENSION_LLVM_SOURCE, - Self::Assembly => revive_common::EXTENSION_ERAVM_ASSEMBLY, + Self::Assembly => revive_common::EXTENSION_POLKAVM_ASSEMBLY, } } } diff --git a/crates/llvm-context/src/lib.rs b/crates/llvm-context/src/lib.rs index 744c740..518ebef 100644 --- a/crates/llvm-context/src/lib.rs +++ b/crates/llvm-context/src/lib.rs @@ -1,74 +1,74 @@ //! The LLVM context library. pub(crate) mod debug_config; -pub(crate) mod eravm; pub(crate) mod optimizer; +pub(crate) mod polkavm; pub(crate) mod target_machine; pub use self::debug_config::ir_type::IRType as DebugConfigIR; pub use self::debug_config::DebugConfig; -pub use self::eravm::build_assembly_text as eravm_build_assembly_text; -pub use self::eravm::context::address_space::AddressSpace as EraVMAddressSpace; -pub use self::eravm::context::argument::Argument as EraVMArgument; -pub use self::eravm::context::attribute::Attribute as EraVMAttribute; -pub use self::eravm::context::build::Build as EraVMBuild; -pub use self::eravm::context::code_type::CodeType as EraVMCodeType; -pub use self::eravm::context::evmla_data::EVMLAData as EraVMContextEVMLAData; -pub use self::eravm::context::function::block::evmla_data::key::Key as EraVMFunctionBlockKey; -pub use self::eravm::context::function::block::evmla_data::EVMLAData as EraVMFunctionBlockEVMLAData; -pub use self::eravm::context::function::block::Block as EraVMFunctionBlock; -pub use self::eravm::context::function::declaration::Declaration as EraVMFunctionDeclaration; -pub use self::eravm::context::function::evmla_data::EVMLAData as EraVMFunctionEVMLAData; -pub use self::eravm::context::function::intrinsics::Intrinsics as EraVMIntrinsicFunction; -pub use self::eravm::context::function::llvm_runtime::LLVMRuntime as EraVMLLVMRuntime; -pub use self::eravm::context::function::r#return::Return as EraVMFunctionReturn; -pub use self::eravm::context::function::runtime::deploy_code::DeployCode as EraVMDeployCodeFunction; -pub use self::eravm::context::function::runtime::entry::Entry as EraVMEntryFunction; -pub use self::eravm::context::function::runtime::runtime_code::RuntimeCode as EraVMRuntimeCodeFunction; -pub use self::eravm::context::function::runtime::Runtime as EraVMRuntime; -pub use self::eravm::context::function::vyper_data::VyperData as EraVMFunctionVyperData; -pub use self::eravm::context::function::yul_data::YulData as EraVMFunctionYulData; -pub use self::eravm::context::function::Function as EraVMFunction; -pub use self::eravm::context::global::Global as EraVMGlobal; -pub use self::eravm::context::pointer::Pointer as EraVMPointer; -pub use self::eravm::context::r#loop::Loop as EraVMLoop; -pub use self::eravm::context::solidity_data::SolidityData as EraVMContextSolidityData; -pub use self::eravm::context::vyper_data::VyperData as EraVMContextVyperData; -pub use self::eravm::context::yul_data::YulData as EraVMContextYulData; -pub use self::eravm::context::Context as EraVMContext; -pub use self::eravm::evm::arithmetic as eravm_evm_arithmetic; -pub use self::eravm::evm::bitwise as eravm_evm_bitwise; -pub use self::eravm::evm::call as eravm_evm_call; -pub use self::eravm::evm::calldata as eravm_evm_calldata; -pub use self::eravm::evm::comparison as eravm_evm_comparison; -pub use self::eravm::evm::context as eravm_evm_contract_context; -pub use self::eravm::evm::create as eravm_evm_create; -pub use self::eravm::evm::crypto as eravm_evm_crypto; -pub use self::eravm::evm::ether_gas as eravm_evm_ether_gas; -pub use self::eravm::evm::event as eravm_evm_event; -pub use self::eravm::evm::ext_code as eravm_evm_ext_code; -pub use self::eravm::evm::immutable as eravm_evm_immutable; -pub use self::eravm::evm::math as eravm_evm_math; -pub use self::eravm::evm::memory as eravm_evm_memory; -pub use self::eravm::evm::r#return as eravm_evm_return; -pub use self::eravm::evm::return_data as eravm_evm_return_data; -pub use self::eravm::evm::storage as eravm_evm_storage; -pub use self::eravm::metadata_hash::MetadataHash as EraVMMetadataHash; -pub use self::eravm::r#const as eravm_const; -pub use self::eravm::utils as eravm_utils; -pub use self::eravm::Dependency as EraVMDependency; -pub use self::eravm::DummyDependency as EraVMDummyDependency; -pub use self::eravm::DummyLLVMWritable as EraVMDummyLLVMWritable; -pub use self::eravm::WriteLLVM as EraVMWriteLLVM; pub use self::optimizer::settings::size_level::SizeLevel as OptimizerSettingsSizeLevel; pub use self::optimizer::settings::Settings as OptimizerSettings; pub use self::optimizer::Optimizer; +pub use self::polkavm::build_assembly_text as polkavm_build_assembly_text; +pub use self::polkavm::context::address_space::AddressSpace as PolkaVMAddressSpace; +pub use self::polkavm::context::argument::Argument as PolkaVMArgument; +pub use self::polkavm::context::attribute::Attribute as PolkaVMAttribute; +pub use self::polkavm::context::build::Build as PolkaVMBuild; +pub use self::polkavm::context::code_type::CodeType as PolkaVMCodeType; +pub use self::polkavm::context::evmla_data::EVMLAData as PolkaVMContextEVMLAData; +pub use self::polkavm::context::function::block::evmla_data::key::Key as PolkaVMFunctionBlockKey; +pub use self::polkavm::context::function::block::evmla_data::EVMLAData as PolkaVMFunctionBlockEVMLAData; +pub use self::polkavm::context::function::block::Block as PolkaVMFunctionBlock; +pub use self::polkavm::context::function::declaration::Declaration as PolkaVMFunctionDeclaration; +pub use self::polkavm::context::function::evmla_data::EVMLAData as PolkaVMFunctionEVMLAData; +pub use self::polkavm::context::function::intrinsics::Intrinsics as PolkaVMIntrinsicFunction; +pub use self::polkavm::context::function::llvm_runtime::LLVMRuntime as PolkaVMLLVMRuntime; +pub use self::polkavm::context::function::r#return::Return as PolkaVMFunctionReturn; +pub use self::polkavm::context::function::runtime::deploy_code::DeployCode as PolkaVMDeployCodeFunction; +pub use self::polkavm::context::function::runtime::entry::Entry as PolkaVMEntryFunction; +pub use self::polkavm::context::function::runtime::runtime_code::RuntimeCode as PolkaVMRuntimeCodeFunction; +pub use self::polkavm::context::function::runtime::Runtime as PolkaVMRuntime; +pub use self::polkavm::context::function::vyper_data::VyperData as PolkaVMFunctionVyperData; +pub use self::polkavm::context::function::yul_data::YulData as PolkaVMFunctionYulData; +pub use self::polkavm::context::function::Function as PolkaVMFunction; +pub use self::polkavm::context::global::Global as PolkaVMGlobal; +pub use self::polkavm::context::pointer::Pointer as PolkaVMPointer; +pub use self::polkavm::context::r#loop::Loop as PolkaVMLoop; +pub use self::polkavm::context::solidity_data::SolidityData as PolkaVMContextSolidityData; +pub use self::polkavm::context::vyper_data::VyperData as PolkaVMContextVyperData; +pub use self::polkavm::context::yul_data::YulData as PolkaVMContextYulData; +pub use self::polkavm::context::Context as PolkaVMContext; +pub use self::polkavm::evm::arithmetic as polkavm_evm_arithmetic; +pub use self::polkavm::evm::bitwise as polkavm_evm_bitwise; +pub use self::polkavm::evm::call as polkavm_evm_call; +pub use self::polkavm::evm::calldata as polkavm_evm_calldata; +pub use self::polkavm::evm::comparison as polkavm_evm_comparison; +pub use self::polkavm::evm::context as polkavm_evm_contract_context; +pub use self::polkavm::evm::create as polkavm_evm_create; +pub use self::polkavm::evm::crypto as polkavm_evm_crypto; +pub use self::polkavm::evm::ether_gas as polkavm_evm_ether_gas; +pub use self::polkavm::evm::event as polkavm_evm_event; +pub use self::polkavm::evm::ext_code as polkavm_evm_ext_code; +pub use self::polkavm::evm::immutable as polkavm_evm_immutable; +pub use self::polkavm::evm::math as polkavm_evm_math; +pub use self::polkavm::evm::memory as polkavm_evm_memory; +pub use self::polkavm::evm::r#return as polkavm_evm_return; +pub use self::polkavm::evm::return_data as polkavm_evm_return_data; +pub use self::polkavm::evm::storage as polkavm_evm_storage; +pub use self::polkavm::metadata_hash::MetadataHash as PolkaVMMetadataHash; +pub use self::polkavm::r#const as polkavm_const; +pub use self::polkavm::utils as polkavm_utils; +pub use self::polkavm::Dependency as PolkaVMDependency; +pub use self::polkavm::DummyDependency as PolkaVMDummyDependency; +pub use self::polkavm::DummyLLVMWritable as PolkaVMDummyLLVMWritable; +pub use self::polkavm::WriteLLVM as PolkaVMWriteLLVM; pub use self::target_machine::target::Target; pub use self::target_machine::TargetMachine; /// Initializes the target machine. pub fn initialize_target(target: Target) { match target { - Target::PVM => self::eravm::initialize_target(), + Target::PVM => self::polkavm::initialize_target(), } } diff --git a/crates/llvm-context/src/eravm/const.rs b/crates/llvm-context/src/polkavm/const.rs similarity index 99% rename from crates/llvm-context/src/eravm/const.rs rename to crates/llvm-context/src/polkavm/const.rs index a049ac7..20b42d3 100644 --- a/crates/llvm-context/src/eravm/const.rs +++ b/crates/llvm-context/src/polkavm/const.rs @@ -3,7 +3,7 @@ /// The LLVM framework version. pub const LLVM_VERSION: semver::Version = semver::Version::new(18, 1, 4); -/// The EraVM version. +/// The PolkaVM version. pub const ZKEVM_VERSION: semver::Version = semver::Version::new(1, 3, 2); /// The register width sized type diff --git a/crates/llvm-context/src/eravm/context/address_space.rs b/crates/llvm-context/src/polkavm/context/address_space.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/address_space.rs rename to crates/llvm-context/src/polkavm/context/address_space.rs diff --git a/crates/llvm-context/src/eravm/context/argument.rs b/crates/llvm-context/src/polkavm/context/argument.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/argument.rs rename to crates/llvm-context/src/polkavm/context/argument.rs diff --git a/crates/llvm-context/src/eravm/context/attribute.rs b/crates/llvm-context/src/polkavm/context/attribute.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/attribute.rs rename to crates/llvm-context/src/polkavm/context/attribute.rs diff --git a/crates/llvm-context/src/eravm/context/build.rs b/crates/llvm-context/src/polkavm/context/build.rs similarity index 89% rename from crates/llvm-context/src/eravm/context/build.rs rename to crates/llvm-context/src/polkavm/context/build.rs index 5e6705c..4b2aee0 100644 --- a/crates/llvm-context/src/eravm/context/build.rs +++ b/crates/llvm-context/src/polkavm/context/build.rs @@ -8,13 +8,13 @@ use serde::Serialize; /// The LLVM module build. #[derive(Debug, Serialize, Deserialize)] pub struct Build { - /// The EraVM text assembly. + /// The PolkaVM text assembly. pub assembly_text: String, /// The metadata hash. pub metadata_hash: Option<[u8; revive_common::BYTE_LENGTH_FIELD]>, - /// The EraVM binary bytecode. + /// The PolkaVM binary bytecode. pub bytecode: Vec, - /// The EraVM bytecode hash. + /// The PolkaVM bytecode hash. pub bytecode_hash: String, /// The hash-to-full-path mapping of the contract factory dependencies. pub factory_dependencies: BTreeMap, diff --git a/crates/llvm-context/src/eravm/context/code_type.rs b/crates/llvm-context/src/polkavm/context/code_type.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/code_type.rs rename to crates/llvm-context/src/polkavm/context/code_type.rs diff --git a/crates/llvm-context/src/eravm/context/debug_info.rs b/crates/llvm-context/src/polkavm/context/debug_info.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/debug_info.rs rename to crates/llvm-context/src/polkavm/context/debug_info.rs diff --git a/crates/llvm-context/src/eravm/context/evmla_data.rs b/crates/llvm-context/src/polkavm/context/evmla_data.rs similarity index 94% rename from crates/llvm-context/src/eravm/context/evmla_data.rs rename to crates/llvm-context/src/polkavm/context/evmla_data.rs index c983a66..ba8ac97 100644 --- a/crates/llvm-context/src/eravm/context/evmla_data.rs +++ b/crates/llvm-context/src/polkavm/context/evmla_data.rs @@ -1,6 +1,6 @@ //! The LLVM IR generator EVM legacy assembly data. -use crate::eravm::context::argument::Argument; +use crate::polkavm::context::argument::Argument; /// The LLVM IR generator EVM legacy assembly data. /// Describes some data that is only relevant to the EVM legacy assembly. diff --git a/crates/llvm-context/src/eravm/context/function/block/evmla_data/key.rs b/crates/llvm-context/src/polkavm/context/function/block/evmla_data/key.rs similarity index 94% rename from crates/llvm-context/src/eravm/context/function/block/evmla_data/key.rs rename to crates/llvm-context/src/polkavm/context/function/block/evmla_data/key.rs index 50faa04..d890753 100644 --- a/crates/llvm-context/src/eravm/context/function/block/evmla_data/key.rs +++ b/crates/llvm-context/src/polkavm/context/function/block/evmla_data/key.rs @@ -1,6 +1,6 @@ //! The LLVM IR generator function block key. -use crate::eravm::context::code_type::CodeType; +use crate::polkavm::context::code_type::CodeType; /// The LLVM IR generator function block key. /// Is only relevant to the EVM legacy assembly. diff --git a/crates/llvm-context/src/eravm/context/function/block/evmla_data/mod.rs b/crates/llvm-context/src/polkavm/context/function/block/evmla_data/mod.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/function/block/evmla_data/mod.rs rename to crates/llvm-context/src/polkavm/context/function/block/evmla_data/mod.rs diff --git a/crates/llvm-context/src/eravm/context/function/block/mod.rs b/crates/llvm-context/src/polkavm/context/function/block/mod.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/function/block/mod.rs rename to crates/llvm-context/src/polkavm/context/function/block/mod.rs diff --git a/crates/llvm-context/src/eravm/context/function/declaration.rs b/crates/llvm-context/src/polkavm/context/function/declaration.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/function/declaration.rs rename to crates/llvm-context/src/polkavm/context/function/declaration.rs diff --git a/crates/llvm-context/src/eravm/context/function/evmla_data.rs b/crates/llvm-context/src/polkavm/context/function/evmla_data.rs similarity index 94% rename from crates/llvm-context/src/eravm/context/function/evmla_data.rs rename to crates/llvm-context/src/polkavm/context/function/evmla_data.rs index 5b3ae59..eeb1f32 100644 --- a/crates/llvm-context/src/eravm/context/function/evmla_data.rs +++ b/crates/llvm-context/src/polkavm/context/function/evmla_data.rs @@ -2,8 +2,8 @@ use std::collections::BTreeMap; -use crate::eravm::context::function::block::evmla_data::key::Key as BlockKey; -use crate::eravm::context::function::block::Block; +use crate::polkavm::context::function::block::evmla_data::key::Key as BlockKey; +use crate::polkavm::context::function::block::Block; /// The LLVM function EVM legacy assembly data. /// Describes some data that is only relevant to the EVM legacy assembly. diff --git a/crates/llvm-context/src/eravm/context/function/intrinsics.rs b/crates/llvm-context/src/polkavm/context/function/intrinsics.rs similarity index 97% rename from crates/llvm-context/src/eravm/context/function/intrinsics.rs rename to crates/llvm-context/src/polkavm/context/function/intrinsics.rs index 5d69bfb..0c752a1 100644 --- a/crates/llvm-context/src/eravm/context/function/intrinsics.rs +++ b/crates/llvm-context/src/polkavm/context/function/intrinsics.rs @@ -2,8 +2,8 @@ use inkwell::types::BasicType; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::function::declaration::Declaration as FunctionDeclaration; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration; /// The LLVM intrinsic functions, implemented in the LLVM back-end. /// Most of them are translated directly into bytecode instructions. diff --git a/crates/llvm-context/src/eravm/context/function/llvm_runtime.rs b/crates/llvm-context/src/polkavm/context/function/llvm_runtime.rs similarity index 98% rename from crates/llvm-context/src/eravm/context/function/llvm_runtime.rs rename to crates/llvm-context/src/polkavm/context/function/llvm_runtime.rs index 66c7e22..bbc90b0 100644 --- a/crates/llvm-context/src/eravm/context/function/llvm_runtime.rs +++ b/crates/llvm-context/src/polkavm/context/function/llvm_runtime.rs @@ -2,10 +2,10 @@ use inkwell::types::BasicType; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::function::declaration::Declaration as FunctionDeclaration; -use crate::eravm::context::function::Function; use crate::optimizer::Optimizer; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration; +use crate::polkavm::context::function::Function; /// The runtime functions, implemented on the LLVM side. /// The functions are automatically linked to the LLVM implementations if the signatures match. @@ -415,8 +415,8 @@ impl<'ctx> LLVMRuntime<'ctx> { llvm.custom_width_int_type(revive_common::BIT_LENGTH_FIELD as u32) .as_basic_type_enum() .into(); - crate::eravm::context::function::runtime::entry::Entry::MANDATORY_ARGUMENTS_COUNT - + crate::eravm::EXTRA_ABI_DATA_SIZE + crate::polkavm::context::function::runtime::entry::Entry::MANDATORY_ARGUMENTS_COUNT + + crate::polkavm::EXTRA_ABI_DATA_SIZE ]; let mut mimic_call_arguments = external_call_arguments.clone(); mimic_call_arguments.push( @@ -439,7 +439,7 @@ impl<'ctx> LLVMRuntime<'ctx> { ) .as_basic_type_enum() .into(); - crate::eravm::EXTRA_ABI_DATA_SIZE + crate::polkavm::EXTRA_ABI_DATA_SIZE ]); let mut mimic_call_arguments_by_ref = external_call_arguments_by_ref.clone(); mimic_call_arguments_by_ref.push( diff --git a/crates/llvm-context/src/eravm/context/function/mod.rs b/crates/llvm-context/src/polkavm/context/function/mod.rs similarity index 99% rename from crates/llvm-context/src/eravm/context/function/mod.rs rename to crates/llvm-context/src/polkavm/context/function/mod.rs index 323dd4f..7425f36 100644 --- a/crates/llvm-context/src/eravm/context/function/mod.rs +++ b/crates/llvm-context/src/polkavm/context/function/mod.rs @@ -12,10 +12,10 @@ pub mod yul_data; use std::collections::HashMap; -use crate::eravm::context::attribute::Attribute; -use crate::eravm::context::pointer::Pointer; use crate::optimizer::settings::size_level::SizeLevel; use crate::optimizer::Optimizer; +use crate::polkavm::context::attribute::Attribute; +use crate::polkavm::context::pointer::Pointer; use self::declaration::Declaration; use self::evmla_data::EVMLAData; diff --git a/crates/llvm-context/src/eravm/context/function/return.rs b/crates/llvm-context/src/polkavm/context/function/return.rs similarity index 97% rename from crates/llvm-context/src/eravm/context/function/return.rs rename to crates/llvm-context/src/polkavm/context/function/return.rs index 268920f..a318949 100644 --- a/crates/llvm-context/src/eravm/context/function/return.rs +++ b/crates/llvm-context/src/polkavm/context/function/return.rs @@ -1,6 +1,6 @@ //! The LLVM IR generator function return entity. -use crate::eravm::context::pointer::Pointer; +use crate::polkavm::context::pointer::Pointer; /// The LLVM IR generator function return entity. #[derive(Debug, Clone, Copy)] diff --git a/crates/llvm-context/src/eravm/context/function/runtime/default_call.rs b/crates/llvm-context/src/polkavm/context/function/runtime/default_call.rs similarity index 93% rename from crates/llvm-context/src/eravm/context/function/runtime/default_call.rs rename to crates/llvm-context/src/polkavm/context/function/runtime/default_call.rs index f28ee69..98e97e4 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/default_call.rs +++ b/crates/llvm-context/src/polkavm/context/function/runtime/default_call.rs @@ -2,12 +2,12 @@ use inkwell::types::BasicType; -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::Context; -use crate::eravm::Dependency; -use crate::eravm::WriteLLVM; +use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration; +use crate::polkavm::context::function::llvm_runtime::LLVMRuntime; +use crate::polkavm::context::function::Function; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; +use crate::polkavm::WriteLLVM; /// The `default_call` function. /// Generates a default contract call, if the `msg.value` is zero. @@ -150,7 +150,7 @@ where /* context.build_store(status_code_result_pointer, context.field_const(0)); - let abi_data = crate::eravm::utils::abi_data( + let abi_data = crate::polkavm::utils::abi_data( context, input_offset, input_length, @@ -163,7 +163,7 @@ where let result = context .build_call( self.inner_function(context), - crate::eravm::utils::external_call_arguments( + crate::polkavm::utils::external_call_arguments( context, abi_data.as_basic_value_enum(), address, @@ -225,11 +225,11 @@ where context.write_abi_pointer( result_abi_data_pointer, - crate::eravm::GLOBAL_RETURN_DATA_POINTER, + crate::polkavm::GLOBAL_RETURN_DATA_POINTER, ); context.write_abi_data_size( result_abi_data_pointer, - crate::eravm::GLOBAL_RETURN_DATA_SIZE, + crate::polkavm::GLOBAL_RETURN_DATA_SIZE, ); */ context.build_unconditional_branch(context.current_function().borrow().return_block()); diff --git a/crates/llvm-context/src/eravm/context/function/runtime/deploy_code.rs b/crates/llvm-context/src/polkavm/context/function/runtime/deploy_code.rs similarity index 87% rename from crates/llvm-context/src/eravm/context/function/runtime/deploy_code.rs rename to crates/llvm-context/src/polkavm/context/function/runtime/deploy_code.rs index 6c5feb5..14eff77 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/deploy_code.rs +++ b/crates/llvm-context/src/polkavm/context/function/runtime/deploy_code.rs @@ -2,13 +2,13 @@ use std::marker::PhantomData; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::code_type::CodeType; -use crate::eravm::context::function::runtime::Runtime; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; -use crate::eravm::WriteLLVM; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::code_type::CodeType; +use crate::polkavm::context::function::runtime::Runtime; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; +use crate::polkavm::WriteLLVM; /// The deploy code function. /// Is a special function that is only used by the front-end generated code. @@ -63,7 +63,7 @@ where context.set_code_type(CodeType::Deploy); if let Some(vyper) = context.vyper_data.as_ref() { for index in 0..vyper.immutables_size() / revive_common::BYTE_LENGTH_FIELD { - let offset = (crate::eravm::r#const::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + let offset = (crate::polkavm::r#const::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA as usize) + (1 + index) * 2 * revive_common::BYTE_LENGTH_FIELD; let value = index * revive_common::BYTE_LENGTH_FIELD; diff --git a/crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs b/crates/llvm-context/src/polkavm/context/function/runtime/deployer_call.rs similarity index 93% rename from crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs rename to crates/llvm-context/src/polkavm/context/function/runtime/deployer_call.rs index 974f9f9..90fb78e 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/deployer_call.rs +++ b/crates/llvm-context/src/polkavm/context/function/runtime/deployer_call.rs @@ -2,12 +2,12 @@ use inkwell::types::BasicType; -use crate::eravm::context::address_space::AddressSpace; -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; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::function::Function; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; +use crate::polkavm::WriteLLVM; /// The `deployer_call` function. /// Calls the deployer system contract, which returns the newly deployed contract address or 0. @@ -112,7 +112,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::polkavm::utils::abi_data( context, input_offset, input_length, @@ -159,7 +159,7 @@ where context.build_store( arguments_offset_pointer, context.field_const( - (crate::eravm::DEPLOYER_CALL_HEADER_SIZE + (crate::polkavm::DEPLOYER_CALL_HEADER_SIZE - (revive_common::BYTE_LENGTH_X32 + revive_common::BYTE_LENGTH_FIELD)) as u64, ), @@ -179,7 +179,7 @@ where ); let arguments_length_value = context.builder().build_int_sub( input_length, - context.field_const(crate::eravm::DEPLOYER_CALL_HEADER_SIZE as u64), + context.field_const(crate::polkavm::DEPLOYER_CALL_HEADER_SIZE as u64), "deployer_call_arguments_length", )?; context.build_store(arguments_length_pointer, arguments_length_value)?; @@ -212,7 +212,7 @@ where //let deployer_call_result = context // .build_call( // context.llvm_runtime().far_call, - // crate::eravm::utils::external_call_arguments( + // crate::polkavm::utils::external_call_arguments( // context, // abi_data, // context.field_const(zkevm_opcode_defs::ADDRESS_CONTRACT_DEPLOYER.into()), @@ -230,14 +230,14 @@ where //let deployer_call_result = context // .build_call( // context.llvm_runtime().far_call, - // crate::eravm::utils::external_call_arguments( + // crate::polkavm::utils::external_call_arguments( // context, // abi_data.as_basic_value_enum(), // context.field_const(zkevm_opcode_defs::ADDRESS_MSG_VALUE.into()), // vec![ // value, // context.field_const(zkevm_opcode_defs::ADDRESS_CONTRACT_DEPLOYER.into()), - // context.field_const(u64::from(crate::eravm::r#const::SYSTEM_CALL_BIT)), + // context.field_const(u64::from(crate::polkavm::r#const::SYSTEM_CALL_BIT)), // ], // None, // ) @@ -307,11 +307,11 @@ where ); context.write_abi_pointer( result_abi_data_pointer, - crate::eravm::GLOBAL_RETURN_DATA_POINTER, + crate::polkavm::GLOBAL_RETURN_DATA_POINTER, ); context.write_abi_data_size( result_abi_data_pointer, - crate::eravm::GLOBAL_RETURN_DATA_SIZE, + crate::polkavm::GLOBAL_RETURN_DATA_SIZE, ); context.build_unconditional_branch(context.current_function().borrow().return_block()); diff --git a/crates/llvm-context/src/eravm/context/function/runtime/entry.rs b/crates/llvm-context/src/polkavm/context/function/runtime/entry.rs similarity index 88% rename from crates/llvm-context/src/eravm/context/function/runtime/entry.rs rename to crates/llvm-context/src/polkavm/context/function/runtime/entry.rs index b77b887..19ff5a9 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/entry.rs +++ b/crates/llvm-context/src/polkavm/context/function/runtime/entry.rs @@ -2,12 +2,12 @@ use inkwell::types::BasicType; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::function::runtime::Runtime; -use crate::eravm::context::Context; -use crate::eravm::Dependency; -use crate::eravm::WriteLLVM; -use crate::EraVMPointer as Pointer; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::function::runtime::Runtime; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; +use crate::polkavm::WriteLLVM; +use crate::PolkaVMPointer as Pointer; /// The entry function. /// The function is a wrapper managing the runtime and deploy code calling logic. @@ -33,40 +33,40 @@ impl Entry { { let calldata_type = context.array_type(context.byte_type(), Self::MAX_CALLDATA_SIZE); context.set_global( - crate::eravm::GLOBAL_CALLDATA_POINTER, + crate::polkavm::GLOBAL_CALLDATA_POINTER, calldata_type, AddressSpace::Stack, calldata_type.get_undef(), ); context.set_global( - crate::eravm::GLOBAL_HEAP_MEMORY_POINTER, + crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER, context.llvm().ptr_type(AddressSpace::Generic.into()), AddressSpace::Stack, context.xlen_type().get_undef(), ); context.build_store( context - .get_global(crate::eravm::GLOBAL_HEAP_MEMORY_POINTER)? + .get_global(crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER)? .into(), context.build_sbrk(context.integer_const(32, 0))?, )?; context.set_global( - crate::eravm::GLOBAL_CALLDATA_SIZE, + crate::polkavm::GLOBAL_CALLDATA_SIZE, context.field_type(), AddressSpace::Stack, context.field_undef(), ); context.set_global( - crate::eravm::GLOBAL_RETURN_DATA_SIZE, + crate::polkavm::GLOBAL_RETURN_DATA_SIZE, context.field_type(), AddressSpace::Stack, context.field_const(0), ); context.set_global( - crate::eravm::GLOBAL_CALL_FLAGS, + crate::polkavm::GLOBAL_CALL_FLAGS, context.field_type(), AddressSpace::Stack, context.field_const(0), @@ -74,10 +74,10 @@ impl Entry { let extra_abi_data_type = context.array_type( context.field_type().as_basic_type_enum(), - crate::eravm::EXTRA_ABI_DATA_SIZE, + crate::polkavm::EXTRA_ABI_DATA_SIZE, ); context.set_global( - crate::eravm::GLOBAL_EXTRA_ABI_DATA, + crate::polkavm::GLOBAL_EXTRA_ABI_DATA, extra_abi_data_type, AddressSpace::Stack, extra_abi_data_type.const_zero(), @@ -93,7 +93,7 @@ impl Entry { D: Dependency + Clone, { let input_pointer = context - .get_global(crate::eravm::GLOBAL_CALLDATA_POINTER)? + .get_global(crate::polkavm::GLOBAL_CALLDATA_POINTER)? .value .as_pointer_value(); let input_pointer_casted = context.builder.build_ptr_to_int( @@ -129,7 +129,7 @@ impl Entry { "zext_input_len", )?; context.set_global( - crate::eravm::GLOBAL_CALLDATA_SIZE, + crate::polkavm::GLOBAL_CALLDATA_SIZE, context.field_type(), AddressSpace::Stack, calldata_size_casted, @@ -152,9 +152,9 @@ impl Entry { ); context.write_abi_pointer( calldata_end_pointer, - crate::eravm::GLOBAL_RETURN_DATA_POINTER, + crate::polkavm::GLOBAL_RETURN_DATA_POINTER, ); - context.write_abi_pointer(calldata_end_pointer, crate::eravm::GLOBAL_ACTIVE_POINTER); + context.write_abi_pointer(calldata_end_pointer, crate::polkavm::GLOBAL_ACTIVE_POINTER); Ok(()) } @@ -171,7 +171,7 @@ impl Entry { .get_nth_param(Self::ARGUMENT_INDEX_CALL_FLAGS); context.set_global( - crate::eravm::GLOBAL_CALL_FLAGS, + crate::polkavm::GLOBAL_CALL_FLAGS, is_deploy.get_type(), AddressSpace::Stack, is_deploy.into_int_value(), @@ -233,10 +233,10 @@ where .expect("the entry function should already be declared") .borrow() .declaration; - crate::EraVMFunction::set_attributes( + crate::PolkaVMFunction::set_attributes( context.llvm(), entry, - vec![crate::EraVMAttribute::NoReturn], + vec![crate::PolkaVMAttribute::NoReturn], true, ); diff --git a/crates/llvm-context/src/eravm/context/function/runtime/mod.rs b/crates/llvm-context/src/polkavm/context/function/runtime/mod.rs similarity index 91% rename from crates/llvm-context/src/eravm/context/function/runtime/mod.rs rename to crates/llvm-context/src/polkavm/context/function/runtime/mod.rs index 805df58..66e360c 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/mod.rs +++ b/crates/llvm-context/src/polkavm/context/function/runtime/mod.rs @@ -6,11 +6,11 @@ pub mod deployer_call; pub mod entry; pub mod runtime_code; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::function::declaration::Declaration as FunctionDeclaration; -use crate::eravm::context::Context; -use crate::eravm::Dependency; -use crate::eravm::WriteLLVM; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; +use crate::polkavm::WriteLLVM; use self::default_call::DefaultCall; use self::deployer_call::DeployerCall; diff --git a/crates/llvm-context/src/eravm/context/function/runtime/runtime_code.rs b/crates/llvm-context/src/polkavm/context/function/runtime/runtime_code.rs similarity index 90% rename from crates/llvm-context/src/eravm/context/function/runtime/runtime_code.rs rename to crates/llvm-context/src/polkavm/context/function/runtime/runtime_code.rs index 1172d02..d5af09c 100644 --- a/crates/llvm-context/src/eravm/context/function/runtime/runtime_code.rs +++ b/crates/llvm-context/src/polkavm/context/function/runtime/runtime_code.rs @@ -2,11 +2,11 @@ use std::marker::PhantomData; -use crate::eravm::context::code_type::CodeType; -use crate::eravm::context::function::runtime::Runtime; -use crate::eravm::context::Context; -use crate::eravm::Dependency; -use crate::eravm::WriteLLVM; +use crate::polkavm::context::code_type::CodeType; +use crate::polkavm::context::function::runtime::Runtime; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; +use crate::polkavm::WriteLLVM; /// The runtime code function. /// Is a special function that is only used by the front-end generated code. diff --git a/crates/llvm-context/src/eravm/context/function/vyper_data.rs b/crates/llvm-context/src/polkavm/context/function/vyper_data.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/function/vyper_data.rs rename to crates/llvm-context/src/polkavm/context/function/vyper_data.rs diff --git a/crates/llvm-context/src/eravm/context/function/yul_data.rs b/crates/llvm-context/src/polkavm/context/function/yul_data.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/function/yul_data.rs rename to crates/llvm-context/src/polkavm/context/function/yul_data.rs diff --git a/crates/llvm-context/src/eravm/context/global.rs b/crates/llvm-context/src/polkavm/context/global.rs similarity index 89% rename from crates/llvm-context/src/eravm/context/global.rs rename to crates/llvm-context/src/polkavm/context/global.rs index c86116f..2e3fcc7 100644 --- a/crates/llvm-context/src/eravm/context/global.rs +++ b/crates/llvm-context/src/polkavm/context/global.rs @@ -3,9 +3,9 @@ use inkwell::types::BasicType; use inkwell::values::BasicValue; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::Context; -use crate::EraVMDependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::Context; +use crate::PolkaVMDependency; /// The LLVM global value. #[derive(Debug, Clone, Copy)] @@ -26,7 +26,7 @@ impl<'ctx> Global<'ctx> { name: &str, ) -> Self where - D: EraVMDependency + Clone, + D: PolkaVMDependency + Clone, T: BasicType<'ctx>, V: BasicValue<'ctx>, { diff --git a/crates/llvm-context/src/eravm/context/loop.rs b/crates/llvm-context/src/polkavm/context/loop.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/loop.rs rename to crates/llvm-context/src/polkavm/context/loop.rs diff --git a/crates/llvm-context/src/eravm/context/mod.rs b/crates/llvm-context/src/polkavm/context/mod.rs similarity index 99% rename from crates/llvm-context/src/eravm/context/mod.rs rename to crates/llvm-context/src/polkavm/context/mod.rs index aa0ab32..4800edc 100644 --- a/crates/llvm-context/src/eravm/context/mod.rs +++ b/crates/llvm-context/src/polkavm/context/mod.rs @@ -25,10 +25,10 @@ use std::rc::Rc; use inkwell::types::BasicType; use inkwell::values::BasicValue; -use crate::eravm::DebugConfig; -use crate::eravm::Dependency; use crate::optimizer::settings::Settings as OptimizerSettings; use crate::optimizer::Optimizer; +use crate::polkavm::DebugConfig; +use crate::polkavm::Dependency; use crate::target_machine::target::Target; use crate::target_machine::TargetMachine; @@ -282,7 +282,7 @@ where let assembly_text = revive_linker::link(buffer.as_slice()).map(hex::encode)?; - let build = match crate::eravm::build_assembly_text( + let build = match crate::polkavm::build_assembly_text( contract_path, assembly_text.as_str(), metadata_hash, @@ -951,7 +951,7 @@ where "invoke_catch_landing", ) .unwrap(); - crate::eravm::utils::throw(self); + crate::polkavm::utils::throw(self); self.set_basic_block(current_block); let call_site_value = self @@ -1224,7 +1224,7 @@ where assert_eq!(length.get_type(), self.xlen_type()); let heap_start = self - .get_global(crate::eravm::GLOBAL_HEAP_MEMORY_POINTER)? + .get_global(crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER)? .value .as_pointer_value(); let heap_end = self.build_sbrk(self.integer_const(32, 0))?; @@ -1368,7 +1368,7 @@ where /// Returns the register witdh sized type. pub fn xlen_type(&self) -> inkwell::types::IntType<'ctx> { - self.llvm.custom_width_int_type(crate::eravm::XLEN as u32) + self.llvm.custom_width_int_type(crate::polkavm::XLEN as u32) } /// Returns the runtime value width sized type. diff --git a/crates/llvm-context/src/eravm/context/pointer.rs b/crates/llvm-context/src/polkavm/context/pointer.rs similarity index 94% rename from crates/llvm-context/src/eravm/context/pointer.rs rename to crates/llvm-context/src/polkavm/context/pointer.rs index 79ed393..174d4f6 100644 --- a/crates/llvm-context/src/eravm/context/pointer.rs +++ b/crates/llvm-context/src/polkavm/context/pointer.rs @@ -2,10 +2,10 @@ use inkwell::types::BasicType; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::global::Global; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::global::Global; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// The LLVM pointer. #[derive(Debug, Clone, Copy)] diff --git a/crates/llvm-context/src/eravm/context/solidity_data.rs b/crates/llvm-context/src/polkavm/context/solidity_data.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/solidity_data.rs rename to crates/llvm-context/src/polkavm/context/solidity_data.rs diff --git a/crates/llvm-context/src/eravm/context/tests.rs b/crates/llvm-context/src/polkavm/context/tests.rs similarity index 96% rename from crates/llvm-context/src/eravm/context/tests.rs rename to crates/llvm-context/src/polkavm/context/tests.rs index 8856e84..38f4ad6 100644 --- a/crates/llvm-context/src/eravm/context/tests.rs +++ b/crates/llvm-context/src/polkavm/context/tests.rs @@ -1,16 +1,16 @@ //! The LLVM IR generator context tests. -use crate::eravm::context::attribute::Attribute; -use crate::eravm::context::Context; -use crate::eravm::DummyDependency; use crate::optimizer::settings::Settings as OptimizerSettings; use crate::optimizer::Optimizer; +use crate::polkavm::context::attribute::Attribute; +use crate::polkavm::context::Context; +use crate::polkavm::DummyDependency; pub fn create_context( llvm: &inkwell::context::Context, optimizer_settings: OptimizerSettings, ) -> Context { - crate::eravm::initialize_target(); + crate::polkavm::initialize_target(); let module = llvm.create_module("test"); let optimizer = Optimizer::new(optimizer_settings); diff --git a/crates/llvm-context/src/eravm/context/vyper_data.rs b/crates/llvm-context/src/polkavm/context/vyper_data.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/vyper_data.rs rename to crates/llvm-context/src/polkavm/context/vyper_data.rs diff --git a/crates/llvm-context/src/eravm/context/yul_data.rs b/crates/llvm-context/src/polkavm/context/yul_data.rs similarity index 100% rename from crates/llvm-context/src/eravm/context/yul_data.rs rename to crates/llvm-context/src/polkavm/context/yul_data.rs diff --git a/crates/llvm-context/src/eravm/evm/arithmetic.rs b/crates/llvm-context/src/polkavm/evm/arithmetic.rs similarity index 98% rename from crates/llvm-context/src/eravm/evm/arithmetic.rs rename to crates/llvm-context/src/polkavm/evm/arithmetic.rs index 90c7a9e..9990ec3 100644 --- a/crates/llvm-context/src/eravm/evm/arithmetic.rs +++ b/crates/llvm-context/src/polkavm/evm/arithmetic.rs @@ -2,8 +2,8 @@ use inkwell::values::BasicValue; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the arithmetic addition. pub fn addition<'ctx, D>( diff --git a/crates/llvm-context/src/eravm/evm/bitwise.rs b/crates/llvm-context/src/polkavm/evm/bitwise.rs similarity index 99% rename from crates/llvm-context/src/eravm/evm/bitwise.rs rename to crates/llvm-context/src/polkavm/evm/bitwise.rs index fdcd881..ab99747 100644 --- a/crates/llvm-context/src/eravm/evm/bitwise.rs +++ b/crates/llvm-context/src/polkavm/evm/bitwise.rs @@ -2,8 +2,8 @@ use inkwell::values::BasicValue; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the bitwise OR. pub fn or<'ctx, D>( diff --git a/crates/llvm-context/src/eravm/evm/call.rs b/crates/llvm-context/src/polkavm/evm/call.rs similarity index 94% rename from crates/llvm-context/src/eravm/evm/call.rs rename to crates/llvm-context/src/polkavm/evm/call.rs index 49da7f9..878dd4f 100644 --- a/crates/llvm-context/src/eravm/evm/call.rs +++ b/crates/llvm-context/src/polkavm/evm/call.rs @@ -2,10 +2,10 @@ use inkwell::values::BasicValue; -use crate::eravm::context::argument::Argument; -use crate::eravm::context::function::declaration::Declaration as FunctionDeclaration; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::argument::Argument; +use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates a contract call. /// If the `simulation_address` is specified, the call is substituted with another instruction diff --git a/crates/llvm-context/src/eravm/evm/calldata.rs b/crates/llvm-context/src/polkavm/evm/calldata.rs similarity index 83% rename from crates/llvm-context/src/eravm/evm/calldata.rs rename to crates/llvm-context/src/polkavm/evm/calldata.rs index 6dd4e32..2c646b3 100644 --- a/crates/llvm-context/src/eravm/evm/calldata.rs +++ b/crates/llvm-context/src/polkavm/evm/calldata.rs @@ -1,9 +1,9 @@ //! Translates the calldata instructions. -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; use inkwell::types::BasicType; /// Translates the calldata load. @@ -15,7 +15,7 @@ where D: Dependency + Clone, { let calldata_pointer = context - .get_global(crate::eravm::GLOBAL_CALLDATA_POINTER)? + .get_global(crate::polkavm::GLOBAL_CALLDATA_POINTER)? .value .as_pointer_value(); let offset = context.build_gep( @@ -36,7 +36,7 @@ pub fn size<'ctx, D>( where D: Dependency + Clone, { - let value = context.get_global_value(crate::eravm::GLOBAL_CALLDATA_SIZE)?; + let value = context.get_global_value(crate::polkavm::GLOBAL_CALLDATA_SIZE)?; Ok(value) } @@ -56,7 +56,7 @@ where let destination = context.build_heap_gep(offset, size)?; let calldata_pointer = context - .get_global(crate::eravm::GLOBAL_CALLDATA_POINTER)? + .get_global(crate::polkavm::GLOBAL_CALLDATA_POINTER)? .value .as_pointer_value(); let source = context.build_gep( diff --git a/crates/llvm-context/src/eravm/evm/comparison.rs b/crates/llvm-context/src/polkavm/evm/comparison.rs similarity index 92% rename from crates/llvm-context/src/eravm/evm/comparison.rs rename to crates/llvm-context/src/polkavm/evm/comparison.rs index 6ec1317..e8838f0 100644 --- a/crates/llvm-context/src/eravm/evm/comparison.rs +++ b/crates/llvm-context/src/polkavm/evm/comparison.rs @@ -2,8 +2,8 @@ use inkwell::values::BasicValue; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the comparison operations. /// There is not difference between the EVM and LLVM IR behaviors. diff --git a/crates/llvm-context/src/eravm/evm/context.rs b/crates/llvm-context/src/polkavm/evm/context.rs similarity index 95% rename from crates/llvm-context/src/eravm/evm/context.rs rename to crates/llvm-context/src/polkavm/evm/context.rs index 7643bd2..eb04ae0 100644 --- a/crates/llvm-context/src/eravm/evm/context.rs +++ b/crates/llvm-context/src/polkavm/evm/context.rs @@ -2,8 +2,8 @@ use inkwell::values::BasicValue; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `gas_limit` instruction. pub fn gas_limit<'ctx, D>( @@ -115,7 +115,7 @@ where { let heap_end = context.build_sbrk(context.xlen_type().const_zero())?; let heap_start = context - .get_global(crate::eravm::GLOBAL_HEAP_MEMORY_POINTER)? + .get_global(crate::polkavm::GLOBAL_HEAP_MEMORY_POINTER)? .value .as_pointer_value(); let heap_size = context.builder().build_int_nuw_sub( diff --git a/crates/llvm-context/src/eravm/evm/create.rs b/crates/llvm-context/src/polkavm/evm/create.rs similarity index 90% rename from crates/llvm-context/src/eravm/evm/create.rs rename to crates/llvm-context/src/polkavm/evm/create.rs index d9ba7b0..5bbe452 100644 --- a/crates/llvm-context/src/eravm/evm/create.rs +++ b/crates/llvm-context/src/polkavm/evm/create.rs @@ -3,11 +3,11 @@ use inkwell::values::BasicValue; use num::Zero; -use crate::eravm::context::argument::Argument; -use crate::eravm::context::code_type::CodeType; -use crate::eravm::context::function::runtime::Runtime; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::argument::Argument; +use crate::polkavm::context::code_type::CodeType; +use crate::polkavm::context::function::runtime::Runtime; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the contract `create` instruction. /// The instruction is simulated by a call to a system contract. @@ -21,7 +21,7 @@ where D: Dependency + Clone, { let signature_hash_string = - crate::eravm::utils::keccak256(crate::eravm::DEPLOYER_SIGNATURE_CREATE.as_bytes()); + crate::polkavm::utils::keccak256(crate::polkavm::DEPLOYER_SIGNATURE_CREATE.as_bytes()); let signature_hash = context.field_const_str_hex(signature_hash_string.as_str()); let salt = context.field_const(0); @@ -57,7 +57,7 @@ where D: Dependency + Clone, { let signature_hash_string = - crate::eravm::utils::keccak256(crate::eravm::DEPLOYER_SIGNATURE_CREATE2.as_bytes()); + crate::polkavm::utils::keccak256(crate::polkavm::DEPLOYER_SIGNATURE_CREATE2.as_bytes()); let signature_hash = context.field_const_str_hex(signature_hash_string.as_str()); let salt = salt.unwrap_or_else(|| context.field_const(0)); @@ -162,9 +162,9 @@ where anyhow::bail!("type({}).runtimeCode is not supported", identifier); } - let size_bigint = num::BigUint::from(crate::eravm::DEPLOYER_CALL_HEADER_SIZE); + let size_bigint = num::BigUint::from(crate::polkavm::DEPLOYER_CALL_HEADER_SIZE); let size_value = context - .field_const(crate::eravm::DEPLOYER_CALL_HEADER_SIZE as u64) + .field_const(crate::polkavm::DEPLOYER_CALL_HEADER_SIZE as u64) .as_basic_value_enum(); Ok(Argument::new_with_constant(size_value, size_bigint)) } diff --git a/crates/llvm-context/src/eravm/evm/crypto.rs b/crates/llvm-context/src/polkavm/evm/crypto.rs similarity index 95% rename from crates/llvm-context/src/eravm/evm/crypto.rs rename to crates/llvm-context/src/polkavm/evm/crypto.rs index 7eda9eb..ae7abd5 100644 --- a/crates/llvm-context/src/eravm/evm/crypto.rs +++ b/crates/llvm-context/src/polkavm/evm/crypto.rs @@ -1,7 +1,7 @@ //! Translates the cryptographic operations. -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `sha3` instruction. pub fn sha3<'ctx, D>( diff --git a/crates/llvm-context/src/eravm/evm/ether_gas.rs b/crates/llvm-context/src/polkavm/evm/ether_gas.rs similarity index 90% rename from crates/llvm-context/src/eravm/evm/ether_gas.rs rename to crates/llvm-context/src/polkavm/evm/ether_gas.rs index 6dde07a..5624de7 100644 --- a/crates/llvm-context/src/eravm/evm/ether_gas.rs +++ b/crates/llvm-context/src/polkavm/evm/ether_gas.rs @@ -2,8 +2,8 @@ use inkwell::values::BasicValue; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `gas` instruction. pub fn gas<'ctx, D>( @@ -37,7 +37,10 @@ where )?; context.build_store( output_length_pointer, - context.integer_const(crate::eravm::XLEN, revive_common::BYTE_LENGTH_VALUE as u64), + context.integer_const( + crate::polkavm::XLEN, + revive_common::BYTE_LENGTH_VALUE as u64, + ), )?; context.builder().build_call( diff --git a/crates/llvm-context/src/eravm/evm/event.rs b/crates/llvm-context/src/polkavm/evm/event.rs similarity index 84% rename from crates/llvm-context/src/eravm/evm/event.rs rename to crates/llvm-context/src/polkavm/evm/event.rs index e123c4a..4f56a8d 100644 --- a/crates/llvm-context/src/eravm/evm/event.rs +++ b/crates/llvm-context/src/polkavm/evm/event.rs @@ -1,7 +1,7 @@ //! Translates a log or event call. -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates a log or event call. /// The decoding logic is implemented in a system contract, which is called from here. @@ -21,8 +21,8 @@ where let failure_block = context.append_basic_block("event_failure_block"); let join_block = context.append_basic_block("event_join_block"); - let gas = crate::eravm::evm::ether_gas::gas(context)?.into_int_value(); - let abi_data = crate::eravm::utils::abi_data( + let gas = crate::polkavm::evm::ether_gas::gas(context)?.into_int_value(); + let abi_data = crate::polkavm::utils::abi_data( context, input_offset, input_length, @@ -37,7 +37,7 @@ where let result = context .build_call( context.llvm_runtime().far_call, - crate::eravm::utils::external_call_arguments( + crate::polkavm::utils::external_call_arguments( context, abi_data.as_basic_value_enum(), context.field_const(zkevm_opcode_defs::ADDRESS_EVENT_WRITER as u64), @@ -64,7 +64,7 @@ where )?; context.set_basic_block(failure_block); - crate::eravm::evm::r#return::revert(context, context.field_const(0), context.field_const(0))?; + crate::polkavm::evm::r#return::revert(context, context.field_const(0), context.field_const(0))?; context.set_basic_block(join_block); */ diff --git a/crates/llvm-context/src/eravm/evm/ext_code.rs b/crates/llvm-context/src/polkavm/evm/ext_code.rs similarity index 89% rename from crates/llvm-context/src/eravm/evm/ext_code.rs rename to crates/llvm-context/src/polkavm/evm/ext_code.rs index f35c9a8..7d7c66a 100644 --- a/crates/llvm-context/src/eravm/evm/ext_code.rs +++ b/crates/llvm-context/src/polkavm/evm/ext_code.rs @@ -1,7 +1,7 @@ //! Translates the external code operations. -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `extcodesize` instruction. pub fn size<'ctx, D>( diff --git a/crates/llvm-context/src/eravm/evm/immutable.rs b/crates/llvm-context/src/polkavm/evm/immutable.rs similarity index 90% rename from crates/llvm-context/src/eravm/evm/immutable.rs rename to crates/llvm-context/src/polkavm/evm/immutable.rs index 4d05d03..310d9a1 100644 --- a/crates/llvm-context/src/eravm/evm/immutable.rs +++ b/crates/llvm-context/src/polkavm/evm/immutable.rs @@ -1,10 +1,10 @@ //! Translates the contract immutable operations. -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::code_type::CodeType; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::code_type::CodeType; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the contract immutable load. /// In the deploy code the values are read from the auxiliary heap. @@ -29,7 +29,7 @@ where let offset_absolute = context.builder().build_int_add( index_double, context.field_const( - crate::eravm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + crate::polkavm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + (3 * revive_common::BYTE_LENGTH_FIELD) as u64, ), "immutable_offset_absolute", @@ -74,7 +74,7 @@ where let index_offset_absolute = context.builder().build_int_add( index_double, context.field_const( - crate::eravm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + crate::polkavm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + (2 * revive_common::BYTE_LENGTH_FIELD) as u64, ), "index_offset_absolute", diff --git a/crates/llvm-context/src/eravm/evm/math.rs b/crates/llvm-context/src/polkavm/evm/math.rs similarity index 97% rename from crates/llvm-context/src/eravm/evm/math.rs rename to crates/llvm-context/src/polkavm/evm/math.rs index 7a003b8..68f59ef 100644 --- a/crates/llvm-context/src/eravm/evm/math.rs +++ b/crates/llvm-context/src/polkavm/evm/math.rs @@ -2,8 +2,8 @@ use inkwell::values::BasicValue; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `addmod` instruction. pub fn add_mod<'ctx, D>( diff --git a/crates/llvm-context/src/eravm/evm/memory.rs b/crates/llvm-context/src/polkavm/evm/memory.rs similarity index 90% rename from crates/llvm-context/src/eravm/evm/memory.rs rename to crates/llvm-context/src/polkavm/evm/memory.rs index f0f6968..e21e51d 100644 --- a/crates/llvm-context/src/eravm/evm/memory.rs +++ b/crates/llvm-context/src/polkavm/evm/memory.rs @@ -1,9 +1,9 @@ //! Translates the heap memory operations. -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `mload` instruction. /// Uses the main heap. diff --git a/crates/llvm-context/src/eravm/evm/mod.rs b/crates/llvm-context/src/polkavm/evm/mod.rs similarity index 100% rename from crates/llvm-context/src/eravm/evm/mod.rs rename to crates/llvm-context/src/polkavm/evm/mod.rs diff --git a/crates/llvm-context/src/eravm/evm/return.rs b/crates/llvm-context/src/polkavm/evm/return.rs similarity index 86% rename from crates/llvm-context/src/eravm/evm/return.rs rename to crates/llvm-context/src/polkavm/evm/return.rs index 0e5065d..b6b30c6 100644 --- a/crates/llvm-context/src/eravm/evm/return.rs +++ b/crates/llvm-context/src/polkavm/evm/return.rs @@ -1,10 +1,10 @@ //! Translates the transaction return operations. -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::code_type::CodeType; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::code_type::CodeType; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the `return` instruction. /// Unlike in EVM, zkSync constructors return the array of contract immutables. @@ -25,7 +25,7 @@ where context, AddressSpace::HeapAuxiliary, context.field_type(), - context.field_const(crate::eravm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA), + context.field_const(crate::polkavm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA), "immutables_offset_pointer", ); context.build_store( @@ -38,7 +38,7 @@ where AddressSpace::HeapAuxiliary, context.field_type(), context.field_const( - crate::eravm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + crate::polkavm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA + (revive_common::BYTE_LENGTH_FIELD as u64), ), "immutables_number_pointer", @@ -62,7 +62,7 @@ where context.build_exit( context.integer_const(32, 0), - context.field_const(crate::eravm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA), + context.field_const(crate::polkavm::HEAP_AUX_OFFSET_CONSTRUCTOR_RETURN_DATA), return_data_length, )?; } @@ -105,7 +105,7 @@ pub fn invalid(context: &mut Context) -> anyhow::Result<()> where D: Dependency + Clone, { - crate::eravm::evm::memory::store( + crate::polkavm::evm::memory::store( context, context.field_type().const_all_ones(), context.field_const(0), diff --git a/crates/llvm-context/src/eravm/evm/return_data.rs b/crates/llvm-context/src/polkavm/evm/return_data.rs similarity index 85% rename from crates/llvm-context/src/eravm/evm/return_data.rs rename to crates/llvm-context/src/polkavm/evm/return_data.rs index 9eae836..0024ce2 100644 --- a/crates/llvm-context/src/eravm/evm/return_data.rs +++ b/crates/llvm-context/src/polkavm/evm/return_data.rs @@ -3,10 +3,10 @@ use inkwell::types::BasicType; use inkwell::values::BasicValue; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the return data size. pub fn size<'ctx, D>( @@ -15,7 +15,7 @@ pub fn size<'ctx, D>( where D: Dependency + Clone, { - match context.get_global_value(crate::eravm::GLOBAL_RETURN_DATA_SIZE) { + match context.get_global_value(crate::polkavm::GLOBAL_RETURN_DATA_SIZE) { Ok(global) => Ok(global), Err(_error) => Ok(context.field_const(0).as_basic_value_enum()), } @@ -48,7 +48,7 @@ where context.build_conditional_branch(is_copy_out_of_bounds, error_block, join_block)?; context.set_basic_block(error_block); - crate::eravm::evm::r#return::revert(context, context.field_const(0), context.field_const(0))?; + crate::polkavm::evm::r#return::revert(context, context.field_const(0), context.field_const(0))?; context.set_basic_block(join_block); let destination = Pointer::new_with_offset( @@ -60,7 +60,7 @@ where ); let return_data_pointer_global = - context.get_global(crate::eravm::GLOBAL_RETURN_DATA_POINTER)?; + context.get_global(crate::polkavm::GLOBAL_RETURN_DATA_POINTER)?; let return_data_pointer_pointer = return_data_pointer_global.into(); let return_data_pointer = context.build_load(return_data_pointer_pointer, "return_data_pointer")?; diff --git a/crates/llvm-context/src/eravm/evm/storage.rs b/crates/llvm-context/src/polkavm/evm/storage.rs similarity index 92% rename from crates/llvm-context/src/eravm/evm/storage.rs rename to crates/llvm-context/src/polkavm/evm/storage.rs index 5badb1c..917507d 100644 --- a/crates/llvm-context/src/eravm/evm/storage.rs +++ b/crates/llvm-context/src/polkavm/evm/storage.rs @@ -1,9 +1,9 @@ //! Translates the storage operations. -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::pointer::Pointer; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::pointer::Pointer; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Translates the storage load. pub fn load<'ctx, D>( diff --git a/crates/llvm-context/src/eravm/metadata_hash.rs b/crates/llvm-context/src/polkavm/metadata_hash.rs similarity index 100% rename from crates/llvm-context/src/eravm/metadata_hash.rs rename to crates/llvm-context/src/polkavm/metadata_hash.rs diff --git a/crates/llvm-context/src/eravm/mod.rs b/crates/llvm-context/src/polkavm/mod.rs similarity index 98% rename from crates/llvm-context/src/eravm/mod.rs rename to crates/llvm-context/src/polkavm/mod.rs index b3b0522..9601460 100644 --- a/crates/llvm-context/src/eravm/mod.rs +++ b/crates/llvm-context/src/polkavm/mod.rs @@ -14,12 +14,12 @@ use crate::optimizer::settings::Settings as OptimizerSettings; use self::context::build::Build; use self::context::Context; -/// Initializes the EraVM target machine. +/// Initializes the PolkaVM target machine. pub fn initialize_target() { inkwell::targets::Target::initialize_riscv(&Default::default()); } -/// Builds EraVM assembly text. +/// Builds PolkaVM assembly text. pub fn build_assembly_text( contract_path: &str, assembly_text: &str, diff --git a/crates/llvm-context/src/eravm/utils.rs b/crates/llvm-context/src/polkavm/utils.rs similarity index 90% rename from crates/llvm-context/src/eravm/utils.rs rename to crates/llvm-context/src/polkavm/utils.rs index 982aba1..945b14e 100644 --- a/crates/llvm-context/src/eravm/utils.rs +++ b/crates/llvm-context/src/polkavm/utils.rs @@ -2,10 +2,10 @@ use inkwell::values::BasicValue; -use crate::eravm::context::address_space::AddressSpace; -use crate::eravm::context::function::llvm_runtime::LLVMRuntime; -use crate::eravm::context::Context; -use crate::eravm::Dependency; +use crate::polkavm::context::address_space::AddressSpace; +use crate::polkavm::context::function::llvm_runtime::LLVMRuntime; +use crate::polkavm::context::Context; +use crate::polkavm::Dependency; /// Clamps `value` to `max_value`, if `value` is bigger than `max_value`. pub fn clamp<'ctx, D>( @@ -70,8 +70,8 @@ where D: Dependency + Clone, { let mut result = Vec::with_capacity( - crate::eravm::context::function::runtime::entry::Entry::MANDATORY_ARGUMENTS_COUNT - + crate::eravm::EXTRA_ABI_DATA_SIZE + crate::polkavm::context::function::runtime::entry::Entry::MANDATORY_ARGUMENTS_COUNT + + crate::polkavm::EXTRA_ABI_DATA_SIZE + usize::from(mimic.is_some()), ); result.push(abi_data); @@ -100,13 +100,13 @@ pub fn abi_data<'ctx, D>( where D: Dependency + Clone, { - let input_offset = crate::eravm::utils::clamp( + let input_offset = crate::polkavm::utils::clamp( context, input_offset, context.field_const(u32::MAX as u64), "abi_data_input_offset", )?; - let input_length = crate::eravm::utils::clamp( + let input_length = crate::polkavm::utils::clamp( context, input_length, context.field_const(u32::MAX as u64), @@ -115,9 +115,9 @@ where let gas = match gas { Some(gas) => gas, - None => crate::eravm::evm::ether_gas::gas(context)?.into_int_value(), + None => crate::polkavm::evm::ether_gas::gas(context)?.into_int_value(), }; - let gas = crate::eravm::utils::clamp( + let gas = crate::polkavm::utils::clamp( context, gas, context.field_const(u32::MAX as u64), @@ -182,14 +182,14 @@ where pub fn pad_extra_abi_data<'ctx, D>( context: &Context<'ctx, D>, initial_data: Vec>, -) -> [inkwell::values::IntValue<'ctx>; crate::eravm::EXTRA_ABI_DATA_SIZE] +) -> [inkwell::values::IntValue<'ctx>; crate::polkavm::EXTRA_ABI_DATA_SIZE] where D: Dependency + Clone, { let mut padded_data = initial_data; padded_data.extend(vec![ context.field_undef(); - crate::eravm::EXTRA_ABI_DATA_SIZE - padded_data.len() + crate::polkavm::EXTRA_ABI_DATA_SIZE - padded_data.len() ]); padded_data.try_into().expect("Always valid") } diff --git a/crates/llvm-context/src/target_machine/target.rs b/crates/llvm-context/src/target_machine/target.rs index a1a4756..ffb4acf 100644 --- a/crates/llvm-context/src/target_machine/target.rs +++ b/crates/llvm-context/src/target_machine/target.rs @@ -5,7 +5,7 @@ use std::str::FromStr; /// The LLVM target. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Target { - /// The EraVM target. + /// The PolkaVM target. PVM, } diff --git a/crates/solidity/Cargo.toml b/crates/solidity/Cargo.toml index a9c74bf..2ff421e 100644 --- a/crates/solidity/Cargo.toml +++ b/crates/solidity/Cargo.toml @@ -7,7 +7,7 @@ authors = [ ] license = "MIT OR Apache-2.0" edition = "2021" -description = "EraVM Solidity compiler" +description = "PolkaVM Solidity frontend" [[bin]] name = "zksolc" diff --git a/crates/solidity/src/build/contract.rs b/crates/solidity/src/build/contract.rs index 7d83cc1..d18e582 100644 --- a/crates/solidity/src/build/contract.rs +++ b/crates/solidity/src/build/contract.rs @@ -19,7 +19,7 @@ pub struct Contract { /// The auxiliary identifier. Used to identify Yul objects. pub identifier: String, /// The LLVM module build. - pub build: revive_llvm_context::EraVMBuild, + pub build: revive_llvm_context::PolkaVMBuild, /// The metadata JSON. pub metadata_json: serde_json::Value, /// The factory dependencies. @@ -31,7 +31,7 @@ impl Contract { pub fn new( path: String, identifier: String, - build: revive_llvm_context::EraVMBuild, + build: revive_llvm_context::PolkaVMBuild, metadata_json: serde_json::Value, factory_dependencies: HashSet, ) -> Self { @@ -55,7 +55,7 @@ impl Contract { let file_name = Self::short_path(self.path.as_str()); if output_assembly { - let file_name = format!("{}.{}", file_name, revive_common::EXTENSION_ERAVM_ASSEMBLY); + let file_name = format!("{}.{}", file_name, revive_common::EXTENSION_POLKAVM_ASSEMBLY); let mut file_path = path.to_owned(); file_path.push(file_name); @@ -76,7 +76,7 @@ impl Contract { } if output_binary { - let file_name = format!("{}.{}", file_name, revive_common::EXTENSION_ERAVM_BINARY); + let file_name = format!("{}.{}", file_name, revive_common::EXTENSION_POLKAVM_BINARY); let mut file_path = path.to_owned(); file_path.push(file_name); diff --git a/crates/solidity/src/const.rs b/crates/solidity/src/const.rs index 8adcd96..96a9bb8 100644 --- a/crates/solidity/src/const.rs +++ b/crates/solidity/src/const.rs @@ -1,4 +1,4 @@ -//! Solidity to EraVM compiler constants. +//! Solidity to PolkaVM compiler constants. #![allow(dead_code)] diff --git a/crates/solidity/src/evmla/assembly/instruction/codecopy.rs b/crates/solidity/src/evmla/assembly/instruction/codecopy.rs index aac9d69..f6fa8cb 100644 --- a/crates/solidity/src/evmla/assembly/instruction/codecopy.rs +++ b/crates/solidity/src/evmla/assembly/instruction/codecopy.rs @@ -2,12 +2,12 @@ /// Translates the contract hash copying. pub fn contract_hash<'ctx, D>( - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, offset: inkwell::values::IntValue<'ctx>, value: inkwell::values::IntValue<'ctx>, ) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let offset = context.builder().build_int_add( offset, @@ -17,21 +17,21 @@ where "datacopy_contract_hash_offset", )?; - revive_llvm_context::eravm_evm_memory::store(context, offset, value)?; + revive_llvm_context::polkavm_evm_memory::store(context, offset, value)?; Ok(()) } /// Translates the library marker copying. pub fn library_marker( - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, offset: u64, value: u64, ) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { - revive_llvm_context::eravm_evm_memory::store_byte( + revive_llvm_context::polkavm_evm_memory::store_byte( context, context.field_const(offset), context.field_const(value), @@ -42,12 +42,12 @@ where /// Translates the static data copying. pub fn static_data<'ctx, D>( - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, destination: inkwell::values::IntValue<'ctx>, source: &str, ) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let mut offset = 0; for (index, chunk) in source @@ -68,7 +68,7 @@ where format!("datacopy_destination_index_{index}").as_str(), )?; let datacopy_value = context.field_const_str_hex(value_string.as_str()); - revive_llvm_context::eravm_evm_memory::store( + revive_llvm_context::polkavm_evm_memory::store( context, datacopy_destination, datacopy_value, diff --git a/crates/solidity/src/evmla/assembly/instruction/jump.rs b/crates/solidity/src/evmla/assembly/instruction/jump.rs index 82ebb74..678c91e 100644 --- a/crates/solidity/src/evmla/assembly/instruction/jump.rs +++ b/crates/solidity/src/evmla/assembly/instruction/jump.rs @@ -2,17 +2,17 @@ /// Translates the unconditional jump. pub fn unconditional( - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, destination: num::BigUint, stack_hash: md5::Digest, ) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let code_type = context .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?; - let block_key = revive_llvm_context::EraVMFunctionBlockKey::new(code_type, destination); + let block_key = revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, destination); let block = context .current_function() @@ -26,24 +26,24 @@ where /// Translates the conditional jump. pub fn conditional( - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, destination: num::BigUint, stack_hash: md5::Digest, stack_height: usize, ) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let code_type = context .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?; - let block_key = revive_llvm_context::EraVMFunctionBlockKey::new(code_type, destination); + let block_key = revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, destination); let condition_pointer = context.evmla().stack[stack_height] .to_llvm() .into_pointer_value(); let condition = context.build_load( - revive_llvm_context::EraVMPointer::new_stack_field(context, condition_pointer), + revive_llvm_context::PolkaVMPointer::new_stack_field(context, condition_pointer), format!("conditional_{block_key}_condition").as_str(), )?; let condition = context.builder().build_int_compare( diff --git a/crates/solidity/src/evmla/assembly/instruction/mod.rs b/crates/solidity/src/evmla/assembly/instruction/mod.rs index fc58fc1..f1e2cc0 100644 --- a/crates/solidity/src/evmla/assembly/instruction/mod.rs +++ b/crates/solidity/src/evmla/assembly/instruction/mod.rs @@ -328,11 +328,11 @@ impl Instruction { /// Initializes a recursive function `Call` instruction. pub fn recursive_call( name: String, - entry_key: revive_llvm_context::EraVMFunctionBlockKey, + entry_key: revive_llvm_context::PolkaVMFunctionBlockKey, stack_hash: md5::Digest, input_size: usize, output_size: usize, - return_address: revive_llvm_context::EraVMFunctionBlockKey, + return_address: revive_llvm_context::PolkaVMFunctionBlockKey, previous: &Self, ) -> Self { Self { diff --git a/crates/solidity/src/evmla/assembly/instruction/name.rs b/crates/solidity/src/evmla/assembly/instruction/name.rs index 82f06c5..3f0b953 100644 --- a/crates/solidity/src/evmla/assembly/instruction/name.rs +++ b/crates/solidity/src/evmla/assembly/instruction/name.rs @@ -300,10 +300,10 @@ pub enum Name { /// The eponymous EVM instruction. CREATE2, - /// The eponymous EraVM instruction. + /// The eponymous PolkaVM instruction. #[serde(rename = "$ZK_CREATE")] ZK_CREATE, - /// The eponymous EraVM instruction. + /// The eponymous PolkaVM instruction. #[serde(rename = "$ZK_CREATE2")] ZK_CREATE2, @@ -370,7 +370,7 @@ pub enum Name { /// The called function name. name: String, /// The called function key. - entry_key: revive_llvm_context::EraVMFunctionBlockKey, + entry_key: revive_llvm_context::PolkaVMFunctionBlockKey, /// The stack state hash after return. stack_hash: md5::Digest, /// The input size. @@ -378,7 +378,7 @@ pub enum Name { /// The output size. output_size: usize, /// The return address. - return_address: revive_llvm_context::EraVMFunctionBlockKey, + return_address: revive_llvm_context::PolkaVMFunctionBlockKey, }, /// The recursive function return instruction. #[serde(skip)] diff --git a/crates/solidity/src/evmla/assembly/instruction/stack.rs b/crates/solidity/src/evmla/assembly/instruction/stack.rs index 56983b0..87e9f89 100644 --- a/crates/solidity/src/evmla/assembly/instruction/stack.rs +++ b/crates/solidity/src/evmla/assembly/instruction/stack.rs @@ -4,11 +4,11 @@ use inkwell::values::BasicValue; /// Translates the ordinar value push. pub fn push<'ctx, D>( - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, value: String, ) -> anyhow::Result> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let result = context .field_type() @@ -23,11 +23,11 @@ where /// Translates the block tag label push. pub fn push_tag<'ctx, D>( - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, value: String, ) -> anyhow::Result> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let result = context .field_type() @@ -38,17 +38,17 @@ where /// Translates the stack memory duplicate. pub fn dup<'ctx, D>( - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, offset: usize, height: usize, original: &mut Option, ) -> anyhow::Result> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let element = &context.evmla().stack[height - offset - 1]; let value = context.build_load( - revive_llvm_context::EraVMPointer::new_stack_field( + revive_llvm_context::PolkaVMPointer::new_stack_field( context, element.to_llvm().into_pointer_value(), ), @@ -62,22 +62,22 @@ where /// Translates the stack memory swap. pub fn swap( - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, offset: usize, height: usize, ) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let top_element = context.evmla().stack[height - 1].to_owned(); - let top_pointer = revive_llvm_context::EraVMPointer::new_stack_field( + let top_pointer = revive_llvm_context::PolkaVMPointer::new_stack_field( context, top_element.to_llvm().into_pointer_value(), ); let top_value = context.build_load(top_pointer, format!("swap{offset}_top_value").as_str())?; let swap_element = context.evmla().stack[height - offset - 1].to_owned(); - let swap_pointer = revive_llvm_context::EraVMPointer::new_stack_field( + let swap_pointer = revive_llvm_context::PolkaVMPointer::new_stack_field( context, swap_element.to_llvm().into_pointer_value(), ); @@ -94,9 +94,9 @@ where } /// Translates the stack memory pop. -pub fn pop(_context: &mut revive_llvm_context::EraVMContext) -> anyhow::Result<()> +pub fn pop(_context: &mut revive_llvm_context::PolkaVMContext) -> anyhow::Result<()> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { Ok(()) } diff --git a/crates/solidity/src/evmla/assembly/mod.rs b/crates/solidity/src/evmla/assembly/mod.rs index 2817ecf..79a2292 100644 --- a/crates/solidity/src/evmla/assembly/mod.rs +++ b/crates/solidity/src/evmla/assembly/mod.rs @@ -45,7 +45,7 @@ impl Assembly { /// Gets the contract `keccak256` hash. pub fn keccak256(&self) -> String { let json = serde_json::to_vec(self).expect("Always valid"); - revive_llvm_context::eravm_utils::keccak256(json.as_slice()) + revive_llvm_context::polkavm_utils::keccak256(json.as_slice()) } /// Sets the full contract path. @@ -180,28 +180,28 @@ impl Assembly { } } -impl revive_llvm_context::EraVMWriteLLVM for Assembly +impl revive_llvm_context::PolkaVMWriteLLVM for Assembly where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { - let mut entry = revive_llvm_context::EraVMEntryFunction::default(); + let mut entry = revive_llvm_context::PolkaVMEntryFunction::default(); entry.declare(context)?; - let mut runtime = revive_llvm_context::EraVMRuntime::new( - revive_llvm_context::EraVMAddressSpace::Heap, + let mut runtime = revive_llvm_context::PolkaVMRuntime::new( + revive_llvm_context::PolkaVMAddressSpace::Heap, ); runtime.declare(context)?; - revive_llvm_context::EraVMDeployCodeFunction::new( - revive_llvm_context::EraVMDummyLLVMWritable::default(), + revive_llvm_context::PolkaVMDeployCodeFunction::new( + revive_llvm_context::PolkaVMDummyLLVMWritable::default(), ) .declare(context)?; - revive_llvm_context::EraVMRuntimeCodeFunction::new( - revive_llvm_context::EraVMDummyLLVMWritable::default(), + revive_llvm_context::PolkaVMRuntimeCodeFunction::new( + revive_llvm_context::PolkaVMDummyLLVMWritable::default(), ) .declare(context)?; @@ -214,7 +214,7 @@ where fn into_llvm( mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let full_path = self.full_path().to_owned(); @@ -223,7 +223,7 @@ where } let deploy_code_blocks = EtherealIR::get_blocks( context.evmla().version.to_owned(), - revive_llvm_context::EraVMCodeType::Deploy, + revive_llvm_context::PolkaVMCodeType::Deploy, self.code .as_deref() .ok_or_else(|| anyhow::anyhow!("Deploy code instructions not found"))?, @@ -250,7 +250,7 @@ where }; let runtime_code_blocks = EtherealIR::get_blocks( context.evmla().version.to_owned(), - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMCodeType::Runtime, runtime_code_instructions.as_slice(), )?; @@ -265,12 +265,12 @@ where ethereal_ir.declare(context)?; ethereal_ir.into_llvm(context)?; - revive_llvm_context::EraVMDeployCodeFunction::new(EntryLink::new( - revive_llvm_context::EraVMCodeType::Deploy, + revive_llvm_context::PolkaVMDeployCodeFunction::new(EntryLink::new( + revive_llvm_context::PolkaVMCodeType::Deploy, )) .into_llvm(context)?; - revive_llvm_context::EraVMRuntimeCodeFunction::new(EntryLink::new( - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMRuntimeCodeFunction::new(EntryLink::new( + revive_llvm_context::PolkaVMCodeType::Runtime, )) .into_llvm(context)?; diff --git a/crates/solidity/src/evmla/ethereal_ir/entry_link.rs b/crates/solidity/src/evmla/ethereal_ir/entry_link.rs index 8c78fe7..292913e 100644 --- a/crates/solidity/src/evmla/ethereal_ir/entry_link.rs +++ b/crates/solidity/src/evmla/ethereal_ir/entry_link.rs @@ -9,23 +9,23 @@ use crate::evmla::ethereal_ir::EtherealIR; #[derive(Debug, Clone)] pub struct EntryLink { /// The code part type. - pub code_type: revive_llvm_context::EraVMCodeType, + pub code_type: revive_llvm_context::PolkaVMCodeType, } impl EntryLink { /// A shortcut constructor. - pub fn new(code_type: revive_llvm_context::EraVMCodeType) -> Self { + pub fn new(code_type: revive_llvm_context::PolkaVMCodeType) -> Self { Self { code_type } } } -impl revive_llvm_context::EraVMWriteLLVM for EntryLink +impl revive_llvm_context::PolkaVMWriteLLVM for EntryLink where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let target = context .get_function(EtherealIR::DEFAULT_ENTRY_FUNCTION_NAME) @@ -33,10 +33,10 @@ where .borrow() .declaration(); let is_deploy_code = match self.code_type { - revive_llvm_context::EraVMCodeType::Deploy => context + revive_llvm_context::PolkaVMCodeType::Deploy => context .integer_type(revive_common::BIT_LENGTH_BOOLEAN) .const_int(1, false), - revive_llvm_context::EraVMCodeType::Runtime => context + revive_llvm_context::PolkaVMCodeType::Runtime => context .integer_type(revive_common::BIT_LENGTH_BOOLEAN) .const_int(0, false), }; 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 e2435cd..076f8a6 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 @@ -44,10 +44,10 @@ impl Element { /// Pops the specified number of arguments, converted into their LLVM values. fn pop_arguments_llvm<'ctx, D>( &mut self, - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, ) -> Vec> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let input_size = self.instruction.input_size(&context.evmla().version); let output_size = self.instruction.output_size(); @@ -59,7 +59,7 @@ impl Element { .into_pointer_value(); let value = context .build_load( - revive_llvm_context::EraVMPointer::new_stack_field(context, pointer), + revive_llvm_context::PolkaVMPointer::new_stack_field(context, pointer), format!("argument_{index}").as_str(), ) .unwrap(); @@ -69,13 +69,13 @@ impl Element { } } -impl revive_llvm_context::EraVMWriteLLVM for Element +impl revive_llvm_context::PolkaVMWriteLLVM for Element where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( mut self, - context: &mut revive_llvm_context::EraVMContext<'_, D>, + context: &mut revive_llvm_context::PolkaVMContext<'_, D>, ) -> anyhow::Result<()> { let mut original = self.instruction.value.clone(); @@ -127,7 +127,7 @@ where ) .map(Some), InstructionName::PUSH_ContractHash => { - revive_llvm_context::eravm_evm_create::contract_hash( + revive_llvm_context::polkavm_evm_create::contract_hash( context, self.instruction .value @@ -136,7 +136,7 @@ where .map(|argument| Some(argument.value)) } InstructionName::PUSH_ContractHashSize => { - revive_llvm_context::eravm_evm_create::header_size( + revive_llvm_context::polkavm_evm_create::header_size( context, self.instruction .value @@ -425,7 +425,7 @@ where InstructionName::ADD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::addition( + revive_llvm_context::polkavm_evm_arithmetic::addition( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -434,7 +434,7 @@ where } InstructionName::SUB => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::subtraction( + revive_llvm_context::polkavm_evm_arithmetic::subtraction( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -443,7 +443,7 @@ where } InstructionName::MUL => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::multiplication( + revive_llvm_context::polkavm_evm_arithmetic::multiplication( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -452,7 +452,7 @@ where } InstructionName::DIV => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::division( + revive_llvm_context::polkavm_evm_arithmetic::division( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -461,7 +461,7 @@ where } InstructionName::MOD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::remainder( + revive_llvm_context::polkavm_evm_arithmetic::remainder( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -470,7 +470,7 @@ where } InstructionName::SDIV => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::division_signed( + revive_llvm_context::polkavm_evm_arithmetic::division_signed( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -479,7 +479,7 @@ where } InstructionName::SMOD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_arithmetic::remainder_signed( + revive_llvm_context::polkavm_evm_arithmetic::remainder_signed( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -489,7 +489,7 @@ where InstructionName::LT => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -499,7 +499,7 @@ where } InstructionName::GT => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -509,7 +509,7 @@ where } InstructionName::EQ => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -519,7 +519,7 @@ where } InstructionName::ISZERO => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), context.field_const(0), @@ -529,7 +529,7 @@ where } InstructionName::SLT => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -539,7 +539,7 @@ where } InstructionName::SGT => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -550,7 +550,7 @@ where InstructionName::OR => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::or( + revive_llvm_context::polkavm_evm_bitwise::or( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -559,7 +559,7 @@ where } InstructionName::XOR => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::xor( + revive_llvm_context::polkavm_evm_bitwise::xor( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -568,7 +568,7 @@ where } InstructionName::NOT => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::xor( + revive_llvm_context::polkavm_evm_bitwise::xor( context, arguments[0].into_int_value(), context.field_type().const_all_ones(), @@ -577,7 +577,7 @@ where } InstructionName::AND => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::and( + revive_llvm_context::polkavm_evm_bitwise::and( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -586,7 +586,7 @@ where } InstructionName::SHL => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::shift_left( + revive_llvm_context::polkavm_evm_bitwise::shift_left( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -595,7 +595,7 @@ where } InstructionName::SHR => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::shift_right( + revive_llvm_context::polkavm_evm_bitwise::shift_right( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -604,7 +604,7 @@ where } InstructionName::SAR => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::shift_right_arithmetic( + revive_llvm_context::polkavm_evm_bitwise::shift_right_arithmetic( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -613,7 +613,7 @@ where } InstructionName::BYTE => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_bitwise::byte( + revive_llvm_context::polkavm_evm_bitwise::byte( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -623,7 +623,7 @@ where InstructionName::ADDMOD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_math::add_mod( + revive_llvm_context::polkavm_evm_math::add_mod( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -633,7 +633,7 @@ where } InstructionName::MULMOD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_math::mul_mod( + revive_llvm_context::polkavm_evm_math::mul_mod( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -643,7 +643,7 @@ where } InstructionName::EXP => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_math::exponent( + revive_llvm_context::polkavm_evm_math::exponent( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -652,7 +652,7 @@ where } InstructionName::SIGNEXTEND => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_math::sign_extend( + revive_llvm_context::polkavm_evm_math::sign_extend( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -662,7 +662,7 @@ where InstructionName::SHA3 | InstructionName::KECCAK256 => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_crypto::sha3( + revive_llvm_context::polkavm_evm_crypto::sha3( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -672,7 +672,7 @@ where InstructionName::MLOAD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_memory::load( + revive_llvm_context::polkavm_evm_memory::load( context, arguments[0].into_int_value(), ) @@ -680,7 +680,7 @@ where } InstructionName::MSTORE => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_memory::store( + revive_llvm_context::polkavm_evm_memory::store( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -689,7 +689,7 @@ where } InstructionName::MSTORE8 => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_memory::store_byte( + revive_llvm_context::polkavm_evm_memory::store_byte( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -698,16 +698,16 @@ where } InstructionName::MCOPY => { let arguments = self.pop_arguments_llvm(context); - let destination = revive_llvm_context::EraVMPointer::new_with_offset( + let destination = revive_llvm_context::PolkaVMPointer::new_with_offset( context, - revive_llvm_context::EraVMAddressSpace::Heap, + revive_llvm_context::PolkaVMAddressSpace::Heap, context.byte_type(), arguments[0].into_int_value(), "mcopy_destination", ); - let source = revive_llvm_context::EraVMPointer::new_with_offset( + let source = revive_llvm_context::PolkaVMPointer::new_with_offset( context, - revive_llvm_context::EraVMAddressSpace::Heap, + revive_llvm_context::PolkaVMAddressSpace::Heap, context.byte_type(), arguments[1].into_int_value(), "mcopy_source", @@ -725,7 +725,7 @@ where InstructionName::SLOAD => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_storage::load( + revive_llvm_context::polkavm_evm_storage::load( context, arguments[0].into_int_value(), ) @@ -733,7 +733,7 @@ where } InstructionName::SSTORE => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_storage::store( + revive_llvm_context::polkavm_evm_storage::store( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -759,7 +759,7 @@ where .get_or_allocate_immutable(key.as_str()); let index = context.field_const(offset as u64); - revive_llvm_context::eravm_evm_immutable::load(context, index).map(Some) + revive_llvm_context::polkavm_evm_immutable::load(context, index).map(Some) } InstructionName::ASSIGNIMMUTABLE => { let mut arguments = self.pop_arguments_llvm(context); @@ -773,7 +773,7 @@ where let index = context.field_const(offset as u64); let value = arguments.pop().expect("Always exists").into_int_value(); - revive_llvm_context::eravm_evm_immutable::store(context, index, value) + revive_llvm_context::polkavm_evm_immutable::store(context, index, value) .map(|_| None) } @@ -782,12 +782,12 @@ where .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { Ok(Some(context.field_const(0).as_basic_value_enum())) } - revive_llvm_context::EraVMCodeType::Runtime => { + revive_llvm_context::PolkaVMCodeType::Runtime => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_calldata::load( + revive_llvm_context::polkavm_evm_calldata::load( context, arguments[0].into_int_value(), ) @@ -800,11 +800,11 @@ where .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { Ok(Some(context.field_const(0).as_basic_value_enum())) } - revive_llvm_context::EraVMCodeType::Runtime => { - revive_llvm_context::eravm_evm_calldata::size(context).map(Some) + revive_llvm_context::PolkaVMCodeType::Runtime => { + revive_llvm_context::polkavm_evm_calldata::size(context).map(Some) } } } @@ -815,11 +815,11 @@ where .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { let calldata_size = - revive_llvm_context::eravm_evm_calldata::size(context)?; + revive_llvm_context::polkavm_evm_calldata::size(context)?; - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), calldata_size.into_int_value(), @@ -827,8 +827,8 @@ where ) .map(|_| None) } - revive_llvm_context::EraVMCodeType::Runtime => { - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::PolkaVMCodeType::Runtime => { + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -843,10 +843,10 @@ where .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { - revive_llvm_context::eravm_evm_calldata::size(context).map(Some) + revive_llvm_context::PolkaVMCodeType::Deploy => { + revive_llvm_context::polkavm_evm_calldata::size(context).map(Some) } - revive_llvm_context::EraVMCodeType::Runtime => { + revive_llvm_context::PolkaVMCodeType::Runtime => { todo!() } } @@ -879,18 +879,18 @@ where match context.code_type().ok_or_else(|| { anyhow::anyhow!("The contract code part type is undefined") })? { - revive_llvm_context::EraVMCodeType::Deploy => { - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::PolkaVMCodeType::Deploy => { + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), arguments[1].into_int_value(), arguments[2].into_int_value(), ) } - revive_llvm_context::EraVMCodeType::Runtime => { + revive_llvm_context::PolkaVMCodeType::Runtime => { let calldata_size = - revive_llvm_context::eravm_evm_calldata::size(context)?; - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::polkavm_evm_calldata::size(context)?; + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), calldata_size.into_int_value(), @@ -904,11 +904,11 @@ where } InstructionName::PUSHSIZE => Ok(Some(context.field_const(0).as_basic_value_enum())), InstructionName::RETURNDATASIZE => { - revive_llvm_context::eravm_evm_return_data::size(context).map(Some) + revive_llvm_context::polkavm_evm_return_data::size(context).map(Some) } InstructionName::RETURNDATACOPY => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_return_data::copy( + revive_llvm_context::polkavm_evm_return_data::copy( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -918,7 +918,7 @@ where } InstructionName::EXTCODESIZE => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_ext_code::size( + revive_llvm_context::polkavm_evm_ext_code::size( context, arguments[0].into_int_value(), ) @@ -926,7 +926,7 @@ where } InstructionName::EXTCODEHASH => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_ext_code::hash( + revive_llvm_context::polkavm_evm_ext_code::hash( context, arguments[0].into_int_value(), ) @@ -935,7 +935,7 @@ where InstructionName::RETURN => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_return::r#return( + revive_llvm_context::polkavm_evm_return::r#return( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -944,7 +944,7 @@ where } InstructionName::REVERT => { let arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_return::revert( + revive_llvm_context::polkavm_evm_return::revert( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -952,15 +952,15 @@ where .map(|_| None) } InstructionName::STOP => { - revive_llvm_context::eravm_evm_return::stop(context).map(|_| None) + revive_llvm_context::polkavm_evm_return::stop(context).map(|_| None) } InstructionName::INVALID => { - revive_llvm_context::eravm_evm_return::invalid(context).map(|_| None) + revive_llvm_context::polkavm_evm_return::invalid(context).map(|_| None) } InstructionName::LOG0 => { let mut arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments.remove(0).into_int_value(), arguments.remove(0).into_int_value(), @@ -973,7 +973,7 @@ where } InstructionName::LOG1 => { let mut arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments.remove(0).into_int_value(), arguments.remove(0).into_int_value(), @@ -986,7 +986,7 @@ where } InstructionName::LOG2 => { let mut arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments.remove(0).into_int_value(), arguments.remove(0).into_int_value(), @@ -999,7 +999,7 @@ where } InstructionName::LOG3 => { let mut arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments.remove(0).into_int_value(), arguments.remove(0).into_int_value(), @@ -1012,7 +1012,7 @@ where } InstructionName::LOG4 => { let mut arguments = self.pop_arguments_llvm(context); - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments.remove(0).into_int_value(), arguments.remove(0).into_int_value(), @@ -1037,7 +1037,7 @@ where todo!() /* - revive_llvm_context::eravm_evm_call::default( + revive_llvm_context::polkavm_evm_call::default( context, context.llvm_runtime().far_call, gas, @@ -1062,7 +1062,7 @@ where let output_offset = arguments.remove(0).into_int_value(); let output_size = arguments.remove(0).into_int_value(); - revive_llvm_context::eravm_evm_call::default( + revive_llvm_context::polkavm_evm_call::default( context, context.llvm_runtime().static_call, gas, @@ -1086,7 +1086,7 @@ where let output_offset = arguments.remove(0).into_int_value(); let output_size = arguments.remove(0).into_int_value(); - revive_llvm_context::eravm_evm_call::default( + revive_llvm_context::polkavm_evm_call::default( context, context.llvm_runtime().delegate_call, gas, @@ -1108,7 +1108,7 @@ where let input_offset = arguments[1].into_int_value(); let input_length = arguments[2].into_int_value(); - revive_llvm_context::eravm_evm_create::create( + revive_llvm_context::polkavm_evm_create::create( context, value, input_offset, @@ -1124,7 +1124,7 @@ where let input_length = arguments[2].into_int_value(); let salt = arguments[3].into_int_value(); - revive_llvm_context::eravm_evm_create::create2( + revive_llvm_context::polkavm_evm_create::create2( context, value, input_offset, @@ -1138,44 +1138,44 @@ where InstructionName::CALLER => todo!(), InstructionName::CALLVALUE => { - revive_llvm_context::eravm_evm_ether_gas::value(context).map(Some) + revive_llvm_context::polkavm_evm_ether_gas::value(context).map(Some) } InstructionName::GAS => { - revive_llvm_context::eravm_evm_ether_gas::gas(context).map(Some) + revive_llvm_context::polkavm_evm_ether_gas::gas(context).map(Some) } InstructionName::BALANCE => { let arguments = self.pop_arguments_llvm(context); let address = arguments[0].into_int_value(); - revive_llvm_context::eravm_evm_ether_gas::balance(context, address).map(Some) + revive_llvm_context::polkavm_evm_ether_gas::balance(context, address).map(Some) } InstructionName::SELFBALANCE => todo!(), InstructionName::GASLIMIT => { - revive_llvm_context::eravm_evm_contract_context::gas_limit(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::gas_limit(context).map(Some) } InstructionName::GASPRICE => { - revive_llvm_context::eravm_evm_contract_context::gas_price(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::gas_price(context).map(Some) } InstructionName::ORIGIN => { - revive_llvm_context::eravm_evm_contract_context::origin(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::origin(context).map(Some) } InstructionName::CHAINID => { - revive_llvm_context::eravm_evm_contract_context::chain_id(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::chain_id(context).map(Some) } InstructionName::TIMESTAMP => { - revive_llvm_context::eravm_evm_contract_context::block_timestamp(context) + revive_llvm_context::polkavm_evm_contract_context::block_timestamp(context) .map(Some) } InstructionName::NUMBER => { - revive_llvm_context::eravm_evm_contract_context::block_number(context) + revive_llvm_context::polkavm_evm_contract_context::block_number(context) .map(Some) } InstructionName::BLOCKHASH => { let arguments = self.pop_arguments_llvm(context); let index = arguments[0].into_int_value(); - revive_llvm_context::eravm_evm_contract_context::block_hash(context, index) + revive_llvm_context::polkavm_evm_contract_context::block_hash(context, index) .map(Some) } InstructionName::BLOBHASH => { @@ -1183,19 +1183,19 @@ where anyhow::bail!("The `BLOBHASH` instruction is not supported until zkVM v1.5.0"); } InstructionName::DIFFICULTY | InstructionName::PREVRANDAO => { - revive_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::difficulty(context).map(Some) } InstructionName::COINBASE => { - revive_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::coinbase(context).map(Some) } InstructionName::BASEFEE => { - revive_llvm_context::eravm_evm_contract_context::basefee(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::basefee(context).map(Some) } InstructionName::BLOBBASEFEE => { anyhow::bail!("The `BLOBBASEFEE` instruction is not supported until zkVM v1.5.0"); } InstructionName::MSIZE => { - revive_llvm_context::eravm_evm_contract_context::msize(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::msize(context).map(Some) } InstructionName::CALLCODE => { @@ -1244,7 +1244,7 @@ where .to_llvm() .into_pointer_value(); context.build_store( - revive_llvm_context::EraVMPointer::new_stack_field( + revive_llvm_context::PolkaVMPointer::new_stack_field( context, pointer, ), value, @@ -1261,9 +1261,9 @@ where format!("return_value_element_{}", index).as_str(), ) .expect("Always exists"); - let pointer = revive_llvm_context::EraVMPointer::new( + let pointer = revive_llvm_context::PolkaVMPointer::new( context.field_type(), - revive_llvm_context::EraVMAddressSpace::Stack, + revive_llvm_context::PolkaVMAddressSpace::Stack, context.evmla().stack [self.stack.elements.len() - output_size + index] .to_llvm() @@ -1292,12 +1292,12 @@ where arguments.pop(); match context.current_function().borrow().r#return() { - revive_llvm_context::EraVMFunctionReturn::None => {} - revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => { + revive_llvm_context::PolkaVMFunctionReturn::None => {} + revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => { assert_eq!(arguments.len(), 1); context.build_store(pointer, arguments.remove(0))?; } - revive_llvm_context::EraVMFunctionReturn::Compound { + revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => { for (index, argument) in arguments.into_iter().enumerate() { @@ -1327,7 +1327,7 @@ where .to_llvm() .into_pointer_value(); context.build_store( - revive_llvm_context::EraVMPointer::new_stack_field(context, pointer), + revive_llvm_context::PolkaVMPointer::new_stack_field(context, pointer), result, )?; context.evmla_mut().stack[self.stack.elements.len() - 1].original = original; diff --git a/crates/solidity/src/evmla/ethereal_ir/function/block/mod.rs b/crates/solidity/src/evmla/ethereal_ir/function/block/mod.rs index dca4a76..b3b75da 100644 --- a/crates/solidity/src/evmla/ethereal_ir/function/block/mod.rs +++ b/crates/solidity/src/evmla/ethereal_ir/function/block/mod.rs @@ -18,13 +18,13 @@ pub struct Block { /// The Solidity compiler version. pub solc_version: semver::Version, /// The block key. - pub key: revive_llvm_context::EraVMFunctionBlockKey, + pub key: revive_llvm_context::PolkaVMFunctionBlockKey, /// The block instance. pub instance: Option, /// The block elements relevant to the stack consistency. pub elements: Vec, /// The block predecessors. - pub predecessors: HashSet<(revive_llvm_context::EraVMFunctionBlockKey, usize)>, + pub predecessors: HashSet<(revive_llvm_context::PolkaVMFunctionBlockKey, usize)>, /// The initial stack state. pub initial_stack: ElementStack, /// The stack. @@ -42,7 +42,7 @@ impl Block { /// Assembles a block from the sequence of instructions. pub fn try_from_instructions( solc_version: semver::Version, - code_type: revive_llvm_context::EraVMCodeType, + code_type: revive_llvm_context::PolkaVMCodeType, slice: &[Instruction], ) -> anyhow::Result<(Self, usize)> { let mut cursor = 0; @@ -63,7 +63,7 @@ impl Block { let mut block = Self { solc_version: solc_version.clone(), - key: revive_llvm_context::EraVMFunctionBlockKey::new(code_type, tag), + key: revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, tag), instance: None, elements: Vec::with_capacity(Self::ELEMENTS_VECTOR_DEFAULT_CAPACITY), predecessors: HashSet::with_capacity(Self::PREDECESSORS_HASHSET_DEFAULT_CAPACITY), @@ -106,20 +106,20 @@ impl Block { /// Inserts a predecessor tag. pub fn insert_predecessor( &mut self, - key: revive_llvm_context::EraVMFunctionBlockKey, + key: revive_llvm_context::PolkaVMFunctionBlockKey, instance: usize, ) { self.predecessors.insert((key, instance)); } } -impl revive_llvm_context::EraVMWriteLLVM for Block +impl revive_llvm_context::PolkaVMWriteLLVM for Block where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { context.set_code_type(self.key.code_type); diff --git a/crates/solidity/src/evmla/ethereal_ir/function/mod.rs b/crates/solidity/src/evmla/ethereal_ir/function/mod.rs index 67ab02a..ae07430 100644 --- a/crates/solidity/src/evmla/ethereal_ir/function/mod.rs +++ b/crates/solidity/src/evmla/ethereal_ir/function/mod.rs @@ -43,7 +43,7 @@ pub struct Function { /// The function name. pub name: String, /// The separately labelled blocks. - pub blocks: BTreeMap>, + pub blocks: BTreeMap>, /// The function type. pub r#type: Type, /// The function stack size. @@ -74,8 +74,8 @@ impl Function { /// Runs the function block traversal. pub fn traverse( &mut self, - blocks: &HashMap, - functions: &mut BTreeMap, + blocks: &HashMap, + functions: &mut BTreeMap, extra_metadata: &ExtraMetadata, visited_functions: &mut BTreeSet, ) -> anyhow::Result<()> { @@ -84,8 +84,8 @@ impl Function { match self.r#type { Type::Initial => { for code_type in [ - revive_llvm_context::EraVMCodeType::Deploy, - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMCodeType::Deploy, + revive_llvm_context::PolkaVMCodeType::Runtime, ] { self.consume_block( blocks, @@ -94,7 +94,7 @@ impl Function { visited_functions, &mut visited_blocks, QueueElement::new( - revive_llvm_context::EraVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMFunctionBlockKey::new( code_type, num::BigUint::zero(), ), @@ -138,8 +138,8 @@ impl Function { /// Consumes the entry or a conditional block attached to another one. fn consume_block( &mut self, - blocks: &HashMap, - functions: &mut BTreeMap, + blocks: &HashMap, + functions: &mut BTreeMap, extra_metadata: &ExtraMetadata, visited_functions: &mut BTreeSet, visited_blocks: &mut BTreeSet, @@ -214,11 +214,11 @@ impl Function { /// the invalid part is truncated after terminating with an `INVALID` instruction. #[allow(clippy::too_many_arguments)] fn handle_instruction( - blocks: &HashMap, - functions: &mut BTreeMap, + blocks: &HashMap, + functions: &mut BTreeMap, extra_metadata: &ExtraMetadata, visited_functions: &mut BTreeSet, - code_type: revive_llvm_context::EraVMCodeType, + code_type: revive_llvm_context::PolkaVMCodeType, instance: usize, block_stack: &mut Stack, block_element: &mut BlockElement, @@ -247,13 +247,13 @@ impl Function { .ok_or_else(|| anyhow::anyhow!("Destination tag is missing"))? { Element::Tag(destination) if destination > &num::BigUint::from(u32::MAX) => { - revive_llvm_context::EraVMFunctionBlockKey::new( - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMCodeType::Runtime, destination.to_owned() - num::BigUint::from(1u64 << 32), ) } Element::Tag(destination) => { - revive_llvm_context::EraVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMFunctionBlockKey::new( code_type, destination.to_owned(), ) @@ -311,13 +311,13 @@ impl Function { .ok_or_else(|| anyhow::anyhow!("Destination tag is missing"))? { Element::Tag(destination) if destination > &num::BigUint::from(u32::MAX) => { - revive_llvm_context::EraVMFunctionBlockKey::new( - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMCodeType::Runtime, destination.to_owned() - num::BigUint::from(1u64 << 32), ) } Element::Tag(destination) => { - revive_llvm_context::EraVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMFunctionBlockKey::new( code_type, destination.to_owned(), ) @@ -347,7 +347,7 @@ impl Function { } => { let tag: num::BigUint = tag.parse().expect("Always valid"); let block_key = - revive_llvm_context::EraVMFunctionBlockKey::new(code_type, tag); + revive_llvm_context::PolkaVMFunctionBlockKey::new(code_type, tag); queue_element.predecessor = Some((queue_element.block_key.clone(), instance)); queue_element.block_key = block_key.clone(); @@ -1006,16 +1006,16 @@ impl Function { #[allow(clippy::too_many_arguments)] fn handle_recursive_function_call( recursive_function: &RecursiveFunction, - blocks: &HashMap, - functions: &mut BTreeMap, + blocks: &HashMap, + functions: &mut BTreeMap, extra_metadata: &ExtraMetadata, visited_functions: &mut BTreeSet, - block_key: revive_llvm_context::EraVMFunctionBlockKey, + block_key: revive_llvm_context::PolkaVMFunctionBlockKey, block_stack: &mut Stack, block_element: &mut BlockElement, version: &semver::Version, ) -> anyhow::Result<( - revive_llvm_context::EraVMFunctionBlockKey, + revive_llvm_context::PolkaVMFunctionBlockKey, Vec, )> { let return_address_offset = block_stack.elements.len() - 2 - recursive_function.input_size; @@ -1024,7 +1024,7 @@ impl Function { let return_address = match block_stack.elements[return_address_offset] { Element::Tag(ref return_address) => { - revive_llvm_context::EraVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMFunctionBlockKey::new( block_key.code_type, return_address.to_owned(), ) @@ -1104,14 +1104,14 @@ impl Function { /// Checks whether the tag value actually references an existing block. /// Checks both deploy and runtime code. fn is_tag_value_valid( - blocks: &HashMap, + blocks: &HashMap, tag: &num::BigUint, ) -> bool { - blocks.contains_key(&revive_llvm_context::EraVMFunctionBlockKey::new( - revive_llvm_context::EraVMCodeType::Deploy, + blocks.contains_key(&revive_llvm_context::PolkaVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMCodeType::Deploy, tag & num::BigUint::from(u32::MAX), - )) || blocks.contains_key(&revive_llvm_context::EraVMFunctionBlockKey::new( - revive_llvm_context::EraVMCodeType::Runtime, + )) || blocks.contains_key(&revive_llvm_context::PolkaVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMCodeType::Runtime, tag & num::BigUint::from(u32::MAX), )) } @@ -1133,13 +1133,13 @@ impl Function { } } -impl revive_llvm_context::EraVMWriteLLVM for Function +impl revive_llvm_context::PolkaVMWriteLLVM for Function where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let (function_type, output_size) = match self.r#type { Type::Initial => { @@ -1178,7 +1178,7 @@ where Some(inkwell::module::Linkage::Private), )?; function.borrow_mut().set_evmla_data( - revive_llvm_context::EraVMFunctionEVMLAData::new(self.stack_size), + revive_llvm_context::PolkaVMFunctionEVMLAData::new(self.stack_size), ); Ok(()) @@ -1186,7 +1186,7 @@ where fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { context.set_current_function(self.name.as_str())?; @@ -1196,8 +1196,8 @@ where let mut stack_hashes = vec![block.initial_stack.hash()]; stack_hashes.extend_from_slice(block.extra_hashes.as_slice()); let evmla_data = - revive_llvm_context::EraVMFunctionBlockEVMLAData::new(stack_hashes); - let mut block = revive_llvm_context::EraVMFunctionBlock::new(inner); + revive_llvm_context::PolkaVMFunctionBlockEVMLAData::new(stack_hashes); + let mut block = revive_llvm_context::PolkaVMFunctionBlock::new(inner); block.set_evmla_data(evmla_data); context .current_function() @@ -1229,7 +1229,7 @@ where _ => context.field_const(0).as_basic_value_enum(), }; context.build_store(pointer, value)?; - stack_variables.push(revive_llvm_context::EraVMArgument::new( + stack_variables.push(revive_llvm_context::PolkaVMArgument::new( pointer.value.as_basic_value_enum(), )); } @@ -1243,15 +1243,15 @@ where .get_nth_param(0) .into_int_value(); let deploy_code_block = context.current_function().borrow().evmla().find_block( - &revive_llvm_context::EraVMFunctionBlockKey::new( - revive_llvm_context::EraVMCodeType::Deploy, + &revive_llvm_context::PolkaVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMCodeType::Deploy, num::BigUint::zero(), ), &Stack::default().hash(), )?; let runtime_code_block = context.current_function().borrow().evmla().find_block( - &revive_llvm_context::EraVMFunctionBlockKey::new( - revive_llvm_context::EraVMCodeType::Runtime, + &revive_llvm_context::PolkaVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMCodeType::Runtime, num::BigUint::zero(), ), &Stack::default().hash(), @@ -1297,14 +1297,14 @@ where context.set_basic_block(context.current_function().borrow().return_block()); match context.current_function().borrow().r#return() { - revive_llvm_context::EraVMFunctionReturn::None => { + revive_llvm_context::PolkaVMFunctionReturn::None => { context.build_return(None); } - revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => { + revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => { let return_value = context.build_load(pointer, "return_value")?; context.build_return(Some(&return_value)); } - revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => { + revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => { let return_value = context.build_load(pointer, "return_value")?; context.build_return(Some(&return_value)); } diff --git a/crates/solidity/src/evmla/ethereal_ir/function/queue_element.rs b/crates/solidity/src/evmla/ethereal_ir/function/queue_element.rs index 87628f1..6a28d31 100644 --- a/crates/solidity/src/evmla/ethereal_ir/function/queue_element.rs +++ b/crates/solidity/src/evmla/ethereal_ir/function/queue_element.rs @@ -6,9 +6,9 @@ use crate::evmla::ethereal_ir::function::block::element::stack::Stack; #[derive(Debug, Clone)] pub struct QueueElement { /// The block key. - pub block_key: revive_llvm_context::EraVMFunctionBlockKey, + pub block_key: revive_llvm_context::PolkaVMFunctionBlockKey, /// The block predecessor. - pub predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>, + pub predecessor: Option<(revive_llvm_context::PolkaVMFunctionBlockKey, usize)>, /// The predecessor's last stack state. pub stack: Stack, } @@ -16,8 +16,8 @@ pub struct QueueElement { impl QueueElement { /// A shortcut constructor. pub fn new( - block_key: revive_llvm_context::EraVMFunctionBlockKey, - predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>, + block_key: revive_llvm_context::PolkaVMFunctionBlockKey, + predecessor: Option<(revive_llvm_context::PolkaVMFunctionBlockKey, usize)>, stack: Stack, ) -> Self { Self { diff --git a/crates/solidity/src/evmla/ethereal_ir/function/type.rs b/crates/solidity/src/evmla/ethereal_ir/function/type.rs index f795268..1dbeffa 100644 --- a/crates/solidity/src/evmla/ethereal_ir/function/type.rs +++ b/crates/solidity/src/evmla/ethereal_ir/function/type.rs @@ -10,7 +10,7 @@ pub enum Type { /// The function name. name: String, /// The function initial block key. - block_key: revive_llvm_context::EraVMFunctionBlockKey, + block_key: revive_llvm_context::PolkaVMFunctionBlockKey, /// The size of stack input (in cells or 256-bit words). input_size: usize, /// The size of stack output (in cells or 256-bit words). @@ -27,7 +27,7 @@ impl Type { /// A shortcut constructor. pub fn new_recursive( name: String, - block_key: revive_llvm_context::EraVMFunctionBlockKey, + block_key: revive_llvm_context::PolkaVMFunctionBlockKey, input_size: usize, output_size: usize, ) -> Self { diff --git a/crates/solidity/src/evmla/ethereal_ir/function/visited_element.rs b/crates/solidity/src/evmla/ethereal_ir/function/visited_element.rs index be74374..c8456eb 100644 --- a/crates/solidity/src/evmla/ethereal_ir/function/visited_element.rs +++ b/crates/solidity/src/evmla/ethereal_ir/function/visited_element.rs @@ -6,7 +6,7 @@ use std::cmp::Ordering; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct VisitedElement { /// The block key. - pub block_key: revive_llvm_context::EraVMFunctionBlockKey, + pub block_key: revive_llvm_context::PolkaVMFunctionBlockKey, /// The initial stack state hash. pub stack_hash: md5::Digest, } @@ -14,7 +14,7 @@ pub struct VisitedElement { impl VisitedElement { /// A shortcut constructor. pub fn new( - block_key: revive_llvm_context::EraVMFunctionBlockKey, + block_key: revive_llvm_context::PolkaVMFunctionBlockKey, stack_hash: md5::Digest, ) -> Self { Self { @@ -34,20 +34,20 @@ impl Ord for VisitedElement { fn cmp(&self, other: &Self) -> Ordering { match (self.block_key.code_type, other.block_key.code_type) { ( - revive_llvm_context::EraVMCodeType::Deploy, - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMCodeType::Deploy, + revive_llvm_context::PolkaVMCodeType::Runtime, ) => Ordering::Less, ( - revive_llvm_context::EraVMCodeType::Runtime, - revive_llvm_context::EraVMCodeType::Deploy, + revive_llvm_context::PolkaVMCodeType::Runtime, + revive_llvm_context::PolkaVMCodeType::Deploy, ) => Ordering::Greater, ( - revive_llvm_context::EraVMCodeType::Deploy, - revive_llvm_context::EraVMCodeType::Deploy, + revive_llvm_context::PolkaVMCodeType::Deploy, + revive_llvm_context::PolkaVMCodeType::Deploy, ) | ( - revive_llvm_context::EraVMCodeType::Runtime, - revive_llvm_context::EraVMCodeType::Runtime, + revive_llvm_context::PolkaVMCodeType::Runtime, + revive_llvm_context::PolkaVMCodeType::Runtime, ) => { let tag_comparison = self.block_key.tag.cmp(&other.block_key.tag); if tag_comparison == Ordering::Equal { diff --git a/crates/solidity/src/evmla/ethereal_ir/mod.rs b/crates/solidity/src/evmla/ethereal_ir/mod.rs index 98bcbaa..dabffa4 100644 --- a/crates/solidity/src/evmla/ethereal_ir/mod.rs +++ b/crates/solidity/src/evmla/ethereal_ir/mod.rs @@ -31,7 +31,7 @@ pub struct EtherealIR { /// The all-inlined function. pub entry_function: Function, /// The recursive functions. - pub recursive_functions: BTreeMap, + pub recursive_functions: BTreeMap, } impl EtherealIR { @@ -45,7 +45,7 @@ impl EtherealIR { pub fn new( solc_version: semver::Version, extra_metadata: ExtraMetadata, - blocks: HashMap, + blocks: HashMap, ) -> anyhow::Result { let mut entry_function = Function::new(solc_version.clone(), FunctionType::new_initial()); let mut recursive_functions = BTreeMap::new(); @@ -68,9 +68,9 @@ impl EtherealIR { /// Gets blocks for the specified type of the contract code. pub fn get_blocks( solc_version: semver::Version, - code_type: revive_llvm_context::EraVMCodeType, + code_type: revive_llvm_context::PolkaVMCodeType, instructions: &[Instruction], - ) -> anyhow::Result> { + ) -> anyhow::Result> { let mut blocks = HashMap::with_capacity(Self::BLOCKS_HASHMAP_DEFAULT_CAPACITY); let mut offset = 0; @@ -81,7 +81,7 @@ impl EtherealIR { &instructions[offset..], )?; blocks.insert( - revive_llvm_context::EraVMFunctionBlockKey::new( + revive_llvm_context::PolkaVMFunctionBlockKey::new( code_type, block.key.tag.clone(), ), @@ -94,13 +94,13 @@ impl EtherealIR { } } -impl revive_llvm_context::EraVMWriteLLVM for EtherealIR +impl revive_llvm_context::PolkaVMWriteLLVM for EtherealIR where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.entry_function.declare(context)?; @@ -113,7 +113,7 @@ where fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { context.evmla_mut().stack = vec![]; diff --git a/crates/solidity/src/lib.rs b/crates/solidity/src/lib.rs index 471ea3e..e2de603 100644 --- a/crates/solidity/src/lib.rs +++ b/crates/solidity/src/lib.rs @@ -1,4 +1,4 @@ -//! Solidity to EraVM compiler library. +//! Solidity to PolkaVM compiler library. pub(crate) mod build; pub(crate) mod r#const; @@ -120,7 +120,7 @@ pub fn llvm_ir( Ok(build) } -/// Runs the EraVM assembly mode. +/// Runs the PolkaVM assembly mode. pub fn zkasm( input_files: &[PathBuf], include_metadata_hash: bool, @@ -130,7 +130,7 @@ pub fn zkasm( 1 => input_files.first().expect("Always exists"), 0 => anyhow::bail!("The input file is missing"), length => anyhow::bail!( - "Only one input file is allowed in the EraVM assembly mode, but found {}", + "Only one input file is allowed in the PolkaVM assembly mode, but found {}", length, ), }; @@ -268,7 +268,7 @@ pub fn standard_json( let include_metadata_hash = match solc_input.settings.metadata { Some(ref metadata) => { - metadata.bytecode_hash != Some(revive_llvm_context::EraVMMetadataHash::None) + metadata.bytecode_hash != Some(revive_llvm_context::PolkaVMMetadataHash::None) } None => true, }; diff --git a/crates/solidity/src/project/contract/ir/evmla.rs b/crates/solidity/src/project/contract/ir/evmla.rs index 9cb2ac2..36ea7c3 100644 --- a/crates/solidity/src/project/contract/ir/evmla.rs +++ b/crates/solidity/src/project/contract/ir/evmla.rs @@ -30,20 +30,20 @@ impl EVMLA { } } -impl revive_llvm_context::EraVMWriteLLVM for EVMLA +impl revive_llvm_context::PolkaVMWriteLLVM for EVMLA where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.assembly.declare(context) } fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.assembly.into_llvm(context) } diff --git a/crates/solidity/src/project/contract/ir/mod.rs b/crates/solidity/src/project/contract/ir/mod.rs index 296ea4e..90adeb1 100644 --- a/crates/solidity/src/project/contract/ir/mod.rs +++ b/crates/solidity/src/project/contract/ir/mod.rs @@ -31,7 +31,7 @@ pub enum IR { EVMLA(EVMLA), /// The LLVM IR source code. LLVMIR(LLVMIR), - /// The EraVM assembly source code. + /// The PolkaVM assembly source code. ZKASM(ZKASM), } @@ -67,13 +67,13 @@ impl IR { } } -impl revive_llvm_context::EraVMWriteLLVM for IR +impl revive_llvm_context::PolkaVMWriteLLVM for IR where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { match self { Self::Yul(inner) => inner.declare(context), @@ -85,7 +85,7 @@ where fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { match self { Self::Yul(inner) => inner.into_llvm(context), diff --git a/crates/solidity/src/project/contract/ir/yul.rs b/crates/solidity/src/project/contract/ir/yul.rs index 3c122fb..b15c07c 100644 --- a/crates/solidity/src/project/contract/ir/yul.rs +++ b/crates/solidity/src/project/contract/ir/yul.rs @@ -31,20 +31,20 @@ impl Yul { } } -impl revive_llvm_context::EraVMWriteLLVM for Yul +impl revive_llvm_context::PolkaVMWriteLLVM for Yul where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.object.declare(context) } fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.object.into_llvm(context) } diff --git a/crates/solidity/src/project/contract/ir/zkasm.rs b/crates/solidity/src/project/contract/ir/zkasm.rs index 23f77aa..c4d28c0 100644 --- a/crates/solidity/src/project/contract/ir/zkasm.rs +++ b/crates/solidity/src/project/contract/ir/zkasm.rs @@ -1,15 +1,15 @@ -//! The contract EraVM assembly source code. +//! The contract PolkaVM assembly source code. use serde::Deserialize; use serde::Serialize; -/// The contract EraVM assembly source code. +/// The contract PolkaVM assembly source code. #[derive(Debug, Serialize, Deserialize, Clone)] #[allow(clippy::upper_case_acronyms)] pub struct ZKASM { - /// The EraVM assembly file path. + /// The PolkaVM assembly file path. pub path: String, - /// The EraVM assembly source code. + /// The PolkaVM assembly source code. pub source: String, } diff --git a/crates/solidity/src/project/contract/metadata.rs b/crates/solidity/src/project/contract/metadata.rs index d7bb6a8..931b27c 100644 --- a/crates/solidity/src/project/contract/metadata.rs +++ b/crates/solidity/src/project/contract/metadata.rs @@ -12,9 +12,9 @@ pub struct Metadata { pub solc_version: semver::Version, /// The zkVM `solc` edition. pub solc_zkvm_edition: Option, - /// The EraVM compiler version. + /// The PolkaVM compiler version. pub zk_version: semver::Version, - /// The EraVM compiler optimizer settings. + /// The PolkaVM compiler optimizer settings. pub optimizer_settings: revive_llvm_context::OptimizerSettings, } diff --git a/crates/solidity/src/project/contract/mod.rs b/crates/solidity/src/project/contract/mod.rs index 75e35cc..602c90e 100644 --- a/crates/solidity/src/project/contract/mod.rs +++ b/crates/solidity/src/project/contract/mod.rs @@ -9,7 +9,7 @@ use serde::Deserialize; use serde::Serialize; use sha3::Digest; -use revive_llvm_context::EraVMWriteLLVM; +use revive_llvm_context::PolkaVMWriteLLVM; use crate::build::contract::Contract as ContractBuild; use crate::project::Project; @@ -117,7 +117,7 @@ impl Contract { .map_err(|error| anyhow::anyhow!(error.to_string()))? } IR::ZKASM(ref zkasm) => { - let build = revive_llvm_context::eravm_build_assembly_text( + let build = revive_llvm_context::polkavm_build_assembly_text( self.path.as_str(), zkasm.source.as_str(), metadata_hash, @@ -133,7 +133,7 @@ impl Contract { } _ => llvm.create_module(self.path.as_str()), }; - let mut context = revive_llvm_context::EraVMContext::new( + let mut context = revive_llvm_context::PolkaVMContext::new( &llvm, module, optimizer, @@ -141,15 +141,15 @@ impl Contract { include_metadata_hash, debug_config, ); - context.set_solidity_data(revive_llvm_context::EraVMContextSolidityData::default()); + context.set_solidity_data(revive_llvm_context::PolkaVMContextSolidityData::default()); match self.ir { IR::Yul(_) => { - let yul_data = revive_llvm_context::EraVMContextYulData::new(is_system_mode); + let yul_data = revive_llvm_context::PolkaVMContextYulData::new(is_system_mode); context.set_yul_data(yul_data); } IR::EVMLA(_) => { let evmla_data = - revive_llvm_context::EraVMContextEVMLAData::new(version.default); + revive_llvm_context::PolkaVMContextEVMLAData::new(version.default); context.set_evmla_data(evmla_data); } IR::LLVMIR(_) => {} @@ -190,20 +190,20 @@ impl Contract { } } -impl EraVMWriteLLVM for Contract +impl PolkaVMWriteLLVM for Contract where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.ir.declare(context) } fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.ir.into_llvm(context) } diff --git a/crates/solidity/src/project/mod.rs b/crates/solidity/src/project/mod.rs index 4514d41..ebc7052 100644 --- a/crates/solidity/src/project/mod.rs +++ b/crates/solidity/src/project/mod.rs @@ -213,7 +213,7 @@ impl Project { let source_hash = sha3::Keccak256::digest(source_code.as_bytes()).into(); let source_version = - SolcVersion::new_simple(revive_llvm_context::eravm_const::LLVM_VERSION); + SolcVersion::new_simple(revive_llvm_context::polkavm_const::LLVM_VERSION); let path = path.to_string_lossy().to_string(); let mut project_contracts = BTreeMap::new(); @@ -235,15 +235,15 @@ impl Project { )) } - /// Parses the EraVM assembly source code file and returns the source data. + /// Parses the PolkaVM assembly source code file and returns the source data. pub fn try_from_zkasm_path(path: &Path) -> anyhow::Result { let source_code = std::fs::read_to_string(path).map_err(|error| { - anyhow::anyhow!("EraVM assembly file {:?} reading error: {}", path, error) + anyhow::anyhow!("PolkaVM assembly file {:?} reading error: {}", path, error) })?; let source_hash = sha3::Keccak256::digest(source_code.as_bytes()).into(); let source_version = - SolcVersion::new_simple(revive_llvm_context::eravm_const::ZKEVM_VERSION); + SolcVersion::new_simple(revive_llvm_context::polkavm_const::ZKEVM_VERSION); let path = path.to_string_lossy().to_string(); let mut project_contracts = BTreeMap::new(); @@ -266,7 +266,7 @@ impl Project { } } -impl revive_llvm_context::EraVMDependency for Project { +impl revive_llvm_context::PolkaVMDependency for Project { fn compile( project: Self, identifier: &str, diff --git a/crates/solidity/src/solc/standard_json/input/settings/metadata.rs b/crates/solidity/src/solc/standard_json/input/settings/metadata.rs index d64dfee..cfbd555 100644 --- a/crates/solidity/src/solc/standard_json/input/settings/metadata.rs +++ b/crates/solidity/src/solc/standard_json/input/settings/metadata.rs @@ -9,12 +9,12 @@ use serde::Serialize; pub struct Metadata { /// The bytecode hash mode. #[serde(skip_serializing_if = "Option::is_none")] - pub bytecode_hash: Option, + pub bytecode_hash: Option, } impl Metadata { /// A shortcut constructor. - pub fn new(bytecode_hash: revive_llvm_context::EraVMMetadataHash) -> Self { + pub fn new(bytecode_hash: revive_llvm_context::PolkaVMMetadataHash) -> Self { Self { bytecode_hash: Some(bytecode_hash), } diff --git a/crates/solidity/src/solc/standard_json/output/contract/evm/extra_metadata/mod.rs b/crates/solidity/src/solc/standard_json/output/contract/evm/extra_metadata/mod.rs index 6fb4796..f734419 100644 --- a/crates/solidity/src/solc/standard_json/output/contract/evm/extra_metadata/mod.rs +++ b/crates/solidity/src/solc/standard_json/output/contract/evm/extra_metadata/mod.rs @@ -20,18 +20,18 @@ impl ExtraMetadata { /// Returns the recursive function reference for the specified tag. pub fn get( &self, - block_key: &revive_llvm_context::EraVMFunctionBlockKey, + block_key: &revive_llvm_context::PolkaVMFunctionBlockKey, ) -> Option<&RecursiveFunction> { for function in self.recursive_functions.iter() { match block_key.code_type { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { if let Some(creation_tag) = function.creation_tag { if num::BigUint::from(creation_tag) == block_key.tag { return Some(function); } } } - revive_llvm_context::EraVMCodeType::Runtime => { + revive_llvm_context::PolkaVMCodeType::Runtime => { if let Some(runtime_tag) = function.runtime_tag { if num::BigUint::from(runtime_tag) == block_key.tag { return Some(function); diff --git a/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs b/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs index 82a56b3..3ed4b7f 100644 --- a/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs +++ b/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs @@ -15,18 +15,18 @@ use self::bytecode::DeployedBytecode; use self::extra_metadata::ExtraMetadata; /// The `solc --standard-json` output contract EVM data. -/// It is replaced by EraVM data after compiling. +/// It is replaced by PolkaVM data after compiling. #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct EVM { /// The contract EVM legacy assembly code. #[serde(rename = "legacyAssembly")] pub assembly: Option, - /// The contract EraVM assembly code. + /// The contract PolkaVM assembly code. #[serde(rename = "assembly")] pub assembly_text: Option, /// The contract bytecode. - /// Is reset by that of EraVM before yielding the compiled project artifacts. + /// Is reset by that of PolkaVM before yielding the compiled project artifacts. pub bytecode: Option, /// The contract deployed bytecode. pub deployed_bytecode: Option, @@ -39,7 +39,7 @@ pub struct EVM { } impl EVM { - /// Sets the EraVM assembly and bytecode. + /// Sets the PolkaVM assembly and bytecode. pub fn modify(&mut self, assembly_text: String, bytecode: String) { self.assembly_text = Some(assembly_text); self.bytecode = Some(Bytecode::new(bytecode)); diff --git a/crates/solidity/src/solc/standard_json/output/contract/mod.rs b/crates/solidity/src/solc/standard_json/output/contract/mod.rs index 18407aa..c919821 100644 --- a/crates/solidity/src/solc/standard_json/output/contract/mod.rs +++ b/crates/solidity/src/solc/standard_json/output/contract/mod.rs @@ -35,7 +35,7 @@ pub struct Contract { /// The contract optimized IR code. #[serde(default, skip_serializing_if = "Option::is_none")] pub ir_optimized: Option, - /// The contract EraVM bytecode hash. + /// The contract PolkaVM bytecode hash. #[serde(default, skip_serializing_if = "Option::is_none")] pub hash: Option, /// The contract factory dependencies. diff --git a/crates/solidity/src/solc/standard_json/output/mod.rs b/crates/solidity/src/solc/standard_json/output/mod.rs index a4d55f6..9dbd46b 100644 --- a/crates/solidity/src/solc/standard_json/output/mod.rs +++ b/crates/solidity/src/solc/standard_json/output/mod.rs @@ -166,12 +166,12 @@ impl Output { let mut messages = Vec::new(); for (path, source) in sources.iter() { if let Some(ast) = source.ast.as_ref() { - let mut eravm_messages = + let mut polkavm_messages = Source::get_messages(ast, version, pipeline, suppressed_warnings); - for message in eravm_messages.iter_mut() { + for message in polkavm_messages.iter_mut() { message.push_contract_path(path.as_str()); } - messages.extend(eravm_messages); + messages.extend(polkavm_messages); } } diff --git a/crates/solidity/src/yul/parser/statement/assignment.rs b/crates/solidity/src/yul/parser/statement/assignment.rs index 25e48d8..8f4c236 100644 --- a/crates/solidity/src/yul/parser/statement/assignment.rs +++ b/crates/solidity/src/yul/parser/statement/assignment.rs @@ -107,13 +107,13 @@ impl Assignment { } } -impl revive_llvm_context::EraVMWriteLLVM for Assignment +impl revive_llvm_context::PolkaVMWriteLLVM for Assignment where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let value = match self.initializer.into_llvm(context)? { Some(value) => value, diff --git a/crates/solidity/src/yul/parser/statement/block.rs b/crates/solidity/src/yul/parser/statement/block.rs index efa88f6..622c206 100644 --- a/crates/solidity/src/yul/parser/statement/block.rs +++ b/crates/solidity/src/yul/parser/statement/block.rs @@ -128,13 +128,13 @@ impl Block { } } -impl revive_llvm_context::EraVMWriteLLVM for Block +impl revive_llvm_context::PolkaVMWriteLLVM for Block where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let current_function = context.current_function().borrow().name().to_owned(); let current_block = context.basic_block(); diff --git a/crates/solidity/src/yul/parser/statement/code.rs b/crates/solidity/src/yul/parser/statement/code.rs index c721d17..1460d00 100644 --- a/crates/solidity/src/yul/parser/statement/code.rs +++ b/crates/solidity/src/yul/parser/statement/code.rs @@ -55,13 +55,13 @@ impl Code { } } -impl revive_llvm_context::EraVMWriteLLVM for Code +impl revive_llvm_context::PolkaVMWriteLLVM for Code where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.block.into_llvm(context)?; 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 3fd4efb..65469bc 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 @@ -117,17 +117,17 @@ impl FunctionCall { /// Converts the function call into an LLVM value. pub fn into_llvm<'ctx, D>( mut self, - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, ) -> anyhow::Result>> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let location = self.location; match self.name { Name::UserDefined(name) if name.starts_with( - revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX, + revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX, ) && context.is_system_mode() => { unimplemented!(); @@ -166,7 +166,7 @@ impl FunctionCall { Name::Add => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::addition( + revive_llvm_context::polkavm_evm_arithmetic::addition( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -175,7 +175,7 @@ impl FunctionCall { } Name::Sub => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::subtraction( + revive_llvm_context::polkavm_evm_arithmetic::subtraction( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -184,7 +184,7 @@ impl FunctionCall { } Name::Mul => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::multiplication( + revive_llvm_context::polkavm_evm_arithmetic::multiplication( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -193,7 +193,7 @@ impl FunctionCall { } Name::Div => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::division( + revive_llvm_context::polkavm_evm_arithmetic::division( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -202,7 +202,7 @@ impl FunctionCall { } Name::Mod => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::remainder( + revive_llvm_context::polkavm_evm_arithmetic::remainder( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -211,7 +211,7 @@ impl FunctionCall { } Name::Sdiv => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::division_signed( + revive_llvm_context::polkavm_evm_arithmetic::division_signed( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -220,7 +220,7 @@ impl FunctionCall { } Name::Smod => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_arithmetic::remainder_signed( + revive_llvm_context::polkavm_evm_arithmetic::remainder_signed( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -230,7 +230,7 @@ impl FunctionCall { Name::Lt => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -240,7 +240,7 @@ impl FunctionCall { } Name::Gt => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -250,7 +250,7 @@ impl FunctionCall { } Name::Eq => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -260,7 +260,7 @@ impl FunctionCall { } Name::IsZero => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), context.field_const(0), @@ -270,7 +270,7 @@ impl FunctionCall { } Name::Slt => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -280,7 +280,7 @@ impl FunctionCall { } Name::Sgt => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_comparison::compare( + revive_llvm_context::polkavm_evm_comparison::compare( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -291,7 +291,7 @@ impl FunctionCall { Name::Or => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::or( + revive_llvm_context::polkavm_evm_bitwise::or( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -300,7 +300,7 @@ impl FunctionCall { } Name::Xor => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::xor( + revive_llvm_context::polkavm_evm_bitwise::xor( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -309,7 +309,7 @@ impl FunctionCall { } Name::Not => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::xor( + revive_llvm_context::polkavm_evm_bitwise::xor( context, arguments[0].into_int_value(), context.field_type().const_all_ones(), @@ -318,7 +318,7 @@ impl FunctionCall { } Name::And => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::and( + revive_llvm_context::polkavm_evm_bitwise::and( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -327,7 +327,7 @@ impl FunctionCall { } Name::Shl => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::shift_left( + revive_llvm_context::polkavm_evm_bitwise::shift_left( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -336,7 +336,7 @@ impl FunctionCall { } Name::Shr => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::shift_right( + revive_llvm_context::polkavm_evm_bitwise::shift_right( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -345,7 +345,7 @@ impl FunctionCall { } Name::Sar => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::shift_right_arithmetic( + revive_llvm_context::polkavm_evm_bitwise::shift_right_arithmetic( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -354,7 +354,7 @@ impl FunctionCall { } Name::Byte => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_bitwise::byte( + revive_llvm_context::polkavm_evm_bitwise::byte( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -368,7 +368,7 @@ impl FunctionCall { Name::AddMod => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_math::add_mod( + revive_llvm_context::polkavm_evm_math::add_mod( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -378,7 +378,7 @@ impl FunctionCall { } Name::MulMod => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_math::mul_mod( + revive_llvm_context::polkavm_evm_math::mul_mod( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -388,7 +388,7 @@ impl FunctionCall { } Name::Exp => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_math::exponent( + revive_llvm_context::polkavm_evm_math::exponent( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -397,7 +397,7 @@ impl FunctionCall { } Name::SignExtend => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_math::sign_extend( + revive_llvm_context::polkavm_evm_math::sign_extend( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -407,7 +407,7 @@ impl FunctionCall { Name::Keccak256 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_crypto::sha3( + revive_llvm_context::polkavm_evm_crypto::sha3( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -417,7 +417,7 @@ impl FunctionCall { Name::MLoad => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_memory::load( + revive_llvm_context::polkavm_evm_memory::load( context, arguments[0].into_int_value(), ) @@ -425,7 +425,7 @@ impl FunctionCall { } Name::MStore => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_memory::store( + revive_llvm_context::polkavm_evm_memory::store( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -434,7 +434,7 @@ impl FunctionCall { } Name::MStore8 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_memory::store_byte( + revive_llvm_context::polkavm_evm_memory::store_byte( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -443,16 +443,16 @@ impl FunctionCall { } Name::MCopy => { let arguments = self.pop_arguments_llvm::(context)?; - let destination = revive_llvm_context::EraVMPointer::new_with_offset( + let destination = revive_llvm_context::PolkaVMPointer::new_with_offset( context, - revive_llvm_context::EraVMAddressSpace::Heap, + revive_llvm_context::PolkaVMAddressSpace::Heap, context.byte_type(), arguments[0].into_int_value(), "mcopy_destination", ); - let source = revive_llvm_context::EraVMPointer::new_with_offset( + let source = revive_llvm_context::PolkaVMPointer::new_with_offset( context, - revive_llvm_context::EraVMAddressSpace::Heap, + revive_llvm_context::PolkaVMAddressSpace::Heap, context.byte_type(), arguments[1].into_int_value(), "mcopy_source", @@ -470,7 +470,7 @@ impl FunctionCall { Name::SLoad => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_storage::load( + revive_llvm_context::polkavm_evm_storage::load( context, arguments[0].into_int_value(), ) @@ -478,7 +478,7 @@ impl FunctionCall { } Name::SStore => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_storage::store( + revive_llvm_context::polkavm_evm_storage::store( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -514,7 +514,7 @@ impl FunctionCall { let index = context.field_const(offset as u64); let value = arguments[2].value.into_int_value(); - revive_llvm_context::eravm_evm_immutable::store(context, index, value) + revive_llvm_context::polkavm_evm_immutable::store(context, index, value) .map(|_| None) } @@ -525,11 +525,11 @@ impl FunctionCall { .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { Ok(Some(context.field_const(0).as_basic_value_enum())) } - revive_llvm_context::EraVMCodeType::Runtime => { - revive_llvm_context::eravm_evm_calldata::load( + revive_llvm_context::PolkaVMCodeType::Runtime => { + revive_llvm_context::polkavm_evm_calldata::load( context, arguments[0].into_int_value(), ) @@ -542,11 +542,11 @@ impl FunctionCall { .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { Ok(Some(context.field_const(0).as_basic_value_enum())) } - revive_llvm_context::EraVMCodeType::Runtime => { - revive_llvm_context::eravm_evm_calldata::size(context).map(Some) + revive_llvm_context::PolkaVMCodeType::Runtime => { + revive_llvm_context::polkavm_evm_calldata::size(context).map(Some) } } } @@ -557,11 +557,11 @@ impl FunctionCall { .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { + revive_llvm_context::PolkaVMCodeType::Deploy => { let calldata_size = - revive_llvm_context::eravm_evm_calldata::size(context)?; + revive_llvm_context::polkavm_evm_calldata::size(context)?; - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), calldata_size.into_int_value(), @@ -569,8 +569,8 @@ impl FunctionCall { ) .map(|_| None) } - revive_llvm_context::EraVMCodeType::Runtime => { - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::PolkaVMCodeType::Runtime => { + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -585,16 +585,16 @@ impl FunctionCall { .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { - revive_llvm_context::EraVMCodeType::Deploy => { - revive_llvm_context::eravm_evm_calldata::size(context).map(Some) + revive_llvm_context::PolkaVMCodeType::Deploy => { + revive_llvm_context::polkavm_evm_calldata::size(context).map(Some) } - revive_llvm_context::EraVMCodeType::Runtime => { + revive_llvm_context::PolkaVMCodeType::Runtime => { todo!() } } } Name::CodeCopy => { - if let revive_llvm_context::EraVMCodeType::Runtime = context + if let revive_llvm_context::PolkaVMCodeType::Runtime = context .code_type() .ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))? { @@ -605,7 +605,7 @@ impl FunctionCall { } let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_calldata::copy( + revive_llvm_context::polkavm_evm_calldata::copy( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -614,11 +614,11 @@ impl FunctionCall { .map(|_| None) } Name::ReturnDataSize => { - revive_llvm_context::eravm_evm_return_data::size(context).map(Some) + revive_llvm_context::polkavm_evm_return_data::size(context).map(Some) } Name::ReturnDataCopy => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_return_data::copy( + revive_llvm_context::polkavm_evm_return_data::copy( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -628,7 +628,7 @@ impl FunctionCall { } Name::ExtCodeSize => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_ext_code::size( + revive_llvm_context::polkavm_evm_ext_code::size( context, arguments[0].into_int_value(), ) @@ -636,7 +636,7 @@ impl FunctionCall { } Name::ExtCodeHash => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_ext_code::hash( + revive_llvm_context::polkavm_evm_ext_code::hash( context, arguments[0].into_int_value(), ) @@ -645,7 +645,7 @@ impl FunctionCall { Name::Return => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_return::r#return( + revive_llvm_context::polkavm_evm_return::r#return( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -654,21 +654,21 @@ impl FunctionCall { } Name::Revert => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_return::revert( + revive_llvm_context::polkavm_evm_return::revert( context, arguments[0].into_int_value(), arguments[1].into_int_value(), ) .map(|_| None) } - Name::Stop => revive_llvm_context::eravm_evm_return::stop(context).map(|_| None), + Name::Stop => revive_llvm_context::polkavm_evm_return::stop(context).map(|_| None), Name::Invalid => { - revive_llvm_context::eravm_evm_return::invalid(context).map(|_| None) + revive_llvm_context::polkavm_evm_return::invalid(context).map(|_| None) } Name::Log0 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -678,7 +678,7 @@ impl FunctionCall { } Name::Log1 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -691,7 +691,7 @@ impl FunctionCall { } Name::Log2 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -704,7 +704,7 @@ impl FunctionCall { } Name::Log3 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -717,7 +717,7 @@ impl FunctionCall { } Name::Log4 => { let arguments = self.pop_arguments_llvm::(context)?; - revive_llvm_context::eravm_evm_event::log( + revive_llvm_context::polkavm_evm_event::log( context, arguments[0].into_int_value(), arguments[1].into_int_value(), @@ -747,7 +747,7 @@ impl FunctionCall { todo!() /* - revive_llvm_context::eravm_evm_call::default( + revive_llvm_context::polkavm_evm_call::default( context, context.llvm_runtime().far_call, gas, @@ -777,7 +777,7 @@ impl FunctionCall { .map(|mut argument| argument.constant.take()) .collect(); - revive_llvm_context::eravm_evm_call::default( + revive_llvm_context::polkavm_evm_call::default( context, context.llvm_runtime().static_call, gas, @@ -806,7 +806,7 @@ impl FunctionCall { .map(|mut argument| argument.constant.take()) .collect(); - revive_llvm_context::eravm_evm_call::default( + revive_llvm_context::polkavm_evm_call::default( context, context.llvm_runtime().delegate_call, gas, @@ -828,7 +828,7 @@ impl FunctionCall { let input_offset = arguments[1].into_int_value(); let input_length = arguments[2].into_int_value(); - revive_llvm_context::eravm_evm_create::create( + revive_llvm_context::polkavm_evm_create::create( context, value, input_offset, @@ -844,7 +844,7 @@ impl FunctionCall { let input_length = arguments[2].into_int_value(); let salt = arguments[3].into_int_value(); - revive_llvm_context::eravm_evm_create::create2( + revive_llvm_context::polkavm_evm_create::create2( context, value, input_offset, @@ -860,7 +860,7 @@ impl FunctionCall { anyhow::anyhow!("{} `dataoffset` object identifier is missing", location) })?; - revive_llvm_context::eravm_evm_create::contract_hash(context, identifier) + revive_llvm_context::polkavm_evm_create::contract_hash(context, identifier) .map(|argument| Some(argument.value)) } Name::DataSize => { @@ -870,7 +870,7 @@ impl FunctionCall { anyhow::anyhow!("{} `dataoffset` object identifier is missing", location) })?; - revive_llvm_context::eravm_evm_create::header_size(context, identifier) + revive_llvm_context::polkavm_evm_create::header_size(context, identifier) .map(|argument| Some(argument.value)) } Name::DataCopy => { @@ -882,7 +882,7 @@ impl FunctionCall { ), "datacopy_contract_hash_offset", )?; - revive_llvm_context::eravm_evm_memory::store( + revive_llvm_context::polkavm_evm_memory::store( context, offset, arguments[1].into_int_value(), @@ -912,42 +912,42 @@ impl FunctionCall { } Name::CallValue => { - revive_llvm_context::eravm_evm_ether_gas::value(context).map(Some) + revive_llvm_context::polkavm_evm_ether_gas::value(context).map(Some) } - Name::Gas => revive_llvm_context::eravm_evm_ether_gas::gas(context).map(Some), + Name::Gas => revive_llvm_context::polkavm_evm_ether_gas::gas(context).map(Some), Name::Balance => { let arguments = self.pop_arguments_llvm::(context)?; let address = arguments[0].into_int_value(); - revive_llvm_context::eravm_evm_ether_gas::balance(context, address).map(Some) + revive_llvm_context::polkavm_evm_ether_gas::balance(context, address).map(Some) } Name::SelfBalance => todo!(), Name::GasLimit => { - revive_llvm_context::eravm_evm_contract_context::gas_limit(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::gas_limit(context).map(Some) } Name::GasPrice => { - revive_llvm_context::eravm_evm_contract_context::gas_price(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::gas_price(context).map(Some) } Name::Origin => { - revive_llvm_context::eravm_evm_contract_context::origin(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::origin(context).map(Some) } Name::ChainId => { - revive_llvm_context::eravm_evm_contract_context::chain_id(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::chain_id(context).map(Some) } Name::Timestamp => { - revive_llvm_context::eravm_evm_contract_context::block_timestamp(context) + revive_llvm_context::polkavm_evm_contract_context::block_timestamp(context) .map(Some) } Name::Number => { - revive_llvm_context::eravm_evm_contract_context::block_number(context) + revive_llvm_context::polkavm_evm_contract_context::block_number(context) .map(Some) } Name::BlockHash => { let arguments = self.pop_arguments_llvm::(context)?; let index = arguments[0].into_int_value(); - revive_llvm_context::eravm_evm_contract_context::block_hash(context, index) + revive_llvm_context::polkavm_evm_contract_context::block_hash(context, index) .map(Some) } Name::BlobHash => { @@ -958,13 +958,13 @@ impl FunctionCall { ); } Name::Difficulty | Name::Prevrandao => { - revive_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::difficulty(context).map(Some) } Name::CoinBase => { - revive_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::coinbase(context).map(Some) } Name::BaseFee => { - revive_llvm_context::eravm_evm_contract_context::basefee(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::basefee(context).map(Some) } Name::BlobBaseFee => { anyhow::bail!( @@ -973,7 +973,7 @@ impl FunctionCall { ); } Name::MSize => { - revive_llvm_context::eravm_evm_contract_context::msize(context).map(Some) + revive_llvm_context::polkavm_evm_contract_context::msize(context).map(Some) } Name::Verbatim { @@ -1006,10 +1006,10 @@ impl FunctionCall { /// Pops the specified number of arguments, converted into their LLVM values. fn pop_arguments_llvm<'ctx, D, const N: usize>( &mut self, - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, ) -> anyhow::Result<[inkwell::values::BasicValueEnum<'ctx>; N]> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let mut arguments = Vec::with_capacity(N); for expression in self.arguments.drain(0..N).rev() { @@ -1023,10 +1023,10 @@ impl FunctionCall { /// Pops the specified number of arguments. fn pop_arguments<'ctx, D, const N: usize>( &mut self, - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, - ) -> anyhow::Result<[revive_llvm_context::EraVMArgument<'ctx>; N]> + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, + ) -> anyhow::Result<[revive_llvm_context::PolkaVMArgument<'ctx>; N]> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { let mut arguments = Vec::with_capacity(N); for expression in self.arguments.drain(0..N).rev() { 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 0553620..3d82098 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 @@ -4,13 +4,13 @@ use crate::yul::parser::statement::expression::function_call::FunctionCall; /// Translates the verbatim simulations. pub fn verbatim<'ctx, D>( - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, call: &mut FunctionCall, _input_size: usize, output_size: usize, ) -> anyhow::Result>> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { if output_size > 1 { anyhow::bail!( diff --git a/crates/solidity/src/yul/parser/statement/expression/literal.rs b/crates/solidity/src/yul/parser/statement/expression/literal.rs index 3b6ed9f..d266153 100644 --- a/crates/solidity/src/yul/parser/statement/expression/literal.rs +++ b/crates/solidity/src/yul/parser/statement/expression/literal.rs @@ -72,10 +72,10 @@ impl Literal { /// Converts the literal into its LLVM. pub fn into_llvm<'ctx, D>( self, - context: &revive_llvm_context::EraVMContext<'ctx, D>, - ) -> anyhow::Result> + context: &revive_llvm_context::PolkaVMContext<'ctx, D>, + ) -> anyhow::Result> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { match self.inner { LexicalLiteral::Boolean(inner) => { @@ -97,7 +97,7 @@ impl Literal { BooleanLiteral::True => num::BigUint::one(), }; - Ok(revive_llvm_context::EraVMArgument::new_with_constant( + Ok(revive_llvm_context::PolkaVMArgument::new_with_constant( value, constant, )) } @@ -127,7 +127,7 @@ impl Literal { } .expect("Always valid"); - Ok(revive_llvm_context::EraVMArgument::new_with_constant( + Ok(revive_llvm_context::PolkaVMArgument::new_with_constant( value, constant, )) } @@ -201,7 +201,7 @@ impl Literal { }; if hex_string.len() > revive_common::BYTE_LENGTH_FIELD * 2 { - return Ok(revive_llvm_context::EraVMArgument::new_with_original( + return Ok(revive_llvm_context::PolkaVMArgument::new_with_original( r#type.const_zero().as_basic_value_enum(), string, )); @@ -221,7 +221,7 @@ impl Literal { ) .expect("The value is valid") .as_basic_value_enum(); - Ok(revive_llvm_context::EraVMArgument::new_with_original( + Ok(revive_llvm_context::PolkaVMArgument::new_with_original( value, string, )) } diff --git a/crates/solidity/src/yul/parser/statement/expression/mod.rs b/crates/solidity/src/yul/parser/statement/expression/mod.rs index 4220b76..14bb021 100644 --- a/crates/solidity/src/yul/parser/statement/expression/mod.rs +++ b/crates/solidity/src/yul/parser/statement/expression/mod.rs @@ -96,10 +96,10 @@ impl Expression { /// Converts the expression into an LLVM value. pub fn into_llvm<'ctx, D>( self, - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, - ) -> anyhow::Result>> + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, + ) -> anyhow::Result>> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { match self { Self::Literal(literal) => literal @@ -137,7 +137,7 @@ impl Expression { match constant { Some(constant) => Ok(Some( - revive_llvm_context::EraVMArgument::new_with_constant( + revive_llvm_context::PolkaVMArgument::new_with_constant( value, constant, ), )), @@ -146,7 +146,7 @@ impl Expression { } Self::FunctionCall(call) => Ok(call .into_llvm(context)? - .map(revive_llvm_context::EraVMArgument::new)), + .map(revive_llvm_context::PolkaVMArgument::new)), } } } diff --git a/crates/solidity/src/yul/parser/statement/for_loop.rs b/crates/solidity/src/yul/parser/statement/for_loop.rs index dfb1b4b..95c6171 100644 --- a/crates/solidity/src/yul/parser/statement/for_loop.rs +++ b/crates/solidity/src/yul/parser/statement/for_loop.rs @@ -60,13 +60,13 @@ impl ForLoop { } } -impl revive_llvm_context::EraVMWriteLLVM for ForLoop +impl revive_llvm_context::PolkaVMWriteLLVM for ForLoop where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { self.initializer.into_llvm(context)?; diff --git a/crates/solidity/src/yul/parser/statement/function_definition.rs b/crates/solidity/src/yul/parser/statement/function_definition.rs index 075f9be..2be27c6 100644 --- a/crates/solidity/src/yul/parser/statement/function_definition.rs +++ b/crates/solidity/src/yul/parser/statement/function_definition.rs @@ -35,7 +35,7 @@ pub struct FunctionDefinition { /// The function body block. pub body: Block, /// The function LLVM attributes encoded in the identifier. - pub attributes: BTreeSet, + pub attributes: BTreeSet, } impl FunctionDefinition { @@ -95,7 +95,7 @@ impl FunctionDefinition { let (mut arguments, next) = Identifier::parse_typed_list(lexer, None)?; if identifier .inner - .contains(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX) + .contains(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX) { if arguments.is_empty() { return Err(ParserError::InvalidNumberOfArguments { @@ -110,7 +110,7 @@ impl FunctionDefinition { arguments.remove(0); } if identifier.inner.contains( - revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER, + revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER, ) && !arguments.is_empty() { return Err(ParserError::InvalidNumberOfArguments { @@ -181,7 +181,7 @@ impl FunctionDefinition { /// Gets the list of LLVM attributes provided in the function name. pub fn get_llvm_attributes( identifier: &Identifier, - ) -> Result, Error> { + ) -> Result, Error> { let mut valid_attributes = BTreeSet::new(); let llvm_begin = identifier.inner.find(Self::LLVM_ATTRIBUTE_PREFIX); @@ -198,7 +198,7 @@ impl FunctionDefinition { let mut invalid_attributes = BTreeSet::new(); for value in attribute_string.split('_') { - match revive_llvm_context::EraVMAttribute::try_from(value) { + match revive_llvm_context::PolkaVMAttribute::try_from(value) { Ok(attribute) => valid_attributes.insert(attribute), Err(value) => invalid_attributes.insert(value), }; @@ -216,13 +216,13 @@ impl FunctionDefinition { } } -impl revive_llvm_context::EraVMWriteLLVM for FunctionDefinition +impl revive_llvm_context::PolkaVMWriteLLVM for FunctionDefinition where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let argument_types: Vec<_> = self .arguments @@ -237,7 +237,7 @@ where argument_types, self.result.len(), self.identifier - .starts_with(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX), + .starts_with(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX), ); let function = context.add_function( @@ -246,7 +246,7 @@ where self.result.len(), Some(inkwell::module::Linkage::Private), )?; - revive_llvm_context::EraVMFunction::set_attributes( + revive_llvm_context::PolkaVMFunction::set_attributes( context.llvm(), function.borrow().declaration(), self.attributes.clone().into_iter().collect(), @@ -254,22 +254,22 @@ where ); function .borrow_mut() - .set_yul_data(revive_llvm_context::EraVMFunctionYulData::default()); + .set_yul_data(revive_llvm_context::PolkaVMFunctionYulData::default()); Ok(()) } fn into_llvm( mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { context.set_current_function(self.identifier.as_str())?; let r#return = context.current_function().borrow().r#return(); context.set_basic_block(context.current_function().borrow().entry_block()); match r#return { - revive_llvm_context::EraVMFunctionReturn::None => {} - revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => { + revive_llvm_context::PolkaVMFunctionReturn::None => {} + revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => { let identifier = self.result.pop().expect("Always exists"); let r#type = identifier.r#type.unwrap_or_default(); context.build_store(pointer, r#type.into_llvm(context).const_zero())?; @@ -278,7 +278,7 @@ where .borrow_mut() .insert_stack_pointer(identifier.inner, pointer); } - revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => { + revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => { for (index, identifier) in self.result.into_iter().enumerate() { let r#type = identifier.r#type.unwrap_or_default().into_llvm(context); let pointer = context.build_gep( @@ -317,10 +317,10 @@ where .insert_stack_pointer(argument.inner.clone(), pointer); if self .identifier - .starts_with(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX) + .starts_with(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX) && matches!( context.current_function().borrow().r#return(), - revive_llvm_context::EraVMFunctionReturn::Compound { .. } + revive_llvm_context::PolkaVMFunctionReturn::Compound { .. } ) && context.is_system_mode() { @@ -346,21 +346,21 @@ where context.set_basic_block(context.current_function().borrow().return_block()); match context.current_function().borrow().r#return() { - revive_llvm_context::EraVMFunctionReturn::None => { + revive_llvm_context::PolkaVMFunctionReturn::None => { context.build_return(None); } - revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => { + revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => { let return_value = context.build_load(pointer, "return_value")?; context.build_return(Some(&return_value)); } - revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } + revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } if context.current_function().borrow().name().starts_with( - revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX, + revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX, ) => { context.build_return(Some(&pointer.value)); } - revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => { + revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => { let return_value = context.build_load(pointer, "return_value")?; context.build_return(Some(&return_value)); } diff --git a/crates/solidity/src/yul/parser/statement/if_conditional.rs b/crates/solidity/src/yul/parser/statement/if_conditional.rs index 5bec161..bfdd2da 100644 --- a/crates/solidity/src/yul/parser/statement/if_conditional.rs +++ b/crates/solidity/src/yul/parser/statement/if_conditional.rs @@ -48,13 +48,13 @@ impl IfConditional { } } -impl revive_llvm_context::EraVMWriteLLVM for IfConditional +impl revive_llvm_context::PolkaVMWriteLLVM for IfConditional where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let condition = self .condition diff --git a/crates/solidity/src/yul/parser/statement/object.rs b/crates/solidity/src/yul/parser/statement/object.rs index 337a698..f9cd994 100644 --- a/crates/solidity/src/yul/parser/statement/object.rs +++ b/crates/solidity/src/yul/parser/statement/object.rs @@ -175,35 +175,35 @@ impl Object { } } -impl revive_llvm_context::EraVMWriteLLVM for Object +impl revive_llvm_context::PolkaVMWriteLLVM for Object where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn declare( &mut self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { - let mut entry = revive_llvm_context::EraVMEntryFunction::default(); + let mut entry = revive_llvm_context::PolkaVMEntryFunction::default(); entry.declare(context)?; - let mut runtime = revive_llvm_context::EraVMRuntime::new( - revive_llvm_context::EraVMAddressSpace::Heap, + let mut runtime = revive_llvm_context::PolkaVMRuntime::new( + revive_llvm_context::PolkaVMAddressSpace::Heap, ); runtime.declare(context)?; - revive_llvm_context::EraVMDeployCodeFunction::new( - revive_llvm_context::EraVMDummyLLVMWritable::default(), + revive_llvm_context::PolkaVMDeployCodeFunction::new( + revive_llvm_context::PolkaVMDummyLLVMWritable::default(), ) .declare(context)?; - revive_llvm_context::EraVMRuntimeCodeFunction::new( - revive_llvm_context::EraVMDummyLLVMWritable::default(), + revive_llvm_context::PolkaVMRuntimeCodeFunction::new( + revive_llvm_context::PolkaVMDummyLLVMWritable::default(), ) .declare(context)?; for name in [ - revive_llvm_context::EraVMRuntime::FUNCTION_DEPLOY_CODE, - revive_llvm_context::EraVMRuntime::FUNCTION_RUNTIME_CODE, - revive_llvm_context::EraVMRuntime::FUNCTION_ENTRY, + revive_llvm_context::PolkaVMRuntime::FUNCTION_DEPLOY_CODE, + revive_llvm_context::PolkaVMRuntime::FUNCTION_RUNTIME_CODE, + revive_llvm_context::PolkaVMRuntime::FUNCTION_ENTRY, ] .into_iter() { @@ -211,7 +211,7 @@ where .get_function(name) .expect("Always exists") .borrow_mut() - .set_yul_data(revive_llvm_context::EraVMFunctionYulData::default()); + .set_yul_data(revive_llvm_context::PolkaVMFunctionYulData::default()); } entry.into_llvm(context)?; @@ -221,13 +221,13 @@ where fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { if self.identifier.ends_with("_deployed") { - revive_llvm_context::EraVMRuntimeCodeFunction::new(self.code) + revive_llvm_context::PolkaVMRuntimeCodeFunction::new(self.code) .into_llvm(context)?; } else { - revive_llvm_context::EraVMDeployCodeFunction::new(self.code) + revive_llvm_context::PolkaVMDeployCodeFunction::new(self.code) .into_llvm(context)?; } @@ -236,8 +236,8 @@ where object.into_llvm(context)?; } None => { - let runtime = revive_llvm_context::EraVMRuntime::new( - revive_llvm_context::EraVMAddressSpace::Heap, + let runtime = revive_llvm_context::PolkaVMRuntime::new( + revive_llvm_context::PolkaVMAddressSpace::Heap, ); runtime.into_llvm(context)?; } diff --git a/crates/solidity/src/yul/parser/statement/switch/mod.rs b/crates/solidity/src/yul/parser/statement/switch/mod.rs index 4fd60c9..b21a953 100644 --- a/crates/solidity/src/yul/parser/statement/switch/mod.rs +++ b/crates/solidity/src/yul/parser/statement/switch/mod.rs @@ -118,13 +118,13 @@ impl Switch { } } -impl revive_llvm_context::EraVMWriteLLVM for Switch +impl revive_llvm_context::PolkaVMWriteLLVM for Switch where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm( self, - context: &mut revive_llvm_context::EraVMContext, + context: &mut revive_llvm_context::PolkaVMContext, ) -> anyhow::Result<()> { let scrutinee = self.expression.into_llvm(context)?; diff --git a/crates/solidity/src/yul/parser/statement/variable_declaration.rs b/crates/solidity/src/yul/parser/statement/variable_declaration.rs index 8e3b43f..57be2e8 100644 --- a/crates/solidity/src/yul/parser/statement/variable_declaration.rs +++ b/crates/solidity/src/yul/parser/statement/variable_declaration.rs @@ -91,13 +91,13 @@ impl VariableDeclaration { } } -impl revive_llvm_context::EraVMWriteLLVM for VariableDeclaration +impl revive_llvm_context::PolkaVMWriteLLVM for VariableDeclaration where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { fn into_llvm<'ctx>( mut self, - context: &mut revive_llvm_context::EraVMContext<'ctx, D>, + context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>, ) -> anyhow::Result<()> { if self.bindings.len() == 1 { let identifier = self.bindings.remove(0); diff --git a/crates/solidity/src/yul/parser/type.rs b/crates/solidity/src/yul/parser/type.rs index 4da2bfa..e8a01d7 100644 --- a/crates/solidity/src/yul/parser/type.rs +++ b/crates/solidity/src/yul/parser/type.rs @@ -64,10 +64,10 @@ impl Type { /// Converts the type into its LLVM. pub fn into_llvm<'ctx, D>( self, - context: &revive_llvm_context::EraVMContext<'ctx, D>, + context: &revive_llvm_context::PolkaVMContext<'ctx, D>, ) -> inkwell::types::IntType<'ctx> where - D: revive_llvm_context::EraVMDependency + Clone, + D: revive_llvm_context::PolkaVMDependency + Clone, { match self { Self::Bool => context.integer_type(revive_common::BIT_LENGTH_BOOLEAN), diff --git a/crates/solidity/src/zksolc/arguments.rs b/crates/solidity/src/zksolc/arguments.rs index 062745c..d93a741 100644 --- a/crates/solidity/src/zksolc/arguments.rs +++ b/crates/solidity/src/zksolc/arguments.rs @@ -1,4 +1,4 @@ -//! Solidity to EraVM compiler arguments. +//! Solidity to PolkaVM compiler arguments. use std::collections::BTreeSet; use std::path::Path; @@ -13,7 +13,7 @@ use structopt::StructOpt; /// output directory. /// Example: zksolc ERC20.sol -O3 --bin --output-dir './build/' #[derive(Debug, StructOpt)] -#[structopt(name = "The EraVM Solidity compiler")] +#[structopt(name = "The PolkaVM Solidity compiler")] pub struct Arguments { /// Print the version and exit. #[structopt(long = "version")] @@ -22,7 +22,7 @@ pub struct Arguments { /// Specify the input paths and remappings. /// If an argument contains a '=', it is considered a remapping. /// Multiple Solidity files can be passed in the default Solidity mode. - /// Yul, LLVM IR, and EraVM Assembly modes currently support only a single file. + /// Yul, LLVM IR, and PolkaVM Assembly modes currently support only a single file. pub inputs: Vec, /// Set the given path as the root of the source tree instead of the root of the filesystem. @@ -113,10 +113,10 @@ pub struct Arguments { #[structopt(long = "llvm-ir")] pub llvm_ir: bool, - /// Switch to EraVM assembly mode. - /// Only one input EraVM assembly file is allowed. + /// Switch to PolkaVM assembly mode. + /// Only one input PolkaVM assembly file is allowed. /// Cannot be used with combined and standard JSON modes. - /// Use this mode at your own risk, as EraVM assembly input validation is not implemented. + /// Use this mode at your own risk, as PolkaVM assembly input validation is not implemented. #[structopt(long = "zkasm")] pub zkasm: bool, @@ -127,8 +127,8 @@ pub struct Arguments { pub force_evmla: bool, /// Enable system contract compilation mode. - /// In this mode EraVM extensions are enabled. For example, calls to addresses `0xFFFF` and below - /// are substituted by special EraVM instructions. + /// In this mode PolkaVM extensions are enabled. For example, calls to addresses `0xFFFF` and below + /// are substituted by special PolkaVM instructions. /// In the Yul mode, the `verbatim_*` instruction family is available. #[structopt(long = "system-mode")] pub is_system_mode: bool, @@ -139,11 +139,11 @@ pub struct Arguments { #[structopt(long = "metadata-hash")] pub metadata_hash: Option, - /// Output EraVM assembly of the contracts. + /// Output PolkaVM assembly of the contracts. #[structopt(long = "asm")] pub output_assembly: bool, - /// Output EraVM bytecode of the contracts. + /// Output PolkaVM bytecode of the contracts. #[structopt(long = "bin")] pub output_binary: bool, @@ -207,66 +207,66 @@ impl Arguments { .filter(|&&x| x) .count(); if modes_count > 1 { - anyhow::bail!("Only one modes is allowed at the same time: Yul, LLVM IR, EraVM assembly, combined JSON, standard JSON."); + anyhow::bail!("Only one modes is allowed at the same time: Yul, LLVM IR, PolkaVM assembly, combined JSON, standard JSON."); } if self.yul || self.llvm_ir || self.zkasm { if self.base_path.is_some() { - anyhow::bail!("`base-path` is not used in Yul, LLVM IR and EraVM assembly modes."); + anyhow::bail!("`base-path` is not used in Yul, LLVM IR and PolkaVM assembly modes."); } if !self.include_paths.is_empty() { anyhow::bail!( - "`include-paths` is not used in Yul, LLVM IR and EraVM assembly modes." + "`include-paths` is not used in Yul, LLVM IR and PolkaVM assembly modes." ); } if self.allow_paths.is_some() { anyhow::bail!( - "`allow-paths` is not used in Yul, LLVM IR and EraVM assembly modes." + "`allow-paths` is not used in Yul, LLVM IR and PolkaVM assembly modes." ); } if !self.libraries.is_empty() { anyhow::bail!( - "Libraries are not supported in Yul, LLVM IR and EraVM assembly modes." + "Libraries are not supported in Yul, LLVM IR and PolkaVM assembly modes." ); } if self.evm_version.is_some() { anyhow::bail!( - "`evm-version` is not used in Yul, LLVM IR and EraVM assembly modes." + "`evm-version` is not used in Yul, LLVM IR and PolkaVM assembly modes." ); } if self.force_evmla { - anyhow::bail!("EVM legacy assembly mode is not supported in Yul, LLVM IR and EraVM assembly modes."); + anyhow::bail!("EVM legacy assembly mode is not supported in Yul, LLVM IR and PolkaVM assembly modes."); } if self.disable_solc_optimizer { - anyhow::bail!("Disabling the solc optimizer is not supported in Yul, LLVM IR and EraVM assembly modes."); + anyhow::bail!("Disabling the solc optimizer is not supported in Yul, LLVM IR and PolkaVM assembly modes."); } } if self.llvm_ir || self.zkasm { if self.solc.is_some() { - anyhow::bail!("`solc` is not used in LLVM IR and EraVM assembly modes."); + anyhow::bail!("`solc` is not used in LLVM IR and PolkaVM assembly modes."); } if self.is_system_mode { anyhow::bail!( - "System contract mode is not supported in LLVM IR and EraVM assembly modes." + "System contract mode is not supported in LLVM IR and PolkaVM assembly modes." ); } } if self.zkasm { if self.optimization.is_some() { - anyhow::bail!("LLVM optimizations are not supported in EraVM assembly mode."); + anyhow::bail!("LLVM optimizations are not supported in PolkaVM assembly mode."); } if self.fallback_to_optimizing_for_size { - anyhow::bail!("Falling back to -Oz is not supported in EraVM assembly mode."); + anyhow::bail!("Falling back to -Oz is not supported in PolkaVM assembly mode."); } if self.disable_system_request_memoization { - anyhow::bail!("Disabling the system request memoization is not supported in EraVM assembly mode."); + anyhow::bail!("Disabling the system request memoization is not supported in PolkaVM assembly mode."); } } diff --git a/crates/solidity/src/zksolc/main.rs b/crates/solidity/src/zksolc/main.rs index d1fa5a0..df199ea 100644 --- a/crates/solidity/src/zksolc/main.rs +++ b/crates/solidity/src/zksolc/main.rs @@ -1,4 +1,4 @@ -//! Solidity to EraVM compiler binary. +//! Solidity to PolkaVM compiler binary. pub mod arguments; @@ -96,8 +96,8 @@ fn main_inner() -> anyhow::Result<()> { let include_metadata_hash = match arguments.metadata_hash { Some(metadata_hash) => { let metadata = - revive_llvm_context::EraVMMetadataHash::from_str(metadata_hash.as_str())?; - metadata != revive_llvm_context::EraVMMetadataHash::None + revive_llvm_context::PolkaVMMetadataHash::from_str(metadata_hash.as_str())?; + metadata != revive_llvm_context::PolkaVMMetadataHash::None } None => true, }; diff --git a/crates/stdlib/src/lib.rs b/crates/stdlib/src/lib.rs index 997321d..dd886a2 100644 --- a/crates/stdlib/src/lib.rs +++ b/crates/stdlib/src/lib.rs @@ -1,7 +1,7 @@ //! This crate vendors EVM related standard library functionality and provides a LLVM module, //! exporting the standard library functions. //! The standard library code is inherited and adapted from [0]. -//! [0]: [https://github.com/matter-labs/era-compiler-llvm/blob/v1.4.1/llvm/lib/Target/EraVM/eravm-stdlib.ll] +//! [0]: [https://github.com/matter-labs/era-compiler-llvm/blob/v1.4.1/llvm/lib/Target/PolkaVM/polkavm-stdlib.ll] use inkwell::{context::Context, memory_buffer::MemoryBuffer, module::Module, support::LLVMString};