Skip to content

Commit 80557b4

Browse files
committed
fix: the extra_metadata serialization
1 parent 49d5c16 commit 80557b4

File tree

28 files changed

+204
-179
lines changed

28 files changed

+204
-179
lines changed

CHANGELOG.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
### Fixed
3838

39-
- The compilation pipeline that was not run without output parameters
39+
- Skipped compilation if no output parameters are provided
4040
- Broken `--output-dir` output paths for non-Solidity contracts
4141
- `solc` that was not picked up from `${PATH}` in standard JSON mode
4242
- `solc` exit code check which is now before the output parsing
@@ -337,7 +337,7 @@
337337

338338
### Changed
339339

340-
- Internal function pointers now trigger a compile-time error with the EVMLA pipeline
340+
- Internal function pointers now trigger a compile-time error with the EVMLA codegen
341341
- Calldata instructions now return 0 in deploy code
342342

343343
### Removed
@@ -356,7 +356,7 @@
356356

357357
### Added
358358

359-
- Better errors for unsupported `type(X).runtimeCode` with the Yul pipeline
359+
- Better errors for unsupported `type(X).runtimeCode` with the Yul codegen
360360
- An option to disable the `solc` optimizer
361361

362362
### Changed
@@ -366,9 +366,9 @@
366366

367367
### Fixed
368368

369-
- Another stack overflow issue with the EVMLA pipeline
370-
- `CODECOPY` in runtime code now does not copy calldata with the EVMLA pipeline
371-
- `CODESIZE` in runtime code now returns 0 with the EVMLA pipeline
369+
- Another stack overflow issue with the EVMLA codegen
370+
- `CODECOPY` in runtime code now does not copy calldata with the EVMLA codegen
371+
- `CODESIZE` in runtime code now returns 0 with the EVMLA codegen
372372
- Hexadecimal arguments in EVMLA are now parsed as case-insensitive
373373

374374
## [1.3.7] - 2023-03-15
@@ -421,7 +421,7 @@
421421
### Fixed
422422

423423
- The `send` and `transfer` now produce a warning again due to false-positives
424-
- Malfunctioned `CODECOPY` in some cases with the EVMLA pipeline
424+
- Malfunctioned `CODECOPY` in some cases with the EVMLA codegen
425425
- The near call exception handling for the requests to system contracts
426426

427427
## [1.3.2] - 2023-02-14

era-compiler-solidity/src/evmla/assembly/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Assembly {
4040
#[serde(default)]
4141
pub factory_dependencies: HashSet<String>,
4242
/// The EVMLA extra metadata.
43-
#[serde(skip_serializing)]
43+
#[serde(skip_serializing_if = "Option::is_none")]
4444
pub extra_metadata: Option<ExtraMetadata>,
4545
}
4646

era-compiler-solidity/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub fn standard_output_eravm(
272272
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
273273
) -> anyhow::Result<EraVMBuild> {
274274
let solc_version = solc_compiler.version.to_owned();
275-
let solc_pipeline = SolcCodegen::new(&solc_version, codegen);
275+
let solc_codegen = SolcCodegen::new(&solc_version, codegen);
276276

277277
let mut solc_input = SolcStandardJsonInput::try_from_solidity_paths(
278278
paths,
@@ -282,7 +282,7 @@ pub fn standard_output_eravm(
282282
codegen,
283283
evm_version,
284284
enable_eravm_extensions,
285-
SolcStandardJsonInputSettingsSelection::new_required(Some(solc_pipeline)),
285+
SolcStandardJsonInputSettingsSelection::new_required(Some(solc_codegen)),
286286
SolcStandardJsonInputSettingsMetadata::new(use_literal_content, metadata_hash_type),
287287
llvm_options.clone(),
288288
suppressed_errors,
@@ -293,7 +293,7 @@ pub fn standard_output_eravm(
293293
let libraries = solc_input.settings.libraries.clone();
294294
let mut solc_output = solc_compiler.standard_json(
295295
&mut solc_input,
296-
Some(solc_pipeline),
296+
Some(solc_codegen),
297297
messages,
298298
base_path,
299299
include_paths,
@@ -304,7 +304,7 @@ pub fn standard_output_eravm(
304304

305305
let project = Project::try_from_solc_output(
306306
libraries,
307-
solc_pipeline,
307+
solc_codegen,
308308
&mut solc_output,
309309
solc_compiler,
310310
debug_config.as_ref(),
@@ -347,7 +347,7 @@ pub fn standard_output_evm(
347347
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
348348
) -> anyhow::Result<EVMBuild> {
349349
let solc_version = solc_compiler.version.to_owned();
350-
let solc_pipeline = SolcCodegen::new(&solc_version, codegen);
350+
let solc_codegen = SolcCodegen::new(&solc_version, codegen);
351351

352352
let mut solc_input = SolcStandardJsonInput::try_from_solidity_paths(
353353
paths,
@@ -357,7 +357,7 @@ pub fn standard_output_evm(
357357
codegen,
358358
evm_version,
359359
false,
360-
SolcStandardJsonInputSettingsSelection::new_required(Some(solc_pipeline)),
360+
SolcStandardJsonInputSettingsSelection::new_required(Some(solc_codegen)),
361361
SolcStandardJsonInputSettingsMetadata::new(use_literal_content, metadata_hash_type),
362362
llvm_options.clone(),
363363
vec![],
@@ -368,7 +368,7 @@ pub fn standard_output_evm(
368368
let libraries = solc_input.settings.libraries.clone();
369369
let mut solc_output = solc_compiler.standard_json(
370370
&mut solc_input,
371-
Some(solc_pipeline),
371+
Some(solc_codegen),
372372
messages,
373373
base_path,
374374
include_paths,
@@ -379,7 +379,7 @@ pub fn standard_output_evm(
379379

380380
let project = Project::try_from_solc_output(
381381
libraries,
382-
solc_pipeline,
382+
solc_codegen,
383383
&mut solc_output,
384384
solc_compiler,
385385
debug_config.as_ref(),
@@ -447,12 +447,12 @@ pub fn standard_json_eravm(
447447
None => SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME)?,
448448
};
449449

450-
let solc_pipeline = SolcCodegen::new(&solc_compiler.version, codegen);
451-
solc_input.normalize(Some(solc_pipeline));
450+
let solc_codegen = SolcCodegen::new(&solc_compiler.version, codegen);
451+
solc_input.normalize(Some(solc_codegen));
452452

453453
let mut solc_output = solc_compiler.standard_json(
454454
&mut solc_input,
455-
Some(solc_pipeline),
455+
Some(solc_codegen),
456456
messages,
457457
base_path,
458458
include_paths,
@@ -464,7 +464,7 @@ pub fn standard_json_eravm(
464464

465465
let project = Project::try_from_solc_output(
466466
libraries,
467-
solc_pipeline,
467+
solc_codegen,
468468
&mut solc_output,
469469
&solc_compiler,
470470
debug_config.as_ref(),
@@ -594,12 +594,12 @@ pub fn standard_json_evm(
594594
None => SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME)?,
595595
};
596596

597-
let solc_pipeline = SolcCodegen::new(&solc_compiler.version, codegen);
598-
solc_input.normalize(Some(solc_pipeline));
597+
let solc_codegen = SolcCodegen::new(&solc_compiler.version, codegen);
598+
solc_input.normalize(Some(solc_codegen));
599599

600600
let mut solc_output = solc_compiler.standard_json(
601601
&mut solc_input,
602-
Some(solc_pipeline),
602+
Some(solc_codegen),
603603
messages,
604604
base_path,
605605
include_paths,
@@ -611,7 +611,7 @@ pub fn standard_json_evm(
611611

612612
let project = Project::try_from_solc_output(
613613
libraries,
614-
solc_pipeline,
614+
solc_codegen,
615615
&mut solc_output,
616616
&solc_compiler,
617617
debug_config.as_ref(),

era-compiler-solidity/src/project/contract/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Contract {
145145
let solc_version = dependency_data
146146
.solc_version
147147
.clone()
148-
.expect("The EVM assembly pipeline cannot be executed without `solc`");
148+
.expect("The EVM assembly codegen cannot be executed without `solc`");
149149

150150
let module = llvm.create_module(self.name.full_path.as_str());
151151
let mut context = era_compiler_llvm_context::EraVMContext::new(

era-compiler-solidity/src/project/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ impl Project {
8585
///
8686
pub fn try_from_solc_output(
8787
libraries: BTreeMap<String, BTreeMap<String, String>>,
88-
pipeline: SolcCodegen,
88+
codegen: SolcCodegen,
8989
solc_output: &mut SolcStandardJsonOutput,
9090
solc_compiler: &SolcCompiler,
9191
debug_config: Option<&era_compiler_llvm_context::DebugConfig>,
9292
) -> anyhow::Result<Self> {
93-
if let SolcCodegen::EVMLA = pipeline {
93+
if let SolcCodegen::EVMLA = codegen {
9494
solc_output.preprocess_dependencies()?;
9595
}
9696

@@ -123,7 +123,7 @@ impl Project {
123123
);
124124
let full_path = name.full_path.clone();
125125

126-
let result = match pipeline {
126+
let result = match codegen {
127127
SolcCodegen::Yul => ContractYul::try_from_source(
128128
&name,
129129
contract.ir_optimized.as_deref(),

era-compiler-solidity/src/solc/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Compiler {
8888
pub fn standard_json(
8989
&self,
9090
input: &mut StandardJsonInput,
91-
pipeline: Option<Codegen>,
91+
codegen: Option<Codegen>,
9292
messages: &mut Vec<StandardJsonOutputError>,
9393
base_path: Option<String>,
9494
include_paths: Vec<String>,
@@ -179,7 +179,7 @@ impl Compiler {
179179
));
180180
}
181181

182-
if let Some(pipeline) = pipeline {
182+
if let Some(codegen) = codegen {
183183
let mut suppressed_errors = input.suppressed_errors.clone();
184184
suppressed_errors.extend_from_slice(input.settings.suppressed_errors.as_slice());
185185

@@ -190,7 +190,7 @@ impl Compiler {
190190
solc_output.preprocess_ast(
191191
&input.sources,
192192
&self.version,
193-
pipeline,
193+
codegen,
194194
suppressed_errors.as_slice(),
195195
suppressed_warnings.as_slice(),
196196
)?;

era-compiler-solidity/src/solc/standard_json/input/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ impl Input {
222222
///
223223
/// Sets the necessary defaults for EraVM compilation.
224224
///
225-
pub fn normalize(&mut self, pipeline: Option<SolcCodegen>) {
226-
self.settings.normalize(pipeline);
225+
pub fn normalize(&mut self, codegen: Option<SolcCodegen>) {
226+
self.settings.normalize(codegen);
227227
}
228228

229229
///

era-compiler-solidity/src/solc/standard_json/input/settings/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ impl Settings {
128128
///
129129
/// Sets the necessary defaults for EraVM compilation.
130130
///
131-
pub fn normalize(&mut self, pipeline: Option<SolcCodegen>) {
131+
pub fn normalize(&mut self, codegen: Option<SolcCodegen>) {
132132
self.output_selection
133133
.get_or_insert_with(Selection::default)
134-
.extend_with_required(pipeline);
134+
.extend_with_required(codegen);
135135
}
136136

137137
///

era-compiler-solidity/src/solc/standard_json/input/settings/selection/file/flag.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub enum Flag {
4545
}
4646

4747
impl From<SolcCodegen> for Flag {
48-
fn from(pipeline: SolcCodegen) -> Self {
49-
match pipeline {
48+
fn from(codegen: SolcCodegen) -> Self {
49+
match codegen {
5050
SolcCodegen::Yul => Self::Yul,
5151
SolcCodegen::EVMLA => Self::EVMLA,
5252
}

era-compiler-solidity/src/solc/standard_json/input/settings/selection/file/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ impl File {
2727
///
2828
/// Creates the selection required by EraVM compilation process.
2929
///
30-
pub fn new_required(pipeline: Option<SolcCodegen>) -> Self {
31-
let pipeline_ir_flag = pipeline
30+
pub fn new_required(codegen: Option<SolcCodegen>) -> Self {
31+
let codegen_ir_flag = codegen
3232
.map(SelectionFlag::from)
3333
.unwrap_or(SelectionFlag::Yul);
3434

3535
let per_file = HashSet::from_iter([SelectionFlag::AST]);
3636
let per_contract = HashSet::from_iter([
3737
SelectionFlag::MethodIdentifiers,
3838
SelectionFlag::Metadata,
39-
pipeline_ir_flag,
39+
codegen_ir_flag,
4040
]);
4141
Self {
4242
per_file: Some(per_file),
@@ -67,8 +67,8 @@ impl File {
6767
///
6868
/// Extends the output selection with flag required by EraVM compilation process.
6969
///
70-
pub fn extend_with_required(&mut self, pipeline: Option<SolcCodegen>) -> &mut Self {
71-
let required = Self::new_required(pipeline);
70+
pub fn extend_with_required(&mut self, codegen: Option<SolcCodegen>) -> &mut Self {
71+
let required = Self::new_required(codegen);
7272
self.per_file
7373
.get_or_insert_with(HashSet::default)
7474
.extend(required.per_file.unwrap_or_default());

era-compiler-solidity/src/solc/standard_json/input/settings/selection/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ impl Selection {
2525
///
2626
/// Creates the selection required by EraVM compilation process.
2727
///
28-
pub fn new_required(pipeline: Option<SolcCodegen>) -> Self {
28+
pub fn new_required(codegen: Option<SolcCodegen>) -> Self {
2929
Self {
30-
all: Some(FileSelection::new_required(pipeline)),
30+
all: Some(FileSelection::new_required(codegen)),
3131
}
3232
}
3333

@@ -52,10 +52,10 @@ impl Selection {
5252
///
5353
/// Extends the output selection with flag required by EraVM compilation process.
5454
///
55-
pub fn extend_with_required(&mut self, pipeline: Option<SolcCodegen>) -> &mut Self {
55+
pub fn extend_with_required(&mut self, codegen: Option<SolcCodegen>) -> &mut Self {
5656
self.all
57-
.get_or_insert_with(|| FileSelection::new_required(pipeline))
58-
.extend_with_required(pipeline);
57+
.get_or_insert_with(|| FileSelection::new_required(codegen))
58+
.extend_with_required(codegen);
5959
self
6060
}
6161

era-compiler-solidity/src/solc/standard_json/output/error/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ You may disable this error with:
187187
sources: &BTreeMap<String, StandardJSONInputSource>,
188188
) -> Self {
189189
let message = r#"
190-
Internal function pointers are not supported in the EVM assembly pipeline.
190+
Internal function pointers are not supported in the EVM assembly codegen.
191191
Please do one of the following:
192192
1. Use the ZKsync fork of the Solidity compiler: https://github.com/matter-labs/era-solidity/releases
193-
2. Switch to the latest solc with Yul assembly pipeline: https://docs.soliditylang.org/en/latest/yul.html
193+
2. Switch to the latest solc with Yul assembly codegen: https://docs.soliditylang.org/en/latest/yul.html
194194
"#;
195195

196196
Self::new_error(

era-compiler-solidity/src/solc/standard_json/output/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl Output {
223223
&mut self,
224224
sources: &BTreeMap<String, StandardJSONInputSource>,
225225
version: &SolcVersion,
226-
pipeline: SolcCodegen,
226+
codegen: SolcCodegen,
227227
suppressed_errors: &[ErrorType],
228228
suppressed_warnings: &[WarningType],
229229
) -> anyhow::Result<()> {
@@ -248,7 +248,7 @@ impl Output {
248248
&id_paths,
249249
sources,
250250
version,
251-
pipeline,
251+
codegen,
252252
suppressed_errors,
253253
suppressed_warnings,
254254
)

era-compiler-solidity/src/solc/standard_json/output/source.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl Source {
220220
id_paths: &BTreeMap<usize, &String>,
221221
sources: &BTreeMap<String, StandardJSONInputSource>,
222222
solc_version: &SolcVersion,
223-
solc_pipeline: SolcCodegen,
223+
solc_codegen: SolcCodegen,
224224
suppressed_errors: &[ErrorType],
225225
suppressed_warnings: &[WarningType],
226226
) -> Vec<SolcStandardJsonOutputError> {
@@ -235,7 +235,7 @@ impl Source {
235235
if let Some(message) = Self::check_runtime_code(ast, id_paths, sources) {
236236
messages.push(message);
237237
}
238-
if SolcCodegen::EVMLA == solc_pipeline && solc_version.l2_revision.is_none() {
238+
if SolcCodegen::EVMLA == solc_codegen && solc_version.l2_revision.is_none() {
239239
if let Some(message) = Self::check_internal_function_pointer(ast, id_paths, sources) {
240240
messages.push(message);
241241
}
@@ -258,7 +258,7 @@ impl Source {
258258
id_paths,
259259
sources,
260260
solc_version,
261-
solc_pipeline,
261+
solc_codegen,
262262
suppressed_errors,
263263
suppressed_warnings,
264264
));
@@ -271,7 +271,7 @@ impl Source {
271271
id_paths,
272272
sources,
273273
solc_version,
274-
solc_pipeline,
274+
solc_codegen,
275275
suppressed_errors,
276276
suppressed_warnings,
277277
));

0 commit comments

Comments
 (0)