Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix merge conflicts #2115

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 1 addition & 180 deletions .github/workflows/protocol-build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,12 @@ name: Protocol Build & Push Image to AWS ECR
on: # yamllint disable-line rule:truthy
push:
branches:
- 'wl/5.2.x-fns'
- 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:
Expand Down Expand Up @@ -79,147 +44,3 @@ 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
4 changes: 2 additions & 2 deletions protocol/daemons/liquidation/client/sub_task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
perplib "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/lib"
perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types"
pricestypes "github.com/dydxprotocol/v4-chain/protocol/x/prices/types"
sakeeper "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/keeper"
salib "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/lib"
satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types"
)

Expand Down Expand Up @@ -305,7 +305,7 @@ func (c *Client) CheckSubaccountCollateralization(

// Funding payments are lazily settled, so get the settled subaccount
// to ensure that the funding payments are included in the net collateral calculation.
settledSubaccount, _, err := sakeeper.GetSettledSubaccountWithPerpetuals(
settledSubaccount, _, err := salib.GetSettledSubaccountWithPerpetuals(
unsettledSubaccount,
perpInfos,
)
Expand Down
8 changes: 6 additions & 2 deletions protocol/x/clob/keeper/process_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ func (k Keeper) ProcessProposerOperations(
}
k.SendOrderbookUpdates(ctx, allUpdates)

// send local subaccount snapshots
subaccountIdsToUpdate := fetchSubaccountIdsInvolvedInOpQueue(
subaccountIdsFromProposed := fetchSubaccountIdsInvolvedInOpQueue(
operations,
)

subaccountIdsFromLocal := fetchSubaccountIdsInvolvedInOpQueue(
localValidatorOperationsQueue,
)
subaccountIdsToUpdate := lib.MergeMaps(subaccountIdsFromLocal, subaccountIdsFromProposed)
allSubaccountUpdates := make([]satypes.StreamSubaccountUpdate, 0)
for subaccountId := range subaccountIdsToUpdate {
subaccountUpdate := k.subaccountsKeeper.GetStreamSubaccountUpdate(ctx, subaccountId, false)
Expand Down
6 changes: 0 additions & 6 deletions protocol/x/clob/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ type SubaccountsKeeper interface {
ctx sdk.Context,
perpetualId uint32,
) (sdk.AccAddress, error)
DistributeFees(
ctx sdk.Context,
assetId uint32,
quantums *big.Int,
perpetualId uint32,
) error
SendSubaccountUpdates(
ctx sdk.Context,
subaccountUpdates []satypes.StreamSubaccountUpdate,
Expand Down
5 changes: 0 additions & 5 deletions protocol/x/clob/types/mem_clob_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,4 @@ type MemClobKeeper interface {
ctx sdk.Context,
takerOrder StreamTakerOrder,
)
AddOrderToOrderbookSubaccountUpdatesCheck(
ctx sdk.Context,
subaccountId satypes.SubaccountId,
order PendingOpenOrder,
) satypes.UpdateResult
}
8 changes: 4 additions & 4 deletions protocol/x/subaccounts/keeper/isolated_subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// caused a failure, if any.
func (k Keeper) checkIsolatedSubaccountConstraints(
ctx sdk.Context,
settledUpdates []SettledUpdate,
settledUpdates []types.SettledUpdate,
perpInfos map[uint32]perptypes.PerpInfo,
) (
success bool,
Expand Down Expand Up @@ -59,7 +59,7 @@ func (k Keeper) checkIsolatedSubaccountConstraints(
// - a subaccount with no positions cannot be updated to have positions in multiple isolated
// perpetuals or a combination of isolated and non-isolated perpetuals
func isValidIsolatedPerpetualUpdates(
settledUpdate SettledUpdate,
settledUpdate types.SettledUpdate,
perpInfos map[uint32]perptypes.PerpInfo,
) (types.UpdateResult, error) {
// If there are no perpetual updates, then this update does not violate constraints for isolated
Expand Down Expand Up @@ -141,7 +141,7 @@ func isValidIsolatedPerpetualUpdates(
// The input `settledUpdate` must have an updated subaccount (`settledUpdate.SettledSubaccount`),
// so all the updates must have been applied already to the subaccount.
func GetIsolatedPerpetualStateTransition(
settledUpdateWithUpdatedSubaccount SettledUpdate,
settledUpdateWithUpdatedSubaccount types.SettledUpdate,
perpInfos map[uint32]perptypes.PerpInfo,
) (*types.IsolatedPerpetualPositionStateTransition, error) {
// This subaccount needs to have had the updates in the `settledUpdate` already applied to it.
Expand Down Expand Up @@ -317,7 +317,7 @@ func (k *Keeper) transferCollateralForIsolatedPerpetual(
// Note: This uses the `x/bank` keeper and modifies `x/bank` state.
func (k *Keeper) computeAndExecuteCollateralTransfer(
ctx sdk.Context,
settledUpdateWithUpdatedSubaccount SettledUpdate,
settledUpdateWithUpdatedSubaccount types.SettledUpdate,
perpInfos map[uint32]perptypes.PerpInfo,
) error {
// The subaccount in `settledUpdateWithUpdatedSubaccount` already has the perpetual updates
Expand Down
22 changes: 11 additions & 11 deletions protocol/x/subaccounts/keeper/isolated_subaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
tests := map[string]struct {
// parameters
settledUpdateWithUpdatedSubaccount keeper.SettledUpdate
settledUpdateWithUpdatedSubaccount types.SettledUpdate
perpetuals []perptypes.Perpetual

// expectation
expectedStateTransition *types.IsolatedPerpetualPositionStateTransition
expectedErr error
}{
`If no perpetual updates, nil state transition is returned`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: nil,
Expand All @@ -37,7 +37,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedStateTransition: nil,
},
`If single non-isolated perpetual updates, nil state transition is returned`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: nil,
Expand All @@ -57,7 +57,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedStateTransition: nil,
},
`If multiple non-isolated perpetual updates, nil state transition is returned`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: nil,
Expand All @@ -82,7 +82,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedStateTransition: nil,
},
`If multiple non-isolated perpetual positions, nil state transition is returned`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: []*types.PerpetualPosition{
Expand All @@ -106,7 +106,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedStateTransition: nil,
},
`If single isolated perpetual update, no perpetual position, state transition is returned for closed position`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: nil,
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
},
`If single isolated perpetual update, existing perpetual position with same size, state transition is returned for
opened position`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: []*types.PerpetualPosition{
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
},
`If single isolated perpetual update, existing perpetual position with different size, nil state transition
returned`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: []*types.PerpetualPosition{
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedStateTransition: nil,
},
`Returns error if perpetual position was opened with no asset updates`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: []*types.PerpetualPosition{
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedErr: types.ErrFailedToUpdateSubaccounts,
},
`Returns error if perpetual position was opened with multiple asset updates`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: []*types.PerpetualPosition{
Expand Down Expand Up @@ -278,7 +278,7 @@ func TestGetIsolatedPerpetualStateTransition(t *testing.T) {
expectedErr: types.ErrFailedToUpdateSubaccounts,
},
`Returns error if perpetual position was opened with non-usdc asset update`: {
settledUpdateWithUpdatedSubaccount: keeper.SettledUpdate{
settledUpdateWithUpdatedSubaccount: types.SettledUpdate{
SettledSubaccount: types.Subaccount{
Id: &constants.Alice_Num0,
PerpetualPositions: []*types.PerpetualPosition{
Expand Down
Loading
Loading