Ejemplo n.º 1
0
 def _get_account(self, address):
     rlp_account = self._journaltrie.get(address, b'')
     if rlp_account:
         account = rlp.decode(rlp_account, sedes=Account)
     else:
         account = Account()
     return account
Ejemplo n.º 2
0
 def _get_account(self, address: Address, from_journal: bool=True) -> Account:
     rlp_account = (self._journaltrie if from_journal else self._trie_cache).get(address, b'')
     if rlp_account:
         account = rlp.decode(rlp_account, sedes=Account)
     else:
         account = Account()
     return account
Ejemplo n.º 3
0
 def _get_account(self, address: Address, from_journal: bool=True) -> Account:
     if from_journal and address in self._account_cache:
         return self._account_cache[address]
     rlp_account = (self._journaltrie if from_journal else self._trie_cache).get(address, b'')
     if rlp_account:
         account = rlp.decode(rlp_account, sedes=Account)
     else:
         account = Account()
     if from_journal:
         self._account_cache[address] = account
     return account
Ejemplo n.º 4
0
 def create_fake_account(self, address, nonce=0, balance=settings.ACCOUNT_BALANCE, code='', storage=None):
     if storage is None:
         storage = {}
     address = to_canonical_address(address)
     account = Account(nonce=nonce, balance=balance)
     self.vm.state._account_db._set_account(address, account)
     if code and code != '':
         self.vm.state._account_db.set_code(address, code)
     if storage:
         for k,v in storage.items():
             self.vm.state._account_db.set_storage(address, int.from_bytes(decode_hex(k), byteorder="big"), int.from_bytes(decode_hex(v), byteorder="big"))
     self.logger.debug("Created account %s with balance %s", encode_hex(address), account.balance)
     return encode_hex(address)
Ejemplo n.º 5
0
 def _get_account(self, address: Address) -> Account:
     if address in self._account_emulator:
         account = self._account_emulator[address]
     elif not self._remote:
         account = Account()
     else:
         code = self._remote.getCode(address, BLOCK_ID)
         if code:
             code_hash = keccak(code)
             self._code_storage_emulator[code_hash] = code
             if self.snapshot != None:
                 self.snapshot["code"][code_hash] = code
         else:
             code_hash = EMPTY_SHA3
         account = Account(
             int(self._remote.getTransactionCount(address, BLOCK_ID)) + 1,
             self._remote.getBalance(address, BLOCK_ID), BLANK_ROOT_HASH,
             code_hash)
         if self.snapshot != None:
             self.snapshot["account"][address] = account
         self._set_account(address, account)
     return account
Ejemplo n.º 6
0
    def _get_account(self,
                     address: Address,
                     from_journal: bool = True) -> Account:
        if from_journal and address in self._account_cache:
            return self._account_cache[address]

        rlp_account = self._get_encoded_account(address, from_journal)

        if rlp_account:
            account = rlp.decode(rlp_account, sedes=Account)
        else:
            account = Account()
        if from_journal:
            self._account_cache[address] = account
        return account