-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(tests): limit number of nilchain payers in tests #36
base: main
Are you sure you want to change the base?
Conversation
2a38eb9
to
14f597e
Compare
455ec7f
to
4edc596
Compare
4edc596
to
965c22b
Compare
@@ -207,7 +207,7 @@ pub struct Nodes { | |||
stash_client: tokio::sync::Mutex<NillionChainClient>, | |||
next_payment_key_id: AtomicU64, | |||
next_signing_key_id: AtomicU64, | |||
funded_payers: tokio::sync::Mutex<Vec<NillionChainClientPayer>>, | |||
funded_payers: ManagedNillionChainClientPayer, |
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.
What was the reasoning behind moving this logic to a new type? This pooling logic could have been here right? You essentially moved the existing funded_payers
to a new type.
use tracing_fixture::{tracing, Tracing}; | ||
use xshell::{cmd, Shell}; | ||
|
||
const PAYER_FUND_CHUNK: usize = 20; | ||
pub const MAX_PAYERS_NUM: usize = 2; |
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.
The idea here was to fund lots of payers in a single TX to speed tests up. If this doesn't slow anything down we might as well have a single payer and get rid of all this pooling logic? e.g. if going from 40+ payers to 2 doesn't slow it down then making it go down to 1 won't either.
I think this was added because of bors r+ tests though, so you likely won't see the slowdown locally. Did you see how much slower it is there?
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.
some test(s) failed when running all of them with 1 payer, i think some tests require two payers?, but let me double check that
Motivation
There is a need to limit the number of payers (blockchain payment accounts) to be created when running functional tests. Right now fixture creates 100 of them.
Solution
This change introduces a pool-based approach using
ManagedNillionChainClientPayer
that creates a fixed number of payer instances (limited byMAX_PAYERS_NUM
) and hands them out in a round-robin fashion via an atomic counter.If multiple tests end up sharing the same payer concurrently, the call submit_payment() is called concurrently but is guarded by an async mutex (inner), only one task acquires the lock at a time, effectively serialising the payment submissions.
Note:
MAX_PAYERS_NUM
is set to2
, and this doesn't affect func tests peformance locally - they finish in 12 - 20 seconds.Fixes #
Design discussion issue (if applicable) #
Merge requirement checklist