Skip to content

v1.0.0版本分叉文档

suoyc edited this page Dec 10, 2019 · 7 revisions

v1.0.0 版本分叉功能 1.生产节点配置挖矿专用公钥 新增UpdateCandidatePubKey交易类型,payload参数为公钥(如下),交易成功后,生产者即可用该公钥对应的私钥进行挖矿,达到账号私钥与挖矿私钥分离目的。 arg := &args.UpdateCandidatePubKey{         PubKey: pubKey,     } 发送该交易前可先将设置的私钥配置到挖矿节点上,命令为./ft miner setcoinbase "accout123456" priKey.txt 2.协议资产转账 协议资产转账时,from 和 to 需有一个为协议资产的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流通量限制为unint256 2).资产founder不可修改为空 3).解决合约调用sha256 gas扣除异常问题 4).解决重复部署合约gas扣除异常 5).解决先启动dpos后分叉,出块节点列表可能异常问题