Skip to content

Commit

Permalink
td/improve-oimf-ugprade-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyding committed Apr 30, 2024
1 parent fdabebe commit cc4cd2e
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 3 deletions.
6 changes: 4 additions & 2 deletions protocol/app/upgrades/v5.0.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ func blockRateLimitConfigUpdate(
panic(fmt.Sprintf("failed to update the block rate limit configuration: %s", err))
}
ctx.Logger().Info(
"Successfully upgraded block rate limit configuration to: %+v\n",
clobKeeper.GetBlockRateLimitConfiguration(ctx),
fmt.Sprintf(
"Successfully upgraded block rate limit configuration to: %+v\n",
clobKeeper.GetBlockRateLimitConfiguration(ctx),
),
)
}

Expand Down
94 changes: 93 additions & 1 deletion protocol/app/upgrades/v5.0.0/upgrade_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (

const (
AliceBobBTCQuantums = 1_000_000
CarlDaveBTCQuantums = 2_000_000
CarlDaveETHQuantums = 4_000_000
)

func TestStateUpgrade(t *testing.T) {
Expand Down Expand Up @@ -119,6 +121,94 @@ func placeOrders(node *containertest.Node, t *testing.T) {
},
constants.BobAccAddress.String(),
))
require.NoError(t, containertest.BroadcastTx(
node,
&clobtypes.MsgPlaceOrder{
Order: clobtypes.Order{
OrderId: clobtypes.OrderId{
ClientId: 0,
SubaccountId: satypes.SubaccountId{
Owner: constants.CarlAccAddress.String(),
Number: 0,
},
ClobPairId: 0,
},
Side: clobtypes.Order_SIDE_BUY,
Quantums: CarlDaveBTCQuantums,
Subticks: 5_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{
GoodTilBlock: 20,
},
},
},
constants.CarlAccAddress.String(),
))
require.NoError(t, containertest.BroadcastTx(
node,
&clobtypes.MsgPlaceOrder{
Order: clobtypes.Order{
OrderId: clobtypes.OrderId{
ClientId: 0,
SubaccountId: satypes.SubaccountId{
Owner: constants.DaveAccAddress.String(),
Number: 0,
},
ClobPairId: 0,
},
Side: clobtypes.Order_SIDE_SELL,
Quantums: CarlDaveBTCQuantums,
Subticks: 5_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{
GoodTilBlock: 20,
},
},
},
constants.DaveAccAddress.String(),
))
require.NoError(t, containertest.BroadcastTx(
node,
&clobtypes.MsgPlaceOrder{
Order: clobtypes.Order{
OrderId: clobtypes.OrderId{
ClientId: 0,
SubaccountId: satypes.SubaccountId{
Owner: constants.CarlAccAddress.String(),
Number: 0,
},
ClobPairId: 1,
},
Side: clobtypes.Order_SIDE_BUY,
Quantums: CarlDaveETHQuantums,
Subticks: 5_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{
GoodTilBlock: 20,
},
},
},
constants.CarlAccAddress.String(),
))
require.NoError(t, containertest.BroadcastTx(
node,
&clobtypes.MsgPlaceOrder{
Order: clobtypes.Order{
OrderId: clobtypes.OrderId{
ClientId: 0,
SubaccountId: satypes.SubaccountId{
Owner: constants.DaveAccAddress.String(),
Number: 0,
},
ClobPairId: 1,
},
Side: clobtypes.Order_SIDE_SELL,
Quantums: CarlDaveETHQuantums,
Subticks: 5_000_000,
GoodTilOneof: &clobtypes.Order_GoodTilBlock{
GoodTilBlock: 20,
},
},
},
constants.DaveAccAddress.String(),
))
err := node.Wait(2)
require.NoError(t, err)
}
Expand Down Expand Up @@ -186,7 +276,9 @@ func postUpgradePerpetualOIs(node *containertest.Node, t *testing.T) {
for _, perp := range allPerpsResp.Perpetual {
expectedOI := 0
if perp.Params.Id == 0 {
expectedOI = AliceBobBTCQuantums
expectedOI = AliceBobBTCQuantums + CarlDaveBTCQuantums
} else if perp.Params.Id == 1 {
expectedOI = CarlDaveETHQuantums
}
assert.Equalf(t,
dtypes.NewInt(int64(expectedOI)),
Expand Down
28 changes: 28 additions & 0 deletions protocol/testing/containertest/preupgrade_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,34 @@
},
"margin_enabled": true
},
{
"asset_positions": [
{
"asset_id": 0,
"index": 0,
"quantums": "100000000000000000"
}
],
"id": {
"number": 0,
"owner": "dydx1fjg6zp6vv8t9wvy4lps03r5l4g7tkjw9wvmh70"
},
"margin_enabled": true
},
{
"asset_positions": [
{
"asset_id": 0,
"index": 0,
"quantums": "100000000000000000"
}
],
"id": {
"number": 0,
"owner": "dydx1wau5mja7j7zdavtfq9lu7ejef05hm6ffenlcsn"
},
"margin_enabled": true
},
{
"asset_positions": [
{
Expand Down

0 comments on commit cc4cd2e

Please sign in to comment.