From ffcfdf7f91e728c986b166fc72d6ee3ae98eef15 Mon Sep 17 00:00:00 2001 From: palmerlao Date: Tue, 27 Jan 2026 13:55:37 -0800 Subject: [PATCH 1/3] Add trace regions for cache, disk, and in progress account requests --- pkg/accountsdb/accountsdb.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/accountsdb/accountsdb.go b/pkg/accountsdb/accountsdb.go index 1b578b5d..24deb284 100644 --- a/pkg/accountsdb/accountsdb.go +++ b/pkg/accountsdb/accountsdb.go @@ -210,16 +210,21 @@ func (accountsDb *AccountsDb) GetAccount(slot uint64, pubkey solana.PublicKey) ( } func (accountsDb *AccountsDb) getStoredAccount(slot uint64, pubkey solana.PublicKey) (*accounts.Account, error) { + r := trace.StartRegion(context.Background(), "GetStoredAccountCache") cachedAcct, hasAcct := accountsDb.VoteAcctCache.Get(pubkey) if hasAcct { + r.End() return cachedAcct, nil } cachedAcct, hasAcct = accountsDb.CommonAcctsCache.Get(pubkey) if hasAcct { + r.End() return cachedAcct, nil } + r.End() + defer trace.StartRegion(context.Background(), "GetStoredAccountDisk").End() acctIdxEntryBytes, c, err := accountsDb.Index.Get(pubkey[:]) if err != nil { //mlog.Log.Debugf("no account found in accountsdb for pubkey %s: %s", pubkey, err) @@ -276,6 +281,7 @@ func (accountsDb *AccountsDb) getStoredAccount(slot uint64, pubkey solana.Public // Returns a slice of the same length as the input with results matching indexes, nil if not found. // Returns clones to avoid data races with the store worker. func (accountsDb *AccountsDb) getStoreInProgressAccounts(pks []solana.PublicKey) []*accounts.Account { + defer trace.StartRegion(context.Background(), "getStoreInProgressAccounts").End() out := make([]*accounts.Account, len(pks)) accountsDb.inProgressStoreRequestsMu.Lock() defer accountsDb.inProgressStoreRequestsMu.Unlock() From 4d6e734dcb3167ecbd60e1b8518b3da1a8fc99ef Mon Sep 17 00:00:00 2001 From: palmerlao Date: Tue, 27 Jan 2026 18:01:58 -0800 Subject: [PATCH 2/3] Only trace transactions when enabled --- pkg/replay/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/replay/transaction.go b/pkg/replay/transaction.go index 533bcfd5..1cb6e32e 100644 --- a/pkg/replay/transaction.go +++ b/pkg/replay/transaction.go @@ -299,7 +299,7 @@ func verifySignatures(tx *solana.Transaction, slot uint64, sigverifyWg *sync.Wai } func ProcessTransaction(slotCtx *sealevel.SlotCtx, sigverifyWg *sync.WaitGroup, tx *solana.Transaction, txMeta *rpc.TransactionMeta, dbgOpts *DebugOptions, arena *arena.Arena[sealevel.BorrowedAccount]) (*fees.TxFeeInfo, error) { - if slotCtx.TraceCtx != nil { + if trace.IsEnabled() && slotCtx.TraceCtx != nil { region := trace.StartRegion(slotCtx.TraceCtx, "ProcessTransaction") defer region.End() From d4db8357a454b43152219bf289cff14e781eee1c Mon Sep 17 00:00:00 2001 From: palmerlao Date: Tue, 27 Jan 2026 18:02:09 -0800 Subject: [PATCH 3/3] Batch ALT lookups --- pkg/replay/block.go | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/pkg/replay/block.go b/pkg/replay/block.go index 93f64c22..2f2e7f17 100644 --- a/pkg/replay/block.go +++ b/pkg/replay/block.go @@ -206,30 +206,42 @@ func resolveAddrTableLookups(accountsDb *accountsdb.AccountsDb, block *b.Block) continue } - var skipLookup bool for _, addrTableKey := range tx.Message.GetAddressTableLookups().GetTableIDs() { - if _, alreadyLoaded := tables[addrTableKey]; alreadyLoaded { - continue - } - - acct, err := accountsDb.GetAccount(block.Slot, addrTableKey) - if err != nil { - skipLookup = true - break - } + tables[addrTableKey] = nil + } + } - addrLookupTable, err := sealevel.UnmarshalAddressLookupTable(acct.Data) - if err != nil { - return err - } + tablesSlice := make([]solana.PublicKey, 0, len(tables)) + for t := range tables { + tablesSlice = append(tablesSlice, t) + } + accts, err := accountsDb.GetAccountsBatch(context.Background(), block.Slot, tablesSlice) + if err != nil { + return err + } - tables[addrTableKey] = addrLookupTable.Addresses + for i := range tablesSlice { + if len(accts[i].Data) == 0 { + delete(tables, tablesSlice[i]) + continue + } + addrLookupTable, err := sealevel.UnmarshalAddressLookupTable(accts[i].Data) + if err != nil { + return err } + tables[tablesSlice[i]] = addrLookupTable.Addresses + } - if skipLookup { +txResolveLoop: + for _, tx := range block.Transactions { + if !tx.Message.IsVersioned() || tx.Message.AddressTableLookups.NumLookups() == 0 { continue } - + for _, addrTableKey := range tx.Message.GetAddressTableLookups().GetTableIDs() { + if _, ok := tables[addrTableKey]; !ok { + continue txResolveLoop + } + } err := tx.Message.SetAddressTables(tables) if err != nil { return err