Commit a87242b2 authored by hezhengjun's avatar hezhengjun

set gas directly for transfer

parent d5ca6be9
...@@ -664,7 +664,7 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33 ...@@ -664,7 +664,7 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
} }
//param: from,to,evm-packdata,amount //param: from,to,evm-packdata,amount
//交易构造 //交易构造
tx, err := ethtxs.NewTx(ethRelayer.clientSpec, ethRelayer.ethSender, toAddr, intputData, value) tx, err := ethtxs.NewTransferTx(ethRelayer.clientSpec, ethRelayer.ethSender, toAddr, intputData, value)
if err != nil { if err != nil {
relayerLog.Error("handleLogWithdraw", "newTx err", err) relayerLog.Error("handleLogWithdraw", "newTx err", err)
err = errors.New("ErrNewTx") err = errors.New("ErrNewTx")
......
...@@ -148,7 +148,7 @@ func GetEthTxStatus(client ethinterface.EthClientSpec, txhash common.Hash) strin ...@@ -148,7 +148,7 @@ func GetEthTxStatus(client ethinterface.EthClientSpec, txhash common.Hash) strin
return status return status
} }
func NewTx(clientSpec ethinterface.EthClientSpec, from, to common.Address, input []byte, value *big.Int) (*types.Transaction, error) { func NewTransferTx(clientSpec ethinterface.EthClientSpec, from, to common.Address, input []byte, value *big.Int) (*types.Transaction, error) {
price, err := clientSpec.SuggestGasPrice(context.Background()) price, err := clientSpec.SuggestGasPrice(context.Background())
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -160,17 +160,17 @@ func NewTx(clientSpec ethinterface.EthClientSpec, from, to common.Address, input ...@@ -160,17 +160,17 @@ func NewTx(clientSpec ethinterface.EthClientSpec, from, to common.Address, input
} }
var gas uint64 = 21000 var gas uint64 = 21000
if input != nil { if input != nil {
var msg ethereum.CallMsg //var msg ethereum.CallMsg
msg.To = &to //msg.To = &to
msg.Data = input //msg.Data = input
gas, err = clientSpec.EstimateGas(context.Background(), msg) //gas, err = clientSpec.EstimateGas(context.Background(), msg)
if err != nil { //if err != nil {
//return nil,err // //return nil,err
txslog.Error("handleLogWithdraw", "EstimateGas err", err) // txslog.Error("handleLogWithdraw", "EstimateGas err", err)
gas = 80000 // gas = 80000
} //}
//略微增加gas数量,>=120% //实际测试"cumulativeGasUsed": "0xdc82",
gas = uint64(float64(gas) * 1.2) gas = uint64(80000)
} }
ntx := types.NewTx(&types.LegacyTx{ ntx := types.NewTx(&types.LegacyTx{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment