Skip to content

Commit

Permalink
remove compressed source map
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed May 9, 2024
1 parent 2ec5833 commit f7c8bc4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
10 changes: 4 additions & 6 deletions tests/unit/cli/vyper_json/test_compile_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ def test_compile_json(input_json, input_bundle):
"bytecode": {
"object": data["bytecode"],
"opcodes": data["opcodes"],
"sourceMap": data["source_map"]["pc_pos_map_compressed"],
"sourceMapFull": data["source_map_full"],
"sourceMap": data["source_map"],
},
"deployedBytecode": {
"object": data["bytecode_runtime"],
"opcodes": data["opcodes_runtime"],
"sourceMap": data["source_map_runtime"]["pc_pos_map_compressed"],
"sourceMapFull": data["source_map_full_runtime"],
"sourceMap": data["source_map_runtime"],
},
"methodIdentifiers": data["method_identifiers"],
},
Expand Down Expand Up @@ -271,7 +269,7 @@ def test_exc_handler_to_dict_compiler(input_json):


def test_source_ids_increment(input_json):
input_json["settings"]["outputSelection"] = {"*": ["ast", "evm.deployedBytecode.sourceMapFull"]}
input_json["settings"]["outputSelection"] = {"*": ["ast", "evm.deployedBytecode.sourceMap"]}
result = compile_json(input_json)

def get(filename, contractname):
Expand All @@ -280,7 +278,7 @@ def get(filename, contractname):

# grab it via source map to sanity check
contract_info = result["contracts"][filename][contractname]["evm"]
pc_ast_map = contract_info["deployedBytecode"]["sourceMapFull"]["pc_ast_map"]
pc_ast_map = contract_info["deployedBytecode"]["sourceMap"]["pc_ast_map"]
pc_item = next(iter(pc_ast_map.values()))
source_id, node_id = pc_item
assert ret == source_id
Expand Down
12 changes: 3 additions & 9 deletions vyper/cli/vyper_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
"evm.bytecode.object": "bytecode",
"evm.bytecode.opcodes": "opcodes",
"evm.bytecode.sourceMap": "source_map",
"evm.bytecode.sourceMapFull": "source_map_full",
"evm.deployedBytecode.object": "bytecode_runtime",
"evm.deployedBytecode.opcodes": "opcodes_runtime",
"evm.deployedBytecode.sourceMap": "source_map_runtime",
"evm.deployedBytecode.sourceMapFull": "source_map_full_runtime",
"interface": "interface",
"ir": "ir_dict",
"ir_runtime": "ir_runtime_dict",
Expand Down Expand Up @@ -343,17 +341,15 @@ def format_to_output_dict(compiler_data: dict) -> dict:
output_contracts["evm"] = {"methodIdentifiers": data["method_identifiers"]}

evm_keys = ("bytecode", "opcodes")
pc_maps_keys = ("source_map", "source_map_full")
pc_maps_keys = ("source_map",)
if any(i in data for i in evm_keys + pc_maps_keys):
evm = output_contracts.setdefault("evm", {}).setdefault("bytecode", {})
if "bytecode" in data:
evm["object"] = data["bytecode"]
if "opcodes" in data:
evm["opcodes"] = data["opcodes"]
if "source_map" in data:
evm["sourceMap"] = data["source_map"]["pc_pos_map_compressed"]
if "source_map_full" in data:
evm["sourceMapFull"] = data["source_map_full"]
evm["sourceMap"] = data["source_map"]

if any(i + "_runtime" in data for i in evm_keys + pc_maps_keys):
evm = output_contracts.setdefault("evm", {}).setdefault("deployedBytecode", {})
Expand All @@ -362,9 +358,7 @@ def format_to_output_dict(compiler_data: dict) -> dict:
if "opcodes_runtime" in data:
evm["opcodes"] = data["opcodes_runtime"]
if "source_map_runtime" in data:
evm["sourceMap"] = data["source_map_runtime"]["pc_pos_map_compressed"]
if "source_map_full_runtime" in data:
evm["sourceMapFull"] = data["source_map_full_runtime"]
evm["sourceMap"] = data["source_map_runtime"]

return output_dict

Expand Down
2 changes: 0 additions & 2 deletions vyper/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
"abi": output.build_abi_output,
"asm": output.build_asm_output,
"source_map": output.build_source_map_output,
"source_map_full": output.build_source_map_output,
"source_map_runtime": output.build_source_map_runtime_output,
"source_map_full_runtime": output.build_source_map_runtime_output,
# requires bytecode
"bytecode": output.build_bytecode_output,
"bytecode_runtime": output.build_bytecode_runtime_output,
Expand Down

0 comments on commit f7c8bc4

Please sign in to comment.