diff --git a/itest/tapd_harness.go b/itest/tapd_harness.go index 0e6bf5c18..cc362ccd2 100644 --- a/itest/tapd_harness.go +++ b/itest/tapd_harness.go @@ -47,9 +47,19 @@ var ( "allow the postgres fixture to run in total. Needs "+ "to be increased for long-running tests.") - // defaultBackoffConfig is the default backoff config we'll use for - // sending proofs. - defaultBackoffConfig = proof.BackoffCfg{ + // defaultHashmailBackoffConfig is the default backoff config we'll use + // for sending proofs with the hashmail courier. + defaultHashmailBackoffConfig = proof.BackoffCfg{ + BackoffResetWait: time.Second, + NumTries: 5, + InitialBackoff: 300 * time.Millisecond, + MaxBackoff: 600 * time.Millisecond, + } + + // defaultUniverseRpcBackoffConfig is the default backoff config we'll + // use for sending proofs with the universe RPC courier. + defaultUniverseRpcBackoffConfig = proof.BackoffCfg{ + SkipInitDelay: true, BackoffResetWait: time.Second, NumTries: 5, InitialBackoff: 300 * time.Millisecond, @@ -209,9 +219,11 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig, // Populate proof courier specific config fields. // // Use passed in backoff config or default config. - backoffCfg := defaultBackoffConfig + hashmailBackoffCfg := defaultHashmailBackoffConfig + universeRpcBackoffCfg := defaultUniverseRpcBackoffConfig if opts.proofSendBackoffCfg != nil { - backoffCfg = *opts.proofSendBackoffCfg + hashmailBackoffCfg = *opts.proofSendBackoffCfg + universeRpcBackoffCfg = *opts.proofSendBackoffCfg } // Used passed in proof receiver ack timeout or default. @@ -220,12 +232,12 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig, receiverAckTimeout = *opts.proofReceiverAckTimeout } - // TODO(ffranr): Disentangle the hashmail config from the universe RPC - // courier config. Right now, the universe courier takes the backoff - // config from the hashmail courier config. finalCfg.HashMailCourier = &proof.HashMailCourierCfg{ ReceiverAckTimeout: receiverAckTimeout, - BackoffCfg: &backoffCfg, + BackoffCfg: &hashmailBackoffCfg, + } + finalCfg.UniverseRpcCourier = &proof.UniverseRpcCourierCfg{ + BackoffCfg: &universeRpcBackoffCfg, } switch typedProofCourier := (opts.proofCourier).(type) { @@ -243,7 +255,6 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig, default: finalCfg.DefaultProofCourierAddr = "" - finalCfg.HashMailCourier = nil } ht.t.Logf("Using proof courier address: %v", diff --git a/proof/courier.go b/proof/courier.go index f161b8190..6f4fcaa3e 100644 --- a/proof/courier.go +++ b/proof/courier.go @@ -185,13 +185,6 @@ func (h *UniverseRpcCourierAddr) Url() *url.URL { func (h *UniverseRpcCourierAddr) NewCourier(_ context.Context, cfg *CourierCfg, recipient Recipient) (Courier, error) { - // Skip the initial delivery delay for the universe RPC courier. - // This courier skips the initial delay because it uses the backoff - // procedure for each proof within a proof file separately. - // Consequently, if we attempt to perform two consecutive send events - // which share the same proof lineage (matching ancestral proofs), the - // second send event will be delayed by the initial delay. - cfg.BackoffCfg.SkipInitDelay = true backoffHandle := NewBackoffHandler(cfg.BackoffCfg, cfg.TransferLog) // Ensure that the courier address is a universe RPC address. @@ -557,10 +550,10 @@ func (e *BackoffExecError) Error() string { // BackoffCfg configures the behaviour of the proof delivery backoff procedure. type BackoffCfg struct { - // SkipInitDelay is a flag that indicates whether we should skip - // the initial delay before attempting to deliver the proof to the - // receiver. - SkipInitDelay bool + // SkipInitDelay is a flag that indicates whether we should skip the + // initial delay before attempting to deliver the proof to the receiver + // or receiving from the sender. + SkipInitDelay bool `long:"skipinitdelay" description:"Skip the initial delay before attempting to deliver the proof to the receiver or receiving from the sender."` // BackoffResetWait is the amount of time we'll wait before // resetting the backoff counter to its initial state. @@ -1049,6 +1042,13 @@ func (h *HashMailCourier) SetSubscribers( // proof.Courier interface. var _ Courier = (*HashMailCourier)(nil) +// UniverseRpcCourierCfg is the config for the universe RPC proof courier. +type UniverseRpcCourierCfg struct { + // BackoffCfg configures the behaviour of the proof delivery + // functionality. + BackoffCfg *BackoffCfg +} + // UniverseRpcCourier is a universe RPC proof courier service handle. It // implements the Courier interface. type UniverseRpcCourier struct { diff --git a/tapcfg/config.go b/tapcfg/config.go index d5f6c5f5c..ebccde50e 100644 --- a/tapcfg/config.go +++ b/tapcfg/config.go @@ -303,8 +303,9 @@ type Config struct { ReOrgSafeDepth int32 `long:"reorgsafedepth" description:"The number of confirmations we'll wait for before considering a transaction safely buried in the chain."` // The following options are used to configure the proof courier. - DefaultProofCourierAddr string `long:"proofcourieraddr" description:"Default proof courier service address."` - HashMailCourier *proof.HashMailCourierCfg `group:"proofcourier" namespace:"hashmailcourier"` + DefaultProofCourierAddr string `long:"proofcourieraddr" description:"Default proof courier service address."` + HashMailCourier *proof.HashMailCourierCfg `group:"hashmailcourier" namespace:"hashmailcourier"` + UniverseRpcCourier *proof.UniverseRpcCourierCfg `group:"universerpccourier" namespace:"universerpccourier"` 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."` @@ -391,6 +392,15 @@ func DefaultConfig() Config { MaxBackoff: defaultProofTransferMaxBackoff, }, }, + UniverseRpcCourier: &proof.UniverseRpcCourierCfg{ + BackoffCfg: &proof.BackoffCfg{ + SkipInitDelay: true, + BackoffResetWait: defaultProofTransferBackoffResetWait, + NumTries: defaultProofTransferNumTries, + InitialBackoff: defaultProofTransferInitialBackoff, + MaxBackoff: defaultProofTransferMaxBackoff, + }, + }, CustodianProofRetrievalDelay: defaultProofRetrievalDelay, Universe: &UniverseConfig{ SyncInterval: defaultUniverseSyncInterval,