Skip to content

Commit

Permalink
feat: limit query window (#389)
Browse files Browse the repository at this point in the history
ci: update Go to v1.22.2
  • Loading branch information
byte-bandit authored May 27, 2024
1 parent c5d44b9 commit 0ec8c23
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22.2'
cache: false
- name: Run tests
run: go test -v ./...
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.22.2'
cache: false
- name: Go lint
uses: golangci/golangci-lint-action@v6
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
go: '1.21'
go: '1.22.2'
issues-exit-code: 1
timeout: 10m
modules-download-mode: readonly
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
###########################
#### Base image ####
###########################
FROM golang:1.21-bullseye AS base
FROM golang:1.22-bullseye AS base
WORKDIR /app

###########################
Expand All @@ -26,9 +26,9 @@ CMD ["/app/scripts/live-reload.sh", "/hack-start-because-cosmos-always-wants-to-
FROM base AS builder
COPY . /app
RUN \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
cd /app && go build -o /sparrow ./cmd/sparrow
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
cd /app && go build -o /sparrow ./cmd/sparrow

###########################
#### Local testnet ####
Expand Down
14 changes: 8 additions & 6 deletions chain/evm/compass.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,13 @@ func (t *compass) GetBatchSendEvents(ctx context.Context, orchestrator string) (
return nil, err
}

blockNumber := filter.FromBlock.Int64()
currentBlockNumber := filter.FromBlock.Int64()
if t.lastObservedBlockHeights.batchSendEvent == 0 {
t.lastObservedBlockHeights.batchSendEvent = blockNumber - 10000
t.lastObservedBlockHeights.batchSendEvent = currentBlockNumber - 10_000
}

filter.FromBlock = big.NewInt(t.lastObservedBlockHeights.batchSendEvent)
filter.ToBlock = big.NewInt(min(t.lastObservedBlockHeights.batchSendEvent+10_000, currentBlockNumber))

var events []chain.BatchSendEvent

Expand Down Expand Up @@ -672,7 +673,7 @@ func (t *compass) GetBatchSendEvents(ctx context.Context, orchestrator string) (
})
}

t.lastObservedBlockHeights.batchSendEvent = blockNumber
t.lastObservedBlockHeights.batchSendEvent = filter.ToBlock.Int64()

return events, err
}
Expand All @@ -688,12 +689,13 @@ func (t *compass) GetSendToPalomaEvents(ctx context.Context, orchestrator string
return nil, err
}

blockNumber := filter.FromBlock.Int64()
currentBlockNumber := filter.FromBlock.Int64()
if t.lastObservedBlockHeights.sendToPalomaEvent == 0 {
t.lastObservedBlockHeights.sendToPalomaEvent = blockNumber - 1000
t.lastObservedBlockHeights.sendToPalomaEvent = currentBlockNumber - 10_000
}

filter.FromBlock = big.NewInt(t.lastObservedBlockHeights.sendToPalomaEvent)
filter.ToBlock = big.NewInt(min(t.lastObservedBlockHeights.sendToPalomaEvent+10_000, currentBlockNumber))

var events []chain.SendToPalomaEvent

Expand Down Expand Up @@ -753,7 +755,7 @@ func (t *compass) GetSendToPalomaEvents(ctx context.Context, orchestrator string
})
}

t.lastObservedBlockHeights.sendToPalomaEvent = blockNumber
t.lastObservedBlockHeights.sendToPalomaEvent = filter.ToBlock.Int64()

return events, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/palomachain/pigeon

go 1.21
go 1.22.2

require (
cosmossdk.io/errors v1.0.1
Expand Down

0 comments on commit 0ec8c23

Please sign in to comment.