mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 08:11:02 +00:00
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
+3
-3
@@ -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
-1
@@ -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
-1
@@ -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
-2
@@ -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
-2
@@ -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.
|
||||
+6
-6
@@ -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(
|
||||
+2
-2
@@ -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
-1
@@ -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)]
|
||||
+10
-10
@@ -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());
|
||||
+8
-8
@@ -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;
|
||||
+14
-14
@@ -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());
|
||||
|
||||
+21
-21
@@ -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,
|
||||
);
|
||||
|
||||
+5
-5
@@ -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;
|
||||
+5
-5
@@ -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.
|
||||
+4
-4
@@ -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>,
|
||||
{
|
||||
+6
-6
@@ -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.
|
||||
+4
-4
@@ -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)]
|
||||
+4
-4
@@ -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
-2
@@ -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
-2
@@ -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>(
|
||||
+4
-4
@@ -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
|
||||
+7
-7
@@ -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
-2
@@ -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.
|
||||
+3
-3
@@ -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(
|
||||
+9
-9
@@ -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))
|
||||
}
|
||||
+2
-2
@@ -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>(
|
||||
+6
-3
@@ -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(
|
||||
+6
-6
@@ -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);
|
||||
*/
|
||||
+2
-2
@@ -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>(
|
||||
+7
-7
@@ -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
-2
@@ -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>(
|
||||
+4
-4
@@ -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.
|
||||
+9
-9
@@ -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),
|
||||
+7
-7
@@ -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")?;
|
||||
+4
-4
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user