omgnetwork / plasma-mvp

OmiseGO's research implementation of Minimal Viable Plasma
MIT License
561 stars 158 forks source link

Make ChildChain stateful #112

Closed smartcontracts closed 5 years ago

smartcontracts commented 6 years ago

As per the discussion at #32, it makes sense to have ChildChain maintain state. We've already gone ahead and made the CLI stateless as per #102.

Every new block to the child chain should be stored in some DB. We should abstract the DB (see pyethereum for an example) so that we can plug in any DB back-end. I think we'll probably also want an option to run the DB in-memory so we don't need to wipe everything before each unit test.

Van0k commented 6 years ago

Is help needed with this? I think I could handle that.

The plan is: The aforementioned implementation from pyethereum could be used for DB abstraction (_EphemDB could be used for in-memory state storage and as default). Then

# dictionary reads
self.block[blknum]

# dictionary writes
self.block[blknum] = my_block

should be replaced by

# DB reads
self.db.get(blknum)

# DB writes
self.db.put(blknum, my_block)

and db should be passed as an argument to constructor.