mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 09:21:01 +00:00
@@ -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,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(())
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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![];
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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!(
|
||||
|
||||
@@ -72,10 +72,10 @@ impl Literal {
|
||||
/// Converts the literal into its LLVM.
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
self,
|
||||
context: &revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
) -> anyhow::Result<revive_llvm_context::EraVMArgument<'ctx>>
|
||||
context: &revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
) -> anyhow::Result<revive_llvm_context::PolkaVMArgument<'ctx>>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
match self.inner {
|
||||
LexicalLiteral::Boolean(inner) => {
|
||||
@@ -97,7 +97,7 @@ impl Literal {
|
||||
BooleanLiteral::True => num::BigUint::one(),
|
||||
};
|
||||
|
||||
Ok(revive_llvm_context::EraVMArgument::new_with_constant(
|
||||
Ok(revive_llvm_context::PolkaVMArgument::new_with_constant(
|
||||
value, constant,
|
||||
))
|
||||
}
|
||||
@@ -127,7 +127,7 @@ impl Literal {
|
||||
}
|
||||
.expect("Always valid");
|
||||
|
||||
Ok(revive_llvm_context::EraVMArgument::new_with_constant(
|
||||
Ok(revive_llvm_context::PolkaVMArgument::new_with_constant(
|
||||
value, constant,
|
||||
))
|
||||
}
|
||||
@@ -201,7 +201,7 @@ impl Literal {
|
||||
};
|
||||
|
||||
if hex_string.len() > revive_common::BYTE_LENGTH_FIELD * 2 {
|
||||
return Ok(revive_llvm_context::EraVMArgument::new_with_original(
|
||||
return Ok(revive_llvm_context::PolkaVMArgument::new_with_original(
|
||||
r#type.const_zero().as_basic_value_enum(),
|
||||
string,
|
||||
));
|
||||
@@ -221,7 +221,7 @@ impl Literal {
|
||||
)
|
||||
.expect("The value is valid")
|
||||
.as_basic_value_enum();
|
||||
Ok(revive_llvm_context::EraVMArgument::new_with_original(
|
||||
Ok(revive_llvm_context::PolkaVMArgument::new_with_original(
|
||||
value, string,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -96,10 +96,10 @@ impl Expression {
|
||||
/// Converts the expression into an LLVM value.
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
) -> anyhow::Result<Option<revive_llvm_context::EraVMArgument<'ctx>>>
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
) -> anyhow::Result<Option<revive_llvm_context::PolkaVMArgument<'ctx>>>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
match self {
|
||||
Self::Literal(literal) => literal
|
||||
@@ -137,7 +137,7 @@ impl Expression {
|
||||
|
||||
match constant {
|
||||
Some(constant) => Ok(Some(
|
||||
revive_llvm_context::EraVMArgument::new_with_constant(
|
||||
revive_llvm_context::PolkaVMArgument::new_with_constant(
|
||||
value, constant,
|
||||
),
|
||||
)),
|
||||
@@ -146,7 +146,7 @@ impl Expression {
|
||||
}
|
||||
Self::FunctionCall(call) => Ok(call
|
||||
.into_llvm(context)?
|
||||
.map(revive_llvm_context::EraVMArgument::new)),
|
||||
.map(revive_llvm_context::PolkaVMArgument::new)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ impl ForLoop {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for ForLoop
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for ForLoop
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.initializer.into_llvm(context)?;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pub struct FunctionDefinition {
|
||||
/// The function body block.
|
||||
pub body: Block,
|
||||
/// The function LLVM attributes encoded in the identifier.
|
||||
pub attributes: BTreeSet<revive_llvm_context::EraVMAttribute>,
|
||||
pub attributes: BTreeSet<revive_llvm_context::PolkaVMAttribute>,
|
||||
}
|
||||
|
||||
impl FunctionDefinition {
|
||||
@@ -95,7 +95,7 @@ impl FunctionDefinition {
|
||||
let (mut arguments, next) = Identifier::parse_typed_list(lexer, None)?;
|
||||
if identifier
|
||||
.inner
|
||||
.contains(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
|
||||
.contains(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
|
||||
{
|
||||
if arguments.is_empty() {
|
||||
return Err(ParserError::InvalidNumberOfArguments {
|
||||
@@ -110,7 +110,7 @@ impl FunctionDefinition {
|
||||
arguments.remove(0);
|
||||
}
|
||||
if identifier.inner.contains(
|
||||
revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER,
|
||||
revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER,
|
||||
) && !arguments.is_empty()
|
||||
{
|
||||
return Err(ParserError::InvalidNumberOfArguments {
|
||||
@@ -181,7 +181,7 @@ impl FunctionDefinition {
|
||||
/// Gets the list of LLVM attributes provided in the function name.
|
||||
pub fn get_llvm_attributes(
|
||||
identifier: &Identifier,
|
||||
) -> Result<BTreeSet<revive_llvm_context::EraVMAttribute>, Error> {
|
||||
) -> Result<BTreeSet<revive_llvm_context::PolkaVMAttribute>, Error> {
|
||||
let mut valid_attributes = BTreeSet::new();
|
||||
|
||||
let llvm_begin = identifier.inner.find(Self::LLVM_ATTRIBUTE_PREFIX);
|
||||
@@ -198,7 +198,7 @@ impl FunctionDefinition {
|
||||
|
||||
let mut invalid_attributes = BTreeSet::new();
|
||||
for value in attribute_string.split('_') {
|
||||
match revive_llvm_context::EraVMAttribute::try_from(value) {
|
||||
match revive_llvm_context::PolkaVMAttribute::try_from(value) {
|
||||
Ok(attribute) => valid_attributes.insert(attribute),
|
||||
Err(value) => invalid_attributes.insert(value),
|
||||
};
|
||||
@@ -216,13 +216,13 @@ impl FunctionDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for FunctionDefinition
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for FunctionDefinition
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn declare(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let argument_types: Vec<_> = self
|
||||
.arguments
|
||||
@@ -237,7 +237,7 @@ where
|
||||
argument_types,
|
||||
self.result.len(),
|
||||
self.identifier
|
||||
.starts_with(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX),
|
||||
.starts_with(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX),
|
||||
);
|
||||
|
||||
let function = context.add_function(
|
||||
@@ -246,7 +246,7 @@ where
|
||||
self.result.len(),
|
||||
Some(inkwell::module::Linkage::Private),
|
||||
)?;
|
||||
revive_llvm_context::EraVMFunction::set_attributes(
|
||||
revive_llvm_context::PolkaVMFunction::set_attributes(
|
||||
context.llvm(),
|
||||
function.borrow().declaration(),
|
||||
self.attributes.clone().into_iter().collect(),
|
||||
@@ -254,22 +254,22 @@ where
|
||||
);
|
||||
function
|
||||
.borrow_mut()
|
||||
.set_yul_data(revive_llvm_context::EraVMFunctionYulData::default());
|
||||
.set_yul_data(revive_llvm_context::PolkaVMFunctionYulData::default());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn into_llvm(
|
||||
mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
context.set_current_function(self.identifier.as_str())?;
|
||||
let r#return = context.current_function().borrow().r#return();
|
||||
|
||||
context.set_basic_block(context.current_function().borrow().entry_block());
|
||||
match r#return {
|
||||
revive_llvm_context::EraVMFunctionReturn::None => {}
|
||||
revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::None => {}
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => {
|
||||
let identifier = self.result.pop().expect("Always exists");
|
||||
let r#type = identifier.r#type.unwrap_or_default();
|
||||
context.build_store(pointer, r#type.into_llvm(context).const_zero())?;
|
||||
@@ -278,7 +278,7 @@ where
|
||||
.borrow_mut()
|
||||
.insert_stack_pointer(identifier.inner, pointer);
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => {
|
||||
for (index, identifier) in self.result.into_iter().enumerate() {
|
||||
let r#type = identifier.r#type.unwrap_or_default().into_llvm(context);
|
||||
let pointer = context.build_gep(
|
||||
@@ -317,10 +317,10 @@ where
|
||||
.insert_stack_pointer(argument.inner.clone(), pointer);
|
||||
if self
|
||||
.identifier
|
||||
.starts_with(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
|
||||
.starts_with(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
|
||||
&& matches!(
|
||||
context.current_function().borrow().r#return(),
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound { .. }
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { .. }
|
||||
)
|
||||
&& context.is_system_mode()
|
||||
{
|
||||
@@ -346,21 +346,21 @@ where
|
||||
|
||||
context.set_basic_block(context.current_function().borrow().return_block());
|
||||
match context.current_function().borrow().r#return() {
|
||||
revive_llvm_context::EraVMFunctionReturn::None => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::None => {
|
||||
context.build_return(None);
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Primitive { pointer } => {
|
||||
let return_value = context.build_load(pointer, "return_value")?;
|
||||
context.build_return(Some(&return_value));
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. }
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. }
|
||||
if context.current_function().borrow().name().starts_with(
|
||||
revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
|
||||
revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
|
||||
) =>
|
||||
{
|
||||
context.build_return(Some(&pointer.value));
|
||||
}
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { pointer, .. } => {
|
||||
let return_value = context.build_load(pointer, "return_value")?;
|
||||
context.build_return(Some(&return_value));
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ impl IfConditional {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for IfConditional
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for IfConditional
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let condition = self
|
||||
.condition
|
||||
|
||||
@@ -175,35 +175,35 @@ impl Object {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Object
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for Object
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn declare(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<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)?;
|
||||
|
||||
for name in [
|
||||
revive_llvm_context::EraVMRuntime::FUNCTION_DEPLOY_CODE,
|
||||
revive_llvm_context::EraVMRuntime::FUNCTION_RUNTIME_CODE,
|
||||
revive_llvm_context::EraVMRuntime::FUNCTION_ENTRY,
|
||||
revive_llvm_context::PolkaVMRuntime::FUNCTION_DEPLOY_CODE,
|
||||
revive_llvm_context::PolkaVMRuntime::FUNCTION_RUNTIME_CODE,
|
||||
revive_llvm_context::PolkaVMRuntime::FUNCTION_ENTRY,
|
||||
]
|
||||
.into_iter()
|
||||
{
|
||||
@@ -211,7 +211,7 @@ where
|
||||
.get_function(name)
|
||||
.expect("Always exists")
|
||||
.borrow_mut()
|
||||
.set_yul_data(revive_llvm_context::EraVMFunctionYulData::default());
|
||||
.set_yul_data(revive_llvm_context::PolkaVMFunctionYulData::default());
|
||||
}
|
||||
|
||||
entry.into_llvm(context)?;
|
||||
@@ -221,13 +221,13 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
if self.identifier.ends_with("_deployed") {
|
||||
revive_llvm_context::EraVMRuntimeCodeFunction::new(self.code)
|
||||
revive_llvm_context::PolkaVMRuntimeCodeFunction::new(self.code)
|
||||
.into_llvm(context)?;
|
||||
} else {
|
||||
revive_llvm_context::EraVMDeployCodeFunction::new(self.code)
|
||||
revive_llvm_context::PolkaVMDeployCodeFunction::new(self.code)
|
||||
.into_llvm(context)?;
|
||||
}
|
||||
|
||||
@@ -236,8 +236,8 @@ where
|
||||
object.into_llvm(context)?;
|
||||
}
|
||||
None => {
|
||||
let runtime = revive_llvm_context::EraVMRuntime::new(
|
||||
revive_llvm_context::EraVMAddressSpace::Heap,
|
||||
let runtime = revive_llvm_context::PolkaVMRuntime::new(
|
||||
revive_llvm_context::PolkaVMAddressSpace::Heap,
|
||||
);
|
||||
runtime.into_llvm(context)?;
|
||||
}
|
||||
|
||||
@@ -118,13 +118,13 @@ impl Switch {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Switch
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for Switch
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let scrutinee = self.expression.into_llvm(context)?;
|
||||
|
||||
|
||||
@@ -91,13 +91,13 @@ impl VariableDeclaration {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for VariableDeclaration
|
||||
impl<D> revive_llvm_context::PolkaVMWriteLLVM<D> for VariableDeclaration
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
fn into_llvm<'ctx>(
|
||||
mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
) -> anyhow::Result<()> {
|
||||
if self.bindings.len() == 1 {
|
||||
let identifier = self.bindings.remove(0);
|
||||
|
||||
@@ -64,10 +64,10 @@ impl Type {
|
||||
/// Converts the type into its LLVM.
|
||||
pub fn into_llvm<'ctx, D>(
|
||||
self,
|
||||
context: &revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &revive_llvm_context::PolkaVMContext<'ctx, D>,
|
||||
) -> inkwell::types::IntType<'ctx>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::PolkaVMDependency + Clone,
|
||||
{
|
||||
match self {
|
||||
Self::Bool => context.integer_type(revive_common::BIT_LENGTH_BOOLEAN),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Solidity to EraVM compiler arguments.
|
||||
//! Solidity to PolkaVM compiler arguments.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::Path;
|
||||
@@ -13,7 +13,7 @@ use structopt::StructOpt;
|
||||
/// output directory.
|
||||
/// Example: zksolc ERC20.sol -O3 --bin --output-dir './build/'
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "The EraVM Solidity compiler")]
|
||||
#[structopt(name = "The PolkaVM Solidity compiler")]
|
||||
pub struct Arguments {
|
||||
/// Print the version and exit.
|
||||
#[structopt(long = "version")]
|
||||
@@ -22,7 +22,7 @@ pub struct Arguments {
|
||||
/// Specify the input paths and remappings.
|
||||
/// If an argument contains a '=', it is considered a remapping.
|
||||
/// Multiple Solidity files can be passed in the default Solidity mode.
|
||||
/// Yul, LLVM IR, and EraVM Assembly modes currently support only a single file.
|
||||
/// Yul, LLVM IR, and PolkaVM Assembly modes currently support only a single file.
|
||||
pub inputs: Vec<String>,
|
||||
|
||||
/// Set the given path as the root of the source tree instead of the root of the filesystem.
|
||||
@@ -113,10 +113,10 @@ pub struct Arguments {
|
||||
#[structopt(long = "llvm-ir")]
|
||||
pub llvm_ir: bool,
|
||||
|
||||
/// Switch to EraVM assembly mode.
|
||||
/// Only one input EraVM assembly file is allowed.
|
||||
/// Switch to PolkaVM assembly mode.
|
||||
/// Only one input PolkaVM assembly file is allowed.
|
||||
/// Cannot be used with combined and standard JSON modes.
|
||||
/// Use this mode at your own risk, as EraVM assembly input validation is not implemented.
|
||||
/// Use this mode at your own risk, as PolkaVM assembly input validation is not implemented.
|
||||
#[structopt(long = "zkasm")]
|
||||
pub zkasm: bool,
|
||||
|
||||
@@ -127,8 +127,8 @@ pub struct Arguments {
|
||||
pub force_evmla: bool,
|
||||
|
||||
/// Enable system contract compilation mode.
|
||||
/// In this mode EraVM extensions are enabled. For example, calls to addresses `0xFFFF` and below
|
||||
/// are substituted by special EraVM instructions.
|
||||
/// In this mode PolkaVM extensions are enabled. For example, calls to addresses `0xFFFF` and below
|
||||
/// are substituted by special PolkaVM instructions.
|
||||
/// In the Yul mode, the `verbatim_*` instruction family is available.
|
||||
#[structopt(long = "system-mode")]
|
||||
pub is_system_mode: bool,
|
||||
@@ -139,11 +139,11 @@ pub struct Arguments {
|
||||
#[structopt(long = "metadata-hash")]
|
||||
pub metadata_hash: Option<String>,
|
||||
|
||||
/// Output EraVM assembly of the contracts.
|
||||
/// Output PolkaVM assembly of the contracts.
|
||||
#[structopt(long = "asm")]
|
||||
pub output_assembly: bool,
|
||||
|
||||
/// Output EraVM bytecode of the contracts.
|
||||
/// Output PolkaVM bytecode of the contracts.
|
||||
#[structopt(long = "bin")]
|
||||
pub output_binary: bool,
|
||||
|
||||
@@ -207,66 +207,66 @@ impl Arguments {
|
||||
.filter(|&&x| x)
|
||||
.count();
|
||||
if modes_count > 1 {
|
||||
anyhow::bail!("Only one modes is allowed at the same time: Yul, LLVM IR, EraVM assembly, combined JSON, standard JSON.");
|
||||
anyhow::bail!("Only one modes is allowed at the same time: Yul, LLVM IR, PolkaVM assembly, combined JSON, standard JSON.");
|
||||
}
|
||||
|
||||
if self.yul || self.llvm_ir || self.zkasm {
|
||||
if self.base_path.is_some() {
|
||||
anyhow::bail!("`base-path` is not used in Yul, LLVM IR and EraVM assembly modes.");
|
||||
anyhow::bail!("`base-path` is not used in Yul, LLVM IR and PolkaVM assembly modes.");
|
||||
}
|
||||
if !self.include_paths.is_empty() {
|
||||
anyhow::bail!(
|
||||
"`include-paths` is not used in Yul, LLVM IR and EraVM assembly modes."
|
||||
"`include-paths` is not used in Yul, LLVM IR and PolkaVM assembly modes."
|
||||
);
|
||||
}
|
||||
if self.allow_paths.is_some() {
|
||||
anyhow::bail!(
|
||||
"`allow-paths` is not used in Yul, LLVM IR and EraVM assembly modes."
|
||||
"`allow-paths` is not used in Yul, LLVM IR and PolkaVM assembly modes."
|
||||
);
|
||||
}
|
||||
if !self.libraries.is_empty() {
|
||||
anyhow::bail!(
|
||||
"Libraries are not supported in Yul, LLVM IR and EraVM assembly modes."
|
||||
"Libraries are not supported in Yul, LLVM IR and PolkaVM assembly modes."
|
||||
);
|
||||
}
|
||||
|
||||
if self.evm_version.is_some() {
|
||||
anyhow::bail!(
|
||||
"`evm-version` is not used in Yul, LLVM IR and EraVM assembly modes."
|
||||
"`evm-version` is not used in Yul, LLVM IR and PolkaVM assembly modes."
|
||||
);
|
||||
}
|
||||
|
||||
if self.force_evmla {
|
||||
anyhow::bail!("EVM legacy assembly mode is not supported in Yul, LLVM IR and EraVM assembly modes.");
|
||||
anyhow::bail!("EVM legacy assembly mode is not supported in Yul, LLVM IR and PolkaVM assembly modes.");
|
||||
}
|
||||
|
||||
if self.disable_solc_optimizer {
|
||||
anyhow::bail!("Disabling the solc optimizer is not supported in Yul, LLVM IR and EraVM assembly modes.");
|
||||
anyhow::bail!("Disabling the solc optimizer is not supported in Yul, LLVM IR and PolkaVM assembly modes.");
|
||||
}
|
||||
}
|
||||
|
||||
if self.llvm_ir || self.zkasm {
|
||||
if self.solc.is_some() {
|
||||
anyhow::bail!("`solc` is not used in LLVM IR and EraVM assembly modes.");
|
||||
anyhow::bail!("`solc` is not used in LLVM IR and PolkaVM assembly modes.");
|
||||
}
|
||||
|
||||
if self.is_system_mode {
|
||||
anyhow::bail!(
|
||||
"System contract mode is not supported in LLVM IR and EraVM assembly modes."
|
||||
"System contract mode is not supported in LLVM IR and PolkaVM assembly modes."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if self.zkasm {
|
||||
if self.optimization.is_some() {
|
||||
anyhow::bail!("LLVM optimizations are not supported in EraVM assembly mode.");
|
||||
anyhow::bail!("LLVM optimizations are not supported in PolkaVM assembly mode.");
|
||||
}
|
||||
|
||||
if self.fallback_to_optimizing_for_size {
|
||||
anyhow::bail!("Falling back to -Oz is not supported in EraVM assembly mode.");
|
||||
anyhow::bail!("Falling back to -Oz is not supported in PolkaVM assembly mode.");
|
||||
}
|
||||
if self.disable_system_request_memoization {
|
||||
anyhow::bail!("Disabling the system request memoization is not supported in EraVM assembly mode.");
|
||||
anyhow::bail!("Disabling the system request memoization is not supported in PolkaVM assembly mode.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Solidity to EraVM compiler binary.
|
||||
//! Solidity to PolkaVM compiler binary.
|
||||
|
||||
pub mod arguments;
|
||||
|
||||
@@ -96,8 +96,8 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
let include_metadata_hash = match arguments.metadata_hash {
|
||||
Some(metadata_hash) => {
|
||||
let metadata =
|
||||
revive_llvm_context::EraVMMetadataHash::from_str(metadata_hash.as_str())?;
|
||||
metadata != revive_llvm_context::EraVMMetadataHash::None
|
||||
revive_llvm_context::PolkaVMMetadataHash::from_str(metadata_hash.as_str())?;
|
||||
metadata != revive_llvm_context::PolkaVMMetadataHash::None
|
||||
}
|
||||
None => true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user