-
Notifications
You must be signed in to change notification settings - Fork 27
feat(gateway): bundle support #260
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
base: refactor/devex
Are you sure you want to change the base?
Conversation
| impl Bundle<OpTxEnvelope> { | ||
| /// Returns the bundle hash of the bundle. | ||
| pub fn bundle_hash(&self) -> B256 { | ||
| // SAFETY: At this point, the bundle hash is guaranteed to be initialized. |
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.
Safety comments are for unsafe codes, not unwraps, normally
|
|
||
| /// Validates the bundle, including signature validation of included transactions. | ||
| /// | ||
| /// This is a CPU-intensive operation. |
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.
Maybe worth using rayon and par_iter?
| } | ||
|
|
||
| pub fn bundle_hash(&self) -> B256 { | ||
| // SAFETY: At this point, the bundle hash is guaranteed to be initialized. |
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.
same
|
|
||
| impl SimulatedBundle { | ||
| /// Creates a new unsimulated bundle from a validated bundle. | ||
| pub fn new(validated: Arc<ValidatedBundle>) -> Self { |
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.
It feels counter to the type that we can create an unsimulated simulated bundle, and because of that a lot of methods later have to return options...
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.
Fully agree, was not the greatest abstraction here. We should revisit this.
To do: revisit SimulatedBundle abstraction, because it doesn't make sense and can contain unsimulated bundles.
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.
| self.block_number.hash(state); | ||
| self.transactions.hash(state); | ||
| // FIXME: This is actually not fully compatible with <https://docs.titanbuilder.xyz/api/eth_sendbundle#bundle-hash>, | ||
| // because they use strings for the reverting tx hashes. |
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.
We should address this before merging as it's pretty hidden tbh but the fix afaik should be simple enough
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.
The bundle hash is not going to be compatible anyway until all the fields match. Seems like a bit of a waste to first hex encode it, and then hash it, for all transactions
| /// Sends a new order to the order pool. | ||
| fn handle_new_order(&mut self, order: Order, ctx: &mut SequencerContext<Db>, senders: &SendersSpine<Db>) { | ||
| // Add the (unsimulated) order to the TOF snapshot. | ||
| // TODO(mempirate): This might cause issues because it hasn't been simulated, where do we add sim info? |
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 think you handled it, no?
|
|
||
| // Commit to State's in-memory cache (not the underlying db) | ||
| // so subsequent transactions see these state changes | ||
| // TODO(mempirate): validate that this is actually the case and we're not committing to underlying db |
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.
Maybe we can wrap the DB in this function to ensure this?
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 took a look at this and it seems like we shouldn't do .commit_ref(&result_and_state.state); here. It does seem to commit into the underlying db (the cache not all the way to on-disk db) which could mess up the sorting logic. I think what @Karrq suggest should work. Maybe you can add DBBundle on top of DBSorting.
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.
| let _ = std::mem::replace(evm.db_mut(), State::new(db)); |
But doesn't this wrap the provided DB into a new State cache? When we call commit_ref, it seems to be called on that State cache that was just created
5655742 to
8f108bd
Compare
Closes #258