Skip to content

Commit

Permalink
Insert default auciton id when we cannot decode it from the auction (#…
Browse files Browse the repository at this point in the history
…2333)

# Description
We got stuck indexing
https://etherscan.io/tx/0x45a80857fb7c7e56375617ac7a5427903a95a2ff41f302ce3527a91fcee695b4
because we cannot decode the auction id from the calldata (it's not
encoded).

# Changes
- [x] Insert the default auciton ID and not auction data in case we
cannot recover the auction ID from calldata

## How to test
Added an e2e test which is failing on current main.
  • Loading branch information
fleupold authored Jan 29, 2024
1 parent 565bf1e commit bc5e7a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/autopilot/src/on_settlement_event_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ impl OnSettlementEventUpdater {
let (auction_id, auction_data) =
match Self::recover_auction_id_from_calldata(&mut ex, &transaction).await? {
AuctionIdRecoveryStatus::InvalidCalldata => {
return Ok(false);
// To not get stuck on indexing the same transaction over and over again, we
// insert the default auction ID (0)
(Default::default(), None)
}
AuctionIdRecoveryStatus::DoNotAddAuctionData(auction_id) => (auction_id, None),
AuctionIdRecoveryStatus::AddAuctionData(auction_id, settlement) => (
Expand Down
16 changes: 16 additions & 0 deletions crates/e2e/tests/e2e/univ2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ async fn test(web3: Web3) {
);
let uid = services.create_order(&order).await.unwrap();

// Mine a trivial settlement (not encoding auction ID). This mimics fee
// withdrawals and asserts we can handle these gracefully.
tx!(
solver.account(),
onchain.contracts().gp_settlement.settle(
Default::default(),
Default::default(),
Default::default(),
[
vec![(trader.address(), U256::from(0), Default::default())],
Default::default(),
Default::default()
],
)
);

tracing::info!("Waiting for trade.");
let trade_happened =
|| async { token.balance_of(trader.address()).call().await.unwrap() != 0.into() };
Expand Down

0 comments on commit bc5e7a4

Please sign in to comment.