-
Notifications
You must be signed in to change notification settings - Fork 569
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
refactor: make stricter database trait bounds for user ergonomics #1840
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ use crate::{Database, DatabaseRef}; | |
/// Use [WrapDatabaseAsync] to provide [Database] implementation for a type that only implements this trait. | ||
pub trait DatabaseAsync { | ||
/// The database error type. | ||
type Error: Send; | ||
type Error: core::error::Error + Send; | ||
|
||
/// Get basic account information. | ||
fn basic_async( | ||
|
@@ -48,7 +48,7 @@ pub trait DatabaseAsync { | |
/// Use [WrapDatabaseAsync] to provide [DatabaseRef] implementation for a type that only implements this trait. | ||
pub trait DatabaseAsyncRef { | ||
/// The database error type. | ||
type Error: Send; | ||
type Error: core::error::Error + Send; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider adding a |
||
|
||
/// Get basic account information. | ||
fn basic_async_ref( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ pub use empty_db::{EmptyDB, EmptyDBTyped}; | |
#[auto_impl(&mut, Box)] | ||
pub trait Database { | ||
/// The database error type. | ||
type Error; | ||
type Error: core::error::Error; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider adding a |
||
|
||
/// Get basic account information. | ||
fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Self::Error>; | ||
|
@@ -38,7 +38,7 @@ pub trait Database { | |
|
||
/// EVM database commit interface. | ||
#[auto_impl(&mut, Box)] | ||
pub trait DatabaseCommit { | ||
pub trait DatabaseCommit: Database { | ||
/// Commit changes to the database. | ||
fn commit(&mut self, changes: HashMap<Address, Account>); | ||
} | ||
|
@@ -52,7 +52,7 @@ pub trait DatabaseCommit { | |
#[auto_impl(&, &mut, Box, Rc, Arc)] | ||
pub trait DatabaseRef { | ||
/// The database error type. | ||
type Error; | ||
type Error: core::error::Error; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would consider adding a |
||
|
||
/// Get basic account information. | ||
fn basic_ref(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error>; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ use std::sync::Arc; | |
|
||
#[auto_impl(&mut, Box)] | ||
pub trait State { | ||
type Error; | ||
type Error: core::error::Error + 'static; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this case, it's required by the Given that we don't have any examples of errors borrowing (i.e. all our current databases would meet this bound) it seems pretty reasonble to put it here too. This is just an example lib, and I don't feel strongly about its ergonomics tho I would consider adding a |
||
|
||
/// Get basic account information. | ||
fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Self::Error>; | ||
|
@@ -24,7 +24,7 @@ pub trait State { | |
|
||
#[auto_impl(&, &mut, Box, Rc, Arc)] | ||
pub trait StateRef { | ||
type Error; | ||
type Error: core::error::Error + 'static; | ||
|
||
/// Get basic account information. | ||
fn basic(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider adding a
'static
bound here, as described in https://github.com/bluealloy/revm/pull/1840/files#r1819000225