mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 17:18:01 +00:00
expose custom PVM settings in the standard json interface (#318)
Exposes the following PolkaVM specific options via the standard json interface: - Heap size - Stack size - Whether to emit source level debug information Additionally it is now forbidden to specify those as CLI option in standard JSON mode. They are bytecode altering options and having multiple ways to specify them creates unnecessary room for confusion: The standard JSON input description should be sufficient and succint for reproducible builds. Closes #290 --------- Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
@@ -8,6 +8,8 @@ pub use self::standard_json::input::language::Language as SolcStandardJsonInputL
|
||||
pub use self::standard_json::input::settings::metadata::Metadata as SolcStandardJsonInputSettingsMetadata;
|
||||
pub use self::standard_json::input::settings::metadata_hash::MetadataHash as SolcStandardJsonInputSettingsMetadataHash;
|
||||
pub use self::standard_json::input::settings::optimizer::Optimizer as SolcStandardJsonInputSettingsOptimizer;
|
||||
pub use self::standard_json::input::settings::polkavm::memory::MemoryConfig as SolcStandardJsonInputSettingsPolkaVMMemory;
|
||||
pub use self::standard_json::input::settings::polkavm::PolkaVM as SolcStandardJsonInputSettingsPolkaVM;
|
||||
pub use self::standard_json::input::settings::selection::file::flag::Flag as SolcStandardJsonInputSettingsSelectionFileFlag;
|
||||
pub use self::standard_json::input::settings::selection::file::File as SolcStandardJsonInputSettingsSelectionFile;
|
||||
pub use self::standard_json::input::settings::selection::Selection as SolcStandardJsonInputSettingsSelection;
|
||||
|
||||
@@ -18,6 +18,7 @@ use crate::standard_json::input::settings::optimizer::Optimizer as SolcStandardJ
|
||||
use crate::standard_json::input::settings::selection::Selection as SolcStandardJsonInputSettingsSelection;
|
||||
#[cfg(feature = "resolc")]
|
||||
use crate::warning::Warning;
|
||||
use crate::SolcStandardJsonInputSettingsPolkaVM;
|
||||
|
||||
use self::language::Language;
|
||||
use self::settings::Settings;
|
||||
@@ -63,6 +64,7 @@ impl Input {
|
||||
optimizer: SolcStandardJsonInputSettingsOptimizer,
|
||||
metadata: Option<SolcStandardJsonInputSettingsMetadata>,
|
||||
#[cfg(feature = "resolc")] suppressed_warnings: Option<Vec<Warning>>,
|
||||
polkavm: Option<SolcStandardJsonInputSettingsPolkaVM>,
|
||||
) -> anyhow::Result<Self> {
|
||||
let mut paths: BTreeSet<PathBuf> = paths.iter().cloned().collect();
|
||||
let libraries = Settings::parse_libraries(library_map)?;
|
||||
@@ -90,6 +92,7 @@ impl Input {
|
||||
output_selection,
|
||||
optimizer,
|
||||
metadata,
|
||||
polkavm,
|
||||
),
|
||||
#[cfg(feature = "resolc")]
|
||||
suppressed_warnings,
|
||||
@@ -109,6 +112,7 @@ impl Input {
|
||||
optimizer: SolcStandardJsonInputSettingsOptimizer,
|
||||
metadata: Option<SolcStandardJsonInputSettingsMetadata>,
|
||||
suppressed_warnings: Option<Vec<Warning>>,
|
||||
polkavm: Option<SolcStandardJsonInputSettingsPolkaVM>,
|
||||
) -> anyhow::Result<Self> {
|
||||
#[cfg(feature = "parallel")]
|
||||
let iter = sources.into_par_iter(); // Parallel iterator
|
||||
@@ -129,6 +133,7 @@ impl Input {
|
||||
output_selection,
|
||||
optimizer,
|
||||
metadata,
|
||||
polkavm,
|
||||
),
|
||||
suppressed_warnings,
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
pub mod metadata;
|
||||
pub mod metadata_hash;
|
||||
pub mod optimizer;
|
||||
pub mod polkavm;
|
||||
pub mod selection;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
@@ -13,6 +14,7 @@ use serde::Serialize;
|
||||
|
||||
use self::metadata::Metadata;
|
||||
use self::optimizer::Optimizer;
|
||||
use self::polkavm::PolkaVM;
|
||||
use self::selection::Selection;
|
||||
|
||||
/// The `solc --standard-json` input settings.
|
||||
@@ -43,6 +45,9 @@ pub struct Settings {
|
||||
/// The metadata settings.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub metadata: Option<Metadata>,
|
||||
/// The resolc custom PolkaVM settings.
|
||||
#[serde(skip_serializing)]
|
||||
pub polkavm: Option<PolkaVM>,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@@ -54,6 +59,7 @@ impl Settings {
|
||||
output_selection: Selection,
|
||||
optimizer: Optimizer,
|
||||
metadata: Option<Metadata>,
|
||||
polkavm: Option<PolkaVM>,
|
||||
) -> Self {
|
||||
Self {
|
||||
evm_version,
|
||||
@@ -63,6 +69,7 @@ impl Settings {
|
||||
optimizer,
|
||||
metadata,
|
||||
via_ir: Some(true),
|
||||
polkavm,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//! The compile time PolkaVM memory configuration settings.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The PolkaVM memory configuration.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct MemoryConfig {
|
||||
/// The emulated EVM linear heap memory size in bytes.
|
||||
pub heap_size: u32,
|
||||
/// The PVM stack size in bytes.
|
||||
pub stack_size: u32,
|
||||
}
|
||||
|
||||
impl Default for MemoryConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
heap_size: 64 * 1024,
|
||||
stack_size: 32 * 1024,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//! The `resolc --standard-json` polkavm settings.
|
||||
//!
|
||||
//! Used for options specific to PolkaVM which therefor don't exist in solc.
|
||||
|
||||
use memory::MemoryConfig;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod memory;
|
||||
|
||||
/// PVM specific compiler settings.
|
||||
#[derive(Clone, Copy, Default, Debug, Serialize, Deserialize)]
|
||||
pub struct PolkaVM {
|
||||
/// The PolkaVM target machine memory configuration settings.
|
||||
pub memory_config: MemoryConfig,
|
||||
/// Instruct LLVM to emit debug information.
|
||||
pub debug_information: bool,
|
||||
}
|
||||
|
||||
impl PolkaVM {
|
||||
pub fn new(memory_config: Option<MemoryConfig>, debug_information: bool) -> Self {
|
||||
Self {
|
||||
memory_config: memory_config.unwrap_or_default(),
|
||||
debug_information,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user