caivega / ipfslib

Other
2 stars 1 forks source link

S2 - jt_sendTransaction:通过增发代币可以突破发行代币时的total_supply上限 #154

Closed zyd82 closed 3 years ago

zyd82 commented 3 years ago

测试版本:v0.5.3-dev-20201222-4d79cede520d8eb6752703f588cd4a9b83370d91 测试用例:jt_sendTransaction_000370

1、发行9300000000000000000(93后面带17个0)个代币,发行失败,应该是超过上限了,但是返回的错误信息是"total_supply must be integer type"(这里是否考虑改下提示信息)

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        { 
            "type": "IssueCoin",
            "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "secret": "shhquPeZm7uQ6Rvjrqn6L2cR6H33u",
            "name": "",
            "symbol": "CCT",
            "decimals": "6",
            "total_supply": "9300000000000000000",
            "local": false,
            "flags": 196608
        }
    ],
    "id": 1
}
{
    "error": "1 errors",
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": "total_supply must be integer type",
            "message": {
                "decimals": "6",
                "flags": 196608,
                "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
                "local": false,
                "name": "",
                "symbol": "CCT",
                "total_supply": "9300000000000000000",
                "type": "IssueCoin"
            },
            "status": -278,
            "type": "temINVALID"
        }
    ],
    "status": -278,
    "type": "temINVALID"
}

2、发行9200000000000000000(92后面带17个0)个可增发可销毁的代币,发行成功,用jt_getBalance可以查到正确的余额

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        { 
            "type": "IssueCoin",
            "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "secret": "shhquPeZm7uQ6Rvjrqn6L2cR6H33u",
            "name": "",
            "symbol": "CCT",
            "decimals": "6",
            "total_supply": "9200000000000000000",
            "local": false,
            "flags": 196608
        }
    ],
    "id": 1
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "balance": {
            "value": "9200000000000000000",
            "currency": "CCT",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        }
    }
}

3、增发9200000000000000000(92后面带17个0)个代币,增发成功,jt_getBalance可以看到余额变成了18400000000000000000(184后面带17个0)

{
    "jsonrpc": "2.0",
    "method": "jt_sendTransaction",
    "params": [
        { 
            "type": "IssueCoin",
            "from": "jPdx7mG595P6CowtGYbxRkik9HdWUWtB2J",
            "secret": "shhquPeZm7uQ6Rvjrqn6L2cR6H33u",
            "name": "",
            "symbol": "CCT",
            "decimals": "6",
            "total_supply": "9200000000000000000",
            "local": false,
            "flags": 196608
        }
    ],
    "id": 1
}
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "balance": {
            "value": "18400000000000000000",
            "currency": "CCT",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        }
    }
}

4、继续增发9200000000000000000(92后面带17个0)个代币,余额变成27600000000000000000(276后面带17个0)

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "balance": {
            "value": "27600000000000000000",
            "currency": "CCT",
            "issuer": "jjjjjjjjjjjjjjjjjjjjjhoLvTp"
        }
    }
}

这里可以看到发币的上限届于9200000000000000000(92后面带17个0)和9300000000000000000(93后面带17个0)之间,但是通过不断增发,可以突破发币的上限值,这种情况是否允许呢?

caivega commented 3 years ago

这个属于bug, 可以发行成功,但是后续转帐及其他处理都会出错的,这个还是需要检查下的

caivega commented 3 years ago

已修复,下一个build验证

zyd82 commented 3 years ago

在v0.5.3-dev-20201231-72973ab08899c404ac4998f2e79c8b5fac0e199e版本上,想通过增发来使余额突破9000000000000000000的上限已经不能成功了,但是提示信息还不准确,建议修改一下。

1、钱包已经发行了9000000000000000000个代币,此时再增发一个,提示信息是:Can only send non-negative amounts

{
    "error": {
        "count": 1,
        "description": "The compound error.",
        "information": "1 errors"
    },
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": {
                "description": "Can only send non-negative amounts.",
                "information": "Can only send non-negative amounts."
            },
            "status": -298,
            "type": "temBAD_AMOUNT"
        }
    ],
    "status": 1000,
    "type": "tedCOMPOUND"
}

2、钱包已经发行了9000000000000000000个代币,此时再增发9000000000000000000个,提示信息是:Fund insufficient

{
    "error": {
        "count": 1,
        "description": "The compound error.",
        "information": "1 errors"
    },
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": {
                "description": "Fund insufficient.",
                "information": "Fund insufficient."
            },
            "status": -386,
            "type": "telINSUF_FUND"
        }
    ],
    "status": 1000,
    "type": "tedCOMPOUND"
}

建议这种增发失败的提示信息统一改为:Cannot exceed the maximum total supply number.

caivega commented 3 years ago

增加新的错误类型

-385 TelEXCEED_MAXIMUM Cannot exceed the maximum total supply number.
caivega commented 3 years ago

done, 下一个build验证

zyd82 commented 3 years ago

v0.5.3-dev-20210103-bcc6a93d716c6b4916bf52f55df8fb591ab54965版本上验证通过,目前超发的话会返回如下信息:

{
    "error": {
        "count": 1,
        "description": "The compound error.",
        "information": "1 errors"
    },
    "id": 1,
    "jsonrpc": "2.0",
    "result": [
        {
            "error": {
                "description": "Cannot exceed the maximum total supply number.",
                "information": "Cannot exceed the maximum total supply number."
            },
            "status": -385,
            "type": "telEXCEED_MAXIMUM"
        }
    ],
    "status": 1000,
    "type": "tedCOMPOUND"
}