From 0bdf5546e468ab487731fc4d1e283ff6b5064373 Mon Sep 17 00:00:00 2001 From: venkatesh mankena Date: Tue, 23 Jun 2020 11:36:07 +0530 Subject: [PATCH 1/2] change delay interval --- bridge/setu/util/common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge/setu/util/common.go b/bridge/setu/util/common.go index c6999f1f7..e24bccc4c 100644 --- a/bridge/setu/util/common.go +++ b/bridge/setu/util/common.go @@ -54,8 +54,8 @@ const ( TransactionTimeout = 1 * time.Minute CommitTimeout = 2 * time.Minute - TaskDelayBetweenEachVal = 6 * time.Second - ValidatorJoinRetryDelay = 12 * time.Second + TaskDelayBetweenEachVal = 18 * time.Second + ValidatorJoinRetryDelay = 18 * time.Second TimeBetweenTwoBlocks = 6 * time.Second BlocksToDelayBeforeRetry = 6 From 2864b0afe5a8ff33369d64b55a0c98eb17096ad8 Mon Sep 17 00:00:00 2001 From: venkatesh mankena Date: Tue, 23 Jun 2020 11:46:41 +0530 Subject: [PATCH 2/2] change delay interval- name change --- bridge/setu/processor/checkpoint.go | 4 ++-- bridge/setu/processor/clerk.go | 4 ++-- bridge/setu/processor/fee.go | 4 ++-- bridge/setu/processor/staking.go | 16 ++++++++-------- bridge/setu/util/common.go | 6 +++--- go.mod | 1 + go.sum | 2 ++ 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/bridge/setu/processor/checkpoint.go b/bridge/setu/processor/checkpoint.go index 3ba3bfea4..73b0da598 100644 --- a/bridge/setu/processor/checkpoint.go +++ b/bridge/setu/processor/checkpoint.go @@ -288,8 +288,8 @@ func (cp *CheckpointProcessor) sendCheckpointAckToHeimdall(eventName string, che } // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - cp.Logger.Debug("Retrying checkpoint-ack to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + cp.Logger.Debug("Retrying checkpoint-ack to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } // handleCheckpointNoAck - Checkpoint No-Ack handler diff --git a/bridge/setu/processor/clerk.go b/bridge/setu/processor/clerk.go index cbade676e..36afbfa2f 100644 --- a/bridge/setu/processor/clerk.go +++ b/bridge/setu/processor/clerk.go @@ -110,8 +110,8 @@ func (cp *ClerkProcessor) sendStateSyncedToHeimdall(eventName string, logBytes s // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - cp.Logger.Debug("Retrying deposit to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + cp.Logger.Debug("Retrying deposit to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } // isOldTx checks if tx is already processed or not diff --git a/bridge/setu/processor/fee.go b/bridge/setu/processor/fee.go index 25a5de3e9..e174b1090 100644 --- a/bridge/setu/processor/fee.go +++ b/bridge/setu/processor/fee.go @@ -89,8 +89,8 @@ func (fp *FeeProcessor) sendTopUpFeeToHeimdall(eventName string, logBytes string // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - fp.Logger.Debug("Retrying topup to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + fp.Logger.Debug("Retrying topup to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } // isOldTx checks if tx is already processed or not diff --git a/bridge/setu/processor/staking.go b/bridge/setu/processor/staking.go index 6c467fcc8..a8e5ebf7e 100644 --- a/bridge/setu/processor/staking.go +++ b/bridge/setu/processor/staking.go @@ -128,8 +128,8 @@ func (sp *StakingProcessor) sendValidatorJoinToHeimdall(eventName string, logByt } // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - sp.Logger.Debug("Retrying validatorjoin to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + sp.Logger.Debug("Retrying validatorjoin to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } func (sp *StakingProcessor) sendUnstakeInitToHeimdall(eventName string, logBytes string) error { @@ -191,8 +191,8 @@ func (sp *StakingProcessor) sendUnstakeInitToHeimdall(eventName string, logBytes // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - sp.Logger.Debug("Retrying unstake-init to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + sp.Logger.Debug("Retrying unstake-init to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } func (sp *StakingProcessor) sendStakeUpdateToHeimdall(eventName string, logBytes string) error { @@ -249,8 +249,8 @@ func (sp *StakingProcessor) sendStakeUpdateToHeimdall(eventName string, logBytes // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - sp.Logger.Debug("Retrying stake-update to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + sp.Logger.Debug("Retrying stake-update to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } func (sp *StakingProcessor) sendSignerChangeToHeimdall(eventName string, logBytes string) error { @@ -316,8 +316,8 @@ func (sp *StakingProcessor) sendSignerChangeToHeimdall(eventName string, logByte // After broadcasting transaction from bridge, add back the msg to queue with retry delay. // This is to retry side-tx msg incase if it was failed earlier during side-tx processing on heimdall. - sp.Logger.Debug("Retrying signer-change to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) - return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.TimeBetweenTwoBlocks) + sp.Logger.Debug("Retrying signer-change to check if side-tx is successful or not", "after", util.BlocksToDelayBeforeRetry*util.BlockInterval) + return tasks.NewErrRetryTaskLater("retry to check if side-tx is successful or not", util.BlocksToDelayBeforeRetry*util.BlockInterval) } // isOldTx checks if tx is already processed or not diff --git a/bridge/setu/util/common.go b/bridge/setu/util/common.go index e24bccc4c..bbefc59ee 100644 --- a/bridge/setu/util/common.go +++ b/bridge/setu/util/common.go @@ -54,10 +54,10 @@ const ( TransactionTimeout = 1 * time.Minute CommitTimeout = 2 * time.Minute - TaskDelayBetweenEachVal = 18 * time.Second - ValidatorJoinRetryDelay = 18 * time.Second + BlockInterval = 6 * time.Second + TaskDelayBetweenEachVal = 3 * BlockInterval + ValidatorJoinRetryDelay = 3 * BlockInterval - TimeBetweenTwoBlocks = 6 * time.Second BlocksToDelayBeforeRetry = 6 BridgeDBFlag = "bridge-db" diff --git a/go.mod b/go.mod index b0612de18..5226433db 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( github.com/karalabe/usb v0.0.0-20191104083709-911d15fe12a9 // indirect github.com/maticnetwork/bor v0.1.7-0.20200507151553-e03cd94ed12b github.com/olekukonko/tablewriter v0.0.4 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pborman/uuid v1.2.0 github.com/peterh/liner v1.2.0 // indirect github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index ecb539ae9..326513493 100644 --- a/go.sum +++ b/go.sum @@ -419,6 +419,8 @@ github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsq github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/oschwald/maxminddb-golang v1.6.0 h1:KAJSjdHQ8Kv45nFIbtoLGrGWqHFajOIm7skTyz/+Dls= github.com/oschwald/maxminddb-golang v1.6.0/go.mod h1:DUJFucBg2cvqx42YmDa/+xHvb0elJtOm3o4aFQ/nb/w= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=