Skip to content

Commit 9cd7d53

Browse files
committed
multi: create unique cfg for each proof courier
With this commit we disentangle the configurations for the two proof couriers, so we can configure them individually in a proper way.
1 parent a7c0510 commit 9cd7d53

File tree

3 files changed

+44
-23
lines changed

3 files changed

+44
-23
lines changed

itest/tapd_harness.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,19 @@ var (
4747
"allow the postgres fixture to run in total. Needs "+
4848
"to be increased for long-running tests.")
4949

50-
// defaultBackoffConfig is the default backoff config we'll use for
51-
// sending proofs.
52-
defaultBackoffConfig = proof.BackoffCfg{
50+
// defaultHashmailBackoffConfig is the default backoff config we'll use
51+
// for sending proofs with the hashmail courier.
52+
defaultHashmailBackoffConfig = proof.BackoffCfg{
53+
BackoffResetWait: time.Second,
54+
NumTries: 5,
55+
InitialBackoff: 300 * time.Millisecond,
56+
MaxBackoff: 600 * time.Millisecond,
57+
}
58+
59+
// defaultUniverseRpcBackoffConfig is the default backoff config we'll
60+
// use for sending proofs with the universe RPC courier.
61+
defaultUniverseRpcBackoffConfig = proof.BackoffCfg{
62+
SkipInitDelay: true,
5363
BackoffResetWait: time.Second,
5464
NumTries: 5,
5565
InitialBackoff: 300 * time.Millisecond,
@@ -209,9 +219,11 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
209219
// Populate proof courier specific config fields.
210220
//
211221
// Use passed in backoff config or default config.
212-
backoffCfg := defaultBackoffConfig
222+
hashmailBackoffCfg := defaultHashmailBackoffConfig
223+
universeRpcBackoffCfg := defaultUniverseRpcBackoffConfig
213224
if opts.proofSendBackoffCfg != nil {
214-
backoffCfg = *opts.proofSendBackoffCfg
225+
hashmailBackoffCfg = *opts.proofSendBackoffCfg
226+
universeRpcBackoffCfg = *opts.proofSendBackoffCfg
215227
}
216228

217229
// Used passed in proof receiver ack timeout or default.
@@ -220,12 +232,12 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
220232
receiverAckTimeout = *opts.proofReceiverAckTimeout
221233
}
222234

223-
// TODO(ffranr): Disentangle the hashmail config from the universe RPC
224-
// courier config. Right now, the universe courier takes the backoff
225-
// config from the hashmail courier config.
226235
finalCfg.HashMailCourier = &proof.HashMailCourierCfg{
227236
ReceiverAckTimeout: receiverAckTimeout,
228-
BackoffCfg: &backoffCfg,
237+
BackoffCfg: &hashmailBackoffCfg,
238+
}
239+
finalCfg.UniverseRpcCourier = &proof.UniverseRpcCourierCfg{
240+
BackoffCfg: &universeRpcBackoffCfg,
229241
}
230242

231243
switch typedProofCourier := (opts.proofCourier).(type) {
@@ -243,7 +255,6 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
243255

244256
default:
245257
finalCfg.DefaultProofCourierAddr = ""
246-
finalCfg.HashMailCourier = nil
247258
}
248259

249260
ht.t.Logf("Using proof courier address: %v",

proof/courier.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ func (h *UniverseRpcCourierAddr) Url() *url.URL {
185185
func (h *UniverseRpcCourierAddr) NewCourier(_ context.Context,
186186
cfg *CourierCfg, recipient Recipient) (Courier, error) {
187187

188-
// Skip the initial delivery delay for the universe RPC courier.
189-
// This courier skips the initial delay because it uses the backoff
190-
// procedure for each proof within a proof file separately.
191-
// Consequently, if we attempt to perform two consecutive send events
192-
// which share the same proof lineage (matching ancestral proofs), the
193-
// second send event will be delayed by the initial delay.
194-
cfg.BackoffCfg.SkipInitDelay = true
195188
backoffHandle := NewBackoffHandler(cfg.BackoffCfg, cfg.TransferLog)
196189

197190
// Ensure that the courier address is a universe RPC address.
@@ -557,10 +550,10 @@ func (e *BackoffExecError) Error() string {
557550

558551
// BackoffCfg configures the behaviour of the proof delivery backoff procedure.
559552
type BackoffCfg struct {
560-
// SkipInitDelay is a flag that indicates whether we should skip
561-
// the initial delay before attempting to deliver the proof to the
562-
// receiver.
563-
SkipInitDelay bool
553+
// SkipInitDelay is a flag that indicates whether we should skip the
554+
// initial delay before attempting to deliver the proof to the receiver
555+
// or receiving from the sender.
556+
SkipInitDelay bool `long:"skipinitdelay" description:"Skip the initial delay before attempting to deliver the proof to the receiver or receiving from the sender."`
564557

565558
// BackoffResetWait is the amount of time we'll wait before
566559
// resetting the backoff counter to its initial state.
@@ -1049,6 +1042,13 @@ func (h *HashMailCourier) SetSubscribers(
10491042
// proof.Courier interface.
10501043
var _ Courier = (*HashMailCourier)(nil)
10511044

1045+
// UniverseRpcCourierCfg is the config for the universe RPC proof courier.
1046+
type UniverseRpcCourierCfg struct {
1047+
// BackoffCfg configures the behaviour of the proof delivery
1048+
// functionality.
1049+
BackoffCfg *BackoffCfg
1050+
}
1051+
10521052
// UniverseRpcCourier is a universe RPC proof courier service handle. It
10531053
// implements the Courier interface.
10541054
type UniverseRpcCourier struct {

tapcfg/config.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ type Config struct {
303303
ReOrgSafeDepth int32 `long:"reorgsafedepth" description:"The number of confirmations we'll wait for before considering a transaction safely buried in the chain."`
304304

305305
// The following options are used to configure the proof courier.
306-
DefaultProofCourierAddr string `long:"proofcourieraddr" description:"Default proof courier service address."`
307-
HashMailCourier *proof.HashMailCourierCfg `group:"proofcourier" namespace:"hashmailcourier"`
306+
DefaultProofCourierAddr string `long:"proofcourieraddr" description:"Default proof courier service address."`
307+
HashMailCourier *proof.HashMailCourierCfg `group:"hashmailcourier" namespace:"hashmailcourier"`
308+
UniverseRpcCourier *proof.UniverseRpcCourierCfg `group:"universerpccourier" namespace:"universerpccourier"`
308309

309310
CustodianProofRetrievalDelay time.Duration `long:"custodianproofretrievaldelay" description:"The number of seconds the custodian waits after identifying an asset transfer on-chain and before retrieving the corresponding proof."`
310311

@@ -391,6 +392,15 @@ func DefaultConfig() Config {
391392
MaxBackoff: defaultProofTransferMaxBackoff,
392393
},
393394
},
395+
UniverseRpcCourier: &proof.UniverseRpcCourierCfg{
396+
BackoffCfg: &proof.BackoffCfg{
397+
SkipInitDelay: true,
398+
BackoffResetWait: defaultProofTransferBackoffResetWait,
399+
NumTries: defaultProofTransferNumTries,
400+
InitialBackoff: defaultProofTransferInitialBackoff,
401+
MaxBackoff: defaultProofTransferMaxBackoff,
402+
},
403+
},
394404
CustodianProofRetrievalDelay: defaultProofRetrievalDelay,
395405
Universe: &UniverseConfig{
396406
SyncInterval: defaultUniverseSyncInterval,

0 commit comments

Comments
 (0)