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

services/horizon: Remove Horizon Submission Queue #5039

Merged
merged 32 commits into from
Sep 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3db7ed7
Remove horizon submission queue - 1
aditya1702 Aug 29, 2023
e1d96bd
Update system.go
aditya1702 Aug 29, 2023
b7cf3a7
Update system.go
aditya1702 Aug 29, 2023
f5c511a
remove WaitUntilAccountSequence
aditya1702 Aug 30, 2023
627d473
Update system.go
aditya1702 Aug 30, 2023
fa688aa
Remove tests related to WaitUntilAccountSequence - 1
aditya1702 Aug 30, 2023
0e71a79
Update system_test.go
aditya1702 Aug 30, 2023
400fbb0
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 5, 2023
d1c6959
Remove history_transactions_filtered_tmp - 1
aditya1702 Sep 5, 2023
767a9f9
Fix failing tests in system_test.go
aditya1702 Sep 6, 2023
fc34e8b
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 6, 2023
52c43ca
Revert "Remove history_transactions_filtered_tmp - 1"
aditya1702 Sep 8, 2023
0c60edf
Revert "Fix failing tests in system_test.go"
aditya1702 Sep 8, 2023
bcb5d82
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 8, 2023
c257fff
Remove sequenceNumber from checkTxAlreadyExists
aditya1702 Sep 12, 2023
61de345
Undo removing waitUntilAccountSequence
aditya1702 Sep 12, 2023
6775122
Small change - 1
aditya1702 Sep 12, 2023
f1d49c2
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 12, 2023
ff01be7
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 13, 2023
711194d
Small changes - 2
aditya1702 Sep 13, 2023
7d39d5c
fix failing unit tests
aditya1702 Sep 13, 2023
b8bbcc6
Add some comments - 1
aditya1702 Sep 13, 2023
43e3c17
Small changes - 3
aditya1702 Sep 13, 2023
def0437
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 14, 2023
9b3e3ab
Small changes - 4
aditya1702 Sep 14, 2023
ad0cc09
Fix failing tests - 1
aditya1702 Sep 14, 2023
487f41b
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 14, 2023
b2321be
Use defer for sys.finish
aditya1702 Sep 14, 2023
a618186
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 14, 2023
7c2ee7d
Revert "Use defer for sys.finish"
aditya1702 Sep 15, 2023
3d63938
Merge branch 'master' into remove-submission-queue-2
aditya1702 Sep 15, 2023
180aaa7
Small changes - 5
aditya1702 Sep 15, 2023
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
21 changes: 13 additions & 8 deletions services/horizon/internal/txsub/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (sys *System) Submit(
sys.Init()
resultCh := make(chan Result, 1)
resultReadCh = resultCh
var result Result

defer func() {
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
sys.finish(ctx, hash, resultCh, result)
}()

db := sys.DB(ctx)
// The database doesn't (yet) store muxed accounts, so we query
Expand All @@ -116,19 +121,19 @@ func (sys *System) Submit(
minSeqNum := envelope.MinSeqNum()
// Ensure sequence numbers make sense
if seqNum < 0 || (minSeqNum != nil && (*minSeqNum < 0 || *minSeqNum >= seqNum)) {
sys.finish(ctx, hash, resultCh, Result{Err: ErrBadSequence})
result = Result{Err: ErrBadSequence}
return
}

tx, err := txResultByHash(ctx, db, hash)
if err == nil {
sys.Log.Ctx(ctx).WithField("hash", hash).Info("Found submission result in a DB")
sys.finish(ctx, hash, resultCh, Result{Transaction: tx})
result = Result{Transaction: tx}
return
}
if err != ErrNoResults {
sys.Log.Ctx(ctx).WithField("hash", hash).Info("Error getting submission result from a DB")
sys.finish(ctx, hash, resultCh, Result{Transaction: tx, Err: err})
result = Result{Transaction: tx, Err: err}
return
}

Expand All @@ -139,31 +144,31 @@ func (sys *System) Submit(
// any error other than "txBAD_SEQ" is a failure
isBad, err := sr.IsBadSeq()
if err != nil {
sys.finish(ctx, hash, resultCh, Result{Err: err})
result = Result{Err: err}
return
}
if !isBad {
sys.finish(ctx, hash, resultCh, Result{Err: sr.Err})
result = Result{Err: sr.Err}
return
}

// Even if a transaction is successfully submitted to core, Horizon ingestion might
// be lagging behind leading to txBAD_SEQ. This function will block a txsub request
// until the request times out or account sequence is bumped to txn sequence.
if err = sys.waitUntilAccountSequence(ctx, db, sourceAddress, uint64(envelope.SeqNum())); err != nil {
sys.finish(ctx, hash, resultCh, Result{Err: err})
result = Result{Err: err}
return
}

// If error is txBAD_SEQ, check for the result again
tx, err = txResultByHash(ctx, db, hash)
aditya1702 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
// finally, return the bad_seq error if no result was found on 2nd attempt
sys.finish(ctx, hash, resultCh, Result{Err: sr.Err})
result = Result{Err: sr.Err}
return
}
// If we found the result, use it as the result
sys.finish(ctx, hash, resultCh, Result{Transaction: tx})
result = Result{Transaction: tx}
return
}

Expand Down
Loading