Skip to content

Commit 88346dc

Browse files
committed
itest: extract and tune proof courier backoff config
With this commit we optimize the backoff config to enable much faster proof transmission during integration tests. A significant speedup also comes from reducing the time the custodian waits between detecting a transfer on-chain and attempting to fetch the proof with the courier.
1 parent d48747d commit 88346dc

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

itest/tapd_harness.go

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ var (
4646
tapdb.DefaultPostgresFixtureLifetime, "The amount of time to "+
4747
"allow the postgres fixture to run in total. Needs "+
4848
"to be increased for long-running tests.")
49+
50+
// defaultBackoffConfig is the default backoff config we'll use for
51+
// sending proofs.
52+
defaultBackoffConfig = proof.BackoffCfg{
53+
BackoffResetWait: time.Second,
54+
NumTries: 5,
55+
InitialBackoff: 300 * time.Millisecond,
56+
MaxBackoff: 600 * time.Millisecond,
57+
}
58+
59+
// defaultProofRetrievalDelay is the default delay we'll use for the
60+
// custodian to wait from observing a transaction on-chan to retrieving
61+
// the proof from the courier.
62+
defaultProofRetrievalDelay = 200 * time.Millisecond
4963
)
5064

5165
const (
@@ -182,14 +196,9 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
182196
// Populate proof courier specific config fields.
183197
//
184198
// Use passed in backoff config or default config.
185-
backoffCfg := &proof.BackoffCfg{
186-
BackoffResetWait: 2 * time.Second,
187-
NumTries: 3,
188-
InitialBackoff: 2 * time.Second,
189-
MaxBackoff: 2 * time.Second,
190-
}
199+
backoffCfg := defaultBackoffConfig
191200
if opts.proofSendBackoffCfg != nil {
192-
backoffCfg = opts.proofSendBackoffCfg
201+
backoffCfg = *opts.proofSendBackoffCfg
193202
}
194203

195204
// Used passed in proof receiver ack timeout or default.
@@ -203,7 +212,7 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
203212
// config from the hashmail courier config.
204213
finalCfg.HashMailCourier = &proof.HashMailCourierCfg{
205214
ReceiverAckTimeout: receiverAckTimeout,
206-
BackoffCfg: backoffCfg,
215+
BackoffCfg: &backoffCfg,
207216
}
208217

209218
switch typedProofCourier := (opts.proofCourier).(type) {
@@ -224,7 +233,11 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
224233
finalCfg.HashMailCourier = nil
225234
}
226235

236+
ht.t.Logf("Using proof courier address: %v",
237+
finalCfg.DefaultProofCourierAddr)
238+
227239
// Set the custodian proof retrieval delay if it was specified.
240+
finalCfg.CustodianProofRetrievalDelay = defaultProofRetrievalDelay
228241
if opts.custodianProofRetrievalDelay != nil {
229242
finalCfg.CustodianProofRetrievalDelay = *opts.custodianProofRetrievalDelay
230243
}

0 commit comments

Comments
 (0)