code: func MakeGenesisState(db dbm.DB, genesisDoc *genesis.GenesisDoc) (*State, error) {
  	s := NewState(db)
  
  	const errHeader = "MakeGenesisState():"
  	// Make accounts state tree
  	for _, genAcc := range genesisDoc.Accounts {
  		perm := genAcc.Permissions
  		acc := &acm.Account{
  			Address:     genAcc.Address,
  			Balance:     genAcc.Amount,
  			Permissions: perm,
  		}
  		err := s.writeState.UpdateAccount(acc)
  		if err != nil {
  			return nil, fmt.Errorf("%s %v", errHeader, err)
  		}
  	}
  	// Make genesis validators
  	err := s.writeState.MakeGenesisValidators(genesisDoc)
  	if err != nil {
  		return nil, fmt.Errorf("%s %v", errHeader, err)
  	}
  	// global permissions are saved as the 0 address
  	// so they are included in the accounts tree
  	globalPerms := permission.DefaultAccountPermissions
  	globalPerms = genesisDoc.GlobalPermissions
  	// XXX: make sure the set bits are all true
  	// Without it the HasPermission() functions will fail
  	globalPerms.Base.SetBit = permission.AllPermFlags
  
  	permsAcc := &acm.Account{
  		Address:     acm.GlobalPermissionsAddress,
  		Balance:     1337,
  		Permissions: globalPerms,
  	}
  	err = s.writeState.UpdateAccount(permsAcc)
  	if err != nil {
  		return nil, fmt.Errorf("%s %v", errHeader, err)
  	}
  
  	return s, nil
  }
docs: // Make genesis state from GenesisDoc and save to DB