Skip to content
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

Driver settle queue tests #3133

Draft
wants to merge 10 commits into
base: settle-queue-to-driver
Choose a base branch
from

Conversation

squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Nov 22, 2024

Description

An attempt to properly test #3129. The idea is to send multiple /settle requests to the same driver to check that some will be discarded due to the settlement queue limit. To achieve that, I found the easiest way to introduce some delay in the settlement process on the driver's side by using the existing ethrpc batch delay, which is used to wait for a certain amount of time before sending the call to accumulate a batch.

It turned out, that this config was hardcoded, so it was required to enable it in the arguments first to use properly in tests.

Changes

  • A driver's test that validates the settlement queue limit works as expected.
  • Start using ethrpc arguments in the Driver's config.
  • Since a delay is incorporated into all RPC calls, the solve deadline has to be increased in the tests.

Important

ethrpc_max_batch_size = 20 must be added to the Driver's infra config since the default value is 100, which is currently used by other components. And only Driver uses 20. https://github.com/cowprotocol/infrastructure/pull/2301

How to test

This is the test.

@squadgazzz squadgazzz changed the base branch from main to settle-queue-to-driver November 22, 2024 15:12
@squadgazzz squadgazzz marked this pull request as ready for review November 22, 2024 18:11
@squadgazzz squadgazzz requested a review from a team as a code owner November 22, 2024 18:11
Comment on lines +40 to +45
impl Default for Arguments {
fn default() -> Self {
Arguments::parse_from([""])
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is needed 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case only deriving the Default trait, values from clap are not used.

Copy link
Contributor

Choose a reason for hiding this comment

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

but in that case, we could make these Arguments as optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case, the caller side would need to define default values, no? Didn't get the idea here.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant is something like this: #2924

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That didn't really help. Making this config optional would mean that the caller side will be responsible for the values that need to be used by default. While with the current approach, only one struct controls the default values.

Copy link
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.

Using the ethrpc configurations seems weird to make this test work.
Did you consider using anvil's helper methods instead?
You could first disable auto mining and manually clear the mempool to make sure that transactions actually do not get mined so that the submission futures don't return.

.len();
assert_eq!(unique_solutions_count, solution_ids.len());

// `collect_vec` is required to execute futures in the same order.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure this is not true. Can you explain why collecting into a vec should make a difference here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without collecting, the order of the results will be unpredictable.

test.solve(),
test.solve(),
test.solve(),
test.solve(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to make /solve return errors when the queue is already full. Otherwise the solver could continue winning auctions and later get slashed because it can no longer submit them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea, I will address it in the original PR then.

@squadgazzz squadgazzz force-pushed the driver-settle-queue-tests branch 2 times, most recently from de75f95 to 2efbcfe Compare November 28, 2024 10:26
@squadgazzz
Copy link
Contributor Author

You could first disable auto mining and manually clear the mempool to make sure that transactions actually do not get mined so that the submission futures don't return.

Oh, that is cool, didn't know about that. Will try to use this instead.

@squadgazzz squadgazzz marked this pull request as draft November 28, 2024 11:32
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