From 645ca1f6abaee796e0bbe449cf1a908eb6828ccf Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Fri, 6 Oct 2017 09:53:47 +0700 Subject: [PATCH] Also save contract creation code in db sync --- mythril/ether/contractstorage.py | 2 +- mythril/ether/ethcontract.py | 3 ++- tests/ethcontract_test.py | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mythril/ether/contractstorage.py b/mythril/ether/contractstorage.py index 3a345fdd..777a03aa 100644 --- a/mythril/ether/contractstorage.py +++ b/mythril/ether/contractstorage.py @@ -80,7 +80,7 @@ class ContractStorage(persistent.Persistent): # skip contracts with zero balance (disable with --sync-all) continue - code = ETHContract(contract_code) + code = ETHContract(contract_code, tx['input']) m = hashlib.md5() m.update(contract_code.encode('UTF-8')) diff --git a/mythril/ether/ethcontract.py b/mythril/ether/ethcontract.py index 331d8a13..456dffc3 100644 --- a/mythril/ether/ethcontract.py +++ b/mythril/ether/ethcontract.py @@ -6,9 +6,10 @@ from ethereum import utils class ETHContract(persistent.Persistent): - def __init__(self, code = ""): + def __init__(self, code, creation_code = ""): self.code = code + self.creation_code = creation_code def get_xrefs(self): diff --git a/tests/ethcontract_test.py b/tests/ethcontract_test.py index 549debc8..118cebef 100644 --- a/tests/ethcontract_test.py +++ b/tests/ethcontract_test.py @@ -6,12 +6,13 @@ class ETHContractTestCase(unittest.TestCase): def setUp(self): self.code = "0x60606040525b603c5b60006010603e565b9050593681016040523660008237602060003683856040603f5a0204f41560545760206000f35bfe5b50565b005b73c3b2ae46792547a96b9f84405e36d0e07edcd05c5b905600a165627a7a7230582062a884f947232ada573f95940cce9c8bfb7e4e14e21df5af4e884941afb55e590029" + self.creation_code = "0x60606040525b603c5b60006010603e565b9050593681016040523660008237602060003683856040603f5a0204f41560545760206000f35bfe5b50565b005b73c3b2ae46792547a96b9f84405e36d0e07edcd05c5b905600a165627a7a7230582062a884f947232ada573f95940cce9c8bfb7e4e14e21df5af4e884941afb55e590029" class Getinstruction_listTestCase(ETHContractTestCase): def runTest(self): - contract = ETHContract(self.code) + contract = ETHContract(self.code, self.creation_code) instruction_list = contract.get_instruction_list()