Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #15749 +/- ##
=======================================
Coverage 82.6% 82.6%
=======================================
Files 935 935
Lines 373761 373743 -18
=======================================
Hits 309048 309048
+ Misses 64713 64695 -18 🚀 New features to boost your workflow:
|
c04623c to
cc2c9b6
Compare
cc2c9b6 to
b15df0c
Compare
|
Joe, you were recommended by github. I'm not sure why. feel free to remove yourself if this isn't relevant. |
certified Banker |
| /// A bank at `slot` over an empty accounts db, with no parent. Store a chain's pre-state | ||
| /// through it, then build the bank under test on it. Leave it unfrozen: freezing writes | ||
| /// slot history into the pre-state. | ||
| pub fn new_at_slot_for_tests(slot: Slot, accounts_db_config: AccountsDbConfig) -> Self { | ||
| let accounts_db = AccountsDb::new_for_tests_with_config(Vec::new(), accounts_db_config); | ||
| let mut bank = Self::default_with_accounts(Accounts::new(Arc::new(accounts_db))); | ||
| bank.slot = slot; | ||
| bank.epoch = bank.epoch_schedule.get_epoch(slot); | ||
| bank.ancestors = Ancestors::from(vec![slot]); | ||
| bank | ||
| } |
There was a problem hiding this comment.
Please no more Bank constructors. We can already create Banks with an AccountsDbConfig via Bank::new_with_paths_for_tests() and its BankTestConfig parameter.
E.g.
let accounts_db_config = AccountsDbConfig { .. };
let bank = Bank::new_with_paths_for_tests(
genesis_config,
Some(BankTestConfig {
accounts_db_config,
}),
vec![],
None,
);| /// A bank at `slot` over an empty accounts db, with no parent. Store a chain's pre-state | |
| /// through it, then build the bank under test on it. Leave it unfrozen: freezing writes | |
| /// slot history into the pre-state. | |
| pub fn new_at_slot_for_tests(slot: Slot, accounts_db_config: AccountsDbConfig) -> Self { | |
| let accounts_db = AccountsDb::new_for_tests_with_config(Vec::new(), accounts_db_config); | |
| let mut bank = Self::default_with_accounts(Accounts::new(Arc::new(accounts_db))); | |
| bank.slot = slot; | |
| bank.epoch = bank.epoch_schedule.get_epoch(slot); | |
| bank.ancestors = Ancestors::from(vec![slot]); | |
| bank | |
| } |
There was a problem hiding this comment.
I was trying to largely keep the conformance tests state consistent with the current state.
They create an accountsDb at slotN-1, and then create a new slot at SlotN to test things such as leader schedule.
This was the best way I saw to not change the output bank.
The other tests could use new_with_paths, but the function would still need to live in bank.rs unless some fields moved to public.
Another option is modifying the new_for_tests_with_config API to allow for a slot to be passed in.
There was a problem hiding this comment.
What I'm intending to convey is to inline changes to the Bank as needed. E.g. make the bank mut and set slot/epoch/ancestors as needed.
Although I'm thinking this can be simplified further.
E.g. in:
// Populate the accounts DB with the input accounts at the parent slot.
let bank_accounts = new_accounts_for_tests_single_threaded();
let ancestors = Ancestors::from(vec![parent_slot]);
bank_accounts.store_accounts(
(parent_slot, &accounts[..]),
BankId::default(),
None,
&ancestors,
);
bank_accounts.accounts_db.add_root(parent_slot);
let bank_rc = BankRc::new(bank_accounts);Can we create the BankRc earlier, and use its bank id generator, thus ensuring the next Bank that is created later--which uses the same BankRc--gets a unique BankId via the generator's call to next()?
There was a problem hiding this comment.
Yeah, one option would be creating the BankRc and working directly on the BankRc.
eg:
// Accounts DB config and initialization
let bank_rc = BankRc::new(new_accounts_for_tests_single_threaded());
let bank_id = bank_rc.bank_id_generator.next(),
bank_rc.accounts.store_accounts(
(parent_slot, &accounts_to_store[..]),
bank_rc.bank_id_generator.next(),
None,
&Ancestors::default(),
);
brooksprumo
left a comment
There was a problem hiding this comment.
My understanding is that this PR will rebase on top of #15796 once merged.
Commenting so this PR isn't in my 'awaiting review' queue. Please re-request review once ready though!
|
Closing in favor of #15830 |
Problem
Some tests currently create an accounts_db, store some accounts and then wrap it a bank. This will cause issues when bankId is used as the write cache index, as both slots will use the same bankId.
Summary of Changes
Testing
Fixes #