<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_or_instantiate_db_state(working_dir):
 """ Get a read-only handle to the DB. Instantiate it first if it doesn't exist. DO NOT CALL WHILE INDEXING Returns the handle on success Raises on error """


    # instantiates
    new_db = BlockstackDB.borrow_readwrite_instance(working_dir, -1)
    BlockstackDB.release_readwrite_instance(new_db, -1)

    return get_db_state(working_dir)