-
Notifications
You must be signed in to change notification settings - Fork 2
more block tweaks #147
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
more block tweaks #147
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -175,9 +175,13 @@ func (q *Queue) BroadcastPending() (int, error) { | |||||||||||||||||||||||||||||||||||
| cutoff = i + 1 // cutoff is now the count of messages that fit | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // If nothing fits, process at least the first message | ||||||||||||||||||||||||||||||||||||
| // If nothing fits, process at least the first 45 messages or the total number of messages if less than 45 | ||||||||||||||||||||||||||||||||||||
| if cutoff == 0 { | ||||||||||||||||||||||||||||||||||||
| cutoff = 1 | ||||||||||||||||||||||||||||||||||||
| cutoff = 45 | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if cutoff > total { | ||||||||||||||||||||||||||||||||||||
| cutoff = total | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+178
to
185
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical logic flaw: Forcing 45 messages when size limit is exceeded. When The previous logic of setting
Apply this diff to restore safe behavior: - // If nothing fits, process at least the first 45 messages or the total number of messages if less than 45
+ // If nothing fits, process at least the first message
if cutoff == 0 {
- cutoff = 45
+ cutoff = 1
}
if cutoff > total {
cutoff = total
}Alternatively, if larger batches are required for performance, consider removing or increasing 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| log.Info().Msg(fmt.Sprintf("Queue: Posting %d messages to chain...", cutoff)) | ||||||||||||||||||||||||||||||||||||
|
|
@@ -200,7 +204,7 @@ func (q *Queue) BroadcastPending() (int, error) { | |||||||||||||||||||||||||||||||||||
| var i int | ||||||||||||||||||||||||||||||||||||
| for !complete && i < 10 { | ||||||||||||||||||||||||||||||||||||
| i++ | ||||||||||||||||||||||||||||||||||||
| res, err = q.wallet.BroadcastTxAsync(data) | ||||||||||||||||||||||||||||||||||||
| res, err = q.wallet.BroadcastTxSync(data) | ||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||
| if strings.Contains(err.Error(), "tx already exists in cache") { | ||||||||||||||||||||||||||||||||||||
| if data.Sequence != nil { | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
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.
🧩 Analysis chain
Verify rate limit changes align with batch size increases.
The rate limit has become more restrictive (PerTokenMs increased from 300 to 400, Burst decreased from 20 to 10), which reduces broadcast frequency. This aligns with the larger minimum batch size (45 messages) introduced in
queue/queue.go. However, ensure this combination doesn't cause excessive queue buildup during high-traffic periods, as fewer broadcasts with larger batches could lead to delays.Run the following script to check how the rate limiter is used and verify no other components depend on the previous rate limit values:
🏁 Script executed:
Length of output: 4549
Length of output: 2332
🏁 Script executed:
Length of output: 1861
Update outdated rate limit comment and verify configuration aligns with batch processing logic.
The rate limit change is verified: PerTokenMs increased from 300 to 400ms (reducing frequency from 3.33 to 2.5 tokens/sec), and Burst decreased from 20 to 10. This aligns with the minimum batch size of 45 messages enforced in
BroadcastPending()(queue/queue.go:180), supporting fewer but larger broadcasts.However, the comment at queue/queue.go:142 is now outdated. It states "Token-bucket rate limit: allow calling BroadcastPending at most 20 times per 6 seconds," but with the new configuration, the rate allows approximately 15 refilled tokens over 6 seconds (2.5 tokens/sec × 6), not 20. Update this comment to reflect the new rate limit.
🤖 Prompt for AI Agents