-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: add max-msg-num parameter for batch broadcast in chain configs #1470
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -330,6 +330,10 @@ func (mp *messageProcessor) trackAndSendMessages( | |
needsClientUpdate bool, | ||
) error { | ||
broadcastBatch := dst.chainProvider.ProviderConfig().BroadcastMode() == provider.BroadcastModeBatch | ||
maxMsgNum := dst.chainProvider.ProviderConfig().BroadcastMaxMsgNum() | ||
if maxMsgNum < 2 && maxMsgNum != 0 { | ||
maxMsgNum = 2 | ||
} | ||
Comment on lines
+334
to
+336
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. is there any case where it would even make sense to set this variable to a value less than 2? i'm guessing it would always need to be at least 2 since we are attempting to broadcast some msg along with the 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. yes, do we mean we return error instead of auto correct if user wrongly config as 1? 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. Ahh right this check is to ensure the user chosen value is always at least 2. Could this check then be simplified to: if maxMsgNum < 2 {
maxMsgNum = 2
} Since the Perhaps I'm overlooking something here. I would be okay with at least adding a log inside of the |
||
var batch []messageToTrack | ||
|
||
for _, t := range mp.trackers() { | ||
|
@@ -347,6 +351,10 @@ func (mp *messageProcessor) trackAndSendMessages( | |
|
||
if broadcastBatch && (retries == 0 || ordered) { | ||
batch = append(batch, t) | ||
if len(batch) >= int(maxMsgNum) && maxMsgNum != 0 { | ||
go mp.sendBatchMessages(ctx, src, dst, batch) | ||
batch = nil | ||
} | ||
Comment on lines
+354
to
+357
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. just for clarity, is 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. yea, batch <= maxMsgNum |
||
continue | ||
} | ||
go mp.sendSingleMessage(ctx, src, dst, t) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ type ProviderConfig interface { | |
NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (ChainProvider, error) | ||
Validate() error | ||
BroadcastMode() BroadcastMode | ||
BroadcastMaxMsgNum() uint64 | ||
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. can we just name this 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. actually it's to avoid confusion if there's need for BroadcastMaxMsgBytes later 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. that seems fair to me but perhaps it is a premature optimization, i guess i'm not strongly opinionated on this. |
||
} | ||
|
||
type RelayerMessage interface { | ||
|
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.
can we rename this to
BroadcastMaxMsg
, i think the name is more clear with regards to what the value is used for