code: def genesis(chain_class: BaseChain,
              db: BaseAtomicDB=None,
              params: Dict[str, HeaderParams]=None,
              state: GeneralState=None) -> BaseChain:
      
      if state is None:
          genesis_state = {}  # type: AccountState
      else:
          genesis_state = _fill_and_normalize_state(state)
  
      genesis_params_defaults = _get_default_genesis_params(genesis_state)
  
      if params is None:
          genesis_params = genesis_params_defaults
      else:
          genesis_params = merge(genesis_params_defaults, params)
  
      if db is None:
          base_db = AtomicDB()  # type: BaseAtomicDB
      else:
          base_db = db
  
      return chain_class.from_genesis(base_db, genesis_params, genesis_state)
docs: Initialize the given chain class with the given genesis header parameters
      and chain state.