Skip to content

Commit e2548b2

Browse files
committed
fix comments and make tests pass
1 parent 249e302 commit e2548b2

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

relayer/network_utils.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ import (
2222
const retryPeriodSeconds = 5
2323

2424
// Convenience function to initialize connections and check stake for all source blockchains.
25-
// Only returns an error if it fails to get a list of canonical validator or a valid warp config.
26-
//
27-
// Failing a sufficient stake check will only log an error but still return successfully
28-
// since each attempted relay will make an attempt at reconnecting to any missing validators.
25+
// This function blocks until it successfully connects to sufficient stake for all source blockchains
26+
// or returns an error if unable to fetch warpConfigs or to connect to sufficient stake before timeout.
2927
//
3028
// Sufficient stake is determined by the Warp quora of the configured supported destinations,
3129
// or if the subnet supports all destinations, by the quora of all configured destinations.
@@ -43,7 +41,7 @@ func InitializeConnectionsAndCheckStake(
4341
)
4442
defer cancel()
4543

46-
var eg errgroup.Group
44+
eg, ctx := errgroup.WithContext(ctx)
4745
for _, sourceBlockchain := range cfg.SourceBlockchains {
4846
if sourceBlockchain.GetSubnetID() == constants.PrimaryNetworkID {
4947
eg.Go(func() error {
@@ -115,7 +113,7 @@ func connectToNonPrimaryNetworkPeers(
115113
case <-ctx.Done():
116114
return ctx.Err()
117115
default:
118-
time.Sleep(5 * time.Second) // Retry after a short delay
116+
time.Sleep(retryPeriodSeconds * time.Second)
119117
}
120118
}
121119
}
@@ -166,7 +164,7 @@ func connectToPrimaryNetworkPeers(
166164
case <-ctx.Done():
167165
return ctx.Err()
168166
default:
169-
time.Sleep(retryPeriodSeconds)
167+
time.Sleep(retryPeriodSeconds * time.Second)
170168
}
171169
}
172170
}

tests/utils/utils.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,17 @@ func CreateDefaultRelayerConfig(
199199
InfoAPI: &config.APIConfig{
200200
BaseURL: sourceL1sInfo[0].NodeURIs[0],
201201
},
202-
StorageLocation: StorageLocation,
203-
DBWriteIntervalSeconds: DBUpdateSeconds,
204-
ProcessMissedBlocks: false,
205-
MetricsPort: 9090,
206-
SourceBlockchains: sources,
207-
DestinationBlockchains: destinations,
208-
APIPort: 8080,
209-
DeciderURL: "localhost:50051",
210-
SignatureCacheSize: (1024 * 1024),
211-
AllowPrivateIPs: true,
202+
StorageLocation: StorageLocation,
203+
DBWriteIntervalSeconds: DBUpdateSeconds,
204+
ProcessMissedBlocks: false,
205+
MetricsPort: 9090,
206+
SourceBlockchains: sources,
207+
DestinationBlockchains: destinations,
208+
APIPort: 8080,
209+
DeciderURL: "localhost:50051",
210+
SignatureCacheSize: (1024 * 1024),
211+
AllowPrivateIPs: true,
212+
InitialConnectionTimeoutSeconds: 300,
212213
}
213214
}
214215

0 commit comments

Comments
 (0)