Skip to content

Commit

Permalink
fix nits - block gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
najeal committed Jan 12, 2025
1 parent 268aba7 commit d9040bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions messages/teleporter/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ func (m *messageHandler) ShouldSendMessage(destinationClient vms.DestinationClie
return false, fmt.Errorf("failed to calculate Teleporter message ID: %w", err)
}
requiredGasLimit := m.teleporterMessage.RequiredGasLimit.Uint64()
maxGasLimit := destinationClient.BlockGasLimit()
destBlockGasLimit := destinationClient.BlockGasLimit()
// Check if the specified gas limit is below the maximum threshold
if requiredGasLimit > maxGasLimit {
if requiredGasLimit > destBlockGasLimit {
m.logger.Info(
"Gas limit exceeds maximum threshold",
zap.String("destinationBlockchainID", destinationBlockchainID.String()),
zap.String("teleporterMessageID", teleporterMessageID.String()),
zap.Uint64("requiredGasLimit", m.teleporterMessage.RequiredGasLimit.Uint64()),
zap.Uint64("maxGasLimit", maxGasLimit),
zap.Uint64("blockGasLimit", destBlockGasLimit),
)
return false, nil
}
Expand Down
1 change: 1 addition & 0 deletions messages/teleporter/message_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func TestShouldSendMessage(t *testing.T) {
SenderAddress().
Return(test.senderAddressResult).
Times(test.senderAddressTimes)
mockClient.EXPECT().BlockGasLimit().Return(uint64(config.DefaultBlockGasLimit)).AnyTimes()
mockClient.EXPECT().DestinationBlockchainID().Return(destinationBlockchainID).AnyTimes()
if test.messageReceivedCall != nil {
messageReceivedInput := interfaces.CallMsg{
Expand Down
6 changes: 3 additions & 3 deletions relayer/config/destination_blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
// The maximum gas limit that can be specified for a Teleporter message
// The block 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.
DefaultBlockGasLimit = 12_000_000
)
Expand All @@ -29,7 +29,7 @@ type DestinationBlockchain struct {
KMSKeyID string `mapstructure:"kms-key-id" json:"kms-key-id"`
KMSAWSRegion string `mapstructure:"kms-aws-region" json:"kms-aws-region"`
AccountPrivateKey string `mapstructure:"account-private-key" json:"account-private-key"`
BlockGasLimit uint64 `mapstructure:"teleporter-max-gas-limit" json:"teleporter-max-gas-limit"`
BlockGasLimit uint64 `mapstructure:"block-gas-limit" json:"block-gas-limit"`

// Fetched from the chain after startup
warpConfig WarpConfig
Expand Down Expand Up @@ -80,7 +80,7 @@ func (s *DestinationBlockchain) Validate() error {

if s.subnetID == constants.PrimaryNetworkID &&
s.BlockGasLimit > DefaultBlockGasLimit {
return fmt.Errorf("C-Chain max-gas-limit '%d' exceeded", s.BlockGasLimit)
return fmt.Errorf("C-Chain block-gas-limit '%d' exceeded", s.BlockGasLimit)
}

return nil
Expand Down

0 comments on commit d9040bb

Please sign in to comment.