Skip to content
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
349 commits
Select commit Hold shift + click to select a range
82bd47c
Refactor account_tokens.go for streaming with deterministic IDs
aditya1702 Jan 13, 2026
fd5377c
Update ingest_live.go to use simplified token API
aditya1702 Jan 13, 2026
04aa638
Update ingest_backfill.go to use simplified token API
aditya1702 Jan 13, 2026
6e15236
make check and fix tests
aditya1702 Jan 13, 2026
f4fd6b6
refactor: ProcessTokenChanges accepts dbTx for outer transaction part…
aditya1702 Jan 13, 2026
c17d254
refactor: EnsureTrustlineAssetsExist accepts dbTx for outer transaction
aditya1702 Jan 13, 2026
26da9fb
refactor: GetOrInsertContractTokens uses DB query instead of cache
aditya1702 Jan 13, 2026
03e743a
refactor: consolidate live ingestion into single atomic transaction
aditya1702 Jan 13, 2026
652a368
refactor: remove knownContractIDs in-memory cache from ingestService
aditya1702 Jan 13, 2026
36e68a7
refactor: consolidate backfill token operations into single transaction
aditya1702 Jan 13, 2026
ba8b18f
refactor: update TokenCacheWriterMock for new signatures
aditya1702 Jan 13, 2026
6979cba
fix make check
aditya1702 Jan 13, 2026
c45d777
increase trustline batch size
aditya1702 Jan 13, 2026
1b03d61
Update account_tokens.go
aditya1702 Jan 13, 2026
0421d9d
Use deterministic IDs for contract tokens
aditya1702 Jan 13, 2026
c56088c
fix make check
aditya1702 Jan 13, 2026
83506eb
refactor: Replace FetchAndStoreMetadata with FetchMetadata + BatchIns…
aditya1702 Jan 13, 2026
98c1615
refactor: Remove FetchAndStoreMetadata from ContractMetadataService i…
aditya1702 Jan 13, 2026
f2c3c5b
refactor: Remove FetchAndStoreMetadata implementation
aditya1702 Jan 13, 2026
2d5f459
refactor: Remove storeInDB helper and unused pgx import
aditya1702 Jan 13, 2026
706b02c
test: Remove FetchAndStoreMetadata and storeInDB tests
aditya1702 Jan 13, 2026
cffb082
Update ingest_live.go
aditya1702 Jan 13, 2026
25f5a2c
store unique trustline assets and contract IDs from token changes
aditya1702 Jan 13, 2026
b5f5043
fix: Update test helpers to use deterministic IDs and fix mock return…
aditya1702 Jan 13, 2026
29a7d57
fix: Update GraphQL resolver tests to use new GetAccountContracts ret…
aditya1702 Jan 13, 2026
96fa59d
fix: Fix remaining GraphQL resolver test failures
aditya1702 Jan 13, 2026
29eea24
fix: Update Test_ingestService_processTokenChanges for new implementa…
aditya1702 Jan 13, 2026
7fa6d29
fix: Update startBackfilling catchup mode tests for new implementation
aditya1702 Jan 13, 2026
968bde4
chore: change trustline_assets.id from BIGINT to UUID
aditya1702 Jan 13, 2026
8911f86
chore: change contract_tokens.id from BIGINT to UUID
aditya1702 Jan 13, 2026
d820503
chore: change account_trustlines and account_contracts IDs from BIGIN…
aditya1702 Jan 13, 2026
ac915bb
refactor: migrate trustline_assets.go from FNV-64 to UUID v5
aditya1702 Jan 13, 2026
ad27ff8
refactor: migrate contract_tokens.go from FNV-64 to UUID v5
aditya1702 Jan 13, 2026
067f518
refactor: migrate account_tokens.go from int64 to uuid.UUID
aditya1702 Jan 13, 2026
051716a
refactor: update ContractModelMock.BatchGetByIDs to use uuid.UUID
aditya1702 Jan 13, 2026
6aef762
refactor: migrate services/account_tokens.go from int64 to uuid.UUID
aditya1702 Jan 13, 2026
54dcf99
fix tests
aditya1702 Jan 13, 2026
afdc51c
Update ingest_live.go
aditya1702 Jan 13, 2026
d1486b0
Add schema migration for trustline balance tracking
aditya1702 Jan 13, 2026
1b62d1c
Add TrustlineAsset to SAC balance state changes
aditya1702 Jan 13, 2026
31de9d9
Add BatchUpdateBalances method to data layer
aditya1702 Jan 13, 2026
54dafdf
Update checkpoint population to extract and store trustline balances
aditya1702 Jan 13, 2026
7c20a70
Implement updateTrustlineBalances for live ingestion
aditya1702 Jan 13, 2026
11ae492
add GetTrustlinesWithBalances function tokenCacheService
aditya1702 Jan 14, 2026
cf91e55
Add additional fields to account trustlines table
aditya1702 Jan 14, 2026
aaf22e5
update data layer
aditya1702 Jan 14, 2026
cb70d36
process trustline updates too
aditya1702 Jan 14, 2026
704b99d
process trustline changes with full XDR data
aditya1702 Jan 14, 2026
3470542
Remove method to update balances
aditya1702 Jan 14, 2026
8f83a88
Change TrustlineWithFullData to Trustline
aditya1702 Jan 14, 2026
315f10d
Consolidate trustline queries into single GetTrustlines method with JOIN
aditya1702 Jan 14, 2026
d92520b
Remove BatchGetByIDs from trustline_assets
aditya1702 Jan 14, 2026
fdf419a
Simplify TokenCacheReader interface for trustlines
aditya1702 Jan 14, 2026
4257ce2
Update graphql resolver to use new trustline balance calls
aditya1702 Jan 14, 2026
be96290
fix all tests - 1
aditya1702 Jan 14, 2026
7ef3e44
fix tests - 2
aditya1702 Jan 14, 2026
2b6d61a
Fix tests - 3
aditya1702 Jan 14, 2026
bc96c58
remove unused functions
aditya1702 Jan 14, 2026
3c05b56
Add TrustLinesProcessor and integrate into indexer
aditya1702 Jan 14, 2026
ea5de02
Call TrustLinesProcessor and remove StateChangeCategoryTrustline conv…
aditya1702 Jan 14, 2026
10f0b23
Simplify parseTrustline - remove XDR field extraction
aditya1702 Jan 14, 2026
962835b
Remove WithTrustlineXDRFields from StateChangeBuilder
aditya1702 Jan 14, 2026
0ef46fa
Remove trustline XDR fields from StateChange struct
aditya1702 Jan 14, 2026
d9ae3db
fix make check
aditya1702 Jan 14, 2026
667bcd5
remove unused function
aditya1702 Jan 14, 2026
df0e2aa
Update trustlines.go
aditya1702 Jan 14, 2026
d19698c
Add migration for account_native_balances table
aditya1702 Jan 14, 2026
8dcdb6d
Add AccountChange type for native balance tracking
aditya1702 Jan 14, 2026
9b2c5dc
Add AccountsProcessor for native balance tracking
aditya1702 Jan 14, 2026
cf4ca36
Add account changes to IndexerBuffer
aditya1702 Jan 14, 2026
b08bfc1
Wire AccountsProcessor into Indexer with generic interface
aditya1702 Jan 14, 2026
e2afef5
Add NativeBalance type and DB methods to data layer
aditya1702 Jan 14, 2026
2afe938
Add native balance to account tokens
aditya1702 Jan 14, 2026
35c500e
Update ingestion to process account changes
aditya1702 Jan 14, 2026
e633124
Pass account changes through ingestion pipeline
aditya1702 Jan 14, 2026
745f8c5
Update GraphQL resolvers to read native balance from DB
aditya1702 Jan 14, 2026
a7aee8b
fix make check
aditya1702 Jan 14, 2026
24c68ff
remove redundant function to upsert trustlines
aditya1702 Jan 14, 2026
4715086
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 14, 2026
a4b66ef
Update account_tokens.go
aditya1702 Jan 14, 2026
70d22d0
refactor: consolidate contract and trustline batch functions in data …
aditya1702 Jan 14, 2026
a6012b1
refactor: update service layer to use consolidated batch functions
aditya1702 Jan 14, 2026
26487fc
test: update tests for consolidated batch functions
aditya1702 Jan 14, 2026
c0fdaf2
test: update service layer tests for new batch function names
aditya1702 Jan 14, 2026
bf88fcf
remove unused code
aditya1702 Jan 14, 2026
1de9854
Fix failing tests
aditya1702 Jan 14, 2026
20e1e87
Add account_sac_balances table and SACBalanceChange type
aditya1702 Jan 14, 2026
8e6255e
Add SACBalancesProcessor to extract SAC balances from ledger changes
aditya1702 Jan 14, 2026
9099790
Wire SACBalancesProcessor into indexer and add buffer methods
aditya1702 Jan 14, 2026
d900904
Add SACBalance CRUD methods to data layer
aditya1702 Jan 14, 2026
e6b8fbb
Update ProcessTokenChanges to handle SAC balance changes
aditya1702 Jan 14, 2026
06a6721
Update checkpoint population to extract and store SAC balances
aditya1702 Jan 14, 2026
e7f68df
Update GraphQL resolver to read SAC balances from DB
aditya1702 Jan 14, 2026
aa0297f
Store SAC balances while checkpointing
aditya1702 Jan 14, 2026
90715c4
fix make check
aditya1702 Jan 14, 2026
845e62b
fix make check - 2
aditya1702 Jan 14, 2026
5d14675
Use SAC balances from DB
aditya1702 Jan 14, 2026
912f0c1
Use SAC balances from DB - 2
aditya1702 Jan 14, 2026
360d38e
Use ContractBalanceFromContractData function to parse balanc eentry c…
aditya1702 Jan 14, 2026
57d0bf5
Update token_transfer.go
aditya1702 Jan 15, 2026
6c742eb
change TrustLines -> Trustlines
aditya1702 Jan 15, 2026
9c84ccf
Create trustlines_test.go
aditya1702 Jan 15, 2026
ed819f2
Update internal/data/account_tokens.go
aditya1702 Jan 15, 2026
93f7116
Update internal/data/account_tokens.go
aditya1702 Jan 15, 2026
afac0ed
Update internal/data/trustline_assets.go
aditya1702 Jan 15, 2026
26e92fa
Update internal/db/migrations/2025-12-14.0-trustline_assets.sql
aditya1702 Jan 15, 2026
40ea015
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
a06b341
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 15, 2026
6e856dc
Update mocks.go
aditya1702 Jan 15, 2026
c8e54e9
Remove tokenCacheReader interface
aditya1702 Jan 15, 2026
f7389d1
rename files and remove unused method
aditya1702 Jan 15, 2026
9c5e47a
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 15, 2026
8201c58
Add GetNativeBalance method
aditya1702 Jan 15, 2026
55394f8
insert native balances within same batch during checkpoint population
aditya1702 Jan 15, 2026
973bb0e
Add TrustlineBalanceModel for focused trustline balance operations
aditya1702 Jan 15, 2026
d7fa1a7
Add AccountContractTokensModel for focused contract mapping operations
aditya1702 Jan 15, 2026
e40679e
Consolidate migrations: rename table to account_trustline_balances
aditya1702 Jan 15, 2026
35673ae
Update Models struct to use new focused model interfaces
aditya1702 Jan 15, 2026
a0eea75
Split migrations into separate files per model
aditya1702 Jan 15, 2026
0cba06b
Update TokenIngestionService to use new focused models
aditya1702 Jan 15, 2026
1c81707
Update GraphQL resolvers to use new focused models
aditya1702 Jan 15, 2026
872b72d
Update serve.go dependency injection for new model interfaces
aditya1702 Jan 15, 2026
c928381
Update ingest.go to use new model interfaces
aditya1702 Jan 15, 2026
02cd9c6
Update first two test cases to use new model interfaces
aditya1702 Jan 15, 2026
2fae304
Update success test cases (SAC, SEP-41, mixed, contract, trustline V0)
aditya1702 Jan 15, 2026
e83f4dd
Update error and edge case tests to use new model interfaces
aditya1702 Jan 15, 2026
74953e2
Update BalancesByAccountAddresses tests to use new model interfaces
aditya1702 Jan 15, 2026
9e40e7d
Fix error message assertion in partial failure test
aditya1702 Jan 15, 2026
ae99455
Delete old account_tokens.go file (replaced by focused models)
aditya1702 Jan 15, 2026
3e3a427
Delete old account_tokens_test.go (tests for deleted AccountTokensModel)
aditya1702 Jan 15, 2026
32660e4
Update token_ingestion_test.go to use new focused model interfaces
aditya1702 Jan 15, 2026
48b3633
Fix wrapcheck lint error in balance_reader.go
aditya1702 Jan 15, 2026
2b4626b
fix make check
aditya1702 Jan 15, 2026
20e74ef
rename migration files and tables
aditya1702 Jan 15, 2026
99710d5
Update account_contract_tokens.go
aditya1702 Jan 15, 2026
f0c76af
Update trustline_balance.go
aditya1702 Jan 15, 2026
4eaf754
fix typo
aditya1702 Jan 15, 2026
596ca7a
remove unused methods from contract tokens data model
aditya1702 Jan 15, 2026
c4c8b69
fix tests
aditya1702 Jan 15, 2026
713f89b
directly use token changes from buffer
aditya1702 Jan 15, 2026
dbc891c
Add tests for trustline_balances
aditya1702 Jan 15, 2026
651ce2f
Use BatchCopy for inserting new trustlines
aditya1702 Jan 15, 2026
ac2fa47
Revert "Use BatchCopy for inserting new trustlines"
aditya1702 Jan 15, 2026
d52d2ec
Merge main_balances_postgres with PostgreSQL-only storage
aditya1702 Jan 15, 2026
c42a2d4
Remove redis container setup from integration tests
aditya1702 Jan 15, 2026
4a5576a
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
fb3a7da
Update ingest_test.go
aditya1702 Jan 15, 2026
975bcef
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
0edb007
Update ingest_backfill.go
aditya1702 Jan 15, 2026
e8b5dd8
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
8c129dc
Directly call buffer to get trustline and contract changes
aditya1702 Jan 15, 2026
c6e9422
fix make check
aditya1702 Jan 15, 2026
d8b3337
fix failing test
aditya1702 Jan 15, 2026
3fab5a5
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 15, 2026
353b162
Merge calculate-balances-using-changes into store-native-balance
aditya1702 Jan 15, 2026
8a0a37c
Update account_balances_test.go
aditya1702 Jan 15, 2026
7868a7f
Update ingest_backfill.go
aditya1702 Jan 15, 2026
baa47b6
Fix failing tests
aditya1702 Jan 15, 2026
f175e75
Add unit tests for AccountsProcessor
aditya1702 Jan 15, 2026
ca68a5d
Add unit tests for NativeBalanceModel
aditya1702 Jan 15, 2026
490dbbc
Fix NativeBalanceModel test expectations for not-found case
aditya1702 Jan 15, 2026
708a568
store only the latest trustline balance change
aditya1702 Jan 16, 2026
b9ad300
Change token ingestion flow to directly insert without sorting
aditya1702 Jan 16, 2026
d964fce
Update mocks.go
aditya1702 Jan 16, 2026
dfc9689
make check
aditya1702 Jan 16, 2026
2d78bbb
update backfill logic for catchup
aditya1702 Jan 16, 2026
b40a663
merge trustline changes properly
aditya1702 Jan 16, 2026
0d46ae1
merge unique assets and contract ID maps
aditya1702 Jan 16, 2026
ca2e4c1
process batch changes within same txn
aditya1702 Jan 16, 2026
dea1053
Merge calculate-balances-using-changes into store-native-balance
aditya1702 Jan 16, 2026
c5fd0dd
refactor: change accountChanges from slice to map in IndexerBuffer
aditya1702 Jan 16, 2026
845778f
refactor: update IndexerBufferInterface for map-based account changes
aditya1702 Jan 16, 2026
59a5c78
refactor: update ingest_backfill.go for map-based account changes
aditya1702 Jan 16, 2026
ddc0c58
refactor: simplify ProcessTokenChanges for pre-deduplicated account c…
aditya1702 Jan 16, 2026
3b5420d
refactor: update TokenIngestionServiceMock for map-based account changes
aditya1702 Jan 16, 2026
3666981
fix make check
aditya1702 Jan 16, 2026
c7ca787
Add minimum_balance column
aditya1702 Jan 16, 2026
866d7ce
Add minimum balance, buying L, selling L to graphql native balance re…
aditya1702 Jan 16, 2026
cace424
fix make check
aditya1702 Jan 16, 2026
46c9065
Add NativeBalance fragment to GraphQL client queries
aditya1702 Jan 16, 2026
b29189c
Add missing fields to NativeBalance client type
aditya1702 Jan 16, 2026
c5b7263
Fix checkpoint population to calculate MinimumBalance
aditya1702 Jan 16, 2026
77d6e37
Update integration tests to verify native balance updates
aditya1702 Jan 16, 2026
c0a4ac8
Update account_balances_test.go
aditya1702 Jan 16, 2026
a379bec
Merge store-native-balance into store-sep41-balance with SAC balance …
aditya1702 Jan 16, 2026
36d2aa2
Merge branch 'store-native-balance' into store-sep41-balance
aditya1702 Jan 16, 2026
65a2bbe
streamline SAC balance entry processing
aditya1702 Jan 16, 2026
3d9fee9
store all contract tokens at the end during checkpointing
aditya1702 Jan 16, 2026
1ccec34
fix failing tests
aditya1702 Jan 16, 2026
1fdd6e8
update balance resolver to read SAC balances from DB
aditya1702 Jan 16, 2026
2ab56d0
copilot review changes
aditya1702 Jan 16, 2026
e87f854
Update account_balances_test.go
aditya1702 Jan 16, 2026
6a54d5f
fix error comparison
aditya1702 Jan 16, 2026
b1fada6
fix issues - 1
aditya1702 Jan 16, 2026
469ad8f
Use BIGINT for last modified ledger
aditya1702 Jan 16, 2026
b152f69
change last modified ledger to BIGINT
aditya1702 Jan 16, 2026
9855e2d
update table name
aditya1702 Jan 16, 2026
d70ccfd
Add tests for SAC processors
aditya1702 Jan 17, 2026
4fda222
Refactor: Replace GetAllContractIDs with GetExisting for scalability
aditya1702 Jan 19, 2026
5d3ca3f
Remove dead mock methods from TokenCacheWriterMock
aditya1702 Jan 19, 2026
94ec655
Update stale Redis references in test comments and error messages
aditya1702 Jan 19, 2026
e0ebc97
Fix prepareNewContracts call in ingest_backfill.go
aditya1702 Jan 19, 2026
4f47e72
Add deferred FK constraints on account tokens tables
aditya1702 Jan 19, 2026
6d7efba
Merge redis-to-postgres into calculate-balances-using-changes
aditya1702 Jan 19, 2026
d4e393c
Add deferred FK constraints on account tokens tables
aditya1702 Jan 19, 2026
8392d4a
Clean up minor code issues in token ingestion
aditya1702 Jan 19, 2026
8118c64
Update stellar_rpc_config.toml
aditya1702 Jan 19, 2026
36e8e7e
Update backfill_helpers.go
aditya1702 Jan 19, 2026
671a781
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 19, 2026
9ce0d30
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 19, 2026
6adcd48
Use uint32 in graphql for last modified ledger
aditya1702 Jan 19, 2026
77dea34
Merge store-native-balance into store-sep41-balance
aditya1702 Jan 19, 2026
6fcffe8
Add FK constraint to sac_balances table
aditya1702 Jan 19, 2026
9ca90a6
Add error logging in GraphQL balance resolver
aditya1702 Jan 19, 2026
e1772f5
Add buffer test coverage for SAC balance operations
aditya1702 Jan 19, 2026
7953ee3
Add balance validation and define constants for SAC balance fields
aditya1702 Jan 19, 2026
abe267a
Fix test addresses to use valid 56-character format
aditya1702 Jan 19, 2026
a83055e
refactor SAC entries processing
aditya1702 Jan 20, 2026
75c9902
Only insert sep41 token relationships for accounts
aditya1702 Jan 20, 2026
45e1746
Only insert sep41 account token relationships - 2
aditya1702 Jan 20, 2026
47e3d28
Add SACInstanceProcessor to extract SAC contract metadata
aditya1702 Jan 20, 2026
cb3ae04
Add SAC contract tracking to IndexerBuffer
aditya1702 Jan 20, 2026
a30aa40
Wire SACInstanceProcessor in indexer
aditya1702 Jan 20, 2026
0f7591b
change function name
aditya1702 Jan 20, 2026
d44f988
Extend prepareNewContractTokens to include SAC contracts
aditya1702 Jan 20, 2026
9fe307c
Add tests for SACInstanceProcessor
aditya1702 Jan 20, 2026
fdaa8f5
Process SAC instances to extract new assets
aditya1702 Jan 20, 2026
cf75e84
Add proper logging for inserted items in DB
aditya1702 Jan 20, 2026
148603f
Update ingest_live.go
aditya1702 Jan 20, 2026
98b0312
fix failing unit tests
aditya1702 Jan 20, 2026
7d8a110
Update token_ingestion.go
aditya1702 Jan 20, 2026
1c05dc3
Update token_ingestion.go
aditya1702 Jan 20, 2026
ab8c062
fetch missing SAC metadata using RPC
aditya1702 Jan 20, 2026
49cad15
return error for metadata fetching failures
aditya1702 Jan 20, 2026
7957b46
Reduce batch size and set synchronous commit = off
aditya1702 Jan 20, 2026
6e99936
use CopyFromSlice for better type checking
aditya1702 Jan 28, 2026
ca586f7
Merge branch 'redis-to-postgres' into calculate-balances-using-changes
aditya1702 Jan 28, 2026
c677dd7
Use CopyFromSlice for strict checking
aditya1702 Jan 28, 2026
62e3b0e
remove unused network passphrase
aditya1702 Jan 28, 2026
9e5008d
Merge branch 'calculate-balances-using-changes' into store-native-bal…
aditya1702 Jan 28, 2026
e2532e9
remove unused network passphrase
aditya1702 Jan 28, 2026
e615ce5
make check
aditya1702 Jan 28, 2026
c206a1d
Use Greater instead of GreaterOrEqual
aditya1702 Jan 28, 2026
6927bc7
Add assertion for minimum balance
aditya1702 Jan 28, 2026
7175785
Merge branch 'store-native-balance' into store-sep41-balance
aditya1702 Jan 28, 2026
35ee238
use utils isContractAddress function
aditya1702 Jan 28, 2026
2ba6bf1
Update sac_balances.go
aditya1702 Jan 28, 2026
ab6a54d
simplify balance fields extraction for SAC balances
aditya1702 Jan 28, 2026
5e32dfc
Merge branch 'main_balances_postgres' into store-sep41-balance
aditya1702 Jan 28, 2026
c6ed55b
fix tests
aditya1702 Jan 28, 2026
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
2 changes: 0 additions & 2 deletions cmd/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ func (c *ingestCmd) Command() *cobra.Command {
utils.IngestServerPortOption(&cfg.ServerPort),
utils.AdminPortOption(&cfg.AdminPort),
utils.GetLedgersLimitOption(&cfg.GetLedgersLimit),
utils.RedisHostOption(&cfg.RedisHost),
utils.RedisPortOption(&cfg.RedisPort),
utils.EnableParticipantFilteringOption(&cfg.EnableParticipantFiltering),
{
Name: "ingestion-mode",
Expand Down
2 changes: 0 additions & 2 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ func (c *serveCmd) Command() *cobra.Command {
utils.GraphQLComplexityLimitOption(&cfg.GraphQLComplexityLimit),
utils.MaxAccountsPerBalancesQueryOption(&cfg.MaxAccountsPerBalancesQuery),
utils.MaxGraphQLWorkerPoolSizeOption(&cfg.MaxGraphQLWorkerPoolSize),
utils.RedisHostOption(&cfg.RedisHost),
utils.RedisPortOption(&cfg.RedisPort),
utils.EnableParticipantFilteringOption(&cfg.EnableParticipantFiltering),
{
Name: "port",
Expand Down
20 changes: 0 additions & 20 deletions cmd/utils/global_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@ import (
"github.com/stellar/wallet-backend/internal/signing"
)

func RedisHostOption(configKey *string) *config.ConfigOption {
return &config.ConfigOption{
Name: "redis-host",
Usage: "The host of the Redis server.",
OptType: types.String,
ConfigKey: configKey,
FlagDefault: "localhost",
}
}

func RedisPortOption(configKey *int) *config.ConfigOption {
return &config.ConfigOption{
Name: "redis-port",
Usage: "The port of the Redis server.",
OptType: types.Int,
ConfigKey: configKey,
FlagDefault: 6379,
}
}

func IngestServerPortOption(configKey *int) *config.ConfigOption {
return &config.ConfigOption{
Name: "ingest-server-port",
Expand Down
30 changes: 0 additions & 30 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,6 @@ services:
- source: postgres_init
target: /docker-entrypoint-initdb.d/init-schemas.sql

redis:
container_name: redis
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
ports:
- 6379:6379
volumes:
- redis-data:/data
command: >
redis-server
--hash-max-listpack-entries 1000
--hash-max-listpack-value 8000

stellar-rpc-mainnet:
container_name: stellar-rpc-mainnet
image: stellar/stellar-rpc:stable
Expand Down Expand Up @@ -208,8 +190,6 @@ services:
condition: service_completed_successfully
db:
condition: service_healthy
redis:
condition: service_healthy
entrypoint: ""
command:
- sh
Expand Down Expand Up @@ -238,9 +218,6 @@ services:
GET_LEDGERS_LIMIT: 150
TRACKER_DSN: ${TRACKER_DSN}
STELLAR_ENVIRONMENT: ${STELLAR_ENVIRONMENT:-development}
REDIS_HOST: ${REDIS_HOST:-redis}
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
# ADMIN_PORT: 9094 # Optional: Port for pprof endpoints at /debug/pprof. WARNING: Do NOT expose publicly!

ingest-mainnet:
Expand All @@ -256,8 +233,6 @@ services:
condition: service_completed_successfully
db:
condition: service_healthy
redis:
condition: service_healthy
entrypoint: ""
command:
- sh
Expand Down Expand Up @@ -285,15 +260,10 @@ services:
GET_LEDGERS_LIMIT: 20
TRACKER_DSN: ${TRACKER_DSN}
STELLAR_ENVIRONMENT: ${STELLAR_ENVIRONMENT:-development}
REDIS_HOST: ${REDIS_HOST:-redis}
REDIS_PORT: ${REDIS_PORT:-6379}
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
# ADMIN_PORT: 9095 # Optional: Port for pprof endpoints at /debug/pprof. WARNING: Do NOT expose publicly!
volumes:
postgres-db:
driver: local
redis-data:
driver: local

configs:
postgres_init:
Expand Down
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ toolchain go1.24.2

require (
github.com/99designs/gqlgen v0.17.76
github.com/alicebob/miniredis/v2 v2.35.0
github.com/alitto/pond/v2 v2.5.0
github.com/avast/retry-go/v4 v4.6.1
github.com/aws/aws-sdk-go v1.55.7
Expand All @@ -18,6 +17,7 @@ require (
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-playground/validator/v10 v10.27.0
github.com/golang-jwt/jwt/v5 v5.2.3
github.com/google/uuid v1.6.0
github.com/guregu/null v4.0.0+incompatible
github.com/jackc/pgx/v5 v5.7.6
github.com/jmoiron/sqlx v1.4.0
Expand All @@ -26,7 +26,6 @@ require (
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.22.0
github.com/redis/go-redis/v9 v9.16.0
github.com/rubenv/sql-migrate v1.8.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1
Expand Down Expand Up @@ -91,7 +90,6 @@ require (
github.com/creachadair/jrpc2 v1.2.0 // indirect
github.com/creachadair/mds v0.13.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/djherbis/fscache v0.10.1 // indirect
github.com/docker/docker v28.0.1+incompatible // indirect
Expand All @@ -115,7 +113,6 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/schema v1.4.1 // indirect
Expand Down Expand Up @@ -165,7 +162,6 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/errs v1.4.0 // indirect
go.opencensus.io v0.24.0 // indirect
Expand Down
12 changes: 0 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI=
github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM=
github.com/alitto/pond/v2 v2.5.0 h1:vPzS5GnvSDRhWQidmj2djHllOmjFExVFbDGCw1jdqDw=
github.com/alitto/pond/v2 v2.5.0/go.mod h1:xkjYEgQ05RSpWdfSd1nM3OVv7TBhLdy7rMp3+2Nq+yE=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
Expand Down Expand Up @@ -116,10 +114,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -149,8 +143,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ=
github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo=
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
Expand Down Expand Up @@ -420,8 +412,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4=
github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
Expand Down Expand Up @@ -513,8 +503,6 @@ github.com/yudai/golcs v0.0.0-20150405163532-d1c525dea8ce h1:888GrqRxabUce7lj4Oa
github.com/yudai/golcs v0.0.0-20150405163532-d1c525dea8ce/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM=
Expand Down
109 changes: 109 additions & 0 deletions internal/data/account_contract_tokens.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Package data provides data access layer for account-contract token mappings.
// This file handles PostgreSQL storage of account-to-contract relationships.
package data

import (
"context"
"fmt"
"time"

"github.com/google/uuid"
"github.com/jackc/pgx/v5"

"github.com/stellar/wallet-backend/internal/db"
"github.com/stellar/wallet-backend/internal/metrics"
)

// AccountContractTokensModelInterface defines the interface for account-contract mapping operations.
type AccountContractTokensModelInterface interface {
// Read operations (for API/balances queries)
GetByAccount(ctx context.Context, accountAddress string) ([]*Contract, error)

// Write operations (for initial population and live ingestion)
BatchInsert(ctx context.Context, dbTx pgx.Tx, contractsByAccount map[string][]uuid.UUID) error
}

// AccountContractTokensModel implements AccountContractTokensModelInterface.
type AccountContractTokensModel struct {
DB db.ConnectionPool
MetricsService metrics.MetricsService
}

var _ AccountContractTokensModelInterface = (*AccountContractTokensModel)(nil)

// GetByAccount retrieves all contract tokens for an account with full metadata via JOIN.
func (m *AccountContractTokensModel) GetByAccount(ctx context.Context, accountAddress string) ([]*Contract, error) {
if accountAddress == "" {
return nil, fmt.Errorf("empty account address")
}

const query = `
SELECT ct.id, ct.contract_id, ct.type, ct.code, ct.issuer,
ct.name, ct.symbol, ct.decimals, ct.created_at, ct.updated_at
FROM account_contract_tokens ac
INNER JOIN contract_tokens ct ON ct.id = ac.contract_id
WHERE ac.account_address = $1`

start := time.Now()
rows, err := m.DB.PgxPool().Query(ctx, query, accountAddress)
if err != nil {
m.MetricsService.IncDBQueryError("GetByAccount", "account_contract_tokens", "query_error")
return nil, fmt.Errorf("querying contracts for %s: %w", accountAddress, err)
}
defer rows.Close()

var contracts []*Contract
for rows.Next() {
var c Contract
if err := rows.Scan(&c.ID, &c.ContractID, &c.Type, &c.Code, &c.Issuer,
&c.Name, &c.Symbol, &c.Decimals, &c.CreatedAt, &c.UpdatedAt); err != nil {
return nil, fmt.Errorf("scanning contract: %w", err)
}
contracts = append(contracts, &c)
}

if err := rows.Err(); err != nil {
return nil, fmt.Errorf("iterating contracts: %w", err)
}

m.MetricsService.ObserveDBQueryDuration("GetByAccount", "account_contract_tokens", time.Since(start).Seconds())
m.MetricsService.IncDBQuery("GetByAccount", "account_contract_tokens")
return contracts, nil
}

// BatchInsert inserts contract IDs for multiple accounts (contracts are never removed).
func (m *AccountContractTokensModel) BatchInsert(ctx context.Context, dbTx pgx.Tx, contractsByAccount map[string][]uuid.UUID) error {
if len(contractsByAccount) == 0 {
return nil
}

start := time.Now()

// Flatten to parallel arrays for UNNEST
var addresses []string
var contractIDs []uuid.UUID
for accountAddress, ids := range contractsByAccount {
for _, id := range ids {
addresses = append(addresses, accountAddress)
contractIDs = append(contractIDs, id)
}
}

if len(addresses) == 0 {
return nil
}

const query = `
INSERT INTO account_contract_tokens (account_address, contract_id)
SELECT unnest($1::text[]), unnest($2::uuid[])
ON CONFLICT DO NOTHING`

_, err := dbTx.Exec(ctx, query, addresses, contractIDs)
if err != nil {
return fmt.Errorf("batch inserting contract tokens: %w", err)
}

m.MetricsService.ObserveDBQueryDuration("BatchInsert", "account_contract_tokens", time.Since(start).Seconds())
m.MetricsService.IncDBQuery("BatchInsert", "account_contract_tokens")
return nil
}
Loading
Loading