-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement transaction rollback #142
Comments
I'm currently working around this -- targeting more immediately implementable fixes -- but aside from the more general utility this has, #113 depends on it. |
Yes, it's become much higher priority now you're implementing more complex state tests, and it's an important requirement for the VM operation. We can't fully test computation without it. How it's implemented could well have a big performance impact, so we should start looking at potential designs soon. |
@yglukhov mentioned that he is working on this in our last call IIRC. Conceptually, the roll-back is a very simple thing - you just restore the root hash to a previous state. The What I suggest here is that if this is a blocker for something, you can just take the short-cut of restoring a previous root hash. |
Here's a crude example of what I meant: #144 |
Regarding the design, I prefer a That would leave the state consistent in case of a failure. |
+1 for explicit |
Another +1 -- there tends to be fewer ways to succeed than fail, so in terms of minimizing boilerplate and maximizing clarity, it seems better to put |
This has landed in master with an usage example here: The API is quite straight-forward. A transaction is started with |
what's the explicit |
There must be a |
well, for the code to be correct (exception safety, state rollback etc), you must call |
I assume you meant Most code should just use |
this looks like an invitation for extra error handling code - in this sense, I'd consider In "start doing something else" in the same context as an aborted transaction sounds like an anti-pattern - what would be good examples of this? the whole point of a transaction is to contextually tie together several operations in an atomic all-or-nothing setting |
This is not true. |
That describes one possible use of it - here's the full picture: https://docs.microsoft.com/en-us/dotnet/api/system.idisposable?view=netframework-4.7.2
|
My point was that the call to |
yeah, but that's not the reason both |
Well, I'm not convinced the situation in C# is any different. The recommendation is still to use Maybe that's not very obvious here, but |
We require a 'snapshot' ability to rollback the VM state, for instance if there is an error.
Currently this is a commented stub defined in
nimbus\db\db_chain.nim
.For example, Py-Evm describes it's
snapshot
as:Some example implementation references:
Py-Evm defines its journal here https://github.com/ethereum/py-evm/blob/master/eth/db/journal.py
Parity-Ethereum defines its journal here https://github.com/paritytech/parity-ethereum/tree/master/ethcore/src/snapshot
Go-Ethereum defines its journal here https://github.com/ethereum/go-ethereum/blob/master/core/state/journal.go
The text was updated successfully, but these errors were encountered: