mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 03:41:02 +00:00
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user