bnb-chain / node

Mozilla Public License 2.0
77 stars 40 forks source link

can't bring bnbchaind back when there is an order whose symbol is in lower case. #652

Closed unclezoro closed 4 years ago

unclezoro commented 5 years ago
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/binance-chain/node/plugins/dex/order.(*Keeper).LoadOrderBookSnapshot(0xc000313860, 0x13fd1e0, 0xc00cd47350, 0xc000323fc0, 0xb, 0x22f6284, 0x19684b8b, 0xed4fc62ba, 0x0, 0x0, ...)
        /root/bnbchain/src/github.com/binance-chain/node/plugins/dex/order/keeper_recovery.go:171 +0xd58
github.com/binance-chain/node/plugins/dex/order.(*Keeper).initOrderBook(0xc000313860, 0x13fd1e0, 0xc00cd47350, 0xc000323fc0, 0xb, 0x0, 0x7, 0xc00c5c19e0, 0x1409220, 0xc0008bd050, ...)
        /root/bnbchain/src/github.com/binance-chain/node/plugins/dex/order/keeper_recovery.go:282 +0xce
github.com/binance-chain/node/plugins/dex/order.(*Keeper).Init(0xc000313860, 0x13fd1e0, 0xc00cd47350, 0xc000323fc0, 0xb, 0x0, 0x7, 0xc00c5c19e0, 0x1409220, 0xc0008bd050, ...)
        /root/bnbchain/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:94 +0xbb
github.com/binance-chain/node/app.(*BinanceChain).initDex(0xc000152000, 0x1405260, 0xc00000c3a0)
        /root/bnbchain/src/github.com/binance-chain/node/app/app.go:292 +0x2ab
github.com/binance-chain/node/app.NewBinanceChain(0x13fde20, 0xc000e48220, 0x1409220, 0xc00000e390, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000e38300)
        /root/bnbchain/src/github.com/binance-chain/node/app/app.go:233 +0x1891
main.newApp(0x13fde20, 0xc000e48220, 0x1409220, 0xc00000e390, 0x0, 0x0, 0x7635d7, 0xc000e44c10)
        /root/bnbchain/src/github.com/binance-chain/node/cmd/bnbchaind/main.go:23 +0x78
github.com/binance-chain/node/vendor/github.com/cosmos/cosmos-sdk/server.startInProcess(0xc000ca0300, 0x12f7020, 0x1d, 0x0, 0x0)
        /root/bnbchain/src/github.com/binance-chain/node/vendor/github.com/cosmos/cosmos-sdk/server/start.go:117 +0x1a8
github.com/binance-chain/node/vendor/github.com/cosmos/cosmos-sdk/server.StartCmd.func1(0xc000cad440, 0xc000ca2300, 0x0, 0x6, 0x0, 0x0)
        /root/bnbchain/src/github.com/binance-chain/node/vendor/github.com/cosmos/cosmos-sdk/server/start.go:44 +0xab
github.com/binance-chain/node/vendor/github.com/spf13/cobra.(*Command).execute(0xc000cad440, 0xc000ca22a0, 0x6, 0x6, 0xc000cad440, 0xc000ca22a0)
        /root/bnbchain/src/github.com/binance-chain/node/vendor/github.com/spf13/cobra/command.go:698 +0x47a
github.com/binance-chain/node/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc0002ffd40, 0xc000ca0540, 0xc00088fe58, 0xa4178d)
        /root/bnbchain/src/github.com/binance-chain/node/vendor/github.com/spf13/cobra/command.go:783 +0x2dc
github.com/binance-chain/node/vendor/github.com/spf13/cobra.(*Command).Execute(0xc0002ffd40, 0xa41042, 0xc0003a9d50)
        /root/bnbchain/src/github.com/binance-chain/node/vendor/github.com/spf13/cobra/command.go:736 +0x2b
github.com/binance-chain/node/vendor/github.com/tendermint/tendermint/libs/cli.Executor.Execute(0xc0002ffd40, 0x12f7418, 0x2, 0xc000875850)
        /root/bnbchain/src/github.com/binance-chain/node/vendor/github.com/tendermint/tendermint/libs/cli/setup.go:89 +0x4e
main.main()
        /root/bnbchain/src/github.com/binance-chain/node/cmd/bnbchaind/main.go:54 +0x418

One of validator can't bring back. It is because an order whose symbol is: zcb-f00_BNB But in the allOrders the key is all upper, should be ZCB-F00_BNB.

So that will cause the following nil point error:

    for _, m := range ao.Orders {
        orderHolder := m
        if kp.allOrders[m.Symbol] ==nil{
            fmt.Println(m.Symbol)
        }
        kp.allOrders[m.Symbol][m.Id] = &orderHolder
        if m.CreatedHeight == height {
            kp.roundOrders[m.Symbol] = append(kp.roundOrders[m.Symbol], m.Id)
            if m.TimeInForce == TimeInForce.IOC {
                kp.roundIOCOrders[m.Symbol] = append(kp.roundIOCOrders[m.Symbol], m.Id)
            }
        }
        if kp.CollectOrderInfoForPublish {
            if _, exists := kp.OrderInfosForPub[m.Id]; !exists {
                bnclog.Debug("add order to order changes map, during load snapshot, from active orders", "orderId", m.Id)
                kp.OrderInfosForPub[m.Id] = &orderHolder
            }
        }
    }
abelliumnt commented 5 years ago

Why there is a token zcb-f00 with lowercase symbol? The issue msg handler will always convert its symbol to uppercase: https://github.com/binance-chain/node/blob/9ffe9d337c0e49bb623ee6ce317db1270e0e9a14/plugins/tokens/issue/handler.go#L37

unclezoro commented 5 years ago

Why there is a token zcb-f00 with lowercase symbol? The issue msg handler will always convert its symbol to uppercase: https://github.com/binance-chain/node/blob/9ffe9d337c0e49bb623ee6ce317db1270e0e9a14/plugins/tokens/issue/handler.go#L37

msg.Symbol nerver changed into uppercase