Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
a542afe7
Commit
a542afe7
authored
Dec 22, 2021
by
hezhengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct nonce fetch
parent
40b5c96c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
38 deletions
+40
-38
ethereum.go
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
+1
-38
utils.go
...dapp/cross2eth/ebrelayer/relayer/ethereum/ethtxs/utils.go
+39
-0
No files found.
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
View file @
a542afe7
...
...
@@ -664,7 +664,7 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
}
//param: from,to,evm-packdata,amount
//交易构造
tx
,
err
:=
eth
Relayer
.
newTx
(
ethRelayer
.
ethSender
,
toAddr
,
intputData
,
value
)
tx
,
err
:=
eth
txs
.
NewTx
(
ethRelayer
.
clientSpec
,
ethRelayer
.
ethSender
,
toAddr
,
intputData
,
value
)
if
err
!=
nil
{
relayerLog
.
Error
(
"handleLogWithdraw"
,
"newTx err"
,
err
)
err
=
errors
.
New
(
"ErrNewTx"
)
...
...
@@ -771,43 +771,6 @@ func (ethRelayer *Relayer4Ethereum) packBalanceOfData(_to common.Address) ([]byt
}
return
abidata
,
nil
}
func
(
ethRelayer
*
Relayer4Ethereum
)
newTx
(
from
,
to
common
.
Address
,
input
[]
byte
,
value
*
big
.
Int
)
(
*
types
.
Transaction
,
error
)
{
price
,
err
:=
ethRelayer
.
clientSpec
.
SuggestGasPrice
(
context
.
Background
())
if
err
!=
nil
{
return
nil
,
err
}
nonce
,
err
:=
ethRelayer
.
clientSpec
.
PendingNonceAt
(
context
.
Background
(),
from
)
if
err
!=
nil
{
return
nil
,
err
}
var
gas
uint64
=
21000
if
input
!=
nil
{
var
msg
ethereum
.
CallMsg
msg
.
To
=
&
to
msg
.
Data
=
input
gas
,
err
=
ethRelayer
.
clientSpec
.
EstimateGas
(
context
.
Background
(),
msg
)
if
err
!=
nil
{
//return nil,err
relayerLog
.
Error
(
"handleLogWithdraw"
,
"EstimateGas err"
,
err
)
gas
=
80000
}
//略微增加gas数量,>=120%
gas
=
uint64
(
float64
(
gas
)
*
1.2
)
}
ntx
:=
types
.
NewTx
(
&
types
.
LegacyTx
{
Nonce
:
nonce
,
GasPrice
:
price
,
To
:
&
to
,
Data
:
input
,
Value
:
value
,
Gas
:
gas
,
})
return
ntx
,
nil
}
func
(
ethRelayer
*
Relayer4Ethereum
)
handleLogLockBurn
(
chain33Msg
*
events
.
Chain33Msg
)
{
//对于通过代理人登录的中继器,不处理lock和burn事件
...
...
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethtxs/utils.go
View file @
a542afe7
...
...
@@ -8,6 +8,8 @@ import (
"sync"
"time"
"github.com/ethereum/go-ethereum/core/types"
"github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethinterface"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
...
...
@@ -145,3 +147,40 @@ func GetEthTxStatus(client ethinterface.EthClientSpec, txhash common.Hash) strin
return
status
}
func
NewTx
(
clientSpec
ethinterface
.
EthClientSpec
,
from
,
to
common
.
Address
,
input
[]
byte
,
value
*
big
.
Int
)
(
*
types
.
Transaction
,
error
)
{
price
,
err
:=
clientSpec
.
SuggestGasPrice
(
context
.
Background
())
if
err
!=
nil
{
return
nil
,
err
}
nonce
,
err
:=
getNonce
(
from
,
clientSpec
)
if
err
!=
nil
{
return
nil
,
err
}
var
gas
uint64
=
21000
if
input
!=
nil
{
var
msg
ethereum
.
CallMsg
msg
.
To
=
&
to
msg
.
Data
=
input
gas
,
err
=
clientSpec
.
EstimateGas
(
context
.
Background
(),
msg
)
if
err
!=
nil
{
//return nil,err
txslog
.
Error
(
"handleLogWithdraw"
,
"EstimateGas err"
,
err
)
gas
=
80000
}
//略微增加gas数量,>=120%
gas
=
uint64
(
float64
(
gas
)
*
1.2
)
}
ntx
:=
types
.
NewTx
(
&
types
.
LegacyTx
{
Nonce
:
nonce
.
Uint64
(),
GasPrice
:
price
,
To
:
&
to
,
Data
:
input
,
Value
:
value
,
Gas
:
gas
,
})
return
ntx
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment