-
Notifications
You must be signed in to change notification settings - Fork 4
Multithreading queue #108
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
Open
dahn510
wants to merge
60
commits into
main
Choose a base branch
from
multi-queue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Multithreading queue #108
Changes from 4 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
ee9888e
multi thread queue
dahn510 b1a0d1a
queue thread config
dahn510 c6218d4
clarify log messages
dahn510 66dec99
batch send messages
dahn510 f0cb595
tweaking queue init
TheMarstonConnell bb2f201
batch queue
dahn510 c8abaad
clean up
dahn510 701304f
channel queue
dahn510 125c590
replace stop channel with msg output channel
dahn510 27313d3
send msg to free worker channel
dahn510 bf12c63
clean up compile errors
dahn510 5ae1615
tx timer and batch size config
dahn510 bdf7f77
fix build error
dahn510 c59f39c
Merge branch 'main' of github.com:JackalLabs/sequoia into multi-queue
dahn510 534f3e4
max retry error
dahn510 fbfa225
test max retry
dahn510 2eed453
worker test
dahn510 f78e4b8
mock auth query client
dahn510 d200bb4
mock auth client
dahn510 f5539f1
mock tx and rpc clients
dahn510 dcf3ef2
lint cleanup
dahn510 d84c967
test batch full send
dahn510 bd6c12e
clean up
dahn510 5e06959
wait for workers to terminate
dahn510 777f7b1
queue and worker tests
dahn510 9fdb0c4
bench pool Add
dahn510 8bf2b0f
fake and mock query client
dahn510 a89e0db
fake clients
dahn510 6f98006
fake methods used by the wallet
dahn510 529bffc
create new app with options
dahn510 d539b51
add test_mode flag to start cmd
dahn510 f1179c5
use query client from app
dahn510 e5abf22
add query client to api handler
dahn510 5b4afbe
fake query responses to start app
dahn510 d4f2d41
fix blockstore key unmarshal error
dahn510 1b44ad2
pass query client to stray manager
dahn510 186dbf9
tx decoder
dahn510 d5cd8df
decode tx sent to fake rpc client
dahn510 c216924
register feegrant interface
dahn510 b1637f7
fake query file
dahn510 bd31f2d
use passed query client
dahn510 166706b
fix race condition of file prove counter
dahn510 641f4ff
Merge branch 'main' into multi-queue
dahn510 7198fe3
create offset wallet from main wallet
dahn510 bbf3ada
fix hands and worker wallet collision
dahn510 52264ba
Merge branch 'main' into multi-queue
TheMarstonConnell 57fa87d
lint
TheMarstonConnell ebe4c04
gitignore linting
TheMarstonConnell a199413
mem leaks maybe?
TheMarstonConnell 4547d2e
Merge pull request #127 from JackalLabs/marston/mem-leaks
dahn510 bd39aa3
remove wallet offset from new hand
dahn510 a1aa8ac
fix wrong error reference returned
dahn510 52c60ed
fix account sequence mismatch
dahn510 a70c565
fix nil pointer dereference
dahn510 c9a1a0b
fix provider not found init problem
dahn510 7d35001
return init provider on chain err
dahn510 fbd533d
fix sequence mismatch error
dahn510 210c22c
update test
dahn510 28579bc
lint
dahn510 9130089
Merge branch 'main' into multi-queue
dahn510 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package queue | ||
|
|
||
| import ( | ||
| walletTypes "github.com/desmos-labs/cosmos-go-wallet/types" | ||
| "github.com/desmos-labs/cosmos-go-wallet/wallet" | ||
|
|
||
| "github.com/cosmos/cosmos-sdk/types" | ||
|
|
||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
| ) | ||
|
|
||
| func NewTxWorker(id int8, bucketSize int16, msgBatchSize int8, retryAttempt int8, offsetWallet *wallet.Wallet) *TxWorker { | ||
| return &TxWorker{ | ||
| id: id, | ||
| wallet: offsetWallet, | ||
| msgBucketSize: bucketSize, | ||
| msgBucket: make([]*Message, 0, bucketSize), | ||
| msgBatchSize: msgBatchSize, | ||
| retryAttempt: retryAttempt, | ||
| } | ||
| } | ||
|
|
||
| func (t *TxWorker) Address() string { | ||
| return t.wallet.AccAddress() | ||
| } | ||
|
|
||
| func (t *TxWorker) available() int { | ||
| return int(t.msgBucketSize) - len(t.msgBucket) | ||
| } | ||
|
|
||
| func (t *TxWorker) assign(msgs []*Message) int { | ||
| if msgs == nil { | ||
| return 0 | ||
| } | ||
|
|
||
| // take whatever it can to fill the bucket | ||
| // required for the sanity check | ||
| fillCount := min(int(t.msgBucketSize)-len(t.msgBucket), len(msgs)) | ||
| m := msgs[:fillCount] | ||
|
|
||
| t.msgBucket = append(t.msgBucket, m...) | ||
|
dahn510 marked this conversation as resolved.
Outdated
|
||
| return fillCount | ||
| } | ||
|
|
||
| func (t *TxWorker) grabNextBatch() []*Message { | ||
| total := min(len(t.msgBucket), int(t.msgBatchSize)) | ||
| msgs := t.msgBucket[:total] | ||
| t.msgBucket = t.msgBucket[total:] | ||
|
|
||
| return msgs | ||
| } | ||
|
|
||
| func (t *TxWorker) broadCast() { | ||
| batchMessage := t.grabNextBatch() | ||
|
|
||
| batch := make([]types.Msg, len(batchMessage)) | ||
| for i, m := range batchMessage { | ||
| batch[i] = m.msg | ||
| } | ||
| data := walletTypes.NewTransactionData(batch...).WithGasAuto().WithFeeAuto() | ||
|
|
||
| var resp *types.TxResponse | ||
| var err error | ||
| for attempt := 0; attempt < int(t.retryAttempt); attempt++ { | ||
| resp, err = t.wallet.BroadcastTxCommit(data) | ||
| if err != nil { | ||
| // retry if network is not responding | ||
| if code := status.Code(err); code == codes.DeadlineExceeded { | ||
|
dahn510 marked this conversation as resolved.
Outdated
|
||
| err = nil | ||
| } else { | ||
| break | ||
| } | ||
| } else { | ||
| break | ||
| } | ||
|
|
||
| } | ||
| for _, m := range batchMessage { | ||
| m.wg.Done() | ||
| m.res = resp | ||
| m.err = err | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slice bound uses
int8; code will not compilequeueWallets := offsetWallets[:cfg.QueueConfig.QueueThreads]fails whenQueueThreadsisint8:Cast to
intonce and reuse:🤖 Prompt for AI Agents