chain icon indicating copy to clipboard operation
chain copied to clipboard

[Tunnel] implement route - Axelar

Open satawatnack opened this issue 10 months ago • 2 comments

Implementation details

  • Add Axelar route

Integration test

  • [x] Test send packet through the Axelar route

Please ensure the following requirements are met before submitting a pull request:

  • [x] The pull request is targeted against the correct target branch
  • [ ] The pull request is linked to an issue with appropriate discussion and an accepted design OR is linked to a spec that describes the work.
  • [x] The pull request includes a description of the implementation/work done in detail.
  • [ ] The pull request includes any and all appropriate unit/integration tests
  • [ ] You have added a relevant changelog entry to CHANGELOG_UNRELEASED.md
  • [x] You have re-reviewed the files affected by the pull request (e.g. using the Files changed tab in the Github PR explorer)

satawatnack avatar Feb 03 '25 08:02 satawatnack

@CodiumAI-Agent /review

RogerKSI avatar Apr 04 '25 07:04 RogerKSI

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Protobuf Message Indices

The new AxelarRoute and AxelarPacketReceipt definitions adjust the message indices and registration. Verify that the indices and message exporters are consistent with the generated protobuf requirements.

	return nil
}

// AxelarRoute represents a route for Axelar packets and implements the RouteI interface.
type AxelarRoute struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
	unknownFields protoimpl.UnknownFields

	// destination_chain_id is the destination chain ID
	DestinationChainId string `protobuf:"bytes,1,opt,name=destination_chain_id,json=destinationChainId,proto3" json:"destination_chain_id,omitempty"`
	// destination_contract_address is the destination contract address
	DestinationContractAddress string `protobuf:"bytes,2,opt,name=destination_contract_address,json=destinationContractAddress,proto3" json:"destination_contract_address,omitempty"`
	// fee is the fee for each packet in the Axelar network.
	Fee *v1beta11.Coin `protobuf:"bytes,3,opt,name=fee,proto3" json:"fee,omitempty"`
}

func (x *AxelarRoute) Reset() {
	*x = AxelarRoute{}
	if protoimpl.UnsafeEnabled {
		mi := &file_band_tunnel_v1beta1_route_proto_msgTypes[8]
		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
		ms.StoreMessageInfo(mi)
	}
}

func (x *AxelarRoute) String() string {
	return protoimpl.X.MessageStringOf(x)
}

func (*AxelarRoute) ProtoMessage() {}

// Deprecated: Use AxelarRoute.ProtoReflect.Descriptor instead.
func (*AxelarRoute) Descriptor() ([]byte, []int) {
	return file_band_tunnel_v1beta1_route_proto_rawDescGZIP(), []int{8}
}

func (x *AxelarRoute) GetDestinationChainId() string {
	if x != nil {
		return x.DestinationChainId
	}
	return ""
}

func (x *AxelarRoute) GetDestinationContractAddress() string {
	if x != nil {
		return x.DestinationContractAddress
	}
	return ""
}

func (x *AxelarRoute) GetFee() *v1beta11.Coin {
	if x != nil {
		return x.Fee
	}
	return nil
}
CLI Command Parsing

The added CLI commands for creating and updating Axelar tunnels include multiple arguments that need thorough validation and error handling. Verify that the argument parsing and conversion logic is robust.

func GetTxCmdCreateAxelarTunnel() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "axelar [destination-chain-id] [destination-address] [axelar-fee] [initial-deposit] [interval] [signalInfos-json-file]",
		Short: "Create a new Axelar tunnel",
		Args:  cobra.ExactArgs(6),
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientTxContext(cmd)
			if err != nil {
				return err
			}

			destinationChainID := args[0]
			destinationContractAddress := args[1]

			axelarFee, err := sdk.ParseCoinNormalized(args[2])
			if err != nil {
				return err
			}

			initialDeposit, err := sdk.ParseCoinsNormalized(args[3])
			if err != nil {
				return err
			}

			interval, err := strconv.ParseUint(args[4], 10, 64)
			if err != nil {
				return err
			}

			signalInfos, err := parseSignalDeviations(args[5])
			if err != nil {
				return err
			}

			msg, err := types.NewMsgCreateAxelarTunnel(
				signalInfos.ToSignalDeviations(),
				interval,
				destinationChainID,
				destinationContractAddress,
				axelarFee,
				initialDeposit,
				clientCtx.GetFromAddress().String(),
			)
			if err != nil {
				return err
			}

			return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
		},
	}

	flags.AddTxFlagsToCmd(cmd)
	return cmd
}

Parameter Validation

The new AxelarIBCChannel parameter validation checks the channel format. Ensure that the error message is clear and that the validation logic properly permits an empty channel identifier when appropriate.

	return fmt.Errorf("invalid base packet fee: %s", p.BasePacketFee)
}

// validate AxelarIBCChannel
if p.AxelarIBCChannel != "" && !channeltypes.IsChannelIDFormat(p.AxelarIBCChannel) {
	return fmt.Errorf("channel identifier is not in the format: `channel-{N}` or be empty string")
}

QodoAI-Agent avatar Apr 04 '25 07:04 QodoAI-Agent