Giter Site home page Giter Site logo

nekoyume's Introduction

Nekoyume

build coverage pypi chat gitter

Nekoyume is the first MMORPG based on blockchain.

  • Nekoyume is entirely decentralized MMORPG game.
  • Nekoyume uses Dungeon World as a basic rule.
  • To achieve randomness on the blockchain, this project implements Hash random. (Read white paper for details.)

Dependencies

Installation

Installation for development

$ git clone [email protected]:nekoyume/nekoyume.git
$ cd nekoyume
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install -e .[dev,test]
$ git config core.hooksPath hooks
$ nekoyume init

Launching node

$ pip install honcho
$ curl https://raw.githubusercontent.com/nekoyume/nekoyume/master/Procfile > Procfile
$ PORT=5000 honcho start

Mining

$ nekoyume mine "user private key"

Running single node for development

$ cp .env.dist .env
$ docker-compose build
$ docker-compose up

nekoyume's People

Contributors

changhoon-sung avatar chjr avatar dahlia avatar derekdkim avatar earlbread avatar iambenzo avatar incl avatar ipdae avatar jckdotim avatar korean139 avatar leekchan avatar longfin avatar morenice avatar nekoyume-ops avatar qria avatar sconeman avatar ziwon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nekoyume's Issues

Add `doctor` and `repair`

I'll add two things to solve the case when blockchain was broken for several reasons.

  • doctor will detect the problem and show us.
  • repair will remove all of invalid blocks and moves in the database.

Fix errata

I think we have some errata. need to fix it.

Control UNIQUE constraint failed error of neko

Traceback (most recent call last):
  File "/home/ubuntu/nekoyume/.env/bin/nekoyume", line 11, in <module>
    load_entry_point('nekoyume', 'console_scripts', 'nekoyume')()
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/nekoyume/nekoyume/cli.py", line 42, in neko
    click=click,
  File "/home/ubuntu/nekoyume/nekoyume/models.py", line 1193, in create_block
    self.session.commit()
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
    self.transaction.commit()
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
    self._prepare_impl()
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
    self.session.flush()
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
    self._flush(objects)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2380, in _flush
    transaction.rollback(_capture_exception=True)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 249, in reraise
    raise value
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2344, in _flush
    flush_context.execute()
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute
    rec.execute(self)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute
    uow
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
    mapper, table, insert)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 830, in _emit_insert_statements
    execute(statement, multiparams)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 248, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/nekoyume/.env/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 509, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: block.id [SQL: 'INSERT INTO block (id, version, hash, prev_hash, creator, root_hash, suffix, difficulty, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'] [parameters: (5685, 2, '00000fff8660798072c5e59a41f04d4f801ab019b7e68d545607077190bea0c8', '00001bdd9195f0eb2c89c4de273532e6141e340e0d84e80a6075713173b6e795', '0x2a260a110bc7b03f19c40a0bd04ff2c5dcb57594', '9205a6cc2002e27aeb0e3ae011d3ba52484709e3b62cd866bddc4a62a0ce94b8', <memory at 0x7fa2d4d6bf48>, 19, '2018-08-15 02:58:25.528993')] (Background on this error at: http://sqlalche.me/e/gkpj)

Add basic tests

Models

  • Block
    • Block validation
    • Block creation
  • Move
    • Move validation
    • Move creation
  • User
    • Signing
  • Avatar
    • Avatar status based on various Moves

`Block.sync()` raises unexpected duplicated key error.

    Block.sync()
  File "/home/ubuntu/nekoyume/nekoyume/models.py", line 392, in sync
    db.session.commit()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 153, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 943, in commit
    self.transaction.commit()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
    self._prepare_impl()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
    self.session.flush()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2254, in flush
    self._flush(objects)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2380, in _flush
    transaction.rollback(_capture_exception=True)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2344, in _flush
    flush_context.execute()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute
    rec.execute(self)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute
    uow
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
    mapper, table, insert)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 830, in _emit_insert_statements
    execute(statement, multiparams)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) duplicate key value violates unique constraint "block_pkey"
DETAIL:  Key (id)=(16609) already exists.
 [SQL: 'INSERT INTO block (id, hash, prev_hash, creator, root_hash, suffix, difficulty, created_at) VALUES (%(id)s, %(hash)s, %(prev_hash)s, %(creator)s, %(root_hash)s, %(suffix)s, %(difficulty)s, %(created_at)s)'] [parameters: {'id': 16609, 'hash': '000fff02b305d646ac36d488de936903e6c494bdba5ddbed4d8937110935ef4d', 'prev_hash': '00008009cce930028d8cae7eab45e84f1889fe746432046a1a99502c87455a71', 'creator': 'J4tQdMx9tkMEv4f1VKmqbwk9w4x8rW5dDm', 'root_hash': 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'suffix': 'da8', 'difficulty': 11, 'created_at': datetime.datetime(2018, 5, 23, 3, 32, 20, 800464)}] (Background on this error at: http://sqlalche.me/e/gkpj)

Proposal: Compare hashcash algorithm with string comparison and bitwise comparison

It would be a good experiment to compare both methods to implement proof of work(time, visibility, logic).

the one that I wrote:

def run(self):
      nonce = 0
      for i in trange(sys.maxsize, desc="Mining at nonce {i}"):
          # Get flattened data for generating block hash
          data = self.prepare_data(nonce)
          hash = sha256(data.encode()).hexdigest()
          hash_int = int(hash, 16)
          if(hash_int < self.target):
              break
          nonce += 1

      # Set target_bits based on elapsed time for mining
      elapsed = time()

      mine_interval = int(elapsed - self.block.Timestamp)

      self.set_difficulty(mine_interval)


      return nonce, hash

Here is the process

  1. make a hexadecimal string based on hash function run from the block's information
  2. turn the hexadecimal string to integer to get the numerical value
  3. constantly compare with the target integer value with integer from hexadecimal value to satisfy the condition[i.e. leading zeros / trailing zeros(for ethereum)]

It resembles the Ethhash except that I do not reverse the hash(hexadecimal string).

Other resource for my implementation if you want:
Build Blockchain in GO

Korean Translation by mingrammer

Random event of dream

I imagined two things.

  • We can print some random story.
  • We can obtain some random item very rare probability.

Proposal: Using `venv` instead of `virtualenv`

I propose to use venv instead of virtualenv.

Using python3 -m venv instead of virtualenv is recommended by the standard documentation.

And If you create an environment with virtualenv in Python 3.6, and then upgrade to Python 3.7, the virtualenv is broken because you know longer have the shared libraries Python needs. Using venv you can just run python3 -m venv --upgrade.

Following the other player

  • The player can follow the other player
  • The player can see following player's activity on their timeline.

Show item name

Currently, the game is showing the item's ticker symbol (e.g. BNDG)
It is better to show item name for the easy gameplay.
Additionally, we prepare how to show the item's ticker symbol another way.

Add move page

It will be better to make the page which is showing a Move by Move.id

(e.g. https://preview.nekoyu.me/moves/35a6b1592f6d32ac860987699534e0d82dd346da99af043be591970c462a4eb0)

Proposal: rename โ€œnekoโ€ command to โ€œmineโ€

The nekoyume neko command runs a block miner, but it is less likely to guess what it does. There are two assumptions behind the naming that, 1. people knows โ€œnekoโ€ means cat in Japanese, and 2. people knows cat's dreaming is block mining in the Nekoyume world. I find it's somewhat obfuscated, so suggest to add a new nekoyume mine command instead and deprecate the existing nekoyume neko command.

Monster update

At least, I need to add Dark Wood's monsters and some additional master moves.

Update README

Current README.md is little bit outdated.

  • README addresses to use virtualenvwrapper. but I think it is abandoned. need to replace.
  • There is some additional dependencies but we are not addressing.

Yumescan

I think we need block explorer of Nekoyume.

Use setup.cfg instead of fat setup.py to be more declarative

The recent versions of pip and setuptools support a declarative way to describe the package in a setup.cfg file, rather than make a fat setup.py script which is very imperative. It's easier to maintain and reproduce the same environment.

For example, the following setup() function call:

setup(
    name='nekoyume',
    version='0.1.1',
    description='Decentralized MMORPG based on Dungeon World',
    long_description=long_description(),
    url='https://github.com/nekoyume/nekoyume',
    ...

could be rewritten as setup.cfg data:

[metadata]
name = nekoyume
version = 0.1.1
description = Decentralized MMORPG based on Dungeon World
long_description = file: README.rst
url = https://github.com/nekoyume/nekoyume

See also the pyleftpad project for examples.

Proposal: How about using Browser-based Blockchain Network Like Nimiq?

[KO]
README ์•ˆ์— ์žˆ๋Š” ํ…Œ์ŠคํŠธ ๋„คํŠธ์›Œํฌ์— ๋“ค์–ด๊ฐ€์„œ ๊ฒŒ์ž„์„ ํ•ด๋ณด๋ฉด์„œ ๊ตฌ์ง€ ํŒŒ์ด์ฌ ์ชฝ์—์„œ ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ตฌ์„ฑํ•ด์•ผ ๋ ๊นŒ ๊ถ๊ธˆํ•ด์„œ ๋ธŒ๋ผ์šฐ์ € ๋‹จ์—์„œ ๋ชจ๋“  ๋ธ”๋ก์ฒด์ธ ๋„คํŠธ์›Œํฌ๊ฐ€ ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋ฉด ์–ด๋–จ๊ฐ€ ์‹ถ์–ด์„œ ์งˆ๋ฌธ๋“œ๋ ค ๋ด…๋‹ˆ๋‹ค. Nimiq์™€ ๊ฐ™์€ ์‚ฌ๋ก€๋ฅผ ์ฐธ๊ณ ํ•ด์„œ์š”.


[EN]
I've Played nekoyume game on README's Link. But I've thought How about using browser as blokchain network. Like Nimiq.

Proposal: No private key/ public key store or signing process for transactions

So I see command line option here generate private/public key eh?

but I do not see the server handling the transaction signing/ or anything like that.

This is pretty serious issue because everyone can be everyone

for writing a block to ledger you need to sign a transaction to verify that is is generated from oneself

Example

transaction #1:
{
sender: "address which is generated from user's public key(ethereum way) or public key"
recipient: "same thing from sender"
amount :
blockHash:
certificate: <certificate generated from user's private key>
}

Verification

  1. Get sender's public key from sender's address
  2. See if decrypted hash string matches blockHash when the certificate is decrypted by public key
  3. Add transaction to the block

Loopchain just put this with [TODO] and call it as a blockchain.

Proposal: (quasi-)interplayer combat

The current HackAndSlash move (i.e., transaction) does a single-player vs. an NPC combat. It's quite straightforward to design in deterministic way, but there could be more complicated combats without introducing non-deterministic factors.

Since Hash Random, the way to mimic random on the blockchain for games, works in the level of blocks, not transactions, we can involve other moves in the same block, and these move could be made by even other players. This kind of (quasi-)interplayer moves could give Nekoyume more interpersonal playability.

For example, we could introduce a party of multiple players vs. an NPC combat by:

  • organizing a party of players who made a move of the same type, included in a single same block, and
  • determining the same consequence (result) for these moves of the party are involved.

@jckdotim Thoughts?

Private key save button

Currently, people tend to skip saving their auto-generated private key when they met their first page. It will be better providing private key save button so that user can save their private key easily.

Remove redis dependency

Currently, reids is used for two purposes

  • Cache
  • Message Queue Backend (by Celery)

But both are that we can achieve without using redis. (Filesystem cache and RDBMS Backend), So I think we can drop it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.