Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
066e74e
added initial backfill parameter/function scaffolding
cjonas9 Dec 12, 2025
c7a19e9
added scaffolding for ledger ingestion backfill
cjonas9 Dec 15, 2025
e7a1b93
expanded relevant helper functions
cjonas9 Dec 16, 2025
10fccc0
refactored code, made CLI arg a bool instead of int
cjonas9 Dec 16, 2025
ce14b81
moved major legwork to ingest folder
cjonas9 Dec 16, 2025
e27dee6
completed structure without backfilling logic
cjonas9 Dec 16, 2025
11da703
completed backfilling logic, untested code fully written
cjonas9 Dec 17, 2025
a855501
fixed several off-by-one issues, improved error handling
cjonas9 Dec 17, 2025
bb49dcc
refactored code, discovered monotonicity constract in storage backend
cjonas9 Dec 17, 2025
32ee4ce
working implemetnation, not tested robustly or on testnet
cjonas9 Dec 18, 2025
749da32
fixed bug with backwards to forwards transition if starting from empt…
cjonas9 Dec 18, 2025
0214ae2
patched bug in empty DB case
cjonas9 Dec 18, 2025
4bf5abd
large refactoring
cjonas9 Dec 18, 2025
885c220
minor refactoring/bud ID
cjonas9 Dec 18, 2025
cf02b2e
changed to errors.wrap, cleaned up code
cjonas9 Dec 19, 2025
1499ef2
major refactoring; design made pointer-receiver oriented
cjonas9 Dec 19, 2025
965b479
added context timeout for main function
cjonas9 Dec 19, 2025
b09a526
further refactoring and edge case guarding
cjonas9 Dec 19, 2025
c440592
handled rare/unlikely forwards backfill, already written up to tip case
cjonas9 Dec 19, 2025
7537872
handled extremely rare division by zero case
cjonas9 Dec 19, 2025
c31a468
refactored; fixed history_retention>available ledgers bug; fixed prog…
cjonas9 Dec 19, 2025
7b9ffa7
minor: fixed accidental integer division rounding bug
cjonas9 Dec 19, 2025
02978e2
Merge remote-tracking branch 'origin/main' into synchronous-history-b…
cjonas9 Dec 19, 2025
397f581
abstracted ingestion/chunk filling to service.go, debugging service s…
cjonas9 Jan 2, 2026
91f0c73
service start post-backfill working
cjonas9 Jan 5, 2026
5e25abf
patched verification bug
cjonas9 Jan 5, 2026
d67d37c
Merge branch 'main' into synchronous-history-backfilling
cjonas9 Jan 6, 2026
c4241ed
updated git latest ledger test interface
cjonas9 Jan 6, 2026
7e733c9
repaired service test following startService refactor
cjonas9 Jan 6, 2026
484f360
added backfill gap detection unit test
cjonas9 Jan 6, 2026
3bdc240
increased robustness, fixed post-backfill ingestion bug
cjonas9 Jan 8, 2026
e9470d9
added buggy integration test
cjonas9 Jan 8, 2026
612f33f
integration test bones working
cjonas9 Jan 8, 2026
954b6ef
added several integration tests
cjonas9 Jan 9, 2026
e4f0ca1
fixed linter + error messages
cjonas9 Jan 9, 2026
508a7f1
Merge branch 'main' into synchronous-history-backfilling
cjonas9 Jan 9, 2026
89a4edc
minor style improvements
cjonas9 Jan 9, 2026
efc3585
timing code added
cjonas9 Jan 9, 2026
1830382
added config for timing
cjonas9 Jan 9, 2026
c330809
minor timerlog addition
cjonas9 Jan 9, 2026
636223b
repaired integration tests, changed backfill config params, added LCM…
cjonas9 Jan 13, 2026
621037f
added stale DB edge case error message, integration tests now test li…
cjonas9 Jan 14, 2026
7f69666
integration test debugging
cjonas9 Jan 16, 2026
01e316c
working robust integration tests, not flaky
cjonas9 Jan 16, 2026
e524b04
fixed race in tests, refactored backfill and changed empty DB behavior
cjonas9 Jan 16, 2026
9da6f4b
linter fixes and refactoring
cjonas9 Jan 20, 2026
7c669e6
refactored to reduce cyclomatic complexity
cjonas9 Jan 20, 2026
eb7639d
linter duration multiplication fix
cjonas9 Jan 20, 2026
e6addaf
added nolint for funcorder linter directive in test.go
cjonas9 Jan 20, 2026
9148fb4
Merge branch 'main' into synchronous-history-backfilling
cjonas9 Jan 20, 2026
069348d
fixed minor integration test infra bug
cjonas9 Jan 20, 2026
c12256e
clean/restructured code, decreased excessive logging
cjonas9 Jan 20, 2026
604cbf5
minor comment update
cjonas9 Jan 20, 2026
8f5c8b3
removed daemon logging, linter fixes
cjonas9 Jan 20, 2026
df347bc
removed integration test hardcoded captive core binary path
cjonas9 Jan 20, 2026
66e3c5c
delete accidentally committed toml
cjonas9 Jan 20, 2026
815095f
optimized backfill, improved names/comments, removed dead code
cjonas9 Jan 22, 2026
0f9d318
Merge branch 'synchronous-history-backfilling' of https://github.com/…
cjonas9 Jan 22, 2026
9914db0
return backend directly
cjonas9 Jan 22, 2026
0499d2d
reduced memory footprint of gapless check, minor test patches
cjonas9 Jan 22, 2026
729867e
linter: fixed casting danger, lll
cjonas9 Jan 22, 2026
f0169ed
getLedgerCountInRange minor improvement, service naming in Start() li…
cjonas9 Jan 22, 2026
e85a091
linter lll
cjonas9 Jan 23, 2026
43e38ee
optimized InsertEvents
cjonas9 Jan 23, 2026
b106492
bounds setting improvements, minor cosmetic changes
cjonas9 Jan 23, 2026
3ce449d
improved operator documentation/help and linter errors, removed pass-…
cjonas9 Jan 26, 2026
4f59e3a
fixed bounds-setting edge case
cjonas9 Jan 27, 2026
5d9570d
undid events changes
cjonas9 Jan 27, 2026
723bd0c
Merge branch 'main' into synchronous-history-backfilling
cjonas9 Jan 27, 2026
438e757
changed method receiver names
cjonas9 Jan 27, 2026
7805f02
removed timeout configurability
cjonas9 Jan 27, 2026
c8488c4
changed function name + linter error
cjonas9 Jan 27, 2026
7b15443
reduced state, improved warnings/errors
cjonas9 Jan 27, 2026
bc4bf00
changed backend close failure logging to use WithError
cjonas9 Jan 28, 2026
348278d
linter
cjonas9 Jan 28, 2026
721c780
simplified branching logic and resolved nits
cjonas9 Jan 28, 2026
da37199
changed if-else if-else to switch
cjonas9 Jan 28, 2026
2a66cdc
moved backfill logging completion line outside of conditional
cjonas9 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
51 changes: 24 additions & 27 deletions cmd/stellar-rpc/internal/db/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ func (eventHandler *eventHandler) InsertEvents(lcm xdr.LedgerCloseMeta) error {
// where -1 is actually the largest possible uint32.
//
var beforeIndex, afterIndex uint32
// Accumulate all ledger events to insert
var allLedgerEvents []dbEvent

for {
var tx ingest.LedgerTransaction
Expand All @@ -125,7 +127,6 @@ func (eventHandler *eventHandler) InsertEvents(lcm xdr.LedgerCloseMeta) error {

opEvents := allEvents.OperationEvents
txEvents := allEvents.TransactionEvents
insertableEvents := make([]dbEvent, 0, len(txEvents)+len(opEvents))

var afterTxIndex uint32

Expand Down Expand Up @@ -173,13 +174,13 @@ func (eventHandler *eventHandler) InsertEvents(lcm xdr.LedgerCloseMeta) error {
return err
}

insertableEvents = append(insertableEvents, insertedEvent)
allLedgerEvents = append(allLedgerEvents, insertedEvent)
}

// Then, gather all of the operation events.
for opIndex, innerOpEvents := range opEvents {
for eventIndex, event := range innerOpEvents {
insertableEvents = append(insertableEvents, dbEvent{
allLedgerEvents = append(allLedgerEvents, dbEvent{
TxHash: tx.Hash,
Event: xdr.DiagnosticEvent{
InSuccessfulContractCall: tx.Successful(),
Expand All @@ -194,35 +195,31 @@ func (eventHandler *eventHandler) InsertEvents(lcm xdr.LedgerCloseMeta) error {
})
}
}
}

query := sq.Insert(eventTableName).
Columns(
"id",
"contract_id",
"event_type",
"event_data",
"ledger_close_time",
"transaction_hash",
"topic1", "topic2", "topic3", "topic4",
)
if len(allLedgerEvents) == 0 {
return nil
}

for _, event := range insertableEvents {
query, err = insertEvents(query, lcm, event)
if err != nil {
return err
}
}
query := sq.Insert(eventTableName).
Columns(
"id",
"contract_id",
"event_type",
"event_data",
"ledger_close_time",
"transaction_hash",
"topic1", "topic2", "topic3", "topic4",
)

if len(insertableEvents) > 0 { // don't run empty insert
// Ignore the last inserted ID as it is not needed
_, err = query.RunWith(eventHandler.stmtCache).Exec()
if err != nil {
return err
}
for _, event := range allLedgerEvents {
query, err = insertEvents(query, lcm, event)
if err != nil {
return err
}
}

return nil
_, err = query.RunWith(eventHandler.stmtCache).Exec()
return err
}

func insertEvents(
Expand Down
Loading