-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update genesis processing to have a fallback collector id for tests #34135
Update genesis processing to have a fallback collector id for tests #34135
Conversation
9a0b007
to
0c51e1b
Compare
d1f78fa
to
c89ddda
Compare
c89ddda
to
313438e
Compare
313438e
to
6f3a7d3
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #34135 +/- ##
=======================================
Coverage 81.8% 81.8%
=======================================
Files 824 824
Lines 222394 222405 +11
=======================================
+ Hits 181957 181973 +16
+ Misses 40437 40432 -5 |
is there something stopping us from fixing up the |
That was my initial approach but it was too unruly. One thing I ran into is that it should still be possible to create a |
8146144
to
7388d39
Compare
runtime/src/bank.rs
Outdated
self.collector_id = self | ||
.stakes_cache | ||
.stakes() | ||
.highest_staked_node() | ||
.unwrap_or_else(Pubkey::new_unique); | ||
.or(test_collector_id) |
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.
Would it be worse to create-and-store this collector id instead? (And maybe manually add it to stakes cache too.) Then it would actually be a proper stake account.
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 collector id is the "node id" but yeah we could create a stake account and vote account which delegate stake to the collector id. I'll play around with this.. just wary of breaking dozens of tests with brittle assumptions
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.
[..] wary of breaking dozens of tests with brittle assumptions
I definitely understand this...
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.
Thinking about this more, wouldn't it be strange if extra accounts were stored that weren't defined in the genesis?
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.
is a genesis with no collector a reasonable thing? barring tests that don't strictly need one, that is. this is almost certainly yet another case of data structure abuse that would justify refactor
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.
I would like to just add a genesis_collector_id
to the genesis but we can't make backwards incompatible changes to that struct
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.
we can make a wrapper for tests and a trait though, right?
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.
Yeah, we can. It involves updating hundreds of tests and I don't have the time for that.
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.
just gross enough to prevent overuse and encourage a refactor 👍
* wrap test_collector_id in DCOU * rename param to collector_id_for_tests
efcb085
to
00ef349
Compare
I'd like to merge as is, I would also like to this be a bit cleaner but cleaning up the tests is too much of a burden and it's inconvenient that genesis can't be modified to specify an initial collector. |
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.
Looks good to me (but I'm biased a bit). One open question on my end.
@@ -1041,7 +1041,7 @@ impl Bank { | |||
debug_do_not_add_builtins: bool, | |||
accounts_db_config: Option<AccountsDbConfig>, | |||
accounts_update_notifier: Option<AccountsUpdateNotifier>, | |||
#[cfg(feature = "dev-context-only-utils")] collector_id_for_tests: Option<Pubkey>, | |||
#[allow(unused)] collector_id_for_tests: Option<Pubkey>, |
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.
I guess something in the build didn't like marking this parameter as DCOU?
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.
Yeah, there was a call-site that didn't have DCOU handling and then I just figured it was easier to handle internally. What do you think? Is it confusing that the parameter is ignored?
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.
Yeah, there was a call-site that didn't have DCOU handling and then I just figured it was easier to handle internally.
Gotcha, thanks.
What do you think? Is it confusing that the parameter is ignored?
I think it's a little confusing, but... the whole codebase is a little confusing, heh. So doesn't seem too confusing IMO.
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.
"easier" is not really what we should be optimizing for at this point in the project's maturity
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.
Yeah "easier" is not the best word to use there. The main issue is that Rust doesn't let you conditionally add parameters to a function call and so it means duplicating the call site which is a worse dev experience than having an unused parameter.
Problem
When creating bank 0 for tests, oftentimes the genesis config doesn't include a staked node. This means that bank creation has to arbitrarily pick a node id for block 0 in order for bank creation to succeed. The arbitrary node id was recently updated to be a random unique pubkey in #33887 but as discussed here we need to make sure this path is never hit by tests.
Summary of Changes
test_collector_id: Option<Pubkey>
toBank::new_with_paths
which can be used as a fallback collector id if no staked nodes are defined in the genesis. This arg is set toNone
in call-sites that aren't related to testing or benchmarks.Fixes #