-
Notifications
You must be signed in to change notification settings - Fork 631
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
Can we split block_hash
into a separate Blockchain
trait?
#298
Comments
I created a reference implementation: #299 |
Seems fine as a solution, but just to ask the question: Why not write a |
The necessity for a wrapper type makes it such that you need to introduce thread-safe synchronisation patterns for the wrapped objects, thus limiting the individual access of two otherwise completely disparate data models |
For history, copying my response from telegram:
So lets do this. We can have those two traits And have |
The only potential downside of combining the two traits into a wrapper trait
but then we're back to the situation where both the My reference implementation still uses the same error type between the two, but that's only because we internally store the error (and I didn't want to do the extra work of changing that before we agreed). |
Lines 22 to 23 in 488ef8a
Could you have that type |
If you want the two traits to allow for separate error types but only pass one trait to the EVM, you'd need two types on the
At that point it's starting to feel like code duplication to me, though. |
Note: I have just noticed that db error is not even returned, it is set when something happens inside EvmData but it is not returned back. Added comment here: #309 (comment) |
Good catch!
Yeah, implementing it like that would indeed avoid having to have two generics on the EVM, so if you prefer adding the wrapper instead, feel free to. In the end the decision is yours 🙂 |
Here is database component idea: https://github.com/bluealloy/revm/blob/primitives/crates/revm/src/db/components.rs will move it to |
I see you opted for code duplication between the |
merged here: #334 |
In our implementation of Project Rethnet for Hardhat, we're running into an issue because we have separate data models for the blockchain (blocks) and state management (accounts, account storage, code) when implementing the
Database[Ref]
traits.A possible solution would be to separate that trait into two traits:
Database[Ref]
for state queries and aBlockchain
trait that directly deals with the blockchain for retrieving block hashes by their block number`.Is this something that you think would make sense for
revm
's internals?If so, would you want to have two separate containers for caching internally?
The text was updated successfully, but these errors were encountered: