Skip to content

Commit aa31e22

Browse files
committed
multi: make custodian proof retrieval delay configurable
1 parent 62545c4 commit aa31e22

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

itest/tapd_harness.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ type tapdConfig struct {
8181
}
8282

8383
type harnessOpts struct {
84-
proofSendBackoffCfg *proof.BackoffCfg
85-
proofReceiverAckTimeout *time.Duration
86-
proofCourier proof.CourierHarness
87-
addrAssetSyncerDisable bool
84+
proofSendBackoffCfg *proof.BackoffCfg
85+
proofReceiverAckTimeout *time.Duration
86+
proofCourier proof.CourierHarness
87+
custodianProofRetrievalDelay *time.Duration
88+
addrAssetSyncerDisable bool
8889
}
8990

9091
type harnessOption func(*harnessOpts)
@@ -223,6 +224,11 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
223224
finalCfg.HashMailCourier = nil
224225
}
225226

227+
// Set the custodian proof retrieval delay if it was specified.
228+
if opts.custodianProofRetrievalDelay != nil {
229+
finalCfg.CustodianProofRetrievalDelay = *opts.custodianProofRetrievalDelay
230+
}
231+
226232
return &tapdHarness{
227233
cfg: &cfg,
228234
clientCfg: finalCfg,

itest/test_harness.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@ type tapdHarnessParams struct {
325325
// an ack from the proof receiver.
326326
proofReceiverAckTimeout *time.Duration
327327

328+
// custodianProofRetrievalDelay is the time duration the custodian waits
329+
// having identified an asset transfer on-chain and before retrieving
330+
// the corresponding proof via the proof courier service.
331+
custodianProofRetrievalDelay *time.Duration
332+
328333
// addrAssetSyncerDisable is a flag that determines if the address book
329334
// will try and bootstrap unknown assets on address creation.
330335
addrAssetSyncerDisable bool
@@ -371,6 +376,7 @@ func setupTapdHarness(t *testing.T, ht *harnessTest,
371376
ho.proofSendBackoffCfg = params.proofSendBackoffCfg
372377
ho.proofReceiverAckTimeout = params.proofReceiverAckTimeout
373378
ho.proofCourier = selectedProofCourier
379+
ho.custodianProofRetrievalDelay = params.custodianProofRetrievalDelay
374380
ho.addrAssetSyncerDisable = params.addrAssetSyncerDisable
375381
}
376382

tapcfg/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ const (
124124
// universe queries. By default we'll allow 100 qps, with a max burst
125125
// of 10 queries.
126126
defaultUniverseQueriesBurst = 10
127+
128+
// defaultProofRetrievalDelay is the default time duration the custodian
129+
// waits having identified an asset transfer on-chain and before
130+
// retrieving the corresponding proof via the proof courier service.
131+
defaultProofRetrievalDelay = 5 * time.Second
127132
)
128133

129134
var (
@@ -301,6 +306,8 @@ type Config struct {
301306
DefaultProofCourierAddr string `long:"proofcourieraddr" description:"Default proof courier service address."`
302307
HashMailCourier *proof.HashMailCourierCfg `group:"proofcourier" namespace:"hashmailcourier"`
303308

309+
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."`
310+
304311
ChainConf *ChainConfig
305312
RpcConf *RpcConfig
306313

@@ -384,6 +391,7 @@ func DefaultConfig() Config {
384391
MaxBackoff: defaultProofTransferMaxBackoff,
385392
},
386393
},
394+
CustodianProofRetrievalDelay: defaultProofRetrievalDelay,
387395
Universe: &UniverseConfig{
388396
SyncInterval: defaultUniverseSyncInterval,
389397
UniverseQueriesPerSecond: rate.Limit(

tapcfg/server.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,13 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
362362
GroupVerifier: tapgarden.GenGroupVerifier(
363363
context.Background(), assetMintingStore,
364364
),
365-
AddrBook: addrBook,
366-
ProofArchive: proofArchive,
367-
ProofNotifier: assetStore,
368-
ErrChan: mainErrChan,
369-
ProofCourierCfg: proofCourierCfg,
370-
ProofWatcher: reOrgWatcher,
365+
AddrBook: addrBook,
366+
ProofArchive: proofArchive,
367+
ProofNotifier: assetStore,
368+
ErrChan: mainErrChan,
369+
ProofCourierCfg: proofCourierCfg,
370+
ProofRetrievalDelay: cfg.CustodianProofRetrievalDelay,
371+
ProofWatcher: reOrgWatcher,
371372
},
372373
),
373374
ChainBridge: chainBridge,

tapgarden/custodian.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ import (
1818
"github.com/lightningnetwork/lnd/lnrpc"
1919
)
2020

21-
const (
22-
defaultProofRetrievalDelay = 5 * time.Second
23-
)
24-
2521
// CustodianConfig houses all the items that the Custodian needs to carry out
2622
// its duties.
2723
type CustodianConfig struct {
@@ -58,6 +54,11 @@ type CustodianConfig struct {
5854
// service handles.
5955
ProofCourierCfg *proof.CourierCfg
6056

57+
// ProofRetrievalDelay is the time duration the custodian waits having
58+
// identified an asset transfer on-chain and before retrieving the
59+
// corresponding proof via the proof courier service.
60+
ProofRetrievalDelay time.Duration
61+
6162
// ProofWatcher is used to watch new proofs for their anchor transaction
6263
// to be confirmed safely with a minimum number of confirmations.
6364
ProofWatcher proof.Watcher
@@ -420,7 +421,7 @@ func (c *Custodian) inspectWalletTx(walletTx *lndclient.Transaction) error {
420421
// the proof will very likely fail. We should expect
421422
// retrieval success before this delay.
422423
select {
423-
case <-time.After(defaultProofRetrievalDelay):
424+
case <-time.After(c.cfg.ProofRetrievalDelay):
424425
case <-ctx.Done():
425426
return
426427
}

0 commit comments

Comments
 (0)