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-706][SOAK] - Soak Testing TxExpirationRebroadcast feature #962

Draft
wants to merge 62 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2d1a82d
refactor so txm owns blockhash assignment
Farber98 Nov 15, 2024
50dfef0
lastValidBlockHeight shouldn't be exported
Farber98 Nov 15, 2024
4e545e2
better comment
Farber98 Nov 15, 2024
4ded53c
refactor sendWithRetry to make it clearer
Farber98 Nov 15, 2024
9e1be6d
confirm loop refactor
Farber98 Nov 18, 2024
7dd2028
fix infinite loop
Farber98 Nov 18, 2024
6c675f2
move accountID inside msg
Farber98 Nov 19, 2024
b0d9426
lint fix
Farber98 Nov 19, 2024
1b38665
base58 does not contain lower l
Farber98 Nov 19, 2024
6923ddf
fix hash errors
Farber98 Nov 19, 2024
462844b
fix generate random hash
Farber98 Nov 19, 2024
fd785d0
remove blockhash as we only need block height
Farber98 Nov 19, 2024
cf958a4
expired tx changes without tests
Farber98 Nov 19, 2024
c5e957b
add maybe to mocks
Farber98 Nov 19, 2024
a505993
expiration tests
Farber98 Nov 19, 2024
adc8b1c
send txes through queue
Farber98 Nov 19, 2024
7d77f99
revert pendingtx leakage of information. overwrite blockhash
Farber98 Nov 20, 2024
92a280b
fix order of confirm loop and not found signature check
Farber98 Nov 20, 2024
2598e19
fix mocks
Farber98 Nov 20, 2024
42b3da1
prevent confirmation loop to mark tx as errored when it needs to be r…
Farber98 Nov 20, 2024
89af1f3
fix test
Farber98 Nov 20, 2024
5e8a0da
fix pointer
Farber98 Nov 20, 2024
75c1dcd
add comments
Farber98 Nov 21, 2024
4ff2d23
reduce rpc calls + refactors
Farber98 Nov 21, 2024
84e423e
tests + check to save rpc calls
Farber98 Nov 21, 2024
7d8319e
address feedback + remove redundant impl
Farber98 Nov 22, 2024
68f3a3e
iface comment
Farber98 Nov 22, 2024
780179f
address feedback on compute unit limit and lastValidBlockHeight assig…
Farber98 Nov 25, 2024
98f0246
blockhash assignment inside txm.sendWithRetry
Farber98 Nov 25, 2024
cbf55f6
address feedback
Farber98 Nov 26, 2024
90daf33
Merge branch 'develop' into nonevm-706-support-custom-bumping-strateg…
Farber98 Nov 26, 2024
77b28cf
refactors after merge
Farber98 Nov 26, 2024
0c4a7d8
fix interactive rebase
Farber98 Nov 26, 2024
849ac48
fix whitespace diffs
Farber98 Nov 26, 2024
20a1548
fix import
Farber98 Nov 26, 2024
a4d4770
fix mocks
Farber98 Nov 26, 2024
56a64da
add on prebroadcaste error
Farber98 Nov 26, 2024
9148d7d
remove rebroadcast count and fix package
Farber98 Nov 27, 2024
caf2cbf
improve docs
Farber98 Nov 27, 2024
1fbd63f
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Nov 28, 2024
5c22af2
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 5, 2024
02ffd1a
fix comparison against blockHeight instead of slotHeight
Farber98 Dec 5, 2024
c00494c
address feedback
Farber98 Dec 5, 2024
6ac30b0
fix lint
Farber98 Dec 5, 2024
36ee4ec
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 5, 2024
0e38174
fix log
Farber98 Dec 5, 2024
b04653c
config for soaks
Farber98 Dec 5, 2024
d240021
address feedback
Farber98 Dec 6, 2024
4389e13
remove useless slot height
Farber98 Dec 6, 2024
6bcdd8f
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 9, 2024
50dd10f
address feedback
Farber98 Dec 10, 2024
10b0453
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 11, 2024
2ea0c50
validate that tx doesn't exist in any of maps when adding new tx
Farber98 Dec 11, 2024
b5a6927
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 11, 2024
b4b4fd5
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 13, 2024
e7d7680
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 16, 2024
409fd1c
callers set lastValidBlockheight + get blockhash on expiration + inte…
Farber98 Dec 17, 2024
b900abe
Merge branch 'backup-branch-fee-bumping' into soak-expiration-rebroad…
Farber98 Dec 17, 2024
31a65a0
Merge branch 'develop' into backup-branch-fee-bumping
Farber98 Dec 17, 2024
1be704a
add enq iface comm to help callers
Farber98 Dec 17, 2024
9ee8977
address feedback
Farber98 Dec 17, 2024
105e890
Merge branch 'backup-branch-fee-bumping' into soak-expiration-rebroad…
Farber98 Dec 17, 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
address feedback
  • Loading branch information
Farber98 committed Dec 6, 2024

Verified

This commit was signed with the committer’s verified signature.
popenta Alex Popența
commit d24002158c94cc835b6433f5fa23941b6f778b0a
6 changes: 0 additions & 6 deletions pkg/solana/txm/pendingtx.go
Original file line number Diff line number Diff line change
@@ -212,12 +212,6 @@ func (c *pendingTxContext) ListAllSigs() []solana.Signature {
return maps.Keys(c.sigToID)
}

func (c *pendingTxContext) ListAllTxsIDs() []string {
c.lock.RLock()
defer c.lock.RUnlock()
return maps.Values(c.sigToID)
}

// ListAllExpiredBroadcastedTxs returns all the txes that are in broadcasted state and have expired for given block height compared against their lastValidBlockHeight.
// Passing maxUint64 as currHeight will return all broadcasted txes.
func (c *pendingTxContext) ListAllExpiredBroadcastedTxs(currBlockHeight uint64) []pendingTx {
6 changes: 4 additions & 2 deletions pkg/solana/txm/pendingtx_test.go
Original file line number Diff line number Diff line change
@@ -48,8 +48,10 @@ func TestPendingTxContext_add_remove_multiple(t *testing.T) {
// cannot add signature for non existent ID
require.Error(t, txs.AddSignature(uuid.New().String(), solana.Signature{}))

// return list of txsIds
list := txs.ListAllTxsIDs()
list := make([]string, 0, n)
for _, id := range txs.sigToID {
list = append(list, id)
}
assert.Equal(t, n, len(list))

// stop all sub processes
21 changes: 6 additions & 15 deletions pkg/solana/txm/txm.go
Original file line number Diff line number Diff line change
@@ -570,24 +570,21 @@ func (txm *Txm) handleFinalizedSignatureStatus(sig solanaGo.Signature) {
// An expired tx is one where it's blockhash lastValidBlockHeight is smaller than the current slot height.
// If any error occurs during rebroadcast attempt, they are discarded, and the function continues with the next transaction.
func (txm *Txm) rebroadcastExpiredTxs(ctx context.Context, client client.ReaderWriter) {
currBlockHeight, err := client.GetLatestBlock(ctx)
if err != nil || currBlockHeight == nil || currBlockHeight.BlockHeight == nil {
currBlock, err := client.GetLatestBlock(ctx)
if err != nil || currBlock == nil || currBlock.BlockHeight == nil {
txm.lggr.Errorw("failed to get current block height", "error", err)
return
}
// Rebroadcast all expired txes
for _, tx := range txm.txs.ListAllExpiredBroadcastedTxs(*currBlockHeight.BlockHeight) {
txm.lggr.Debugw("transaction expired, rebroadcasting", "id", tx.id, "signature", tx.signatures, "lastValidBlockHeight", tx.lastValidBlockHeight, "currentBlockHeight", *currBlockHeight.BlockHeight)
if len(tx.signatures) == 0 { // prevent panic, shouldn't happen.
txm.lggr.Errorw("no signatures found for expired transaction", "id", tx.id)
continue
}
for _, tx := range txm.txs.ListAllExpiredBroadcastedTxs(*currBlock.BlockHeight) {
txm.lggr.Debugw("transaction expired, rebroadcasting", "id", tx.id, "signature", tx.signatures, "lastValidBlockHeight", tx.lastValidBlockHeight, "currentBlockHeight", *currBlock.BlockHeight)
// Removes all signatures associated to tx and cancels context.
_, err := txm.txs.Remove(tx.id)
if err != nil {
txm.lggr.Errorw("failed to remove expired transaction", "id", tx.id, "error", err)
continue
}
tx.cfg.BaseComputeUnitPrice = txm.fee.BaseComputeUnitPrice() // update compute unit price (priority fee) for rebroadcast
rebroadcastTx := pendingTx{
tx: tx.tx,
cfg: tx.cfg,
@@ -720,17 +717,11 @@ func (txm *Txm) Enqueue(ctx context.Context, accountID string, tx *solanaGo.Tran
}

msg := pendingTx{
id: id,
tx: *tx,
cfg: cfg,
}

// If ID was not set by caller, create one.
if txID != nil && *txID != "" {
msg.id = *txID
} else {
msg.id = uuid.New().String()
}

select {
case txm.chSend <- msg:
default:
9 changes: 4 additions & 5 deletions pkg/solana/txm/txm_internal_test.go
Original file line number Diff line number Diff line change
@@ -978,7 +978,6 @@ func TestTxm_compute_unit_limit_estimation(t *testing.T) {
cfg.Chain.TxRetentionTimeout = relayconfig.MustNewDuration(5 * time.Second)
mc := mocks.NewReaderWriter(t)
mc.On("GetLatestBlock", mock.Anything).Return(&rpc.GetBlockResult{}, nil).Maybe()
mc.On("SlotHeight", mock.Anything).Return(uint64(0), nil).Maybe()

// mock solana keystore
mkey := keyMocks.NewSimpleKeystore(t)
@@ -1292,7 +1291,7 @@ func TestTxm_ExpirationRebroadcast(t *testing.T) {
txExpirationRebroadcast := true
statuses := map[solana.Signature]func() *rpc.SignatureStatusesResult{}

// Mock getLatestBlock to return a value greater than 0
// Mock getLatestBlock to return a value greater than 0 for blockHeight
getLatestBlockFunc := func() (*rpc.GetBlockResult, error) {
val := uint64(1500)
return &rpc.GetBlockResult{
@@ -1304,14 +1303,14 @@ func TestTxm_ExpirationRebroadcast(t *testing.T) {
latestBlockhashFunc := func() (*rpc.GetLatestBlockhashResult, error) {
defer func() { callCount++ }()
if callCount < 1 {
// To force rebroadcast, first call needs to be smaller than slotHeight
// To force rebroadcast, first call needs to be smaller than blockHeight
return &rpc.GetLatestBlockhashResult{
Value: &rpc.LatestBlockhashResult{
LastValidBlockHeight: uint64(1000),
},
}, nil
}
// following rebroadcast call will go through because lastValidBlockHeight is bigger than slotHeight
// following rebroadcast call will go through because lastValidBlockHeight is bigger than blockHeight
return &rpc.GetLatestBlockhashResult{
Value: &rpc.LatestBlockhashResult{
LastValidBlockHeight: uint64(2000),
@@ -1438,7 +1437,7 @@ func TestTxm_ExpirationRebroadcast(t *testing.T) {
}

// Mock LatestBlockhash to return an invalid blockhash in the first 3 attempts (initial + 2 rebroadcasts)
// the last one is valid because it is greater than the slotHeight
// the last one is valid because it is greater than the blockHeight
expectedRebroadcastsCount := 3
callCount := 0
latestBlockhashFunc := func() (*rpc.GetLatestBlockhashResult, error) {
Loading