Skip to content

removed accounts db v1 code#1235

Open
hamza-syndica wants to merge 7 commits intomainfrom
remove-accountsdb-v1
Open

removed accounts db v1 code#1235
hamza-syndica wants to merge 7 commits intomainfrom
remove-accountsdb-v1

Conversation

@hamza-syndica
Copy link
Contributor

Remove AccountsDB v1, use only AccountsDB v2 (Two.zig)

Summary

  • Removes the legacy AccountsDB v1 implementation (~8,400 lines of code deleted)
  • Consolidates all account storage to use AccountsDB v2 (Two.zig) which uses SQLite for rooted storage
  • Updates all dependent code paths, tests, and documentation
    Deleted Files (v1 code)
  • src/accountsdb/db.zig - Main v1 AccountsDB struct (5,060 lines)
  • src/accountsdb/index.zig - v1 account index implementation (705 lines)
  • src/accountsdb/manager.zig - v1 manager loop for flushing/shrinking/snapshots (1,736 lines)
  • src/accountsdb/swiss_map.zig - v1 high-performance hashmap (931 lines)

Key Changes

  • account_store.zig: Removed accounts_db union variant, now only uses accounts_db_two. Fixed slot 0 edge case in getLatest() and added zero-lamport account filtering
  • cmd.zig: Removed mock_rpc_server command (commented out with TODO for v2 support), removed createSnapshot command
  • benchmarks.zig: Removed v1 benchmarks, added new src/accountsdb/two/benchmarks.zig
  • fuzz.zig: Fuzzer rewritten to use v2 API
  • snapshot/data.zig: Moved helper functions (isZeroLamport, slotCountInBucket, pubkeyBinIndex) from deleted db.zig
  • Two.zig: Added constants migrated from v1 (DB_LOG_RATE, MERKLE_FANOUT, etc.)

Not Yet Implemented in v2

The following v1 features are not yet available in v2:

  • Snapshot generation (generateFullSnapshot, generateIncrementalSnapshot)
  • Geyser integration for streaming accounts from snapshots
  • mock_rpc_server command (requires loadWithDefaults and registerRPCHooks)

@github-project-automation github-project-automation bot moved this to 🏗 In progress in Sig Feb 18, 2026
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 90.80460% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/accountsdb/account_store.zig 76.19% 5 Missing ⚠️
src/rpc/server/server.zig 91.66% 3 Missing ⚠️
Files with missing lines Coverage Δ
src/accountsdb/snapshot/data.zig 89.40% <100.00%> (-1.04%) ⬇️
src/consensus/replay_tower.zig 96.15% <100.00%> (+0.01%) ⬆️
src/replay/freeze.zig 97.04% <ø> (-0.49%) ⬇️
src/runtime/account_loader.zig 97.45% <100.00%> (-0.09%) ⬇️
src/utils/tar.zig 81.57% <ø> (ø)
src/rpc/server/server.zig 95.45% <91.66%> (-2.68%) ⬇️
src/accountsdb/account_store.zig 95.39% <76.19%> (-0.09%) ⬇️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hamza-syndica hamza-syndica marked this pull request as ready for review February 18, 2026 17:15
Copy link
Contributor

@Sobeston Sobeston left a comment

Choose a reason for hiding this comment

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

Seems good, just a couple nits

@github-project-automation github-project-automation bot moved this from 🏗 In progress to 👀 In review in Sig Feb 25, 2026
Sobeston
Sobeston previously approved these changes Feb 26, 2026
Copy link
Contributor

@InKryption InKryption left a comment

Choose a reason for hiding this comment

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

A couple minor comments. Love too see the cruft dismantled.


const Two = @import("Two.zig");
const Rooted = @import("Rooted.zig");
const Unrooted = @import("Unrooted.zig");
Copy link
Contributor

Choose a reason for hiding this comment

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

While I'm personally not hard-set on this, the generally established convention for sig is to import these kinds of things through qualified references, ie

Suggested change
const Unrooted = @import("Unrooted.zig");
const sig = @import("../../sig.zig");
const Two = sig.accounts_db.Two;
const Rooted = Two.Rooted;
const Unrooted = Two.Unrooted;

Given the brevity of Two.Rooted, could consider just removing those aliases as well - I leave that up to you

const random = prng.random();

// Generate random pubkeys
var pubkeys = try allocator.alloc(Pubkey, n_accounts);
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer const by default. No reason for this slice to be in a mutable variable.

}

// Generate random accounts
var accounts = try allocator.alloc(AccountSharedData, n_accounts);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

Comment on lines +159 to +160
const allocator = std.testing.allocator;
_ = allocator;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this here?

Comment on lines +345 to +356
const encoded_data: sig.rpc.methods.GetAccountInfo.Response.Value.Data =
switch (encoding) {
.base64 => blk: {
const encoded_len = std.base64.standard.Encoder.calcSize(raw_data.len);
const encoded_buf = try alloc.alloc(u8, encoded_len);
_ = std.base64.standard.Encoder.encode(encoded_buf, raw_data);
break :blk .{ .encoded = .{ encoded_buf, .base64 } };
},
.base58 => return error.UnsupportedEncoding,
.@"base64+zstd" => return error.UnsupportedEncoding,
.jsonParsed => return error.UnsupportedEncoding,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Fwiw, in cases like these, I find a local alias can help:

Suggested change
const encoded_data: sig.rpc.methods.GetAccountInfo.Response.Value.Data =
switch (encoding) {
.base64 => blk: {
const encoded_len = std.base64.standard.Encoder.calcSize(raw_data.len);
const encoded_buf = try alloc.alloc(u8, encoded_len);
_ = std.base64.standard.Encoder.encode(encoded_buf, raw_data);
break :blk .{ .encoded = .{ encoded_buf, .base64 } };
},
.base58 => return error.UnsupportedEncoding,
.@"base64+zstd" => return error.UnsupportedEncoding,
.jsonParsed => return error.UnsupportedEncoding,
};
const GetAccountInfoResp = sig.rpc.methods.GetAccountInfo.Response;
const base64_encoder = std.base64.standard.Encoder;
const encoded_data: GetAccountInfoResp.Value.Data = switch (encoding) {
.base64 => blk: {
const encoded_len = base64_encoder.calcSize(raw_data.len);
const encoded_buf = try alloc.alloc(u8, encoded_len);
_ = base64_encoder.encode(encoded_buf, raw_data);
break :blk .{ .encoded = .{ encoded_buf, .base64 } };
},
.base58 => return error.UnsupportedEncoding,
.@"base64+zstd" => return error.UnsupportedEncoding,
.jsonParsed => return error.UnsupportedEncoding,
};

Note: base64_encoder.calcSize is not guaranteed to yield the exact size, only an upper bound. The exact-sized buffer is what is returned by encode, so maybe realloc the original encoded_buf so that's resized down to the concrete length before returning it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

4 participants