From fa47c905e67172540b8bea8f389a7f4b8a44cedf Mon Sep 17 00:00:00 2001 From: Will Liu Date: Mon, 12 Aug 2024 17:12:27 -0400 Subject: [PATCH] fix --- .github/workflows/protocol-build-and-push.yml | 181 +++++++++++++++++- protocol/x/clob/keeper/keeper.go | 1 + protocol/x/clob/keeper/process_operations.go | 2 +- protocol/x/clob/types/expected_keepers.go | 1 + protocol/x/subaccounts/keeper/subaccount.go | 3 +- protocol/x/subaccounts/types/types.go | 1 + 6 files changed, 186 insertions(+), 3 deletions(-) diff --git a/.github/workflows/protocol-build-and-push.yml b/.github/workflows/protocol-build-and-push.yml index 938f973e6d..fc26dd6e69 100644 --- a/.github/workflows/protocol-build-and-push.yml +++ b/.github/workflows/protocol-build-and-push.yml @@ -3,12 +3,47 @@ name: Protocol Build & Push Image to AWS ECR on: # yamllint disable-line rule:truthy push: branches: - - 'wl/sa3' - main - 'release/protocol/v[0-9]+.[0-9]+.x' # e.g. release/protocol/v0.1.x - 'release/protocol/v[0-9]+.x' # e.g. release/protocol/v1.x jobs: + build-and-push-dev: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./protocol + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: '0' # without this, ignite fails. + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_VALIDATOR_DEV }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_VALIDATOR_DEV }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, Tag, and Push the Image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: dev-validator + run: | + make localnet-build-amd64 + commit_hash=$(git rev-parse --short=7 HEAD) + docker build \ + --platform amd64 \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$commit_hash \ + -f testing/testnet-dev/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags + build-and-push-dev2: runs-on: ubuntu-latest defaults: @@ -44,3 +79,147 @@ jobs: -t $ECR_REGISTRY/$ECR_REPOSITORY:$commit_hash \ -f testing/testnet-dev/Dockerfile . docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags + + build-and-push-dev3: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./protocol + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: '0' # without this, ignite fails. + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_VALIDATOR_DEV3 }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_VALIDATOR_DEV3 }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, Tag, and Push the Image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: dev3-validator + run: | + make localnet-build-amd64 + commit_hash=$(git rev-parse --short=7 HEAD) + docker build \ + --platform amd64 \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$commit_hash \ + -f testing/testnet-dev/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags + + build-and-push-dev4: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./protocol + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: '0' # without this, ignite fails. + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_VALIDATOR_DEV4 }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_VALIDATOR_DEV4 }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, Tag, and Push the Image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: dev4-validator + run: | + make localnet-build-amd64 + commit_hash=$(git rev-parse --short=7 HEAD) + docker build \ + --platform amd64 \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$commit_hash \ + -f testing/testnet-dev/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags + + build-and-push-dev5: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./protocol + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: '0' # without this, ignite fails. + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_VALIDATOR_DEV5 }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_VALIDATOR_DEV5 }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, Tag, and Push the Image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: dev5-validator + run: | + make localnet-build-amd64 + commit_hash=$(git rev-parse --short=7 HEAD) + docker build \ + --platform amd64 \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$commit_hash \ + -f testing/testnet-dev/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags + + build-and-push-staging: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./protocol + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: '0' # without this, ignite fails. + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_VALIDATOR_STAGING }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_VALIDATOR_STAGING }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, Tag, and Push the Image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: staging-validator + run: | + make localnet-build-amd64 + commit_hash=$(git rev-parse --short=7 HEAD) + docker build \ + --platform amd64 \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$commit_hash \ + -f testing/testnet-staging/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags diff --git a/protocol/x/clob/keeper/keeper.go b/protocol/x/clob/keeper/keeper.go index 3dfa801685..6817b43469 100644 --- a/protocol/x/clob/keeper/keeper.go +++ b/protocol/x/clob/keeper/keeper.go @@ -267,6 +267,7 @@ func (k Keeper) InitializeNewStreams(ctx sdk.Context) { subaccountUpdate := k.subaccountsKeeper.GetStreamSubaccountUpdate( ctx, subaccountId, + true, ) return &subaccountUpdate }, diff --git a/protocol/x/clob/keeper/process_operations.go b/protocol/x/clob/keeper/process_operations.go index 60e731efdc..2e349ed0a6 100644 --- a/protocol/x/clob/keeper/process_operations.go +++ b/protocol/x/clob/keeper/process_operations.go @@ -101,7 +101,7 @@ func (k Keeper) ProcessProposerOperations( ) allSubaccountUpdates := make([]satypes.StreamSubaccountUpdate, 0) for subaccountId := range subaccountIdsToUpdate { - subaccountUpdate := k.subaccountsKeeper.GetStreamSubaccountUpdate(ctx, subaccountId) + subaccountUpdate := k.subaccountsKeeper.GetStreamSubaccountUpdate(ctx, subaccountId, false) allSubaccountUpdates = append(allSubaccountUpdates, subaccountUpdate) } k.subaccountsKeeper.SendSubaccountUpdates(ctx, allSubaccountUpdates) diff --git a/protocol/x/clob/types/expected_keepers.go b/protocol/x/clob/types/expected_keepers.go index 57acdc7664..3ed63c0592 100644 --- a/protocol/x/clob/types/expected_keepers.go +++ b/protocol/x/clob/types/expected_keepers.go @@ -40,6 +40,7 @@ type SubaccountsKeeper interface { GetStreamSubaccountUpdate( ctx sdk.Context, id satypes.SubaccountId, + snapshot bool, ) ( val satypes.StreamSubaccountUpdate, ) diff --git a/protocol/x/subaccounts/keeper/subaccount.go b/protocol/x/subaccounts/keeper/subaccount.go index 08b3e5aaa6..12a5af7ef9 100644 --- a/protocol/x/subaccounts/keeper/subaccount.go +++ b/protocol/x/subaccounts/keeper/subaccount.go @@ -135,6 +135,7 @@ func (k Keeper) GetSubaccount( func (k Keeper) GetStreamSubaccountUpdate( ctx sdk.Context, id types.SubaccountId, + snapshot bool, ) (val types.StreamSubaccountUpdate) { subaccount := k.GetSubaccount(ctx, id) assetPositions := make([]*types.SubaccountAssetPosition, len(subaccount.AssetPositions)) @@ -156,7 +157,7 @@ func (k Keeper) GetStreamSubaccountUpdate( SubaccountId: &id, UpdatedAssetPositions: assetPositions, UpdatedPerpetualPositions: perpetualPositions, - Snapshot: true, + Snapshot: snapshot, } } diff --git a/protocol/x/subaccounts/types/types.go b/protocol/x/subaccounts/types/types.go index d4e7018ed6..3effca3878 100644 --- a/protocol/x/subaccounts/types/types.go +++ b/protocol/x/subaccounts/types/types.go @@ -65,6 +65,7 @@ type SubaccountsKeeper interface { GetStreamSubaccountUpdate( ctx sdk.Context, id SubaccountId, + snapshot bool, ) (val StreamSubaccountUpdate) LegacyGetNegativeTncSubaccountSeenAtBlock(ctx sdk.Context) (uint32, bool) GetNegativeTncSubaccountSeenAtBlock(