-
Notifications
You must be signed in to change notification settings - Fork 87
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
Remove auction_transaction #2283
Conversation
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 like the change of the table turning Option<from/nonce> to an Option<AuctionID>
. In fact this could probably be its own PR.
However, I think we should explore populating the auction id field already in the event handler that inserts the original settlement (it should have access to all required information). This way we don't need to create the extra "auction_kind" column which I find quite confusing (as the db values don't match the values on the struct) and don't run into the issue of first requiring one event handler to run before the other one does.
I'm not sure what this means for transitioning, but we could for a while have both systems run in parallel (and assert that the upsert doesn't really change any values other than at the moment of the release when it may be catching up with old auctions).
|
||
// Wait a bit more to not race with the event indexer. | ||
// Otherwise we might miss event and have to wait for next block to retrigger | ||
// loop. | ||
tokio::time::sleep(std::time::Duration::from_secs(1)).await; |
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.
Relying on a fixed time sleep here is super hacky. I think having one block delay wouldn't be so bad, but if it's a must I think we should combine the two event updater (which one is the other one?) and make sure they are processing events in the order we want them to.
Ok(None) | ||
Some(score) => { | ||
if score.winner.0 != tx_from.0 { | ||
tracing::warn!( |
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.
Should this and not being able to recover auction_id from calldata be error logs now (or even return an error)?
CREATE TYPE AuctionKind AS ENUM ('valid', 'invalid', 'unprocessed'); | ||
|
||
ALTER TABLE settlements | ||
ADD COLUMN auction_kind AuctionKind NOT NULL DEFAULT 'unprocessed', |
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.
Are we relying on this default anywhere? If not, can we drop it (I'd rather us use as little fancy SQL features as possible and set all values explicitly in code)
sqlx::PgConnection, | ||
web3::types::Transaction, | ||
}; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub enum AuctionKind { |
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'm not a fan of this type. It has the same entropy as an Option<AuctionId>
with the added complication that in the database it exists in three flavours (including unprocessed)
I did a detailed exploration of this before starting to work on this issue and it can't be done without extra web3 call to get the transaction and decode the |
We are doing this in My suggested plan of action would be:
Wdyt? |
You can do (1) but you still need to keep the Your plan sounds good but it's more involving and I don't we will make it for zero fee launch. I personally see benefit in separating |
I removed the Could I get a review please. |
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.
Once merged, I think the OnSettlementEventUpdater
will try to process the first settlement
without auction_id
which will be some pre-colocation settlement for which the recovery of auction_id
from calldata will fail and it will be stuck.
crates/database/src/settlements.rs
Outdated
.await | ||
} | ||
|
||
pub async fn data_exists(ex: &mut PgConnection, auction_id: i64) -> Result<bool, sqlx::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.
this now means already_processed
instead of data_exists
, I guess
You are right! Pre-colocation production transactions would fail on staging and vice versa. Do you think hardcoding a min block (past colocation launch) would be an ok workaround for this? Edit: this would require a different block per chain which is a bit annoying :-( |
I think that's ok and we can remove it at a later stage of refactoring. |
Would there be an issue with populating a fake auction ID (e.g. -1) for items that are far in the past and cannot be matched? |
I think theoretically this could also happen when solvers start running their own driver (until we have a new smart contract version that enforces the existence of auction_id) so we definitely want to overcome this error and continue processing other settlements. From the top of my head, I don't think -1 would cause something bad (would have to go through the codebase and double check all |
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.
Approving with comment (since I cant approve my own PR 😄 )
The only thing I noticed is that we changed the way we handle InvalidSelector
error on decoding the transaction, but I think this can't happen after colocation (it could happen before colocation because we saved auction_transaction
entry during competition time).
Description
Part of #2282 & #2275
Exchanges
tx_from/tx_nonce
forauction_id
which can be directly encoded from the settlement transaction since we shipped colocation. This allows us to remove an entire database table and a bunch of other complicated code.I'm not yet removing the old columns in case something goes bad with this change.
Changes
auction_transaction
table.settlements
table to contain auction idHow to test
auction_transaction
record (except one settlement (block_number 3), to simulate the existence of settlement from other environment staging/prod)settlements
table,auction_id
were populated as expected.