-
Notifications
You must be signed in to change notification settings - Fork 3
fix: driver maintenance #17
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
Changes from 1 commit
d963f41
4592bf9
c47c6bc
0fdb1be
f500dde
d533bdf
6d10e8b
55a5e09
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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| use signet_types::MarketError; | ||
| use std::fmt::Debug; | ||
| use trevm::{ | ||
| revm::{primitives::EVMError, Database}, | ||
| BundleError, | ||
| }; | ||
|
|
||
| /// Errors that can occur when running a bundle on the Signet EVM. | ||
| #[derive(thiserror::Error)] | ||
| pub enum SignetBundleError<Db: Database> { | ||
| /// A primitive [`BundleError`] error ocurred. | ||
| #[error(transparent)] | ||
| BundleError(#[from] BundleError<Db>), | ||
| /// A [`MarketError`] ocurred. | ||
| #[error(transparent)] | ||
| MarketError(#[from] MarketError), | ||
| } | ||
|
|
||
| impl<Db: Database> Debug for SignetBundleError<Db> { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| SignetBundleError::BundleError(e) => write!(f, "BundleError({:?})", e), | ||
| SignetBundleError::MarketError(e) => write!(f, "MarketError({:?})", e), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<Db: Database> From<EVMError<Db::Error>> for SignetBundleError<Db> { | ||
| fn from(e: EVMError<Db::Error>) -> Self { | ||
| SignetBundleError::BundleError(BundleError::EVMError { inner: e }) | ||
| } | ||
| } | ||
|
|
||
| impl<Db: Database> SignetBundleError<Db> { | ||
| /// Instantiate a new [`SignetBundleError`] from a [`Database::Error`]. | ||
| pub const fn evm_db(e: Db::Error) -> Self { | ||
| SignetBundleError::BundleError(BundleError::EVMError { inner: EVMError::Database(e) }) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,12 +4,22 @@ use trevm::{revm::primitives::BlockEnv, Block}; | |
|
|
||
| impl Block for SignetCallBundle { | ||
| fn fill_block_env(&self, block_env: &mut BlockEnv) { | ||
| block_env.number = | ||
| self.bundle.state_block_number.as_number().map(U256::from).unwrap_or(block_env.number); | ||
| block_env.timestamp = self.bundle.timestamp.map(U256::from).unwrap_or(block_env.timestamp); | ||
| block_env.gas_limit = self.bundle.gas_limit.map(U256::from).unwrap_or(block_env.gas_limit); | ||
| block_env.difficulty = | ||
| self.bundle.difficulty.map(U256::from).unwrap_or(block_env.difficulty); | ||
| block_env.basefee = self.bundle.base_fee.map(U256::from).unwrap_or(block_env.basefee); | ||
| let BlockEnv { | ||
| number, | ||
| coinbase, | ||
| timestamp, | ||
| gas_limit, | ||
| basefee, | ||
| difficulty, | ||
| prevrandao: _, | ||
| blob_excess_gas_and_price: _, | ||
| } = block_env; | ||
|
|
||
| *number = self.bundle.state_block_number.as_number().map(U256::from).unwrap_or(*number); | ||
| *coinbase = self.bundle.coinbase.unwrap_or(*coinbase); | ||
|
Member
Author
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. bugfix is here, coinbase was previously not set
Member
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. great catch
Member
Author
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. ya it's why i recommend destructuring in the implementation guide. easy to forget things |
||
| *timestamp = self.bundle.timestamp.map(U256::from).unwrap_or(*timestamp); | ||
| *gas_limit = self.bundle.gas_limit.map(U256::from).unwrap_or(*gas_limit); | ||
| *difficulty = self.bundle.difficulty.map(U256::from).unwrap_or(*difficulty); | ||
| *basefee = self.bundle.base_fee.map(U256::from).unwrap_or(*basefee); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,7 @@ impl SignetCallBundle { | |
| } | ||
|
|
||
| /// Create a market context from the fills in this bundle. | ||
| pub fn make_context(&self, host_chain_id: u64) -> MarketContext { | ||
| pub fn build_context(&self, host_chain_id: u64) -> MarketContext { | ||
| let mut context = MarketContext::default(); | ||
| self.host_fills.iter().for_each(|(asset, fills)| { | ||
| fills.iter().for_each(|(recipient, amount)| { | ||
|
|
@@ -280,6 +280,18 @@ impl core::ops::DerefMut for SignetCallBundleResponse { | |
| } | ||
| } | ||
|
|
||
| impl AsRef<EthCallBundleResponse> for SignetCallBundleResponse { | ||
| fn as_ref(&self) -> &EthCallBundleResponse { | ||
| &self.inner | ||
| } | ||
| } | ||
|
|
||
| impl AsMut<EthCallBundleResponse> for SignetCallBundleResponse { | ||
| fn as_mut(&mut self) -> &mut EthCallBundleResponse { | ||
| &mut self.inner | ||
| } | ||
| } | ||
|
|
||
| impl From<EthCallBundleResponse> for SignetCallBundleResponse { | ||
| fn from(inner: EthCallBundleResponse) -> Self { | ||
| Self { inner } | ||
|
|
@@ -294,7 +306,7 @@ impl From<SignetCallBundleResponse> for EthCallBundleResponse { | |
|
|
||
| impl SignetCallBundleResponse { | ||
| /// Accumulate a transaction result into the response. | ||
| pub fn accumulate_tx_result(&mut self, tx_result: EthCallBundleTransactionResult) { | ||
| fn accumulate_tx_result(&mut self, tx_result: EthCallBundleTransactionResult) { | ||
|
Member
Author
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. using this instead of |
||
| self.inner.total_gas_used += tx_result.gas_used; | ||
| self.inner.gas_fees += tx_result.gas_fees; | ||
| self.inner.results.push(tx_result); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.