Esempio n. 1
0
    def test_DUP_1(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\x80"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {
            "coinbase": 0,
            "timestamp": 0,
            "number": 0,
            "difficulty": 0,
            "gaslimit": 0
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(
            115792089237316195423570985008687907853269984665640564039457584007913129639935
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(
            new_vm.stack,
            [
                115792089237316195423570985008687907853269984665640564039457584007913129639935,
                115792089237316195423570985008687907853269984665640564039457584007913129639935,
            ],
        )
Esempio n. 2
0
    def test_JUMP_1(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = 'V'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(
            115792089237316195423570985008687907853269984665640564039457584007913129639935L
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(
            new_vm.pc,
            115792089237316195423570985008687907853269984665640564039457584007913129639935L
        )
        self.assertEqual(new_vm.stack, [])
Esempio n. 3
0
    def test_DUP_4(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\x80"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {
            "coinbase": 0,
            "timestamp": 0,
            "number": 0,
            "difficulty": 0,
            "gaslimit": 0
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(
            57896044618658097711785492504343953926634992332820282019728792003956564819952
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(
            new_vm.stack,
            [
                57896044618658097711785492504343953926634992332820282019728792003956564819952,
                57896044618658097711785492504343953926634992332820282019728792003956564819952,
            ],
        )
Esempio n. 4
0
    def test_DUP_5(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\x80"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {
            "coinbase": 0,
            "timestamp": 0,
            "number": 0,
            "difficulty": 0,
            "gaslimit": 0
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(
            3618502788666131106986593281521497120414687020801267626233049500247285301263
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(
            new_vm.stack,
            [
                3618502788666131106986593281521497120414687020801267626233049500247285301263,
                3618502788666131106986593281521497120414687020801267626233049500247285301263,
            ],
        )
Esempio n. 5
0
    def test_DUP_5(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '\x80'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(
            3618502788666131106986593281521497120414687020801267626233049500247285301263L
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [
            3618502788666131106986593281521497120414687020801267626233049500247285301263L,
            3618502788666131106986593281521497120414687020801267626233049500247285301263L
        ])
Esempio n. 6
0
    def test_DUP_4(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '\x80'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(
            57896044618658097711785492504343953926634992332820282019728792003956564819952L
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [
            57896044618658097711785492504343953926634992332820282019728792003956564819952L,
            57896044618658097711785492504343953926634992332820282019728792003956564819952L
        ])
Esempio n. 7
0
    def test_REVERT_11(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\xfd"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {"coinbase": 0, "timestamp": 0, "number": 0, "difficulty": 0, "gaslimit": 0}
        gas = 1000000

        new_vm = evm.EVM(constraints, address, data, caller, value, bytecode, gas=gas, world=world)
        new_vm._push(6089590155545428825848686802984512581899718912)
        new_vm._push(6089590155545428825848686802984512581899718912)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, "OOG")
Esempio n. 8
0
    def test_REVERT_5(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\xfd"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {"coinbase": 0, "timestamp": 0, "number": 0, "difficulty": 0, "gaslimit": 0}
        gas = 1000000

        new_vm = evm.EVM(constraints, address, data, caller, value, bytecode, gas=gas, world=world)
        new_vm._push(115792089237316195423570985008687907853269984665640564039457584007913129639935)
        new_vm._push(3618502788666131106986593281521497120414687020801267626233049500247285301263)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, "OOG")
Esempio n. 9
0
    def test_REVERT_4(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\xfd"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {"coinbase": 0, "timestamp": 0, "number": 0, "difficulty": 0, "gaslimit": 0}
        gas = 1000000

        new_vm = evm.EVM(constraints, address, data, caller, value, bytecode, gas=gas, world=world)
        new_vm._push(115792089237316195423570985008687907853269984665640564039457584007913129639935)
        new_vm._push(57896044618658097711785492504343953926634992332820282019728792003956564819952)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, "OOG")
Esempio n. 10
0
    def test_CALLDATASIZE_1(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"6"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {"coinbase": 0, "timestamp": 0, "number": 0, "difficulty": 0, "gaslimit": 0}
        gas = 1000000

        new_vm = evm.EVM(constraints, address, data, caller, value, bytecode, gas=gas, world=world)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [30])
Esempio n. 11
0
    def test_REVERT_10(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        caller = origin = 0x111111111111111111111111111111111111100
        address = 0x222222222222222222222222222222222222200
        balance = 0
        code = ''
        world.create_account(address=address)
        world.create_account(address=caller)

        price = 0
        value = 10000
        bytecode = '\xfd'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(0)
        new_vm._push(
            115792089237316195423570985008687907853269984665640564039457584007913129639935
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, 'REVERT')
        self.assertEqual(new_vm.stack, [])
Esempio n. 12
0
    def test_GASPRICE_1(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        owner_account = world.create_account(balance=1000)
        contract_account = world.create_account(balance=1000, code=b":")

        world._open_transaction("CALL", contract_account, 10, "",
                                owner_account, 0)
        world._open_transaction("CALL", contract_account, 100, "",
                                owner_account, 0)
        world._open_transaction("CALL", contract_account, 100, "",
                                owner_account, 0)

        new_vm = world.current_vm
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [10])
Esempio n. 13
0
    def test_DUP_9(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '\x80'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(6089590155545428825848686802984512581899718912L)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [
            6089590155545428825848686802984512581899718912L,
            6089590155545428825848686802984512581899718912L
        ])
Esempio n. 14
0
    def test_BLOCKHASH_2(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '@'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(0)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        #Currently the hash("1NONCE")
        self.assertEqual(new_vm.stack, [
            4191156306509761637738076877631970127621839175651556722833009931314104461609L
        ])
Esempio n. 15
0
    def test_REVERT_4(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '\xfd'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(
            115792089237316195423570985008687907853269984665640564039457584007913129639935L
        )
        new_vm._push(
            57896044618658097711785492504343953926634992332820282019728792003956564819952L
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, 'OOG')
Esempio n. 16
0
    def test_REVERT_5(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '\xfd'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(
            115792089237316195423570985008687907853269984665640564039457584007913129639935L
        )
        new_vm._push(
            3618502788666131106986593281521497120414687020801267626233049500247285301263L
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, 'OOG')
Esempio n. 17
0
    def test_NOT_9(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\x19"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {
            "coinbase": 0,
            "timestamp": 0,
            "number": 0,
            "difficulty": 0,
            "gaslimit": 0
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(6089590155545428825848686802984512581899718912)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(
            new_vm.stack,
            [
                115792089237316195423570985008681818263114439236814715352654599495331229921023
            ],
        )
Esempio n. 18
0
    def test_CALLDATALOAD_2(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"5"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {
            "coinbase": 0,
            "timestamp": 0,
            "number": 0,
            "difficulty": 0,
            "gaslimit": 0
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(0)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertSequenceEqual(
            list(map(to_constant, new_vm.stack)),
            [
                29515630589904128245223976570842015727304113738300535931626442982409229107200
            ],
        )
Esempio n. 19
0
    def test_CALLDATALOAD_6(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"5"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {
            "coinbase": 0,
            "timestamp": 0,
            "number": 0,
            "difficulty": 0,
            "gaslimit": 0
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(16)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(
            list(map(to_constant, new_vm.stack)),
            [
                29515630589904128245223976570842010042800435681475029265659040150473943285760
            ],
        )
Esempio n. 20
0
    def test_NOT_5(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b'\x19'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(
            3618502788666131106986593281521497120414687020801267626233049500247285301263
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [
            112173586448650064316584391727166410732855297644839296413224534507665844338672
        ])
Esempio n. 21
0
    def test_CALLCODE_9(self):
        # Make the constraint store
        constraints = ConstraintSet()
        # make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b"\xf2"
        data = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
        header = {"coinbase": 0, "timestamp": 0, "number": 0, "difficulty": 0, "gaslimit": 0}
        gas = 1000000

        new_vm = evm.EVM(constraints, address, data, caller, value, bytecode, gas=gas, world=world)
        new_vm._push(115792089237316195423570985008687907853269984665640564039457584007913129639935)
        new_vm._push(115792089237316195423570985008687907853269984665640564039457584007913129639935)
        new_vm._push(115792089237316195423570985008687907853269984665640564039457584007913129639935)
        new_vm._push(115792089237316195423570985008687907853269984665640564039457584007913129639935)
        new_vm._push(6089590155545428825848686802984512581899718912)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, "INSUFFICIENT STACK")
Esempio n. 22
0
    def _make(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = b'\x05'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        return constraints, world, new_vm
Esempio n. 23
0
    def test_SELFDESTRUCT_2(self):
            #Make the constraint store
            constraints = ConstraintSet()
            #make the ethereum world state
            world = evm.EVMWorld(constraints)

            address = 0x30323232323232323232323232323232323232323232323232323232323232323232323232323030
            balance = 0
            code = ''
            storage = {}
            world.create_account( address=address, balance=balance, code=code, storage=storage)

            address = 0x0
            balance = 0
            code = ''
            storage = {}
            world.create_account( address=address, balance=balance, code=code, storage=storage)

            address=0x222222222222222222222222222222222222200
            caller=origin=0x111111111111111111111111111111111111100
            price=0
            value=10000
            bytecode='\xff'
            data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
            header = { 'coinbase': 0,
                        'timestamp': 0,
                        'number': 0,
                        'difficulty': 0,
                        'gaslimit': 0,
                        }
            gas = 1000000

            new_vm = evm.EVM(constraints, address, origin, price, data, caller, value, bytecode, header, gas=gas, global_storage=world.storage)
            new_vm._push(0)
            last_exception, last_returned = self._execute(new_vm)
            self.assertEqual(last_exception, 'SUICIDED')
            self.assertEqual(new_vm.gas, 995000)
Esempio n. 24
0
    def test_JUMP_2(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = 'V'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        new_vm._push(0)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 0)
        self.assertEqual(new_vm.stack, [])
Esempio n. 25
0
    def test_ADDRESS_1(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '0'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         origin,
                         price,
                         data,
                         caller,
                         value,
                         bytecode,
                         header,
                         gas=gas,
                         global_storage=world.storage)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack,
                         [12179180311090857651697373605969025163799437824L])
Esempio n. 26
0
    def test_CALLDATALOAD_6(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '5'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(16)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [
            29515630589904128245223976570842010042800435681475029265659040150473943285760L
        ])
Esempio n. 27
0
    def __init__(self):

        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)
        initial_state = State(constraints, world)
        super(ManticoreEVM, self).__init__(initial_state)

        #The following should go to manticore.context so we can use multiprocessing
        self.code = {}
        self.context['seth'] = {}
        self.context['seth']['_pending_transaction'] = None
        self.context['seth']['_saved_states'] = []
        self.context['seth']['_final_states'] = []

        self._executor.subscribe('did_load_state', self.load_state_callback)
        self._executor.subscribe('will_terminate_state',
                                 self.terminate_state_callback)
        self._executor.subscribe('will_execute_instruction',
                                 self.will_execute_instruction_callback)
        self._executor.subscribe('did_read_code', self.did_read_code)
        self._executor.subscribe('on_symbolic_sha3', self.symbolic_sha3)
        self._executor.subscribe('on_concrete_sha3', self.concrete_sha3)
Esempio n. 28
0
    def test_CALLDATALOAD_2(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '5'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(0)
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, None)
        self.assertEqual(new_vm.pc, 1)
        self.assertEqual(new_vm.stack, [
            29515630589904128245223976570842015727304113738300535931626442982409229107200
        ])
Esempio n. 29
0
    def test_INVALID_1(self):
            #Make the constraint store
            constraints = ConstraintSet()
            #make the ethereum world state
            world = evm.EVMWorld(constraints)

            address=0x222222222222222222222222222222222222200
            caller=origin=0x111111111111111111111111111111111111100
            price=0
            value=10000
            bytecode='\xfe'
            data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
            header = { 'coinbase': 0,
                        'timestamp': 0,
                        'number': 0,
                        'difficulty': 0,
                        'gaslimit': 0,
                        }
            gas = 1000000

            new_vm = evm.EVM(constraints, address, data, caller, value, bytecode, gas=gas, world=world)
            last_exception, last_returned = self._execute(new_vm)
            self.assertEqual(last_exception, 'INVALID')
            self.assertEqual(new_vm.gas, 1000000)
Esempio n. 30
0
    def test_SELFDESTRUCT_1(self):
        #Make the constraint store
        constraints = ConstraintSet()
        #make the ethereum world state
        world = evm.EVMWorld(constraints)

        address = 0x303232323232323232323232323232323232323
        balance = 0
        code = ''
        storage = {}
        world.create_account(address=address,
                             balance=balance,
                             code=code,
                             storage=storage)

        address = 0xfffffffffffffffffffffffffffffffffffffff
        balance = 0
        code = ''
        storage = {}
        world.create_account(address=address,
                             balance=balance,
                             code=code,
                             storage=storage)

        address = 0x111111111111111111111111111111111111100
        balance = 0
        code = ''
        storage = {}
        world.create_account(address=address,
                             balance=balance,
                             code=code,
                             storage=storage)

        address = 0x222222222222222222222222222222222222200
        balance = 0
        code = ''
        storage = {}
        world.create_account(address=address,
                             balance=balance,
                             code=code,
                             storage=storage)

        address = 0x222222222222222222222222222222222222200
        caller = origin = 0x111111111111111111111111111111111111100
        price = 0
        value = 10000
        bytecode = '\xff'
        data = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
        header = {
            'coinbase': 0,
            'timestamp': 0,
            'number': 0,
            'difficulty': 0,
            'gaslimit': 0,
        }
        gas = 1000000

        new_vm = evm.EVM(constraints,
                         address,
                         data,
                         caller,
                         value,
                         bytecode,
                         gas=gas,
                         world=world)
        new_vm._push(
            115792089237316195423570985008687907853269984665640564039457584007913129639935
        )
        last_exception, last_returned = self._execute(new_vm)
        self.assertEqual(last_exception, 'SELFDESTRUCT')
        self.assertEqual(new_vm.gas, 995000)