From 5c3435c12fe430740e2b5d2a05066d423c61acec Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Sun, 9 Oct 2022 17:36:11 +0200 Subject: [PATCH] Changes necessary to make wallet work pokt networks --- VERSION | 2 +- services/wallet/transfer/commands.go | 10 ++++++++-- services/wallet/transfer/iterative.go | 8 ++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index ccc64186e..28fef661a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.111.5 +0.111.6 diff --git a/services/wallet/transfer/commands.go b/services/wallet/transfer/commands.go index 7391a2030..bb54262d6 100644 --- a/services/wallet/transfer/commands.go +++ b/services/wallet/transfer/commands.go @@ -19,8 +19,10 @@ var ( // archival request. binanceChainMaxInitialRange = big.NewInt(500000) binanceChainErc20BatchSize = big.NewInt(5000) - erc20BatchSize = big.NewInt(100000) + goerliErc20BatchSize = big.NewInt(100000) + erc20BatchSize = big.NewInt(500000) binancChainID = uint64(56) + goerliChainID = uint64(5) binanceTestChainID = uint64(97) numberOfBlocksCheckedPerIteration = 40 ) @@ -101,6 +103,10 @@ func getErc20BatchSize(chainID uint64) *big.Int { return binanceChainErc20BatchSize } + if chainID == goerliChainID { + return goerliErc20BatchSize + } + return erc20BatchSize } @@ -109,7 +115,7 @@ func (c *erc20HistoricalCommand) Run(ctx context.Context) (err error) { if c.iterator == nil { c.iterator, err = SetupIterativeDownloader( c.db, c.chainClient, c.address, - c.erc20, getErc20BatchSize(c.chainClient.ChainID), c.to, c.from, !isBinanceChain(c.chainClient.ChainID)) + c.erc20, getErc20BatchSize(c.chainClient.ChainID), c.to, c.from) if err != nil { log.Error("failed to setup historical downloader for erc20") return err diff --git a/services/wallet/transfer/iterative.go b/services/wallet/transfer/iterative.go index 4d160383d..88353beaa 100644 --- a/services/wallet/transfer/iterative.go +++ b/services/wallet/transfer/iterative.go @@ -12,16 +12,12 @@ import ( // SetupIterativeDownloader configures IterativeDownloader with last known synced block. func SetupIterativeDownloader( db *Database, client HeaderReader, address common.Address, - downloader BatchDownloader, size *big.Int, to *big.Int, from *big.Int, isBatchSizeAdjustable bool) (*IterativeDownloader, error) { + downloader BatchDownloader, size *big.Int, to *big.Int, from *big.Int) (*IterativeDownloader, error) { if to == nil || from == nil { return nil, errors.New("to or from cannot be nil") } - adjustedSize := big.NewInt(0).Div(big.NewInt(0).Sub(to, from), big.NewInt(10)) - if isBatchSizeAdjustable && adjustedSize.Cmp(size) == 1 { - size = adjustedSize - } log.Info("iterative downloader", "address", address, "from", from, "to", to, "size", size) d := &IterativeDownloader{ client: client, @@ -68,7 +64,7 @@ func (d *IterativeDownloader) Next(parent context.Context) ([]*DBHeader, *big.In if from.Cmp(d.from) == -1 { from = d.from } - log.Info("load erc20 transfers in range", "from", from, "to", to) + log.Info("load erc20 transfers in range", "from", from, "to", to, "batchSize", d.batchSize) headers, err := d.downloader.GetHeadersInRange(parent, from, to) if err != nil { log.Error("failed to get transfer in between two bloks", "from", from, "to", to, "error", err)