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

accounts-db: initial implementation #40

Closed
wants to merge 54 commits into from
Closed

accounts-db: initial implementation #40

wants to merge 54 commits into from

Conversation

0xNineteen
Copy link
Contributor

@0xNineteen 0xNineteen commented Oct 19, 2023

@0xNineteen 0xNineteen changed the title 19/bank snapshot logic: code to deserialize bank-fields + accountsdb-fields metadata Oct 19, 2023
@0xNineteen 0xNineteen changed the title snapshot logic: code to deserialize bank-fields + accountsdb-fields metadata snapshot logic: code to deserialize bank/accountsdb metadata Oct 19, 2023
@0xNineteen 0xNineteen changed the title snapshot logic: code to deserialize bank/accountsdb metadata snapshot logic: deserialize bank/accountsdb metadata Oct 19, 2023
@0xNineteen 0xNineteen marked this pull request as ready for review October 19, 2023 21:58
@0xNineteen 0xNineteen linked an issue Dec 6, 2023 that may be closed by this pull request
20 tasks
@0xNineteen 0xNineteen mentioned this pull request Dec 6, 2023
20 tasks
@0xNineteen 0xNineteen changed the title snapshot logic: deserialize bank/accountsdb metadata snapshot: deserialize bank/accountsdb metadata Dec 6, 2023
@0xNineteen 0xNineteen changed the title snapshot: deserialize bank/accountsdb metadata accounts-db: deserialize bank/accountsdb metadata Dec 7, 2023
0xNineteen and others added 7 commits December 15, 2023 15:23
`build.zig`
- make it easy to add new executables with all the required modules

`src/core/accounts_file.zig`
- logic for parsing accounts out of a file

`pubkey.zig`
- removed `cached_str` optimization so we can directly case bytes to the pubkey struct (used when parsing account files)

`src/cmd/snapshot_utils.zig` 
- snapshot utils for: 
  - dumping the `accounts_db.bincode` from the full bank metadata (the full bank metadata is quite large, and we only need the accounts_db fields  to correctly parse the append_vecs) 
  - dump accounts found in append vec into a .csv format (_note_: current approach contains duplicate accounts (ie, multiple slots))
`src/common/accounts_db.zig`
- loading account files + indexing pubkeys 
- verification of snapshot data

`src/common/merkle_tree.zig`
- simple merkle tree hash calculation 

`src/core/account.zig`
- logic for hashing account

`test_data`
- new local snapshot .zstd (same size as genesis.bin)
- matching genesis.bin 
- both used in the accounts-db test

### dev notes: 
- snapshot data / load / verification can take a long time because the mainnet snapshots are so big - so we use the validator + the `solana-ledger-tool` to create smaller local snapshots and load from those
    - _note:_ when doing this the accounts-hash will use the current slot in the hash calculation (because the local slot < feature activation slot) fyi
`bitvec.zig` / `bloom.zig`
- move BitVecConfig from bloom.zig to bitvec.zig 

`clock.zig` -renamed-> `time.zig`

`accounts_db.zig`
- reorg functions to get accounts better `getAccount` (pubkey), `getAccountInner` (file_id, offset) `getAccountType` (get account + cast with data type)
- read and validate status_cache code `validateStatusCache` 

`snapshot_fields.zig` 
- add error enums (required for status cache deser) 

`sysvars.zig`
- add common sysvar pubkeys + structs 

`test_data`
- add an example status_cache to read from for tests
`bincode.zig`
- fix optional EOF fields parsing (we dont need this anymore)

`accounts_db.zig`
- main functions changes: 
  - `loadFromSnapshot` now only takes accounts_db fields 
  - `computeAccountHashesAndLamports`: computes the accounts hash + accounts-delta hash depending on validating a full snapshot or incremental 
  - `validateLoadFromSnapshot`: only validates the accounts-db fields now 
  - add full/incremental snapshot path parsing - needed for finding snapshots + matching incremental snapshots 
  - `unpackZstdTarBall` - decompresses and untars a snapshot 
  - `main` - the full flow of loading the accounts-db and validating (will turn into full validator code) 

`bank.zig`
- rn just includes bank validation against genesis 

`snapshot_fields.zig`
- changes to properly parse incremental snapshot fields + include additional tests 
- `validateStatusCache`

`test_data`
- use different snapshot files (still small - just needed to build a fresh set during testing)
@0xNineteen 0xNineteen changed the title accounts-db: deserialize bank/accountsdb metadata accounts-db: initial implementation Dec 15, 2023
src/core/accounts_db.zig Outdated Show resolved Hide resolved
@0xNineteen 0xNineteen closed this Feb 29, 2024
@0xNineteen 0xNineteen deleted the 19/bank branch March 3, 2024 08:38
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.

Initial AccountsDB implementation
2 participants