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

Test reserve and fallback builder transaction submission via private mempool #1970

Merged
merged 30 commits into from
Sep 5, 2024

Conversation

shenkeyao
Copy link
Member

Closes #1966, closes #1967.

This PR:

  • Refactors the existing builder test into two tests for the reserve and fallback builders.
  • Adds helper functions for testing setup, including URL picking, solver connection, and transaction submission.
  • Modifies the use of the solver base URL to make it consistent in builder and solver code.

Key places to review:

  • marketplace-builder/src/builder.rs.

How to test this PR:

  • Run the two tests.

Copy link
Member

@elliedavidson elliedavidson left a comment

Choose a reason for hiding this comment

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

Just some small nits is all.

@@ -221,7 +223,7 @@ impl BuilderConfig {
let bid_config = bid_config.expect("Missing bid config for the reserve builder.");
let hooks = Arc::new(hooks::EspressoReserveHooks {
namespaces: bid_config.namespaces.into_iter().collect(),
solver_api_url,
solver_base_url,
Copy link
Member

Choose a reason for hiding this comment

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

Good change! This name is clearer.

Comment on lines +386 to +388
let private_key =
<BLSPubKey as SignatureKey>::PrivateKey::generate(&mut rand::thread_rng());
let signature_key = BLSPubKey::from_private(&private_key);
Copy link
Member

Choose a reason for hiding this comment

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

It might just be how GitHub is displaying the diff, but these seems like the same logic that was at line 381? What is the purpose of the logic here?

Copy link
Member Author

@shenkeyao shenkeyao Sep 4, 2024

Choose a reason for hiding this comment

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

signature_keys is the list of keys that can update the registration, while the signature_key without "s" is the key to sign this registration. Alternatively, I could just create a list of keys and use one of them as the signature_key, but I was using the same implementation as in the mock solver test.

Now that I think about this, this helper function could be helpful for both builder and solver tests, so I'm going to simplify the logic here and move the function to the solver crate. (Update: It turns out that using this helper in the solver crate will require some refactoring not needed by the builder tests, so I'll just keep it in the current crate.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, I could just create a list of keys and use one of them as the signature_key, but I was using the same implementation as in the mock solver test.

I realized that this alternative approach wasn't really better than the current implementation, since we would need to keep track of the index in the list and make a copy of the private key associated with signature_key. The current implementation, though looking a bit redundant, actually does the minimal work needed. I'll just keep it as is unless you think it could be optimized. 😃

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense!

marketplace-builder/src/builder.rs Outdated Show resolved Hide resolved
marketplace-builder/src/builder.rs Outdated Show resolved Hide resolved
@shenkeyao shenkeyao merged commit b121de9 into main Sep 5, 2024
14 of 16 checks passed
@shenkeyao shenkeyao deleted the keyao/test-fallback branch September 5, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants