From 581b5da77547ce3c317291a0fa77b8cee02608b5 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sat, 8 Oct 2022 09:57:57 +0800 Subject: [PATCH 1/6] add --no-bytecode-metadata option to vyper-json --- vyper/cli/vyper_json.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vyper/cli/vyper_json.py b/vyper/cli/vyper_json.py index 55b6c38480..34652a6ad3 100755 --- a/vyper/cli/vyper_json.py +++ b/vyper/cli/vyper_json.py @@ -69,6 +69,8 @@ def _parse_args(argv): action="store_true", ) + parser.add_argument("--no-bytecode-metadata", help="Do not add metadata to bytecode.", action="store_true") + args = parser.parse_args(argv) if args.input_file: with Path(args.input_file).open() as fh: @@ -80,7 +82,7 @@ def _parse_args(argv): exc_handler = exc_handler_raises if args.traceback else exc_handler_to_dict output_json = json.dumps( - compile_json(input_json, exc_handler, args.root_folder, json_path), + compile_json(input_json, exc_handler, args.root_folder, json_path, args.no_bytecode_metadata), indent=2 if args.pretty_json else None, sort_keys=True, default=str, @@ -342,6 +344,7 @@ def compile_from_input_dict( input_dict: Dict, exc_handler: Callable = exc_handler_raises, root_folder: Union[str, None] = None, + no_bytecode_metadata: bool = False, ) -> Tuple[Dict, Dict]: root_path = None if root_folder is not None: @@ -377,6 +380,7 @@ def compile_from_input_dict( initial_id=id_, no_optimize=no_optimize, evm_version=evm_version, + no_bytecode_metadata=no_bytecode_metadata, ) except Exception as exc: return exc_handler(contract_path, exc, "compiler"), {} @@ -449,6 +453,7 @@ def compile_json( exc_handler: Callable = exc_handler_raises, root_path: Union[str, None] = None, json_path: Union[str, None] = None, + no_bytecode_metadata: bool = False, ) -> Dict: try: if isinstance(input_json, str): @@ -463,7 +468,7 @@ def compile_json( input_dict = input_json try: - compiler_data, warn_data = compile_from_input_dict(input_dict, exc_handler, root_path) + compiler_data, warn_data = compile_from_input_dict(input_dict, exc_handler, root_path, no_bytecode_metadata) if "errors" in compiler_data: return compiler_data except KeyError as exc: From c504d2a575cf3eb620ec101cdcfb53c87a2f6da8 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sat, 8 Oct 2022 10:20:09 +0800 Subject: [PATCH 2/6] fix lint --- vyper/cli/vyper_json.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vyper/cli/vyper_json.py b/vyper/cli/vyper_json.py index 34652a6ad3..79a3d61f34 100755 --- a/vyper/cli/vyper_json.py +++ b/vyper/cli/vyper_json.py @@ -69,7 +69,9 @@ def _parse_args(argv): action="store_true", ) - parser.add_argument("--no-bytecode-metadata", help="Do not add metadata to bytecode.", action="store_true") + parser.add_argument( + "--no-bytecode-metadata", help="Do not add metadata to bytecode.", action="store_true" + ) args = parser.parse_args(argv) if args.input_file: @@ -82,7 +84,9 @@ def _parse_args(argv): exc_handler = exc_handler_raises if args.traceback else exc_handler_to_dict output_json = json.dumps( - compile_json(input_json, exc_handler, args.root_folder, json_path, args.no_bytecode_metadata), + compile_json( + input_json, exc_handler, args.root_folder, json_path, args.no_bytecode_metadata + ), indent=2 if args.pretty_json else None, sort_keys=True, default=str, @@ -468,7 +472,9 @@ def compile_json( input_dict = input_json try: - compiler_data, warn_data = compile_from_input_dict(input_dict, exc_handler, root_path, no_bytecode_metadata) + compiler_data, warn_data = compile_from_input_dict( + input_dict, exc_handler, root_path, no_bytecode_metadata + ) if "errors" in compiler_data: return compiler_data except KeyError as exc: From 7490fa1cb866d5ad6cabf086c801c0bc37f7ea00 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:10:14 +0800 Subject: [PATCH 3/6] Revert "fix lint" This reverts commit c504d2a575cf3eb620ec101cdcfb53c87a2f6da8. --- vyper/cli/vyper_json.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/vyper/cli/vyper_json.py b/vyper/cli/vyper_json.py index 79a3d61f34..7add786c7e 100755 --- a/vyper/cli/vyper_json.py +++ b/vyper/cli/vyper_json.py @@ -69,10 +69,6 @@ def _parse_args(argv): action="store_true", ) - parser.add_argument( - "--no-bytecode-metadata", help="Do not add metadata to bytecode.", action="store_true" - ) - args = parser.parse_args(argv) if args.input_file: with Path(args.input_file).open() as fh: @@ -84,9 +80,7 @@ def _parse_args(argv): exc_handler = exc_handler_raises if args.traceback else exc_handler_to_dict output_json = json.dumps( - compile_json( - input_json, exc_handler, args.root_folder, json_path, args.no_bytecode_metadata - ), + compile_json(input_json, exc_handler, args.root_folder, json_path), indent=2 if args.pretty_json else None, sort_keys=True, default=str, @@ -472,9 +466,7 @@ def compile_json( input_dict = input_json try: - compiler_data, warn_data = compile_from_input_dict( - input_dict, exc_handler, root_path, no_bytecode_metadata - ) + compiler_data, warn_data = compile_from_input_dict(input_dict, exc_handler, root_path) if "errors" in compiler_data: return compiler_data except KeyError as exc: From 390933590778c3d55cad70544ea6d7b506910e29 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:10:50 +0800 Subject: [PATCH 4/6] Revert "add --no-bytecode-metadata option to vyper-json" This reverts commit 581b5da77547ce3c317291a0fa77b8cee02608b5. --- vyper/cli/vyper_json.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/vyper/cli/vyper_json.py b/vyper/cli/vyper_json.py index 7add786c7e..55b6c38480 100755 --- a/vyper/cli/vyper_json.py +++ b/vyper/cli/vyper_json.py @@ -342,7 +342,6 @@ def compile_from_input_dict( input_dict: Dict, exc_handler: Callable = exc_handler_raises, root_folder: Union[str, None] = None, - no_bytecode_metadata: bool = False, ) -> Tuple[Dict, Dict]: root_path = None if root_folder is not None: @@ -378,7 +377,6 @@ def compile_from_input_dict( initial_id=id_, no_optimize=no_optimize, evm_version=evm_version, - no_bytecode_metadata=no_bytecode_metadata, ) except Exception as exc: return exc_handler(contract_path, exc, "compiler"), {} @@ -451,7 +449,6 @@ def compile_json( exc_handler: Callable = exc_handler_raises, root_path: Union[str, None] = None, json_path: Union[str, None] = None, - no_bytecode_metadata: bool = False, ) -> Dict: try: if isinstance(input_json, str): From 1f02700a97ea63adae64869cab9d005cf01d8db2 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:36:06 +0800 Subject: [PATCH 5/6] add option to json --- vyper/cli/vyper_json.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vyper/cli/vyper_json.py b/vyper/cli/vyper_json.py index 55b6c38480..0abefdebff 100755 --- a/vyper/cli/vyper_json.py +++ b/vyper/cli/vyper_json.py @@ -354,6 +354,7 @@ def compile_from_input_dict( evm_version = get_evm_version(input_dict) no_optimize = not input_dict["settings"].get("optimize", True) + no_bytecode_metadata = not input_dict["settings"].get("bytecodeMetadata", True) contract_sources: ContractCodes = get_input_dict_contracts(input_dict) interface_sources = get_input_dict_interfaces(input_dict) @@ -377,6 +378,7 @@ def compile_from_input_dict( initial_id=id_, no_optimize=no_optimize, evm_version=evm_version, + no_bytecode_metadata=no_bytecode_metadata, ) except Exception as exc: return exc_handler(contract_path, exc, "compiler"), {} From 65928252c0a06dfce269c57c59773974559afc52 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:40:50 +0800 Subject: [PATCH 6/6] update docs --- docs/compiling-a-contract.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/compiling-a-contract.rst b/docs/compiling-a-contract.rst index 76efb1bbf0..1984faa4c7 100644 --- a/docs/compiling-a-contract.rst +++ b/docs/compiling-a-contract.rst @@ -208,6 +208,9 @@ The following example describes the expected input format of ``vyper-json``. Com // optional, whether or not optimizations are turned on // defaults to true "optimize": true, + // optional, whether or not the bytecode should include Vyper's signature + // defaults to true + "bytecodeMetadata": true, // The following is used to select desired outputs based on file names. // File names are given as keys, a star as a file name matches all files. // Outputs can also follow the Solidity format where second level keys