[wallet] Skip transaction on chain id mismatch

Sometimes eth_getBlockByNumber returns txs with chainId which is not
equal to chanin's id. That caused an error and tx fetching was
interrupted. From now on such txs will be skipped.
This commit is contained in:
Roman Volosovskyi 2021-03-19 15:39:01 +02:00
parent 1097b14a7f
commit 6bea21c197
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
7 changed files with 16 additions and 4 deletions

View File

@ -1 +1 @@
0.73.7
0.73.8

View File

@ -474,6 +474,7 @@ func (c *findAndCheckBlockRangeCommand) fastIndex(ctx context.Context, bCache *b
balanceCache: bCache,
address: address,
eth: &ETHTransferDownloader{
chain: c.chain,
client: c.client,
accounts: []common.Address{address},
signer: types.NewEIP155Signer(c.chain),
@ -567,13 +568,13 @@ func loadTransfers(ctx context.Context, accounts []common.Address, db *Database,
if !ok {
blocks, _ = db.GetBlocksByAddress(address, numberOfBlocksCheckedPerIteration)
}
for _, block := range blocks {
transfers := &transfersCommand{
db: db,
client: client,
address: address,
eth: &ETHTransferDownloader{
chain: chain,
client: client,
accounts: []common.Address{address},
signer: types.NewEIP155Signer(chain),
@ -804,6 +805,7 @@ func (c *controlCommand) Run(parent context.Context) error {
}
downloader := &ETHTransferDownloader{
chain: c.chain,
client: c.client,
accounts: c.accounts,
signer: types.NewEIP155Signer(c.chain),
@ -1008,6 +1010,7 @@ func (c *loadTransfersCommand) LoadTransfers(ctx context.Context, downloader *ET
func (c *loadTransfersCommand) Run(parent context.Context) (err error) {
downloader := &ETHTransferDownloader{
chain: c.chain,
client: c.client,
accounts: c.accounts,
signer: types.NewEIP155Signer(c.chain),

View File

@ -48,6 +48,7 @@ func (s *NewBlocksSuite) SetupTest() {
accounts: []common.Address{s.address},
erc20: NewERC20TransfersDownloader(client, []common.Address{s.address}, s.backend.Signer),
eth: &ETHTransferDownloader{
chain: s.backend.Chain,
client: client,
signer: s.backend.Signer,
db: s.db,
@ -197,6 +198,7 @@ func (s *NewBlocksSuite) downloadHistorical() {
db: s.db,
balanceCache: newBalanceCache(),
eth: &ETHTransferDownloader{
chain: s.backend.Chain,
client: client,
signer: s.backend.Signer,
accounts: []common.Address{s.address},

View File

@ -54,6 +54,7 @@ type ETHTransferDownloader struct {
accounts []common.Address
signer types.Signer
db *Database
chain *big.Int
}
var errLogsDownloaderStuck = errors.New("logs downloader stuck")
@ -95,7 +96,6 @@ func (d *ETHTransferDownloader) getTransfersInBlock(ctx context.Context, blk *ty
if err != nil {
return nil, err
}
for _, t := range preloadedTransfers {
transfer, err := d.transferFromLog(ctx, *t.Log, address, t.ID)
if err != nil {
@ -106,8 +106,11 @@ func (d *ETHTransferDownloader) getTransfersInBlock(ctx context.Context, blk *ty
}
for _, tx := range blk.Transactions() {
if tx.ChainId().Cmp(d.chain) != 0 {
continue
}
from, err := types.Sender(d.signer, tx)
if err != nil {
return nil, err
}

View File

@ -55,6 +55,7 @@ func (s *ETHTransferSuite) SetupTest() {
db, stop := setupTestDB(s.Suite.T())
s.dbStop = stop
s.downloader = &ETHTransferDownloader{
chain: big.NewInt(1337),
signer: s.signer,
client: &walletClient{client: s.ethclient},
db: db,

View File

@ -151,6 +151,7 @@ func (r *Reactor) newControlCommand(accounts []common.Address) *controlCommand {
client: client,
accounts: accounts,
eth: &ETHTransferDownloader{
chain: r.chain,
client: client,
accounts: accounts,
signer: signer,

View File

@ -21,6 +21,7 @@ type Backend struct {
Ethereum *eth.Ethereum
Faucet *ecdsa.PrivateKey
Signer types.Signer
Chain *big.Int
}
func NewBackend() (*Backend, error) {
@ -64,6 +65,7 @@ func NewBackend() (*Backend, error) {
Faucet: faucet,
Signer: types.NewEIP155Signer(config.ChainID),
genesis: genesis,
Chain: config.ChainID,
}, nil
}