Skip to content

v1.0.0版本分叉文档

erick yan edited this page Dec 11, 2019 · 7 revisions

v1.0.0 版本分叉文档

1.生产节点配置挖矿专用公钥

新增 UpdateCandidatePubKey 交易类型,payload 参数为公钥(如下),交易成功后,生产者即可用该公钥对应的私钥进行挖矿,达到账号私钥与挖矿私钥分离目的。

arg := &args.UpdateCandidatePubKey{
          PubKey: pubKey,
        }

发送该交易前可先将设置的私钥配置到挖矿节点上,命令为./ft miner setcoinbase "accout123456" priKey.txt

2.协议资产转账

协议资产转账时,fromto 需有一个为协议资产的 contract 账户才可转账。合约新增 transferable()方法后,协议资产的 contract 中存在 transferable()时,协议资产就可以像普通资产一样进行转账,不再受限制。transferable()方法返回 true 时功能生效,返回 false 或者无此方法时仍受原有限制。transferable()方法如下:

 function transferable() public returns(bool) {
    return true;
 }

3.代付手续费

新增代付手续费功能,发送交易可由第三方代付手续费。交易举例如下:

func transferfp(from, to common.Name, amount *big.Int, assetid uint64, nonce uint64, prikey *ecdsa.PrivateKey) {
     key := types.MakeKeyPair(prikey, []uint64{0})
     gasPrice, _ := testcommon.GasPrice()

    fp := &types.FeePayer{
            GasPrice: gasPrice,//代付手续费 GasPrice,代付时必填项
            Payer: toname,//代付手续费账号
            Sign: &types.Signature{0, make([]*types.SignData, 0)},
        }
    payerKey := types.MakeKeyPair(minerprikey, []uint64{0})//代付手续费账号私钥
    sendTransferTxfp(types.Transfer, from, to, nonce, assetid, amount, nil, []*types.KeyPair{key}, fp, []\*types.KeyPair{payerKey})
}

func sendTransferTxfp(txType types.ActionType, from, to common.Name, nonce, assetID uint64, value *big.Int, input []byte, keys []*types.KeyPair, fp *types.FeePayer, payerKeys []*types.KeyPair) {
    action := types.NewAction(txType, from, to, nonce, assetID, gaslimit, value, input, nil)
    gasprice, _ := testcommon.GasPrice()

    if fp != nil {
            gasprice = big.NewInt(0)//存在代付方时,此 gasprice 必须为 0
        }
    tx := types.NewTransaction(0, gasprice, action)

    signer := types.MakeSigner(big.NewInt(1))
    err := types.SignActionWithMultiKey(action, tx, signer, 0, keys)
    if err != nil {
        jww.ERROR.Fatalln(err)
    }

    if fp != nil {
        err = types.SignPayerActionWithMultiKey(action, tx, signer, fp, 0, payerKeys)
        if err != nil {
            jww.ERROR.Fatalln(err)
        }
    }

    rawtx, err := rlp.EncodeToBytes(tx)
    if err != nil {
        jww.ERROR.Fatalln(err)
    }

    hash, err := testcommon.SendRawTx(rawtx)
    if err != nil {
        jww.INFO.Println("result err: ", err)
    }
    jww.INFO.Println("result hash: ", hash.Hex())
}

4.修复已知问题

  • 1.资产 amount 流通量限制为 uint256类型最大值

  • 2.资产 founder 不可修改为空

  • 3.解决合约调用 sha256 gas 扣除异常问题

  • 4.解决重复部署合约 gas 扣除异常

  • 5.解决先启动 dpos 后分叉,出块节点列表可能异常问题