Skip to content

Commit

Permalink
add optimizer settings to solc standard json
Browse files Browse the repository at this point in the history
  • Loading branch information
garythung committed Dec 19, 2023
1 parent 5d35878 commit c526de8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions crytic_compile/platform/solc_standard_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
import json
import logging
import os
from pathlib import Path
import shutil
import subprocess
from typing import TYPE_CHECKING, Dict, List, Optional, Union, Any
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

from crytic_compile.compilation_unit import CompilationUnit
from crytic_compile.compiler.compiler import CompilerVersion
from crytic_compile.platform.exceptions import InvalidCompilation
from crytic_compile.platform.solc import Solc, get_version, is_optimized, relative_to_short
from crytic_compile.platform.solc import (
Solc,
get_version,
is_optimized,
relative_to_short,
)
from crytic_compile.platform.types import Type
from crytic_compile.utils.naming import convert_filename

Expand Down Expand Up @@ -160,7 +165,6 @@ def run_solc_standard_json(
" ".join(cmd),
)
try:

with subprocess.Popen(
cmd,
stdin=subprocess.PIPE,
Expand All @@ -170,7 +174,6 @@ def run_solc_standard_json(
executable=shutil.which(cmd[0]),
**additional_kwargs,
) as process:

stdout_b, stderr_b = process.communicate(json.dumps(solc_input).encode("utf-8"))
stdout, stderr = (
stdout_b.decode(),
Expand Down Expand Up @@ -453,7 +456,9 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: Any) -> None:
compilation_unit.compiler_version = CompilerVersion(
compiler="solc",
version=get_version(solc, solc_env),
optimized=is_optimized(solc_arguments),
optimized=is_optimized(solc_arguments)
or self.to_dict().get("settings", {}).get("optimizer", {}).get("enabled", False),
optimize_runs=self.to_dict().get("settings", {}).get("optimizer", {}).get("runs", None),
)

add_optimization(
Expand Down

0 comments on commit c526de8

Please sign in to comment.