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

feat: add max-msg-num parameter for batch broadcast in chain configs #1470

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Jun 13, 2024

No description provided.

@mmsqe mmsqe requested a review from a team as a code owner June 13, 2024 01:40
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@Reecepbcups Reecepbcups left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mmsqe thanks for the contribution!

What is the need you have for limiting the max number of messages to broadcast?
Are you hitting block size issues? something else? Just a nice to have feature? Any extra context would be helpful here.

Impl looks good.

@mmsqe
Copy link
Contributor Author

mmsqe commented Jun 15, 2024

Hey @mmsqe thanks for the contribution!

What is the need you have for limiting the max number of messages to broadcast? Are you hitting block size issues? something else? Just a nice to have feature? Any extra context would be helpful here.

Impl looks good.

I use max_msg_num to crosscheck gas with hermes, but max_tx_size is more accurate to avoid max bytes in block.

Copy link
Member

@Reecepbcups Reecepbcups left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utAck. cc @jtieri for your thoughts

Copy link
Member

@jtieri jtieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late reply. i had a couple of questions and a couple nit picks but otherwise this seems fine.

Comment on lines +334 to +336
if maxMsgNum < 2 && maxMsgNum != 0 {
maxMsgNum = 2
}
Copy link
Member

Choose a reason for hiding this comment

The 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 MsgUpdateClient

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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 maxMsgNum < 2 would also account for the case of maxMsgNum == 0 since 0 < 2.

Perhaps I'm overlooking something here.

I would be okay with at least adding a log inside of the if statement when we auto correct the maxMsgNum value to 2, that way the user at least is away that they have configured an invalid value.

Comment on lines +354 to +357
if len(batch) >= int(maxMsgNum) && maxMsgNum != 0 {
go mp.sendBatchMessages(ctx, src, dst, batch)
batch = nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for clarity, is batch bound in size by the value of maxMsgNum? i.e. will batch always be less than or equal to maxMsgNum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, batch <= maxMsgNum

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just name this BroadcastMaxMsg? the suffix of Num feels redundant given the type is an integer and dropping the suffix is a bit less verbose

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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.
@Reecepbcups any thoughts on this?

@@ -60,6 +60,7 @@ type PenumbraProviderConfig struct {
Modules []module.AppModuleBasic `json:"-" yaml:"-"`
Slip44 int `json:"coin-type" yaml:"coin-type"`
Broadcast provider.BroadcastMode `json:"broadcast-mode" yaml:"broadcast-mode"`
MaxMsgNum uint64 `json:"max-msg-num" yaml:"max-msg-num"`
Copy link
Member

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

@jtieri
Copy link
Member

jtieri commented Sep 12, 2024

I apologize for the amount of time it's taken to follow up on this. I've moved into a newer role that has led to me having less bandwidth for maintaining the relayer and we have only recently begun to onboard new developers for the role.

Thanks for sticking with us and continuing to make contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants