Skip to content

Hide competition until deadline passes#4330

Open
fafk wants to merge 9 commits intomainfrom
hide-competition
Open

Hide competition until deadline passes#4330
fafk wants to merge 9 commits intomainfrom
hide-competition

Conversation

@fafk
Copy link
Copy Markdown
Contributor

@fafk fafk commented Apr 14, 2026

Description

Hides solver competition API data until the auction's submission deadline block has passed. Feature-gated via hide-competition-before-deadline (default off) to avoid breaking external solver monitoring that depends on these endpoints.

Changes

  • Added hide-competition-before-deadline bool to orderbook config (default false)
  • Wired CurrentBlockWatcher into AppState so handlers can check the current block
  • Return 404 while deadline hasn't passed
  • E2E test updated to exercise both the 404 and the post-deadline visibility

How to test

cargo test -p e2e 'solver_competition::local_node_solver_competition' -- --exact --ignored 

@fafk fafk requested a review from a team as a code owner April 14, 2026 06:45
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a hide_competition_before_deadline configuration to restrict solver competition data visibility until the auction deadline is reached. Feedback identifies a performance issue in the V1 API implementation where an additional database query is executed per request, suggesting a join or DTO update instead. Additionally, a correction was suggested for error handling consistency when acquiring database connections in the new get_auction_deadline method.

@fafk fafk force-pushed the hide-competition branch from 7afc406 to 39e4f02 Compare April 14, 2026 10:56
Copy link
Copy Markdown
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Last nit: I think we should use <= block since the observed block already happened and revealing the information now can no longer affect the auction in question.

-- exclude settlements from another environment for which observation is guaranteed to not exist
WHERE sc.id = $1
LEFT JOIN competition_auctions ca ON sc.id = ca.id
WHERE sc.id = $1 AND ($2::bigint IS NULL OR ca.deadline < $2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WHERE sc.id = $1 AND ($2::bigint IS NULL OR ca.deadline < $2)
WHERE sc.id = $1 AND ($2::bigint IS NULL OR ca.deadline <= $2)

-- outer joins because the data might not have been indexed yet
LEFT OUTER JOIN settlements s ON sc.id = s.auction_id
LEFT JOIN competition_auctions ca ON sc.id = ca.id
WHERE ($2::bigint IS NULL OR ca.deadline < $2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WHERE ($2::bigint IS NULL OR ca.deadline < $2)
WHERE ($2::bigint IS NULL OR ca.deadline <= $2)

JOIN settlements s ON sc.id = s.auction_id
LEFT JOIN competition_auctions ca ON sc.id = ca.id
WHERE sc.id = (SELECT id FROM competition) AND s.solution_uid IS NOT NULL
AND ($2::bigint IS NULL OR ca.deadline < $2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AND ($2::bigint IS NULL OR ca.deadline < $2)
AND ($2::bigint IS NULL OR ca.deadline <= $2)

const FETCH_AUCTION_ID: &str = r#"
SELECT id
FROM competition_auctions
WHERE ($1::bigint IS NULL OR deadline < $1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WHERE ($1::bigint IS NULL OR deadline < $1)
WHERE ($1::bigint IS NULL OR deadline <= $1)

SELECT id, order_uids, price_tokens, price_values, block, deadline
FROM competition_auctions
WHERE id = $1;
WHERE id = $1 AND ($2::bigint IS NULL OR deadline < $2);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WHERE id = $1 AND ($2::bigint IS NULL OR deadline < $2);
WHERE id = $1 AND ($2::bigint IS NULL OR deadline <= $2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants