diff --git a/relayer/chains/archway/archway_chain_processor.go b/relayer/chains/archway/archway_chain_processor.go index 37b1fee9c..45626c032 100644 --- a/relayer/chains/archway/archway_chain_processor.go +++ b/relayer/chains/archway/archway_chain_processor.go @@ -394,7 +394,7 @@ func (ccp *ArchwayChainProcessor) queryCycle(ctx context.Context, persistence *q var latestHeader provider.IBCHeader ccp.SnapshotHeight(int(persistence.latestHeight)) - + for i := persistence.latestQueriedBlock + 1; i <= persistence.latestHeight; i++ { var eg errgroup.Group var blockRes *ctypes.ResultBlockResults @@ -498,10 +498,10 @@ func (ccp *ArchwayChainProcessor) queryCycle(ctx context.Context, persistence *q func (ccp *ArchwayChainProcessor) SnapshotHeight(height int) { - blockInterval := ccp.Provider().ProviderConfig().BlockInterval() + blockInterval := ccp.Provider().ProviderConfig().GetBlockInterval() snapshotThreshold := common.ONE_HOUR / int(blockInterval) - retryAfter := ccp.Provider().FirstRetryBlockAfter() + retryAfter := ccp.Provider().ProviderConfig().GetFirstRetryBlockAfter() snapshotHeight := height - int(retryAfter) if snapshotHeight%snapshotThreshold == 0 { @@ -511,7 +511,6 @@ func (ccp *ArchwayChainProcessor) SnapshotHeight(height int) { } } } -// TODO: review add verifier func (ccp *ArchwayChainProcessor) CollectMetrics(ctx context.Context, persistence *queryCyclePersistence) { ccp.CurrentBlockHeight(ctx, persistence) diff --git a/relayer/chains/archway/provider.go b/relayer/chains/archway/provider.go index 0c9890668..22e8b210c 100644 --- a/relayer/chains/archway/provider.go +++ b/relayer/chains/archway/provider.go @@ -201,10 +201,6 @@ func (pp *ArchwayProviderConfig) Validate() error { return nil } -func (pc *ArchwayProviderConfig) BlockInterval() uint64 { - return pc.ChainBlockInterval -} - func (pp *ArchwayProviderConfig) getRPCAddr() string { return pp.RPCAddr } @@ -213,6 +209,17 @@ func (pp *ArchwayProviderConfig) BroadcastMode() provider.BroadcastMode { return pp.Broadcast } +func (pp *ArchwayProviderConfig) GetBlockInterval() uint64 { + return pp.ChainBlockInterval +} + +func (pp *ArchwayProviderConfig) GetFirstRetryBlockAfter() uint64 { + if pp.FirstRetryBlockAfter != 0 { + return pp.FirstRetryBlockAfter + } + return 3 +} + func (pc *ArchwayProviderConfig) NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error) { if err := pc.Validate(); err != nil { return nil, err @@ -467,13 +474,6 @@ 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 -} - // 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) diff --git a/relayer/chains/cosmos/provider.go b/relayer/chains/cosmos/provider.go index db5943b17..37d528a90 100644 --- a/relayer/chains/cosmos/provider.go +++ b/relayer/chains/cosmos/provider.go @@ -70,10 +70,14 @@ func (pc CosmosProviderConfig) BroadcastMode() provider.BroadcastMode { return pc.Broadcast } -func (pc CosmosProviderConfig) BlockInterval() uint64 { +func (pc CosmosProviderConfig) GetBlockInterval() uint64 { panic("Not implemented for Cosmos") } +func (pc CosmosProviderConfig) GetFirstRetryBlockAfter() uint64 { + return 1 +} + // NewProvider validates the CosmosProviderConfig, instantiates a ChainClient and then instantiates a CosmosProvider func (pc CosmosProviderConfig) NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error) { if err := pc.Validate(); err != nil { @@ -314,10 +318,6 @@ func (cc *CosmosProvider) legacyEncodedEvents(log *zap.Logger, version string) b return semver.Compare("v"+version, cometEncodingThreshold) < 0 } -func (cc *CosmosProvider) 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) diff --git a/relayer/chains/icon/icon_chain_processor.go b/relayer/chains/icon/icon_chain_processor.go index 297f58f07..82bff777e 100644 --- a/relayer/chains/icon/icon_chain_processor.go +++ b/relayer/chains/icon/icon_chain_processor.go @@ -464,10 +464,10 @@ loop: func (icp *IconChainProcessor) SnapshotHeight(height int) { - blockInterval := icp.Provider().ProviderConfig().BlockInterval() + blockInterval := icp.Provider().ProviderConfig().GetBlockInterval() snapshotThreshold := rlycommon.ONE_HOUR / int(blockInterval) - retryAfter := icp.Provider().FirstRetryBlockAfter() + retryAfter := icp.Provider().ProviderConfig().GetFirstRetryBlockAfter() snapshotHeight := height - int(retryAfter) if snapshotHeight%snapshotThreshold == 0 { diff --git a/relayer/chains/icon/provider.go b/relayer/chains/icon/provider.go index 143d0ea8a..9571810b2 100644 --- a/relayer/chains/icon/provider.go +++ b/relayer/chains/icon/provider.go @@ -81,10 +81,17 @@ func (pp *IconProviderConfig) Validate() error { return nil } -func (pp *IconProviderConfig) BlockInterval() uint64 { +func (pp *IconProviderConfig) GetBlockInterval() uint64 { return pp.ChainBlockInterval } +func (pp *IconProviderConfig) GetFirstRetryBlockAfter() uint64 { + if pp.FirstRetryBlockAfter != 0 { + return pp.FirstRetryBlockAfter + } + return 8 +} + // NewProvider should provide a new Icon provider // NewProvider should provide a new Icon provider func (pp *IconProviderConfig) NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error) { @@ -578,10 +585,3 @@ 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 (icp *IconProvider) FirstRetryBlockAfter() uint64 { - if icp.PCfg.FirstRetryBlockAfter != 0 { - return icp.PCfg.FirstRetryBlockAfter - } - return 8 -} diff --git a/relayer/chains/penumbra/provider.go b/relayer/chains/penumbra/provider.go index 1fecbb2a9..f57902aeb 100644 --- a/relayer/chains/penumbra/provider.go +++ b/relayer/chains/penumbra/provider.go @@ -67,10 +67,14 @@ func (pc PenumbraProviderConfig) Validate() error { return nil } -func (pc PenumbraProviderConfig) BlockInterval() uint64 { +func (pc PenumbraProviderConfig) GetBlockInterval() uint64 { panic("Not implemented for Penumbra") } +func (pc PenumbraProviderConfig) GetFirstRetryBlockAfter() uint64 { + return 1 +} + func (pc PenumbraProviderConfig) BroadcastMode() provider.BroadcastMode { return pc.Broadcast } diff --git a/relayer/processor/path_end_runtime.go b/relayer/processor/path_end_runtime.go index f11145851..fec5c175a 100644 --- a/relayer/processor/path_end_runtime.go +++ b/relayer/processor/path_end_runtime.go @@ -492,7 +492,7 @@ func (pathEnd *pathEndRuntime) shouldSendPacketMessage(message packetIBCMessage, // 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() { + if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.ProviderConfig().GetFirstRetryBlockAfter() { return false } } else { @@ -580,7 +580,7 @@ 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() { + if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.ProviderConfig().GetFirstRetryBlockAfter() { return false } } else { @@ -660,7 +660,7 @@ func (pathEnd *pathEndRuntime) shouldSendChannelMessage(message channelIBCMessag // 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() { + if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.ProviderConfig().GetFirstRetryBlockAfter() { return false } } else { diff --git a/relayer/provider/provider.go b/relayer/provider/provider.go index 0d4b1ebed..340017480 100644 --- a/relayer/provider/provider.go +++ b/relayer/provider/provider.go @@ -31,7 +31,8 @@ type ProviderConfig interface { NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (ChainProvider, error) Validate() error BroadcastMode() BroadcastMode - BlockInterval() uint64 + GetBlockInterval() uint64 + GetFirstRetryBlockAfter() uint64 } type RelayerMessage interface { @@ -424,7 +425,6 @@ 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)