Skip to content

Commit 7a3c890

Browse files
authored
les, light: improve txstatus retrieval (ethereum#22349)
Transaction unindexing will be enabled by default as of 1.10, which causes tx status retrieval will be broken without this PR. This PR introduces a retry mechanism in TxStatus retrieval.
1 parent 378e961 commit 7a3c890

14 files changed

+776
-242
lines changed

les/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
122122
leth.retriever = newRetrieveManager(peers, leth.reqDist, leth.serverPool.getTimeout)
123123
leth.relay = newLesTxRelay(peers, leth.retriever)
124124

125-
leth.odr = NewLesOdr(chainDb, light.DefaultClientIndexerConfig, leth.retriever)
125+
leth.odr = NewLesOdr(chainDb, light.DefaultClientIndexerConfig, leth.peers, leth.retriever)
126126
leth.chtIndexer = light.NewChtIndexer(chainDb, leth.odr, params.CHTFrequency, params.HelperTrieConfirmations, config.LightNoPrune)
127127
leth.bloomTrieIndexer = light.NewBloomTrieIndexer(chainDb, leth.odr, params.BloomBitsBlocksClient, params.BloomTrieFrequency, config.LightNoPrune)
128128
leth.odr.SetIndexers(leth.chtIndexer, leth.bloomTrieIndexer, leth.bloomIndexer)

les/fetcher_test.go

+30-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ func TestSequentialAnnouncementsLes2(t *testing.T) { testSequentialAnnouncements
6666
func TestSequentialAnnouncementsLes3(t *testing.T) { testSequentialAnnouncements(t, 3) }
6767

6868
func testSequentialAnnouncements(t *testing.T, protocol int) {
69-
s, c, teardown := newClientServerEnv(t, 4, protocol, nil, nil, 0, false, false, true)
69+
netconfig := testnetConfig{
70+
blocks: 4,
71+
protocol: protocol,
72+
nopruning: true,
73+
}
74+
s, c, teardown := newClientServerEnv(t, netconfig)
7075
defer teardown()
7176

7277
// Create connected peer pair.
@@ -101,7 +106,12 @@ func TestGappedAnnouncementsLes2(t *testing.T) { testGappedAnnouncements(t, 2) }
101106
func TestGappedAnnouncementsLes3(t *testing.T) { testGappedAnnouncements(t, 3) }
102107

103108
func testGappedAnnouncements(t *testing.T, protocol int) {
104-
s, c, teardown := newClientServerEnv(t, 4, protocol, nil, nil, 0, false, false, true)
109+
netconfig := testnetConfig{
110+
blocks: 4,
111+
protocol: protocol,
112+
nopruning: true,
113+
}
114+
s, c, teardown := newClientServerEnv(t, netconfig)
105115
defer teardown()
106116

107117
// Create connected peer pair.
@@ -183,7 +193,13 @@ func testTrustedAnnouncement(t *testing.T, protocol int) {
183193
ids = append(ids, n.String())
184194
}
185195
}
186-
_, c, teardown := newClientServerEnv(t, 0, protocol, nil, ids, 60, false, false, true)
196+
netconfig := testnetConfig{
197+
protocol: protocol,
198+
nopruning: true,
199+
ulcServers: ids,
200+
ulcFraction: 60,
201+
}
202+
_, c, teardown := newClientServerEnv(t, netconfig)
187203
defer teardown()
188204
defer func() {
189205
for i := 0; i < len(teardowns); i++ {
@@ -233,8 +249,17 @@ func testTrustedAnnouncement(t *testing.T, protocol int) {
233249
check([]uint64{10}, 10, func() { <-newHead }) // Sync the whole chain.
234250
}
235251

236-
func TestInvalidAnnounces(t *testing.T) {
237-
s, c, teardown := newClientServerEnv(t, 4, lpv3, nil, nil, 0, false, false, true)
252+
func TestInvalidAnnouncesLES2(t *testing.T) { testInvalidAnnounces(t, lpv2) }
253+
func TestInvalidAnnouncesLES3(t *testing.T) { testInvalidAnnounces(t, lpv3) }
254+
func TestInvalidAnnouncesLES4(t *testing.T) { testInvalidAnnounces(t, lpv4) }
255+
256+
func testInvalidAnnounces(t *testing.T, protocol int) {
257+
netconfig := testnetConfig{
258+
blocks: 4,
259+
protocol: protocol,
260+
nopruning: true,
261+
}
262+
s, c, teardown := newClientServerEnv(t, netconfig)
238263
defer teardown()
239264

240265
// Create connected peer pair.

0 commit comments

Comments
 (0)