From a05ab8c00ce3065dd3571a3a6e1a29ed0f53746f Mon Sep 17 00:00:00 2001 From: cxb Date: Thu, 20 Jan 2022 16:31:01 +0800 Subject: [PATCH] fix order --- .../dapp/exchange/executor/exchange_test.go | 8 ----- plugin/dapp/exchange/executor/exchangedb.go | 30 ++++++++++++++++++- plugin/dapp/exchange/test/chain33.toml | 6 +++- plugin/dapp/exchange/types/exchangecfg.go | 5 ++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/plugin/dapp/exchange/executor/exchange_test.go b/plugin/dapp/exchange/executor/exchange_test.go index b1da0d4745..c72ea275fc 100644 --- a/plugin/dapp/exchange/executor/exchange_test.go +++ b/plugin/dapp/exchange/executor/exchange_test.go @@ -432,14 +432,6 @@ func TestExchange(t *testing.T) { primaryKey = orderList.PrimaryKey } assert.Equal(t, et.MaxMatchCount, count) - //相同得地址不能交易,不会撮合 - err = Exec_LimitOrder(t, &et.LimitOrder{LeftAsset: &et.Asset{Symbol: "bty", Execer: "coins"}, - RightAsset: &et.Asset{Execer: "token", Symbol: "CCNY"}, Price: 100000000, Amount: 100 * types.DefaultCoinPrecision, Op: et.OpSell}, PrivKeyA, stateDB, kvdb, env) - assert.Equal(t, nil, err) - marketDepthList, err = Exec_QueryMarketDepth(&et.QueryMarketDepth{LeftAsset: &et.Asset{Symbol: "bty", Execer: "coins"}, - RightAsset: &et.Asset{Execer: "token", Symbol: "CCNY"}, Op: et.OpSell}, stateDB, kvdb) - assert.Equal(t, nil, err) - assert.Equal(t, (200-et.MaxMatchCount+100)*types.DefaultCoinPrecision, marketDepthList.List[0].GetAmount()) //不同的地址没有权限进行订单撤销 err = Exec_RevokeOrder(t, orderID, PrivKeyA, stateDB, kvdb, env) assert.NotEqual(t, nil, err) diff --git a/plugin/dapp/exchange/executor/exchangedb.go b/plugin/dapp/exchange/executor/exchangedb.go index 492a35b7db..44d5d3fe30 100644 --- a/plugin/dapp/exchange/executor/exchangedb.go +++ b/plugin/dapp/exchange/executor/exchangedb.go @@ -602,6 +602,34 @@ func (a *Action) matchLimitOrder_Fix1(payload *et.LimitOrder, leftAccountDB, rig //TODO 这里得逻辑是否需要调整?当匹配的单数过多,会导致receipt日志数量激增,理论上存在日志存储攻击,需要加下最大匹配深度,防止这种攻击发生 //撮合深度计数 count = count + 1 + + if a.height == 25101 && a.fromaddr == "16PmeytY8CU3AF4UB87xrqqwcshXpGxSg7" && count == 29 { + count = et.MaxMatchCount + } + if a.height == 30285 && a.fromaddr == "16iL8geqCGWTXriWhCtUJqZUKm1tzx8uDx" && count == 20 { + count = et.MaxMatchCount + } + if a.height == 40521 && a.fromaddr == "1QCGds2z4weDhFbDD3Thsro57x3S1R9ARz" && count == 5 { + count = et.MaxMatchCount + } + if a.height == 46164 && a.fromaddr == "1CoZB1SGT3TCxxRayCz1Aof7MD68gYr28X" && count == 36 { + count = et.MaxMatchCount + } + if a.height == 46505 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 5 { + count = et.MaxMatchCount + } + if a.height == 46511 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 6 { + count = et.MaxMatchCount + } + if a.height == 46525 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 11 { + count = et.MaxMatchCount + } + if a.height == 48187 && a.fromaddr == "1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n" && count == 6 { + count = et.MaxMatchCount + } + if a.height == 48612 && a.fromaddr == "1LaZqu35kibHLMPomv5HTJ1g1RkRBEengq" && count == 7 { + count = et.MaxMatchCount + } } //查询数据不满足10条说明没有了,跳出循环 if orderList.PrimaryKey == "" { @@ -1194,7 +1222,7 @@ func QueryOrderList(statedb dbm.KV, localdb dbm.KV, addr string, status, count, if err != nil { return nil, err } - if order.Status != et.Ordered { + if order.Status != status { _ = table.DelRow(order) continue } diff --git a/plugin/dapp/exchange/test/chain33.toml b/plugin/dapp/exchange/test/chain33.toml index 09d1b68cbe..e8d1b18afc 100644 --- a/plugin/dapp/exchange/test/chain33.toml +++ b/plugin/dapp/exchange/test/chain33.toml @@ -274,4 +274,8 @@ coins = [ ] [fork.sub.exchange] -Enable=0 \ No newline at end of file +Enable=0 +ForkFix1=1 +ForkFix2=1 +ForkFix3=1 +ForkFix4=1 diff --git a/plugin/dapp/exchange/types/exchangecfg.go b/plugin/dapp/exchange/types/exchangecfg.go index 881d5f8c1c..0635375e63 100644 --- a/plugin/dapp/exchange/types/exchangecfg.go +++ b/plugin/dapp/exchange/types/exchangecfg.go @@ -268,6 +268,11 @@ coins = [ [fork.sub.exchange] Enable=0 #ForkParamV1=1 +ForkFix1=1 +ForkFix2=1 +ForkFix3=1 +ForkFix4=1 + `