Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v[0-9]+\\.[0-9]+\\.[0-9]+" # Official release version tags e.g. v2.0.5
- "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+" # Release candidate tags e.g. v1.0.3-rc4
- "v[0-9]+\\.[0-9]+\\.[0-9]+-alpha[0-9]+" # Alpha release testing tags e.g. v0.0.3-alpha1
- "sdk47-v[0-9]+\\.[0-9]+\\.[0-9]+" # Official release version tags e.g. v2.0.5
- "sdk47-v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+" # Release candidate tags e.g. v1.0.3-rc4
- "sdk47-v[0-9]+\\.[0-9]+\\.[0-9]+-alpha[0-9]+" # Alpha release testing tags e.g. v0.0.3-alpha1

permissions:
contents: write
Expand Down
1 change: 1 addition & 0 deletions cw-relayer/cmd/cw-relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error {
cfg.Account.AccPrefix,
cfg.GasAdjustment,
cfg.GasPrices,
cfg.FeeGrant.Granter,
)
if err != nil {
return err
Expand Down
13 changes: 9 additions & 4 deletions cw-relayer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ var (
type (
// Config defines all necessary cw-relayer configuration parameters.
Config struct {
Account Account `mapstructure:"account" validate:"required,gt=0,dive,required"`
Keyring Keyring `mapstructure:"keyring" validate:"required,gt=0,dive,required"`
RPC RPC `mapstructure:"rpc" validate:"required,gt=0,dive,required"`
Restart RestartConfig `mapstructure:"restart" validate:"required"`
Account Account `mapstructure:"account" validate:"required,gt=0,dive,required"`
Keyring Keyring `mapstructure:"keyring" validate:"required,gt=0,dive,required"`
RPC RPC `mapstructure:"rpc" validate:"required,gt=0,dive,required"`
Restart RestartConfig `mapstructure:"restart" validate:"required"`
FeeGrant FeeGrantConfig `mapstructure:"fee_grant" validate:"dive"`

ProviderTimeout string `mapstructure:"provider_timeout"`
ContractAddress string `mapstructure:"contract_address"`
Expand Down Expand Up @@ -87,6 +88,10 @@ type (
SkipError bool `mapstructure:"skip_error"`
}

FeeGrantConfig struct {
Granter string `mapstructure:"granter" validate:"omitempty,required"`
}

// RPC defines RPC configuration of both the wasmd chain and Cometbft nodes.
RPC struct {
TMRPCEndpoint string `mapstructure:"tmrpc_endpoint" validate:"required"`
Expand Down
20 changes: 17 additions & 3 deletions cw-relayer/relayer/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type (
GasAdjustment float64
KeyringPassphrase string
ChainHeight *ChainHeight
feeGranter sdk.AccAddress
}

passReader struct {
Expand Down Expand Up @@ -79,6 +80,7 @@ func NewRelayerClient(
accPrefix string,
gasAdjustment float64,
GasPrices string,
granter string,
) (RelayerClient, error) {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(accPrefix, accPrefix+sdk.PrefixPublic)
Expand Down Expand Up @@ -110,6 +112,17 @@ func NewRelayerClient(
return RelayerClient{}, err
}

if len(granter) > 0 {
feeGranterAddr, err := sdk.AccAddressFromBech32(granter)
if err != nil {
return RelayerClient{}, err
}

relayerClient.feeGranter = feeGranterAddr
} else {
relayerClient.feeGranter = clientCtx.GetFeeGranterAddress()
}

blockHeight, err := rpc.GetChainHeight(clientCtx)
if err != nil {
return RelayerClient{}, err
Expand Down Expand Up @@ -179,7 +192,7 @@ func (oc RelayerClient) BroadcastTx(timeoutDuration time.Duration, nextBlockHeig

if latestBlockHeight <= lastCheckHeight {
if time.Since(start).Seconds() >= timeoutDuration.Seconds() {
return fmt.Errorf("timeout duration exceeded")
return fmt.Errorf("timeout duration exceeded, last check height = %v", lastCheckHeight)
}

continue
Expand All @@ -188,7 +201,7 @@ func (oc RelayerClient) BroadcastTx(timeoutDuration time.Duration, nextBlockHeig
// set last check height to latest block height
lastCheckHeight = latestBlockHeight

resp, err := BroadcastTx(clientCtx, factory, msgs...)
resp, err := BroadcastTx(oc.feeGranter, clientCtx, factory, msgs...)
if resp != nil && resp.Code != 0 {
telemetry.IncrCounter(1, "failure", "tx", "code")
oc.logger.Error().Msg(resp.String())
Expand Down Expand Up @@ -347,7 +360,8 @@ func (oc RelayerClient) CreateTxFactory() (tx.Factory, error) {
WithGasPrices(oc.GasPrices).
WithKeybase(clientCtx.Keyring).
WithSignMode(signing.SignMode_SIGN_MODE_DIRECT).
WithSimulateAndExecute(true)
WithSimulateAndExecute(true).
WithFeeGranter(oc.feeGranter)

return txFactory, nil
}
Expand Down
4 changes: 2 additions & 2 deletions cw-relayer/relayer/client/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// Note, BroadcastTx is copied from the SDK except it removes a few unnecessary
// things like prompting for confirmation and printing the response. Instead,
// we return the TxResponse.
func BroadcastTx(clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) (*sdk.TxResponse, error) {
func BroadcastTx(feeGranter sdk.AccAddress, clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) (*sdk.TxResponse, error) {
txf, err := prepareFactory(clientCtx, txf)
if err != nil {
return nil, err
Expand All @@ -31,7 +31,7 @@ func BroadcastTx(clientCtx client.Context, txf tx.Factory, msgs ...sdk.Msg) (*sd
return nil, err
}

unsignedTx.SetFeeGranter(clientCtx.GetFeeGranterAddress())
unsignedTx.SetFeeGranter(feeGranter)

if err = tx.Sign(txf, clientCtx.GetFromName(), unsignedTx, true); err != nil {
return nil, err
Expand Down