Skip to content

Commit 6124dae

Browse files
authored
Merge pull request #2348 from CortexFoundation/dev
do not derive full receipts during rendering
2 parents 62d2148 + 90f009f commit 6124dae

41 files changed

Lines changed: 1855 additions & 357 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/blockchain_reader.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts {
229229
return receipts
230230
}
231231

232+
func (bc *BlockChain) GetRawReceiptsByHash(hash common.Hash) types.Receipts {
233+
number := rawdb.ReadHeaderNumber(bc.db, hash)
234+
if number == nil {
235+
return nil
236+
}
237+
return rawdb.ReadRawReceipts(bc.db, hash, *number)
238+
}
239+
232240
// GetUnclesInChain retrieves all the uncles from a given block backwards until
233241
// a specific distance is reached.
234242
func (bc *BlockChain) GetUnclesInChain(block *types.Block, length int) []*types.Header {

core/filtermaps/chain_view.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type blockchain interface {
2929
GetHeader(hash common.Hash, number uint64) *types.Header
3030
GetCanonicalHash(number uint64) common.Hash
3131
GetReceiptsByHash(hash common.Hash) types.Receipts
32+
GetRawReceiptsByHash(hash common.Hash) types.Receipts
3233
}
3334

3435
// ChainView represents an immutable view of a chain with a block id and a set
@@ -102,10 +103,23 @@ func (cv *ChainView) Receipts(number uint64) types.Receipts {
102103
blockHash := cv.BlockHash(number)
103104
if blockHash == (common.Hash{}) {
104105
log.Error("Chain view: block hash unavailable", "number", number, "head", cv.headNumber)
106+
return nil
105107
}
106108
return cv.chain.GetReceiptsByHash(blockHash)
107109
}
108110

111+
// RawReceipts returns the set of receipts belonging to the block at the given
112+
// block number. Does not derive the fields of the receipts, should only be
113+
// used during creation of the filter maps, please use cv.Receipts during querying.
114+
func (cv *ChainView) RawReceipts(number uint64) types.Receipts {
115+
blockHash := cv.BlockHash(number)
116+
if blockHash == (common.Hash{}) {
117+
log.Error("Chain view: block hash unavailable", "number", number, "head", cv.headNumber)
118+
return nil
119+
}
120+
return cv.chain.GetRawReceiptsByHash(blockHash)
121+
}
122+
109123
// SharedRange returns the block range shared by two chain views.
110124
func (cv *ChainView) SharedRange(cv2 *ChainView) common.Range[uint64] {
111125
cv.lock.Lock()

core/filtermaps/map_renderer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func (f *FilterMaps) newLogIteratorFromMapBoundary(mapIndex uint32, startBlock,
693693
return nil, fmt.Errorf("iterator entry point %d after target chain head block %d", startBlock, f.targetView.HeadNumber())
694694
}
695695
// get block receipts
696-
receipts := f.targetView.Receipts(startBlock)
696+
receipts := f.targetView.RawReceipts(startBlock)
697697
if receipts == nil {
698698
return nil, fmt.Errorf("receipts not found for start block %d", startBlock)
699699
}
@@ -760,7 +760,7 @@ func (l *logIterator) next() error {
760760
if l.delimiter {
761761
l.delimiter = false
762762
l.blockNumber++
763-
l.receipts = l.chainView.Receipts(l.blockNumber)
763+
l.receipts = l.chainView.RawReceipts(l.blockNumber)
764764
if l.receipts == nil {
765765
return fmt.Errorf("receipts not found for block %d", l.blockNumber)
766766
}

ctxc/filters/filter_system_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ func (b *testBackend) CurrentView() *filtermaps.ChainView {
190190
return filtermaps.NewChainView(b, head.Number.Uint64(), head.Hash())
191191
}
192192

193+
func (b *testBackend) GetRawReceiptsByHash(hash common.Hash) types.Receipts {
194+
if number := rawdb.ReadHeaderNumber(b.db, hash); number != nil {
195+
return rawdb.ReadRawReceipts(b.db, hash, *number)
196+
}
197+
return nil
198+
}
199+
193200
func newTestFilterSystem(t testing.TB, db ctxcdb.Database, cfg Config) (*testBackend, *FilterSystem) {
194201
backend := &testBackend{db: db}
195202
sys := NewFilterSystem(backend, cfg)

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/aws/aws-sdk-go-v2/credentials v1.17.67
1515
github.com/aws/aws-sdk-go-v2/service/route53 v1.51.1
1616
github.com/cespare/cp v1.1.1
17-
github.com/charmbracelet/bubbletea v1.3.4
17+
github.com/charmbracelet/bubbletea v1.3.5
1818
github.com/cloudflare/cloudflare-go v0.115.0
1919
github.com/cockroachdb/pebble v1.1.5
2020
github.com/consensys/gnark-crypto v0.17.0
@@ -129,14 +129,14 @@ require (
129129
github.com/cespare/xxhash/v2 v2.3.0 // indirect
130130
github.com/charmbracelet/colorprofile v0.3.1 // indirect
131131
github.com/charmbracelet/lipgloss v1.1.0 // indirect
132-
github.com/charmbracelet/x/ansi v0.8.0 // indirect
132+
github.com/charmbracelet/x/ansi v0.9.2 // indirect
133133
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
134134
github.com/charmbracelet/x/term v0.2.1 // indirect
135135
github.com/cockroachdb/errors v1.11.3 // indirect
136136
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
137137
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
138138
github.com/cockroachdb/redact v1.1.6 // indirect
139-
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
139+
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
140140
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
141141
github.com/consensys/bavard v0.1.30 // indirect
142142
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
@@ -251,7 +251,7 @@ require (
251251
gopkg.in/yaml.v2 v2.4.0 // indirect
252252
gopkg.in/yaml.v3 v3.0.1 // indirect
253253
lukechampine.com/blake3 v1.4.0 // indirect
254-
modernc.org/libc v1.64.0 // indirect
254+
modernc.org/libc v1.64.1 // indirect
255255
modernc.org/mathutil v1.7.1 // indirect
256256
modernc.org/memory v1.10.0 // indirect
257257
modernc.org/sqlite v1.37.0 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,14 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
338338
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
339339
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
340340
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
341-
github.com/charmbracelet/bubbletea v1.3.4 h1:kCg7B+jSCFPLYRA52SDZjr51kG/fMUEoPoZrkaDHyoI=
342-
github.com/charmbracelet/bubbletea v1.3.4/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo=
341+
github.com/charmbracelet/bubbletea v1.3.5 h1:JAMNLTbqMOhSwoELIr0qyP4VidFq72/6E9j7HHmRKQc=
342+
github.com/charmbracelet/bubbletea v1.3.5/go.mod h1:TkCnmH+aBd4LrXhXcqrKiYwRs7qyQx5rBgH5fVY3v54=
343343
github.com/charmbracelet/colorprofile v0.3.1 h1:k8dTHMd7fgw4bnFd7jXTLZrSU/CQrKnL3m+AxCzDz40=
344344
github.com/charmbracelet/colorprofile v0.3.1/go.mod h1:/GkGusxNs8VB/RSOh3fu0TJmQ4ICMMPApIIVn0KszZ0=
345345
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
346346
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
347-
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
348-
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
347+
github.com/charmbracelet/x/ansi v0.9.2 h1:92AGsQmNTRMzuzHEYfCdjQeUzTrgE1vfO5/7fEVoXdY=
348+
github.com/charmbracelet/x/ansi v0.9.2/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
349349
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
350350
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
351351
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
@@ -375,8 +375,8 @@ github.com/cockroachdb/pebble v1.1.5 h1:5AAWCBWbat0uE0blr8qzufZP5tBjkRyy/jWe1QWL
375375
github.com/cockroachdb/pebble v1.1.5/go.mod h1:17wO9el1YEigxkP/YtV8NtCivQDgoCyBg5c4VR/eOWo=
376376
github.com/cockroachdb/redact v1.1.6 h1:zXJBwDZ84xJNlHl1rMyCojqyIxv+7YUpQiJLQ7n4314=
377377
github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
378-
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
379-
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
378+
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb h1:3bCgBvB8PbJVMX1ouCcSIxvsqKPYM7gs72o0zC76n9g=
379+
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
380380
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
381381
github.com/common-nighthawk/go-figure v0.0.0-20190529165535-67e0ed34491a/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
382382
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ=
@@ -1823,8 +1823,8 @@ modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
18231823
modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
18241824
modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
18251825
modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
1826-
modernc.org/libc v1.64.0 h1:U0k8BD2d3cD3e9I8RLcZgJBHAcsJzbXx5mKGSb5pyJA=
1827-
modernc.org/libc v1.64.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
1826+
modernc.org/libc v1.64.1 h1:EnFXu9N9epQohXMH+h1/w3SxHVGozuPjbux5KVFf5bM=
1827+
modernc.org/libc v1.64.1/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
18281828
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
18291829
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
18301830
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=

trie/proof_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,27 +1004,27 @@ func TestRangeProofKeysWithSharedPrefix(t *testing.T) {
10041004
// to exit with errors
10051005
func TestRangeProofErrors(t *testing.T) {
10061006
// Different number of keys to values
1007-
_, err := VerifyRangeProof((common.Hash{}), []byte{}, make([][]byte, 5), make([][]byte, 4), nil)
1007+
_, _, _, _, err := VerifyRangeProof((common.Hash{}), []byte{}, []byte{}, make([][]byte, 5), make([][]byte, 4), nil)
10081008
if have, want := err.Error(), "inconsistent proof data, keys: 5, values: 4"; have != want {
10091009
t.Fatalf("wrong error, have %q, want %q", err.Error(), want)
10101010
}
10111011
// Non-increasing paths
1012-
_, err = VerifyRangeProof((common.Hash{}), []byte{},
1012+
_, _, _, _, err = VerifyRangeProof((common.Hash{}), []byte{}, []byte{},
10131013
[][]byte{[]byte{2, 1}, []byte{2, 1}}, make([][]byte, 2), nil)
10141014
if have, want := err.Error(), "range is not monotonically increasing"; have != want {
10151015
t.Fatalf("wrong error, have %q, want %q", err.Error(), want)
10161016
}
10171017
// A prefixed path is never motivated. Inserting the second element will
10181018
// require rewriting/overwriting the previous value-node, thus can only
10191019
// happen if the data is corrupt.
1020-
_, err = VerifyRangeProof((common.Hash{}), []byte{},
1020+
_, _, _, _, err = VerifyRangeProof((common.Hash{}), []byte{}, []byte{},
10211021
[][]byte{[]byte{2, 1}, []byte{2, 1, 2}},
10221022
[][]byte{[]byte{1}, []byte{1}}, nil)
10231023
if have, want := err.Error(), "range contains path prefixes"; have != want {
10241024
t.Fatalf("wrong error, have %q, want %q", err.Error(), want)
10251025
}
10261026
// Empty values (deletions)
1027-
_, err = VerifyRangeProof((common.Hash{}), []byte{},
1027+
_, _, _, _, err = VerifyRangeProof((common.Hash{}), []byte{}, []byte{},
10281028
[][]byte{[]byte{2, 1}, []byte{2, 2}},
10291029
[][]byte{[]byte{1}, []byte{}}, nil)
10301030
if have, want := err.Error(), "range contains deletion"; have != want {

vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

vendor/github.com/charmbracelet/bubbletea/.golangci.yml

Lines changed: 27 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/charmbracelet/bubbletea/README.md

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)