rename target to polkavm

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-05-02 08:47:44 +02:00
parent 9fc24af355
commit 336fc63f1d
112 changed files with 876 additions and 873 deletions
-115
View File
@@ -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;
-5
View File
@@ -1,5 +0,0 @@
//!
//! The EraVM constants.
//!
pub mod address;
+4 -4
View File
@@ -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";
+2 -2
View File
@@ -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::*;
+115
View File
@@ -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;
+5
View File
@@ -0,0 +1,5 @@
//!
//! The PolkaVM constants.
//!
pub mod address;
+4 -4
View File
@@ -1,7 +1,7 @@
{
"Computation": 7380,
"Baseline": 3912,
"Flipper": 4354,
"Fibonacci": 5971,
"ERC20": 53186
"Baseline": 3912,
"ERC20": 53186,
"Flipper": 4354,
"Computation": 7380
}
+1 -1
View File
@@ -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
@@ -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,
}
}
}
+55 -55
View File
@@ -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(),
}
}
@@ -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
@@ -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<u8>,
/// 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<String, String>,
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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(
@@ -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;
@@ -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)]
@@ -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());
@@ -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;
@@ -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());
@@ -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,
);
@@ -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;
@@ -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.
@@ -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>,
{
@@ -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.
@@ -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)]
@@ -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<DummyDependency> {
crate::eravm::initialize_target();
crate::polkavm::initialize_target();
let module = llvm.create_module("test");
let optimizer = Optimizer::new(optimizer_settings);
@@ -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>(
@@ -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>(
@@ -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
@@ -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(
@@ -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.
@@ -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(
@@ -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))
}
@@ -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>(
@@ -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(
@@ -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);
*/
@@ -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>(
@@ -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",
@@ -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>(
@@ -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.
@@ -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<D>(context: &mut Context<D>) -> 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),
@@ -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")?;
@@ -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>(
@@ -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,
@@ -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>>,
) -> [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")
}
@@ -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,
}
+1 -1
View File
@@ -7,7 +7,7 @@ authors = [
]
license = "MIT OR Apache-2.0"
edition = "2021"
description = "EraVM Solidity compiler"
description = "PolkaVM Solidity frontend"
[[bin]]
name = "zksolc"
+4 -4
View File
@@ -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<String>,
) -> 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);
+1 -1
View File
@@ -1,4 +1,4 @@
//! Solidity to EraVM compiler constants.
//! Solidity to PolkaVM compiler constants.
#![allow(dead_code)]
@@ -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<D>(
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
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,
@@ -2,17 +2,17 @@
/// Translates the unconditional jump.
pub fn unconditional<D>(
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
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<D>(
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
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(
@@ -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 {
@@ -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)]
@@ -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<inkwell::values::BasicValueEnum<'ctx>>
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<inkwell::values::BasicValueEnum<'ctx>>
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<String>,
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
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<D>(
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
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<D>(_context: &mut revive_llvm_context::EraVMContext<D>) -> anyhow::Result<()>
pub fn pop<D>(_context: &mut revive_llvm_context::PolkaVMContext<D>) -> anyhow::Result<()>
where
D: revive_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::PolkaVMDependency + Clone,
{
Ok(())
}
+18 -18
View File
@@ -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<D> revive_llvm_context::EraVMWriteLLVM<D> for Assembly
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> 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)?;
@@ -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<D> revive_llvm_context::EraVMWriteLLVM<D> for EntryLink
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> 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),
};
@@ -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<inkwell::values::BasicValueEnum<'ctx>>
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<D> revive_llvm_context::EraVMWriteLLVM<D> for Element
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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;
@@ -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<usize>,
/// The block elements relevant to the stack consistency.
pub elements: Vec<Element>,
/// 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<D> revive_llvm_context::EraVMWriteLLVM<D> for Block
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
context.set_code_type(self.key.code_type);
@@ -43,7 +43,7 @@ pub struct Function {
/// The function name.
pub name: String,
/// The separately labelled blocks.
pub blocks: BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Vec<Block>>,
pub blocks: BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Vec<Block>>,
/// 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<revive_llvm_context::EraVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
extra_metadata: &ExtraMetadata,
visited_functions: &mut BTreeSet<VisitedElement>,
) -> 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<revive_llvm_context::EraVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
extra_metadata: &ExtraMetadata,
visited_functions: &mut BTreeSet<VisitedElement>,
visited_blocks: &mut BTreeSet<VisitedElement>,
@@ -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<revive_llvm_context::EraVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
extra_metadata: &ExtraMetadata,
visited_functions: &mut BTreeSet<VisitedElement>,
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<revive_llvm_context::EraVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
functions: &mut BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Self>,
extra_metadata: &ExtraMetadata,
visited_functions: &mut BTreeSet<VisitedElement>,
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<Element>,
)> {
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<revive_llvm_context::EraVMFunctionBlockKey, Block>,
blocks: &HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
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<D> revive_llvm_context::EraVMWriteLLVM<D> for Function
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> 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));
}
@@ -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 {
@@ -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 {
@@ -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 {
+9 -9
View File
@@ -31,7 +31,7 @@ pub struct EtherealIR {
/// The all-inlined function.
pub entry_function: Function,
/// The recursive functions.
pub recursive_functions: BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Function>,
pub recursive_functions: BTreeMap<revive_llvm_context::PolkaVMFunctionBlockKey, Function>,
}
impl EtherealIR {
@@ -45,7 +45,7 @@ impl EtherealIR {
pub fn new(
solc_version: semver::Version,
extra_metadata: ExtraMetadata,
blocks: HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
blocks: HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>,
) -> anyhow::Result<Self> {
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<HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>> {
) -> anyhow::Result<HashMap<revive_llvm_context::PolkaVMFunctionBlockKey, Block>> {
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<D> revive_llvm_context::EraVMWriteLLVM<D> for EtherealIR
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.entry_function.declare(context)?;
@@ -113,7 +113,7 @@ where
fn into_llvm(
self,
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
context.evmla_mut().stack = vec![];
+4 -4
View File
@@ -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,
};
@@ -30,20 +30,20 @@ impl EVMLA {
}
}
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for EVMLA
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.assembly.declare(context)
}
fn into_llvm(
self,
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.assembly.into_llvm(context)
}
@@ -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<D> revive_llvm_context::EraVMWriteLLVM<D> for IR
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
match self {
Self::Yul(inner) => inner.into_llvm(context),
@@ -31,20 +31,20 @@ impl Yul {
}
}
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Yul
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.object.declare(context)
}
fn into_llvm(
self,
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.object.into_llvm(context)
}
@@ -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,
}
@@ -12,9 +12,9 @@ pub struct Metadata {
pub solc_version: semver::Version,
/// The zkVM `solc` edition.
pub solc_zkvm_edition: Option<semver::Version>,
/// 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,
}
+10 -10
View File
@@ -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<D> EraVMWriteLLVM<D> for Contract
impl<D> PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.ir.declare(context)
}
fn into_llvm(
self,
context: &mut revive_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.ir.into_llvm(context)
}
+5 -5
View File
@@ -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<Self> {
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,
@@ -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<revive_llvm_context::EraVMMetadataHash>,
pub bytecode_hash: Option<revive_llvm_context::PolkaVMMetadataHash>,
}
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),
}
@@ -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);
@@ -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<Assembly>,
/// The contract EraVM assembly code.
/// The contract PolkaVM assembly code.
#[serde(rename = "assembly")]
pub assembly_text: Option<String>,
/// 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<Bytecode>,
/// The contract deployed bytecode.
pub deployed_bytecode: Option<DeployedBytecode>,
@@ -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));
@@ -35,7 +35,7 @@ pub struct Contract {
/// The contract optimized IR code.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub ir_optimized: Option<String>,
/// The contract EraVM bytecode hash.
/// The contract PolkaVM bytecode hash.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub hash: Option<String>,
/// The contract factory dependencies.
@@ -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);
}
}
@@ -107,13 +107,13 @@ impl Assignment {
}
}
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Assignment
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
let value = match self.initializer.into_llvm(context)? {
Some(value) => value,
@@ -128,13 +128,13 @@ impl Block {
}
}
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Block
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
let current_function = context.current_function().borrow().name().to_owned();
let current_block = context.basic_block();
@@ -55,13 +55,13 @@ impl Code {
}
}
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Code
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> 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<D>,
context: &mut revive_llvm_context::PolkaVMContext<D>,
) -> anyhow::Result<()> {
self.block.into_llvm(context)?;
@@ -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<Option<inkwell::values::BasicValueEnum<'ctx>>>
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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 1>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 1>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 3>(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::<D, 3>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 1>(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::<D, 2>(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::<D, 2>(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::<D, 3>(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::<D, 1>(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::<D, 2>(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::<D, 3>(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::<D, 3>(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::<D, 1>(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::<D, 1>(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::<D, 2>(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::<D, 2>(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::<D, 2>(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::<D, 3>(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::<D, 4>(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::<D, 5>(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::<D, 6>(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::<D, 1>(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::<D, 1>(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() {
@@ -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<Option<inkwell::values::BasicValueEnum<'ctx>>>
where
D: revive_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::PolkaVMDependency + Clone,
{
if output_size > 1 {
anyhow::bail!(

Some files were not shown because too many files have changed in this diff Show More