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

get loaded accounts #212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions grpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,10 @@ func blockContainsAccounts(block *old_faithful_grpc.BlockResponse, accounts []st
}

for _, tx := range block.Transactions {
decoded, err := iplddecoders.DecodeTransaction(tx.Transaction)
decoder := bin.NewBinDecoder(tx.GetTransaction())
solTx, err := solana.TransactionFromDecoder(decoder)
if err != nil {
klog.Warningf("Failed to decode transaction: %w", err)
continue // skip if there's error decoding
}
solTx, err := decoded.GetSolanaTransaction()
if err != nil {
klog.Warningf("Failed to get sol transaction: %w", err)
klog.Errorf("Failed to decode transaction: %v", err)
continue
}

Expand All @@ -696,6 +692,18 @@ func blockContainsAccounts(block *old_faithful_grpc.BlockResponse, accounts []st
}
}

meta, err := solanatxmetaparsers.ParseTransactionStatusMetaContainer(tx.Meta)
if err != nil {
klog.Errorf("Failed to parse transaction meta: %v", err)
}

loadedAccounts := meta.GetLoadedAccounts()
keys := byteSlicesToKeySlice(loadedAccounts)
for _, key := range keys {
if _, exists := accountSet[key.String()]; exists {
return true
}
}
}

return false
Expand Down Expand Up @@ -789,7 +797,7 @@ func (multi *MultiEpoch) processSlotTransactions(
}

for _, tx := range block.Transactions {
decoder := bin.NewBinDecoder(tx.Transaction)
decoder := bin.NewBinDecoder(tx.GetTransaction())
txn, err := solana.TransactionFromDecoder(decoder)
if err != nil {
return status.Errorf(codes.Internal, "Failed to decode transaction: %v", err)
Expand Down
7 changes: 7 additions & 0 deletions solana-tx-meta-parsers/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ func (c *TransactionStatusMetaContainer) GetSerdeOldest() *metaoldest.Transactio
return c.vSerdeOldest
}

func (c *TransactionStatusMetaContainer) GetLoadedAccounts() [][]byte {
if c.vProtobuf != nil {
return append(c.vProtobuf.LoadedReadonlyAddresses, c.vProtobuf.LoadedWritableAddresses...)
}
return nil
}

func ParseTransactionStatusMeta(buf []byte) (*confirmed_block.TransactionStatusMeta, error) {
var status confirmed_block.TransactionStatusMeta
err := proto.Unmarshal(buf, &status)
Expand Down
Loading