Skip to content

Commit 2410e27

Browse files
authored
Merge pull request #82 from 0xPolygon/v3.3.2-beta-candidate
v3.3.2 candidate
2 parents 2f9702e + d7fc073 commit 2410e27

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

db/version/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var (
3131
const (
3232
Major = 3 // Major version component of the current release
3333
Minor = 3 // Minor version component of the current release
34-
Micro = 1 // Micro version component of the current release
34+
Micro = 2 // Micro version component of the current release
3535
Modifier = "" // Modifier component of the current release
3636
DefaultSnapshotGitBranch = "release/3.2" // Branch of erigontech/erigon-snapshot to use in OtterSync
3737
VersionKeyCreated = "ErigonVersionCreated"

rpc/jsonrpc/eth_receipts.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"sort"
2423

2524
"github.com/RoaringBitmap/roaring/v2"
2625

@@ -166,8 +165,9 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t
166165
}
167166

168167
// For a whole block query (blockHash set, no address/topics filters),
169-
// normalize logIndex to be continuous 0..N-1 in canonical order.
170-
if isWholeBlockUnfiltered(crit) && len(rpcLogs) > 0 {
168+
// normalize logIndex (if required) to be continuous 0..N-1 in canonical order.
169+
/* TODO deactivated for memory spike, although already optimizated with `needsRenumber` addition
170+
if isWholeBlockUnfiltered(crit) && len(rpcLogs) > 0 && needsRenumber(rpcLogs) {
171171
sort.Slice(rpcLogs, func(i, j int) bool {
172172
if rpcLogs[i].BlockNumber == rpcLogs[j].BlockNumber {
173173
if rpcLogs[i].TxIndex == rpcLogs[j].TxIndex {
@@ -178,7 +178,6 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t
178178
return rpcLogs[i].BlockNumber < rpcLogs[j].BlockNumber
179179
})
180180
181-
// Now renumber per block so logIndex is 0..N-1 with no gaps.
182181
currentBlock := rpcLogs[0].BlockHash
183182
var idx uint
184183
idx = 0
@@ -191,6 +190,7 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t
191190
idx++
192191
}
193192
}
193+
*/
194194

195195
return rpcLogs, nil
196196
}
@@ -645,3 +645,25 @@ func isWholeBlockUnfiltered(crit filters.FilterCriteria) bool {
645645
}
646646
return true
647647
}
648+
649+
// needsRenumber checks if the log indexes are continuous 0..N-1 per block.
650+
func needsRenumber(rpcLogs types.RPCLogs) bool {
651+
if len(rpcLogs) == 0 {
652+
return false
653+
}
654+
curBlock := rpcLogs[0].BlockHash
655+
var expected uint
656+
expected = 0
657+
658+
for _, l := range rpcLogs {
659+
if l.BlockHash != curBlock {
660+
curBlock = l.BlockHash
661+
expected = 0
662+
}
663+
if l.Index != expected {
664+
return true
665+
}
666+
expected++
667+
}
668+
return false
669+
}

rpc/requests/block.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ func (b *Block) UnmarshalJSON(input []byte) error {
107107
b.Transactions = bd.Transactions
108108

109109
if bd.Transactions != nil {
110-
b.TransactionHashes = make([]common.Hash, len(b.Transactions))
111-
for _, t := range bd.Transactions {
112-
b.TransactionHashes = append(b.TransactionHashes, t.Hash)
110+
b.TransactionHashes = make([]common.Hash, len(bd.Transactions))
111+
for i, t := range bd.Transactions {
112+
b.TransactionHashes[i] = t.Hash
113113
}
114114
}
115115

0 commit comments

Comments
 (0)