Skip to content

Commit

Permalink
fix: used block height when using range block rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsainju committed Aug 5, 2024
1 parent 3edd855 commit 91b4f3c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions relayer/chains/icon/icon_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ func (icp *IconChainProcessor) handlePathProcessorUpdate(ctx context.Context,

if latestHeight != 0 && uint64(latestHeight)-latestHeader.Height() < 3 {
inSync = true
if !icp.inSync {
icp.inSync = true
icp.log.Info("Chain is in sync")
}

Check warning on line 677 in relayer/chains/icon/icon_chain_processor.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/icon/icon_chain_processor.go#L674-L677

Added lines #L674 - L677 were not covered by tests
}

for _, pp := range icp.pathProcessors {
Expand Down
18 changes: 8 additions & 10 deletions relayer/chains/wasm/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1309,17 +1309,15 @@ func parseEventsFromTxResponse(resp *sdk.TxResponse) []provider.RelayerEvent {
return events
}

for _, logs := range resp.Logs {
for _, event := range logs.Events {
attributes := make(map[string]string)
for _, attribute := range event.Attributes {
attributes[attribute.Key] = attribute.Value
}
events = append(events, provider.RelayerEvent{
EventType: event.Type,
Attributes: attributes,
})
for _, event := range resp.Events {
attributes := make(map[string]string)
for _, attribute := range event.Attributes {
attributes[attribute.Key] = attribute.Value
}
events = append(events, provider.RelayerEvent{
EventType: event.Type,
Attributes: attributes,
})
}
return events
}
Expand Down
8 changes: 8 additions & 0 deletions relayer/chains/wasm/wasm_chain_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@ func (ccp *WasmChainProcessor) queryCycle(ctx context.Context, persistence *quer
heighttoSync := syncUpHeight()
delta := persistence.latestHeight - persistence.latestQueriedBlock
if ccp.chainProvider.rangeSupport && delta > 20 {
status, err := ccp.chainProvider.BlockRPCClient.Status(ctx)
if err != nil {
return nil
}
if persistence.latestQueriedBlock > status.SyncInfo.LatestBlockHeight &&
persistence.latestHeight > status.SyncInfo.LatestBlockHeight {
persistence.latestHeight = status.SyncInfo.LatestBlockHeight
}
if (persistence.latestQueriedBlock + 1) >= persistence.latestHeight {
return nil
}
Expand Down

0 comments on commit 91b4f3c

Please sign in to comment.