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

Configurable teleporter-max-gas-limit #621

Merged
merged 8 commits into from
Jan 17, 2025

Conversation

najeal
Copy link
Contributor

@najeal najeal commented Jan 9, 2025

Why this should be merged

It closes #491

How this works

DestinationClient now embeds configured teleporter-max-gas-limit, messageHandler can now decide to reject or not the message based on the teleporter-max-gas-limit value coming from each DestinationClient instead of using default hardcoded value.

If the new config field is not provided, previous default value is set to stay consistent with older versions of icm-services

How this was tested

Existing tests have been updated.

How is this documented

najeal added 3 commits January 9, 2025 14:26
destination_client factory fails fast when creating a client for C-Chain with too high teleporter-max-gas-limit
…ch configured destination_client instead of hardcoded const
Copy link
Collaborator

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! I left some relatively minor comments.

destinationID, err := ids.FromString(destinationBlockchain.BlockchainID)
maxGasLimit := destinationBlockchain.TeleporterMaxGasLimit
isCChain := destinationID == cChainID
if isCChain && maxGasLimit > config.DefaultTeleporterMaxGasLimit {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we do this validation in DestinationBlockchain.Validate instead? If we do so, there shouldn't be any need to pass in cChainID as a parameter.

@@ -210,3 +226,7 @@ func (c *destinationClient) SenderAddress() common.Address {
func (c *destinationClient) DestinationBlockchainID() ids.ID {
return c.destinationBlockchainID
}

func (c *destinationClient) TeleporterMaxGasLimit() uint64 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's rename TeleporterMaxGasLimit to BlockGasLimit here and elsewhere. The destination client tx construction limits are not exclusive to Teleporter.

const (
// The maximum gas limit that can be specified for a Teleporter message
// Based on the C-Chain 15_000_000 gas limit per block, with other Warp message gas overhead conservatively estimated.
DefaultTeleporterMaxGasLimit = 12_000_000
Copy link
Collaborator

Choose a reason for hiding this comment

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

Once the validation is moved to this package as I suggested in another comment, let's not export this const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we really want to make it unexported ?
We use it in two places :

Copy link
Collaborator

Choose a reason for hiding this comment

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

That unit test doesn't need the value of DefaultTeleporterMaxGasLimit specifically. Instead, we can define a gas limit const in the test itself.

Not a huge deal either way, but I'd prefer to not export application variables for unit tests as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I will make the change 👍

Comment on lines 61 to 70
infoClient, err := peers.NewInfoAPI(relayerConfig.InfoAPI)
if err != nil {
logger.Error("Failed to create info API", zap.Error(err))
return nil, err
}
cChainID, err := infoClient.GetBlockchainID(context.Background(), "C")
if err != nil {
logger.Error("Failed to get C-Chain ID", zap.Error(err))
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't need this either if we move the C-Chain gas limit validation to the config package, as I suggested in another comment.

@najeal najeal requested a review from cam-schultz January 16, 2025 22:12
@geoff-vball geoff-vball merged commit 1940014 into ava-labs:main Jan 17, 2025
6 checks passed
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.

Parameterize block gas limit
3 participants