Skip to content

Commit

Permalink
fix: first block try after issue
Browse files Browse the repository at this point in the history
  • Loading branch information
viveksharmapoudel committed Jul 13, 2023
1 parent 7cc09d5 commit b2fe9cc
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 34 deletions.
48 changes: 28 additions & 20 deletions relayer/chains/archway/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,27 @@ var (
)

type ArchwayProviderConfig struct {
KeyDirectory string `json:"key-directory" yaml:"key-directory"`
Key string `json:"key" yaml:"key"`
ChainName string `json:"-" yaml:"-"`
ChainID string `json:"chain-id" yaml:"chain-id"`
RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"`
AccountPrefix string `json:"account-prefix" yaml:"account-prefix"`
KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"`
GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"`
GasPrices string `json:"gas-prices" yaml:"gas-prices"`
MinGasAmount uint64 `json:"min-gas-amount" yaml:"min-gas-amount"`
Debug bool `json:"debug" yaml:"debug"`
Timeout string `json:"timeout" yaml:"timeout"`
BlockTimeout string `json:"block-timeout" yaml:"block-timeout"`
OutputFormat string `json:"output-format" yaml:"output-format"`
SignModeStr string `json:"sign-mode" yaml:"sign-mode"`
ExtraCodecs []string `json:"extra-codecs" yaml:"extra-codecs"`
Modules []module.AppModuleBasic `json:"-" yaml:"-"`
Slip44 int `json:"coin-type" yaml:"coin-type"`
Broadcast provider.BroadcastMode `json:"broadcast-mode" yaml:"broadcast-mode"`
IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"`
KeyDirectory string `json:"key-directory" yaml:"key-directory"`
Key string `json:"key" yaml:"key"`
ChainName string `json:"-" yaml:"-"`
ChainID string `json:"chain-id" yaml:"chain-id"`
RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"`
AccountPrefix string `json:"account-prefix" yaml:"account-prefix"`
KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"`
GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"`
GasPrices string `json:"gas-prices" yaml:"gas-prices"`
MinGasAmount uint64 `json:"min-gas-amount" yaml:"min-gas-amount"`
Debug bool `json:"debug" yaml:"debug"`
Timeout string `json:"timeout" yaml:"timeout"`
BlockTimeout string `json:"block-timeout" yaml:"block-timeout"`
OutputFormat string `json:"output-format" yaml:"output-format"`
SignModeStr string `json:"sign-mode" yaml:"sign-mode"`
ExtraCodecs []string `json:"extra-codecs" yaml:"extra-codecs"`
Modules []module.AppModuleBasic `json:"-" yaml:"-"`
Slip44 int `json:"coin-type" yaml:"coin-type"`
Broadcast provider.BroadcastMode `json:"broadcast-mode" yaml:"broadcast-mode"`
IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"`
FirstRetryBlockAfter uint64 `json:"first-retry-block-after" yaml:"first-retry-block-after"`
}

type ArchwayIBCHeader struct {
Expand Down Expand Up @@ -451,6 +452,13 @@ func (app *ArchwayProvider) MsgRegisterCounterpartyPayee(portID, channelID, rela
return nil, fmt.Errorf("Not implemented for Icon")
}

func (cc *ArchwayProvider) FirstRetryBlockAfter() uint64 {
if cc.PCfg.FirstRetryBlockAfter != 0 {
return cc.PCfg.FirstRetryBlockAfter
}
return 3

Check warning on line 459 in relayer/chains/archway/provider.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/archway/provider.go#L455-L459

Added lines #L455 - L459 were not covered by tests
}

// keysDir returns a string representing the path on the local filesystem where the keystore will be initialized.
func keysDir(home, chainID string) string {
return path.Join(home, "keys", chainID)
Expand Down
4 changes: 4 additions & 0 deletions relayer/chains/cosmos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ func (cc *CosmosProvider) legacyEncodedEvents(log *zap.Logger, version string) b
return semver.Compare("v"+version, cometEncodingThreshold) < 0
}

func (cc *CosmosProvider) FirstRetryBlockAfter() uint64 {
return 1

Check warning on line 314 in relayer/chains/cosmos/provider.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/cosmos/provider.go#L313-L314

Added lines #L313 - L314 were not covered by tests
}

// keysDir returns a string representing the path on the local filesystem where the keystore will be initialized.
func keysDir(home, chainID string) string {
return path.Join(home, "keys", chainID)
Expand Down
32 changes: 20 additions & 12 deletions relayer/chains/icon/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,19 @@ var (
)

type IconProviderConfig struct {
Key string `json:"key" yaml:"key"`
ChainName string `json:"-" yaml:"-"`
ChainID string `json:"chain-id" yaml:"chain-id"`
RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"`
Timeout string `json:"timeout" yaml:"timeout"`
Keystore string `json:"keystore" yaml:"keystore"`
Password string `json:"password" yaml:"password"`
ICONNetworkID int64 `json:"icon-network-id" yaml:"icon-network-id" default:"3"`
BTPNetworkID int64 `json:"btp-network-id" yaml:"btp-network-id"`
BTPNetworkTypeID int64 `json:"btp-network-type-id" yaml:"btp-network-type-id"`
BTPHeight int64 `json:"start-btp-height" yaml:"start-btp-height"`
IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"`
Key string `json:"key" yaml:"key"`
ChainName string `json:"-" yaml:"-"`
ChainID string `json:"chain-id" yaml:"chain-id"`
RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"`
Timeout string `json:"timeout" yaml:"timeout"`
Keystore string `json:"keystore" yaml:"keystore"`
Password string `json:"password" yaml:"password"`
ICONNetworkID int64 `json:"icon-network-id" yaml:"icon-network-id" default:"3"`
BTPNetworkID int64 `json:"btp-network-id" yaml:"btp-network-id"`
BTPNetworkTypeID int64 `json:"btp-network-type-id" yaml:"btp-network-type-id"`
BTPHeight int64 `json:"start-btp-height" yaml:"start-btp-height"`
IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"`
FirstRetryBlockAfter uint64 `json:"first-retry-block-after" yaml:"first-retry-block-after"`
}

func (pp *IconProviderConfig) Validate() error {
Expand Down Expand Up @@ -567,3 +568,10 @@ func (icp *IconProvider) GetCurrentBtpNetworkStartHeight() (int64, error) {
func (icp *IconProvider) MsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr string) (provider.RelayerMessage, error) {
return nil, fmt.Errorf("Not implemented for Icon")
}

func (cc *IconProvider) FirstRetryBlockAfter() uint64 {
if cc.PCfg.FirstRetryBlockAfter != 0 {
return cc.PCfg.FirstRetryBlockAfter
}
return 8

Check warning on line 576 in relayer/chains/icon/provider.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/provider.go#L572-L576

Added lines #L572 - L576 were not covered by tests
}
2 changes: 1 addition & 1 deletion relayer/chains/icon/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func (icp *IconProvider) SendIconTransaction(
if err != nil {
return err
}
icp.log.Debug("Submitted Icon Transaction", zap.String("chain_id", icp.ChainId()), zap.String("method", m.Method), zap.String("tx_hash", string(txParam.TxHash)))
icp.log.Info("Submitted Transaction", zap.String("chain_id", icp.ChainId()), zap.String("method", m.Method), zap.String("tx_hash", string(txParam.TxHash)))

// If update fails, the subsequent txn will fail, result of update not being fetched concurrently
switch m.Method {
Expand Down
4 changes: 4 additions & 0 deletions relayer/chains/penumbra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ func (cc *PenumbraProvider) legacyEncodedEvents(log *zap.Logger, version string)
return semver.Compare("v"+version, cometEncodingThreshold) < 0
}

func (cc *PenumbraProvider) FirstRetryBlockAfter() uint64 {
return 1
}

// keysDir returns a string representing the path on the local filesystem where the keystore will be initialized.
func keysDir(home, chainID string) string {
return path.Join(home, "keys", chainID)
Expand Down
3 changes: 3 additions & 0 deletions relayer/processor/path_end_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,9 @@ func (pathEnd *pathEndRuntime) shouldSendConnectionMessage(message connectionIBC
// this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet.
return false
}
if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.FirstRetryBlockAfter() {
return false
}

Check warning on line 582 in relayer/processor/path_end_runtime.go

View check run for this annotation

Codecov / codecov/patch

relayer/processor/path_end_runtime.go#L580-L582

Added lines #L580 - L582 were not covered by tests
} else {
if blocksSinceLastProcessed < blocksToRetryAssemblyAfter {
// this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet.
Expand Down
2 changes: 1 addition & 1 deletion relayer/processor/path_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (

// If the message was assembled successfully, but sending the message failed,
// how many blocks should pass before retrying.
blocksToRetrySendAfter = 5
blocksToRetrySendAfter = 1

// How many times to retry sending a message before giving up on it.
maxMessageSendRetries = 5
Expand Down
1 change: 1 addition & 0 deletions relayer/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ type QueryProvider interface {
QueryTx(ctx context.Context, hashHex string) (*RelayerTxResponse, error)
QueryTxs(ctx context.Context, page, limit int, events []string) ([]*RelayerTxResponse, error)
QueryLatestHeight(ctx context.Context) (int64, error)
FirstRetryBlockAfter() uint64

// QueryIBCHeader returns the IBC compatible block header at a specific height.
QueryIBCHeader(ctx context.Context, h int64) (IBCHeader, error)
Expand Down

0 comments on commit b2fe9cc

Please sign in to comment.