Skip to content

Commit

Permalink
Merge branch 'main' into decider
Browse files Browse the repository at this point in the history
Signed-off-by: F. Eugene Aumson <[email protected]>
  • Loading branch information
feuGeneA authored Jul 12, 2024
2 parents a4b8007 + 7bcffc7 commit c5245b3
Show file tree
Hide file tree
Showing 52 changed files with 1,599 additions and 995 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax

* @michaelkaplan13 @cam-schultz @minghinmatthewlam @gwen917 @geoff-vball @bernard-avalabs
* @ava-labs/interop
13 changes: 6 additions & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set Go version
run: |
source ./scripts/versions.sh
echo GO_VERSION=$GO_VERSION >> $GITHUB_ENV
echo SUBNET_EVM_VERSION=$SUBNET_EVM_VERSION >> $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: 'go.mod'

- name: Set subnet-evm version
run: |
source ./scripts/versions.sh
echo SUBNET_EVM_VERSION=$SUBNET_EVM_VERSION >> $GITHUB_ENV

- name: Checkout subnet-evm repository
uses: actions/checkout@v4
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ jobs:
with:
submodules: recursive

- name: Set Go version
run: |
source ./scripts/versions.sh
echo GO_VERSION=$GO_VERSION >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: 'go.mod'

- name: Install buf
uses: bufbuild/[email protected]
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
path: awm-relayer
submodules: recursive

# The GO_VERSION must be set explicitly to be used in the Dockerfile.
- name: Set Go version
run: |
source ./awm-relayer/scripts/versions.sh
source ./scripts/versions.sh
echo GO_VERSION=$GO_VERSION >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: 'go.mod'

- name: Set up arm64 cross compiler
run: |
Expand Down Expand Up @@ -70,8 +69,6 @@ jobs:
distribution: goreleaser
version: latest
args: release --clean
workdir: ./awm-relayer/
env:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO_VERSION: ${{ env.GO_VERSION }}
1 change: 0 additions & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: awm-relayer
submodules: recursive

- name: Run Snyk
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set Go version
run: |
source ./scripts/versions.sh
echo GO_VERSION=$GO_VERSION >> $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
go-version-file: 'go.mod'

- name: Run Relayer Unit Tests
run: ./scripts/test.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ server.log
# Foundry outputs
cache/
out/

# Release build outputs
osxcross/
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ linters:
- unconvert
- unused
- whitespace
- lll

linters-settings:
gofmt:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Setup

To start developing on AWM Relayer, you'll need Golang >= v1.21.7.
To start developing on AWM Relayer, you'll need Golang v1.21.12.

## Issues

Expand Down
60 changes: 54 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ The relayer is configured via a JSON file, the path to which is passed in via th

`"source-blockchain-id": string`

- cb58-encoded blockchain ID of the source blockchain.
- cb58-encoded or "0x" prefixed hex-encoded blockchain ID of the source blockchain.

`"destination-blockchain-id": string`

- cb58-encoded blockchain ID of the destination blockchain.
- cb58-encoded or "0x" prefixed hex-encoded blockchain ID of the destination blockchain.

`"source-address": string`

Expand All @@ -219,11 +219,11 @@ The relayer is configured via a JSON file, the path to which is passed in via th

`"subnet-id": string`

- cb58-encoded Subnet ID.
- cb58-encoded or "0x" prefixed hex-encoded Subnet ID.

`"blockchain-id": string`

- cb58-encoded blockchain ID.
- cb58-encoded or "0x" prefixed hex-encoded blockchain ID.

`"vm": string`

Expand Down Expand Up @@ -263,11 +263,11 @@ The relayer is configured via a JSON file, the path to which is passed in via th

`"subnet-id": string`

- cb58-encoded Subnet ID.
- cb58-encoded or "0x" prefixed hex-encoded Subnet ID.

`"blockchain-id": string`

- cb58-encoded blockchain ID.
- cb58-encoded or "0x" prefixed hex-encoded blockchain ID.

`"vm": string`

Expand Down Expand Up @@ -316,6 +316,54 @@ The relayer consists of the following components:
<img src="resources/relayer-diagram.png?raw=true"></img>
</div>

### API

#### `/relay`
- Used to manually relay a Warp message. The body of the request must contain the following JSON:
```json
{
"blockchain-id": "<cb58-encoded or '0x' prefixed hex-encoded of blockchain ID>",
"message-id": "<cb58-encoded or '0x' prefixed hex-encoded of Warp message ID>",
"block-num": "<Block number that the message was sent in>"
}
```
- If successful, the endpoint will return the following JSON:
```json
{
"transaction-hash": "<Transaction hash that includes the delivered warp message>"
}
```

#### `/relay/message`
- Used to manually relay a warp message. The body of the request must contain the following JSON:
```json
{
"unsigned-message-bytes": "<Hex encoded byte array containing the unsigned warp message>",
"source-address": "<Hex encoding of address that sent the warp message>"
}
```
- If successful, the endpoint will return the following JSON:
```json
{
"transaction-hash": "<Transaction hash that includes the delivered Warp message>",
}
```

#### `/health`
- Takes no arguments. Returns a `200` status code if all Application Relayers are healthy. Returns a `503` status if any of the Application Relayers have experienced an unrecoverable error. Here is an example return body:
```json
{
"status": "down",
"details": {
"relayers-all": {
"status": "down",
"timestamp": "2024-06-01T05:06:07.685522Z",
"error": "<List of cb-58 encoded IDs for unhealthy relayers>"
}
}
}
```

## Testing

### Unit Tests
Expand Down
42 changes: 42 additions & 0 deletions api/health_check.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package api

import (
"context"
"fmt"
"net/http"

"github.com/alexliesenfeld/health"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/logging"
"go.uber.org/atomic"
"go.uber.org/zap"
)

const HealthAPIPath = "/health"

func HandleHealthCheck(logger logging.Logger, relayerHealth map[ids.ID]*atomic.Bool) {
http.Handle(HealthAPIPath, healthCheckHandler(logger, relayerHealth))
}

func healthCheckHandler(logger logging.Logger, relayerHealth map[ids.ID]*atomic.Bool) http.Handler {
return health.NewHandler(health.NewChecker(
health.WithCheck(health.Check{
Name: "relayers-all",
Check: func(context.Context) error {
// Store the IDs as the cb58 encoding
var unhealthyRelayers []string
for id, health := range relayerHealth {
if !health.Load() {
unhealthyRelayers = append(unhealthyRelayers, id.String())
}
}

if len(unhealthyRelayers) > 0 {
logger.Fatal("Relayers are unhealthy for blockchains", zap.Strings("blockchains", unhealthyRelayers))
return fmt.Errorf("relayers are unhealthy for blockchains %v", unhealthyRelayers)
}
return nil
},
}),
))
}
Loading

0 comments on commit c5245b3

Please sign in to comment.