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

[NONEVM-984][solana] - Reorg Detection + lighter rpc call #951

Draft
wants to merge 35 commits into
base: backup-branch-fee-bumping
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bdf3457
track status on each signature to detect reorgs
Farber98 Nov 28, 2024
3ad2bc8
move things arround + add reorg detection
Farber98 Nov 29, 2024
4fd327a
linting errors
Farber98 Nov 29, 2024
2b29c33
fix some state tracking instances
Farber98 Nov 29, 2024
a6ce47b
remove redundant sig update
Farber98 Nov 30, 2024
3a6e643
move state from txes to sigs
Farber98 Nov 30, 2024
f4c6069
fix listAllExpiredBroadcastedTxs
Farber98 Nov 30, 2024
f027aeb
handle reorg after confirm cycle
Farber98 Nov 30, 2024
8c18891
associate sigs to retry ctx
Farber98 Dec 2, 2024
2902ec0
remove unused ctx
Farber98 Dec 2, 2024
1c1f723
add errored state and remove finalized
Farber98 Dec 2, 2024
6bc0c62
comment
Farber98 Dec 2, 2024
05442b2
Revert "comment"
Farber98 Dec 3, 2024
9b27a5b
Revert "remove unused ctx"
Farber98 Dec 3, 2024
ee14b60
Revert "associate sigs to retry ctx"
Farber98 Dec 3, 2024
d1f1ae7
Revert "fix listAllExpiredBroadcastedTxs"
Farber98 Dec 3, 2024
8911df2
Revert "move state from txes to sigs"
Farber98 Dec 3, 2024
52ce0e9
fix tx state
Farber98 Dec 3, 2024
fbbe978
address feedback
Farber98 Dec 3, 2024
cef6a91
fix ci
Farber98 Dec 3, 2024
3b3a71b
fix lint
Farber98 Dec 3, 2024
ef782c3
handle multiple sigs case
Farber98 Dec 4, 2024
08b0c6e
improve comment
Farber98 Dec 4, 2024
63a5f3f
improve logic and comments
Farber98 Dec 4, 2024
23f42d1
address feedback
Farber98 Dec 6, 2024
4a20622
Merge branch 'backup-branch-fee-bumping' into nonevm-984-reorg
Farber98 Dec 9, 2024
53948e1
add comment
Farber98 Dec 9, 2024
fdc8068
tests and fix some bugs
Farber98 Dec 9, 2024
34045ae
Merge branch 'backup-branch-fee-bumping' into nonevm-984-reorg
Farber98 Dec 10, 2024
10e5d9d
address feedback
Farber98 Dec 10, 2024
0a4b5aa
Merge branch 'backup-branch-fee-bumping' into nonevm-984-reorg
Farber98 Dec 12, 2024
5b34579
Merge branch 'backup-branch-fee-bumping' into nonevm-984-reorg
Farber98 Dec 12, 2024
17769f7
get height instead of whole block optimization
Farber98 Dec 12, 2024
d6fb891
fix mocks on expiration
Farber98 Dec 12, 2024
b6f4729
fix test
Farber98 Dec 12, 2024
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
Prev Previous commit
Next Next commit
linting errors
Farber98 committed Nov 29, 2024
commit 4fd327a257fd1d41dd383ec2f9121ba40463b2e4
65 changes: 30 additions & 35 deletions pkg/solana/txm/txm_internal_test.go
Original file line number Diff line number Diff line change
@@ -1329,24 +1329,22 @@ func TestTxm_ExpirationRebroadcast(t *testing.T) {
// First transaction should be rebroadcasted.
if time.Since(nowTs) < cfg.TxConfirmTimeout()-2*time.Second {
return nil
} else {
amit-momin marked this conversation as resolved.
Show resolved Hide resolved
// Second transaction should reach finalization.
sigStatusCallCount++
if sigStatusCallCount == 1 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusProcessed,
}
} else if sigStatusCallCount == 2 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusConfirmed,
}
} else {
wg.Done()
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusFinalized,
}
}
// Second transaction should reach finalization.
sigStatusCallCount++
if sigStatusCallCount == 1 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusProcessed,
}
} else if sigStatusCallCount == 2 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusConfirmed,
}
}
wg.Done()
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusFinalized,
}
}

txm, _, mkey := setupTxmTest(txExpirationRebroadcast, latestBlockhashFunc, slotHeightFunc, sendTxFunc, statuses)
@@ -1396,10 +1394,9 @@ func TestTxm_ExpirationRebroadcast(t *testing.T) {
// Transaction remains unconfirmed and should not be rebroadcasted.
if time.Since(nowTs) < cfg.TxConfirmTimeout() {
return nil
} else {
wg.Done()
return nil
}
wg.Done()
return nil
}

txm, _, mkey := setupTxmTest(txExpirationRebroadcast, latestBlockhashFunc, nil, sendTxFunc, statuses)
@@ -1461,24 +1458,22 @@ func TestTxm_ExpirationRebroadcast(t *testing.T) {
// transaction should be rebroadcasted multiple times.
if time.Since(nowTs) < cfg.TxConfirmTimeout()-2*time.Second {
return nil
} else {
// Second transaction should reach finalization.
sigStatusCallCount++
if sigStatusCallCount == 1 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusProcessed,
}
} else if sigStatusCallCount == 2 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusConfirmed,
}
} else {
wg.Done()
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusFinalized,
}
}
// Second transaction should reach finalization.
sigStatusCallCount++
if sigStatusCallCount == 1 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusProcessed,
}
} else if sigStatusCallCount == 2 {
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusConfirmed,
}
}
wg.Done()
return &rpc.SignatureStatusesResult{
ConfirmationStatus: rpc.ConfirmationStatusFinalized,
}
}

txm, _, mkey := setupTxmTest(txExpirationRebroadcast, latestBlockhashFunc, slotHeightFunc, sendTxFunc, statuses)
4 changes: 2 additions & 2 deletions pkg/solana/txm/txm_load_test.go
Original file line number Diff line number Diff line change
@@ -85,8 +85,8 @@ func TestTxm_Integration(t *testing.T) {
assert.Error(t, txm.Start(ctx))
createTx := func(signer solana.PublicKey, sender solana.PublicKey, receiver solana.PublicKey, amt uint64) *solana.Transaction {
// create transfer tx
hash, err := client.LatestBlockhash(ctx)
assert.NoError(t, err)
hash, hashErr := client.LatestBlockhash(ctx)
assert.NoError(t, hashErr)
tx, txErr := solana.NewTransaction(
[]solana.Instruction{
system.NewTransferInstruction(