question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow `VM` class to specify what `ChainDB` class it uses.

See original GitHub issue

What is wrong?

In #350 the differences between shard collations and blocks required a bit of a hack to make the persist_block_to_db to work with both blocks and collations.

While we could try to sufficiently abstract the API, such as separating things into persist_block_to_db and persist_collation_to_db, I don’t believe this is the right solution. Eventually, we are bound to have either blocks, transactions, or something that require more such logic forks to handle.

Py-EVM has so far largely avoided these types of logic forks in it’s code by sufficiently abstracting the overall API so that underlying implementations can be swapped out within each VM.

How can it be fixed

I think that the Chain class should be modified so that it takes a backend DB type, and then delegates to the active VM for the appropriate block number to get the ChainDB. Each VM class can then define their own ChainDB class. Then the ShardVM class can expose it’s own ChainDB class with modified persist_block_to_db method.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
pipermerriamcommented, Mar 3, 2018

So far this is turning out interesting and I think promising. The VMState object’s usage is basically direct database access so it’s looking like I may be able to completely eliminate the snapshot/commit/revert API as well as moving the API for the account state database to be directly on the VMState object.

1reaction
pipermerriamcommented, Feb 27, 2018

So, maybe to tie this all together, though I’m not confident that I’ve got all the pieces right.

  • Independent adapter implementations for VM give internal flexibility with regard to EVM semantics, enabling different logic for dealing with blocks, transactions, collations.
  • Independent adapter implementations for the VMState currently have no direct need that I see, but the implementation looks pretty simple.
  • Independent adapter implementations for the Chain as well as different implementations of the Chain class itself should enable the Fill/Light/Stateless use cases.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stateless/pure transaction processing #195 - GitHub
I think it would be good to do this as a subclass of evm.db.state.StateDB . It may also require some changes to the...
Read more >
Establish Communication Between Virtual Machines
When you create a VM, a virtual network card is allocated by default, allowing it to access the internet. However, you'll have to...
Read more >
ABC — py-evm 0.5.0-alpha.3 documentation
A class to define a block header without mix_hash and nonce which can act as a temporary representation during mining before the block...
Read more >
Types of Virtual Machines - GeeksforGeeks
In this article, we will study about virtual machines, types of virtual machines, and virtual machine languages.
Read more >
What is a VM? Why Use a Virtual Machine? - DNSstuff
VMs allow for reduced overhead, with multiple systems operating from the ... of the hypervisor software you ultimately choose to use, any VM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found