Skip to content

Commit

Permalink
Merge branch 'main' into fix-send-response
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti authored Jun 20, 2024
2 parents b7fb428 + 99f947b commit 4b8999e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: "Build Docker image and push to Dockerhub"
runs-on: ubuntu-latest
env:
AWS_REGION: eu-west-1
AWS_REGION: us-east-1 # This is the region to authenticate against for public ECR repositories
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
Expand All @@ -20,22 +20,21 @@ jobs:
- uses: actions/checkout@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1.6.1
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::118330671040:role/node-indexer-ci
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public

- name: Install prerequisites for Docker build
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- env:
GITHUB_TOKEN: ${{ secrets.DUNE_ENG_ACCESS_TOKEN }}
DOCKER_HUB_KEY: ${{ secrets.DOCKER_HUB_KEY }}
run: |
- run: |
make image-push
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ gen-mocks: bin/moq ./client/jsonrpc/ ./client/duneapi/

image-build:
@echo "# Building Docker images"
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t duneanalytics/node-indexer:latest -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} .
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t public.ecr.aws/duneanalytics/node-indexer:latest .

image-push:
@echo "# Pushing Docker images to Docker Hub (after building)"
echo -n "${DOCKER_HUB_KEY}" | docker login --username duneanalytics --password-stdin
@echo "# Pushing Docker images to ECR (after building)"
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t duneanalytics/node-indexer:latest -f Dockerfile --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} --push .
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v8 -t public.ecr.aws/duneanalytics/node-indexer:latest --push .
18 changes: 9 additions & 9 deletions client/duneapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,22 @@ func (c *client) GetProgressReport(ctx context.Context) (*models.BlockchainIndex
return nil, err
}

if resp.StatusCode == http.StatusNotFound {
// no progress yet, first ingest for this chain
return &models.BlockchainIndexProgress{
BlockchainName: c.cfg.BlockchainName,
EVMStack: c.cfg.Stack.String(),
LastIngestedBlockNumber: -1, // no block ingested
LatestBlockNumber: 0,
}, nil
}
if resp.StatusCode != http.StatusOK {
var errorResp errorResponse
err = json.Unmarshal(responseBody, &errorResp)
if err != nil {
return nil, err
}
err = fmt.Errorf("got non-OK response, status code: %d, body: '%s'", resp.StatusCode, errorResp.Error)
// No progress yet
if resp.StatusCode == http.StatusNotFound {
return &models.BlockchainIndexProgress{
BlockchainName: c.cfg.BlockchainName,
EVMStack: c.cfg.Stack.String(),
LastIngestedBlockNumber: 0,
LatestBlockNumber: 0,
}, nil
}
return nil, err
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ func main() {
progress, err := duneClient.GetProgressReport(ctx)
if err != nil {
stdlog.Fatal(err)
} else {
startBlockNumber = progress.LastIngestedBlockNumber + 1
}
startBlockNumber = progress.LastIngestedBlockNumber + 1
} else {
startBlockNumber = cfg.BlockHeight
}
Expand Down

0 comments on commit 4b8999e

Please sign in to comment.