Skip to content

Commit

Permalink
get loaded accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
anjor committed Dec 18, 2024
1 parent 3ed45d2 commit e3e58c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
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

0 comments on commit e3e58c8

Please sign in to comment.