Skip to content

Commit

Permalink
Merge branch 'main' into reece/pfm-params-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Nov 3, 2023
2 parents dbadb8a + e5a274c commit d6fca16
Show file tree
Hide file tree
Showing 80 changed files with 11,547 additions and 800 deletions.
92 changes: 91 additions & 1 deletion .github/workflows/async-icq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ env:
GO_VERSION: 1.21.0
WORKING_DIRECTORY: modules/async-icq

HOST_TAR_PATH: /tmp/icq-host.tar
HOST_IMAGE_NAME: icq-host
HOST_DOCKER_TAG: icq-host:local

CONTROLLER_TAR_PATH: /tmp/icq-demo.tar
CONTROLLER_IMAGE_NAME: icq-demo
CONTROLLER_DOCKER_TAG: icq-demo:local

jobs:
golangci:
name: Linter
Expand Down Expand Up @@ -38,5 +46,87 @@ jobs:
- name: Test
run: go test ./...
working-directory: ${{ env.WORKING_DIRECTORY }}

build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export Host
uses: docker/build-push-action@v5
with:
context: ${{ env.WORKING_DIRECTORY }}
tags: ${{ env.HOST_DOCKER_TAG }}
file: ${{ env.WORKING_DIRECTORY }}/Dockerfile.icq
outputs: type=docker,dest=${{ env.HOST_TAR_PATH }}

- name: Build and export Controller
uses: docker/build-push-action@v5
with:
context: ${{ env.WORKING_DIRECTORY }}
tags: ${{ env.CONTROLLER_DOCKER_TAG }}
file: ${{ env.WORKING_DIRECTORY }}/Dockerfile.icq-demo
outputs: type=docker,dest=${{ env.CONTROLLER_TAR_PATH }}

- name: Upload host artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.HOST_IMAGE_NAME }}
path: ${{ env.HOST_TAR_PATH }}

- name: Upload controller artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.CONTROLLER_IMAGE_NAME }}
path: ${{ env.CONTROLLER_TAR_PATH }}

e2e-tests:
needs: build-docker
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
strategy:
matrix:
test:
- "ictest-icq"
fail-fast: false

steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: checkout chain
uses: actions/checkout@v4

- name: Download Host Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.HOST_IMAGE_NAME }}
path: /tmp

- name: Download Controller Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.CONTROLLER_IMAGE_NAME }}
path: /tmp

- name: Load Docker Image
run: |
docker image load -i ${{ env.HOST_TAR_PATH }}
docker image load -i ${{ env.CONTROLLER_TAR_PATH }}
docker image ls -a
# TODO: e2e
- name: Run Test
run: make ${{ matrix.test }}
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ func getBoolFromAny(value any) bool {
return boolVal
}

// getReceiver returns the receiver address for a given channel and original sender.
// GetReceiver returns the receiver address for a given channel and original sender.
// it overrides the receiver address to be a hash of the channel/origSender so that
// the receiver address is deterministic and can be used to identify the sender on the
// initial chain.
func getReceiver(channel string, originalSender string) (string, error) {
func GetReceiver(channel string, originalSender string) (string, error) {
senderStr := fmt.Sprintf("%s/%s", channel, originalSender)
senderHash32 := address.Hash(types.ModuleName, []byte(senderStr))
sender := sdk.AccAddress(senderHash32[:20])
Expand Down Expand Up @@ -208,7 +208,7 @@ func (im IBCMiddleware) OnRecvPacket(
}

// override the receiver so that senders cannot move funds through arbitrary addresses.
overrideReceiver, err := getReceiver(packet.DestinationChannel, data.Sender)
overrideReceiver, err := GetReceiver(packet.DestinationChannel, data.Sender)
if err != nil {
logger.Error("packetForwardMiddleware OnRecvPacket failed to construct override receiver", "error", err)
return newErrorAcknowledgement(fmt.Errorf("failed to construct override receiver: %w", err))
Expand Down
24 changes: 24 additions & 0 deletions modules/async-icq/Dockerfile.icq
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# host
# make local-image-icq
# docker run --rm -it icq-host:local q

FROM golang:1.21-alpine3.18 as builder

RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make go;

ENV GOPATH=""

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

RUN make build

FROM alpine:3.18

COPY --from=builder /go/build/* /bin/simd

ENTRYPOINT ["/bin/simd"]
24 changes: 24 additions & 0 deletions modules/async-icq/Dockerfile.icq-demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# make local-image-icq-demo
# docker run --rm -it icq-demo:local q interquery

FROM golang:1.21-alpine3.18 as builder

RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make go;

ENV GOPATH=""

COPY go.mod .
COPY go.sum .
COPY Makefile .

RUN go mod download

COPY ./testing/demo-simapp .

RUN make build

FROM alpine:3.18

COPY --from=builder /go/build/* /bin/icq-demo

ENTRYPOINT ["/bin/icq-demo"]
Loading

0 comments on commit d6fca16

Please sign in to comment.