mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-09 20:01:05 +00:00
remove system mode and request memoization
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -1139,7 +1139,6 @@ where
|
||||
.integer_type(revive_common::BIT_LENGTH_BOOLEAN)
|
||||
.as_basic_type_enum()],
|
||||
output_size,
|
||||
false,
|
||||
);
|
||||
(r#type, output_size)
|
||||
}
|
||||
@@ -1156,7 +1155,6 @@ where
|
||||
input_size
|
||||
],
|
||||
output_size,
|
||||
false,
|
||||
);
|
||||
(r#type, output_size)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ pub fn yul(
|
||||
input_files: &[PathBuf],
|
||||
solc: &mut SolcCompiler,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
@@ -64,27 +63,17 @@ pub fn yul(
|
||||
),
|
||||
};
|
||||
|
||||
let solc_validator = if is_system_mode {
|
||||
None
|
||||
} else {
|
||||
if solc.version()?.default != SolcCompiler::LAST_SUPPORTED_VERSION {
|
||||
anyhow::bail!(
|
||||
if solc.version()?.default != SolcCompiler::LAST_SUPPORTED_VERSION {
|
||||
anyhow::bail!(
|
||||
"The Yul mode is only supported with the most recent version of the Solidity compiler: {}",
|
||||
SolcCompiler::LAST_SUPPORTED_VERSION,
|
||||
);
|
||||
}
|
||||
|
||||
Some(&*solc)
|
||||
};
|
||||
}
|
||||
|
||||
let solc_validator = Some(&*solc);
|
||||
let project = Project::try_from_yul_path(path, solc_validator)?;
|
||||
|
||||
let build = project.compile(
|
||||
optimizer_settings,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)?;
|
||||
let build = project.compile(optimizer_settings, include_metadata_hash, debug_config)?;
|
||||
|
||||
Ok(build)
|
||||
}
|
||||
@@ -93,7 +82,6 @@ pub fn yul(
|
||||
pub fn llvm_ir(
|
||||
input_files: &[PathBuf],
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
@@ -108,12 +96,7 @@ pub fn llvm_ir(
|
||||
|
||||
let project = Project::try_from_llvm_ir_path(path)?;
|
||||
|
||||
let build = project.compile(
|
||||
optimizer_settings,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)?;
|
||||
let build = project.compile(optimizer_settings, include_metadata_hash, debug_config)?;
|
||||
|
||||
Ok(build)
|
||||
}
|
||||
@@ -128,7 +111,6 @@ pub fn standard_output(
|
||||
solc_optimizer_enabled: bool,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
force_evmla: bool,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
base_path: Option<String>,
|
||||
include_paths: Vec<String>,
|
||||
@@ -152,7 +134,6 @@ pub fn standard_output(
|
||||
None,
|
||||
&solc_version.default,
|
||||
optimizer_settings.is_fallback_to_size_enabled(),
|
||||
optimizer_settings.is_system_request_memoization_disabled(),
|
||||
),
|
||||
None,
|
||||
solc_pipeline == SolcPipeline::Yul,
|
||||
@@ -198,12 +179,7 @@ pub fn standard_output(
|
||||
debug_config.as_ref(),
|
||||
)?;
|
||||
|
||||
let build = project.compile(
|
||||
optimizer_settings,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)?;
|
||||
let build = project.compile(optimizer_settings, include_metadata_hash, debug_config)?;
|
||||
|
||||
Ok(build)
|
||||
}
|
||||
@@ -214,7 +190,6 @@ pub fn standard_json(
|
||||
solc: &mut SolcCompiler,
|
||||
detect_missing_libraries: bool,
|
||||
force_evmla: bool,
|
||||
is_system_mode: bool,
|
||||
base_path: Option<String>,
|
||||
include_paths: Vec<String>,
|
||||
allow_paths: Option<String>,
|
||||
@@ -275,12 +250,7 @@ pub fn standard_json(
|
||||
&resolc_version,
|
||||
)?;
|
||||
} else {
|
||||
let build = project.compile(
|
||||
optimizer_settings,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)?;
|
||||
let build = project.compile(optimizer_settings, include_metadata_hash, debug_config)?;
|
||||
build.write_to_standard_json(&mut solc_output, &solc_version, &resolc_version)?;
|
||||
}
|
||||
serde_json::to_writer(std::io::stdout(), &solc_output)?;
|
||||
@@ -298,7 +268,6 @@ pub fn combined_json(
|
||||
solc_optimizer_enabled: bool,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
force_evmla: bool,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
base_path: Option<String>,
|
||||
include_paths: Vec<String>,
|
||||
@@ -319,7 +288,6 @@ pub fn combined_json(
|
||||
solc_optimizer_enabled,
|
||||
optimizer_settings,
|
||||
force_evmla,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
base_path,
|
||||
include_paths,
|
||||
|
||||
@@ -14,8 +14,6 @@ pub struct Input {
|
||||
pub contract: Contract,
|
||||
/// The project representation.
|
||||
pub project: Project,
|
||||
/// The system mode flag.
|
||||
pub is_system_mode: bool,
|
||||
/// Whether to append the metadata hash.
|
||||
pub include_metadata_hash: bool,
|
||||
/// The optimizer settings.
|
||||
@@ -29,7 +27,6 @@ impl Input {
|
||||
pub fn new(
|
||||
contract: Contract,
|
||||
project: Project,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
@@ -37,7 +34,6 @@ impl Input {
|
||||
Self {
|
||||
contract,
|
||||
project,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
optimizer_settings,
|
||||
debug_config,
|
||||
|
||||
@@ -43,7 +43,6 @@ pub fn run(input_file: Option<&mut std::fs::File>) -> anyhow::Result<()> {
|
||||
let result = input.contract.compile(
|
||||
input.project,
|
||||
input.optimizer_settings,
|
||||
input.is_system_mode,
|
||||
input.include_metadata_hash,
|
||||
input.debug_config,
|
||||
);
|
||||
|
||||
@@ -78,7 +78,6 @@ impl Contract {
|
||||
mut self,
|
||||
project: Project,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<ContractBuild> {
|
||||
@@ -127,8 +126,7 @@ impl Contract {
|
||||
context.set_solidity_data(revive_llvm_context::PolkaVMContextSolidityData::default());
|
||||
match self.ir {
|
||||
IR::Yul(_) => {
|
||||
let yul_data = revive_llvm_context::PolkaVMContextYulData::new(is_system_mode);
|
||||
context.set_yul_data(yul_data);
|
||||
context.set_yul_data(Default::default());
|
||||
}
|
||||
IR::EVMLA(_) => {
|
||||
let evmla_data = revive_llvm_context::PolkaVMContextEVMLAData::new(version.default);
|
||||
|
||||
@@ -62,7 +62,6 @@ impl Project {
|
||||
pub fn compile(
|
||||
self,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
@@ -74,7 +73,6 @@ impl Project {
|
||||
let process_output = crate::process::call(ProcessInput::new(
|
||||
contract,
|
||||
project.clone(),
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
optimizer_settings.clone(),
|
||||
debug_config.clone(),
|
||||
@@ -239,7 +237,6 @@ impl revive_llvm_context::PolkaVMDependency for Project {
|
||||
project: Self,
|
||||
identifier: &str,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<String> {
|
||||
@@ -259,7 +256,6 @@ impl revive_llvm_context::PolkaVMDependency for Project {
|
||||
.compile(
|
||||
project,
|
||||
optimizer_settings,
|
||||
is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)
|
||||
|
||||
@@ -62,10 +62,6 @@ pub struct Arguments {
|
||||
#[structopt(long = "fallback-Oz")]
|
||||
pub fallback_to_optimizing_for_size: bool,
|
||||
|
||||
/// Disable the system request memoization.
|
||||
#[structopt(long = "disable-system-request-memoization")]
|
||||
pub disable_system_request_memoization: bool,
|
||||
|
||||
/// Disable the `solc` optimizer.
|
||||
/// Use it if your project uses the `MSIZE` instruction, or in other cases.
|
||||
/// Beware that it will prevent libraries from being inlined.
|
||||
@@ -123,13 +119,6 @@ pub struct Arguments {
|
||||
#[structopt(long = "force-evmla")]
|
||||
pub force_evmla: bool,
|
||||
|
||||
/// Enable system contract compilation mode.
|
||||
/// 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,
|
||||
|
||||
/// Set metadata hash mode.
|
||||
/// The only supported value is `none` that disables appending the metadata hash.
|
||||
/// Is enabled by default.
|
||||
@@ -267,12 +256,6 @@ impl Arguments {
|
||||
if self.solc.is_some() {
|
||||
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 PolkaVM assembly modes."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if self.combined_json.is_some() {
|
||||
@@ -319,11 +302,6 @@ impl Arguments {
|
||||
"Falling back to -Oz must specified in standard JSON input settings."
|
||||
);
|
||||
}
|
||||
if self.disable_system_request_memoization {
|
||||
anyhow::bail!(
|
||||
"Disabling the system request memoization must specified in standard JSON input settings."
|
||||
);
|
||||
}
|
||||
if self.metadata_hash.is_some() {
|
||||
anyhow::bail!("Metadata hash mode must specified in standard JSON input settings.");
|
||||
}
|
||||
|
||||
@@ -101,9 +101,6 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
if arguments.fallback_to_optimizing_for_size {
|
||||
optimizer_settings.enable_fallback_to_size();
|
||||
}
|
||||
if arguments.disable_system_request_memoization {
|
||||
optimizer_settings.disable_system_request_memoization();
|
||||
}
|
||||
optimizer_settings.is_verify_each_enabled = arguments.llvm_verify_each;
|
||||
optimizer_settings.is_debug_logging_enabled = arguments.llvm_debug_logging;
|
||||
|
||||
@@ -121,7 +118,6 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
input_files.as_slice(),
|
||||
&mut solc,
|
||||
optimizer_settings,
|
||||
arguments.is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)
|
||||
@@ -129,7 +125,6 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
revive_solidity::llvm_ir(
|
||||
input_files.as_slice(),
|
||||
optimizer_settings,
|
||||
arguments.is_system_mode,
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
)
|
||||
@@ -138,7 +133,6 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
&mut solc,
|
||||
arguments.detect_missing_libraries,
|
||||
arguments.force_evmla,
|
||||
arguments.is_system_mode,
|
||||
arguments.base_path,
|
||||
arguments.include_paths,
|
||||
arguments.allow_paths,
|
||||
@@ -155,7 +149,6 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
!arguments.disable_solc_optimizer,
|
||||
optimizer_settings,
|
||||
arguments.force_evmla,
|
||||
arguments.is_system_mode,
|
||||
include_metadata_hash,
|
||||
arguments.base_path,
|
||||
arguments.include_paths,
|
||||
@@ -176,7 +169,6 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
!arguments.disable_solc_optimizer,
|
||||
optimizer_settings,
|
||||
arguments.force_evmla,
|
||||
arguments.is_system_mode,
|
||||
include_metadata_hash,
|
||||
arguments.base_path,
|
||||
arguments.include_paths,
|
||||
|
||||
@@ -22,9 +22,6 @@ pub struct Optimizer {
|
||||
/// Whether to try to recompile with -Oz if the bytecode is too large.
|
||||
#[serde(skip_serializing)]
|
||||
pub fallback_to_optimizing_for_size: Option<bool>,
|
||||
/// Whether to disable the system request memoization.
|
||||
#[serde(skip_serializing)]
|
||||
pub disable_system_request_memoization: Option<bool>,
|
||||
}
|
||||
|
||||
impl Optimizer {
|
||||
@@ -34,14 +31,12 @@ impl Optimizer {
|
||||
mode: Option<char>,
|
||||
version: &semver::Version,
|
||||
fallback_to_optimizing_for_size: bool,
|
||||
disable_system_request_memoization: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
enabled,
|
||||
mode,
|
||||
details: Some(Details::disabled(version)),
|
||||
fallback_to_optimizing_for_size: Some(fallback_to_optimizing_for_size),
|
||||
disable_system_request_memoization: Some(disable_system_request_memoization),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +61,6 @@ impl TryFrom<&Optimizer> for revive_llvm_context::OptimizerSettings {
|
||||
if value.fallback_to_optimizing_for_size.unwrap_or_default() {
|
||||
result.enable_fallback_to_size();
|
||||
}
|
||||
if value.disable_system_request_memoization.unwrap_or_default() {
|
||||
result.disable_system_request_memoization();
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ pub fn build_solidity_with_options(
|
||||
None,
|
||||
&solc_version.default,
|
||||
false,
|
||||
false,
|
||||
),
|
||||
None,
|
||||
pipeline == SolcPipeline::Yul,
|
||||
@@ -106,7 +105,7 @@ pub fn build_solidity_with_options(
|
||||
|
||||
let project = output.try_to_project(sources, libraries, pipeline, &solc_version, None)?;
|
||||
|
||||
let build: crate::Build = project.compile(optimizer_settings, false, false, None)?;
|
||||
let build: crate::Build = project.compile(optimizer_settings, false, None)?;
|
||||
build.write_to_standard_json(
|
||||
&mut output,
|
||||
&solc_version,
|
||||
@@ -144,7 +143,6 @@ pub fn build_solidity_with_options_evm(
|
||||
None,
|
||||
&solc_version.default,
|
||||
false,
|
||||
false,
|
||||
),
|
||||
None,
|
||||
pipeline == SolcPipeline::Yul,
|
||||
@@ -193,13 +191,7 @@ pub fn build_solidity_and_detect_missing_libraries(
|
||||
libraries.clone(),
|
||||
None,
|
||||
SolcStandardJsonInputSettingsSelection::new_required(pipeline),
|
||||
SolcStandardJsonInputSettingsOptimizer::new(
|
||||
true,
|
||||
None,
|
||||
&solc_version.default,
|
||||
false,
|
||||
false,
|
||||
),
|
||||
SolcStandardJsonInputSettingsOptimizer::new(true, None, &solc_version.default, false),
|
||||
None,
|
||||
pipeline == SolcPipeline::Yul,
|
||||
None,
|
||||
@@ -229,7 +221,7 @@ pub fn build_yul(source_code: &str) -> anyhow::Result<()> {
|
||||
|
||||
let project =
|
||||
Project::try_from_yul_string(PathBuf::from("test.yul").as_path(), source_code, None)?;
|
||||
let _build = project.compile(optimizer_settings, false, false, None)?;
|
||||
let _build = project.compile(optimizer_settings, false, None)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -259,13 +251,7 @@ pub fn check_solidity_warning(
|
||||
libraries,
|
||||
None,
|
||||
SolcStandardJsonInputSettingsSelection::new_required(pipeline),
|
||||
SolcStandardJsonInputSettingsOptimizer::new(
|
||||
true,
|
||||
None,
|
||||
&solc_version.default,
|
||||
false,
|
||||
false,
|
||||
),
|
||||
SolcStandardJsonInputSettingsOptimizer::new(true, None, &solc_version.default, false),
|
||||
None,
|
||||
pipeline == SolcPipeline::Yul,
|
||||
suppressed_warnings,
|
||||
|
||||
@@ -128,7 +128,7 @@ impl FunctionCall {
|
||||
Name::UserDefined(name)
|
||||
if name.starts_with(
|
||||
revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
|
||||
) && context.is_system_mode() =>
|
||||
) =>
|
||||
{
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
@@ -234,12 +234,7 @@ where
|
||||
})
|
||||
.collect();
|
||||
|
||||
let function_type = context.function_type(
|
||||
argument_types,
|
||||
self.result.len(),
|
||||
self.identifier
|
||||
.starts_with(revive_llvm_context::PolkaVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX),
|
||||
);
|
||||
let function_type = context.function_type(argument_types, self.result.len());
|
||||
|
||||
let function = context.add_function(
|
||||
self.identifier.as_str(),
|
||||
@@ -323,7 +318,6 @@ where
|
||||
context.current_function().borrow().r#return(),
|
||||
revive_llvm_context::PolkaVMFunctionReturn::Compound { .. }
|
||||
)
|
||||
&& context.is_system_mode()
|
||||
{
|
||||
index += 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user