Skip to content

Commit 9dac2ed

Browse files
sameh-faroukclaude
andauthored
Support multiple substrate URLs (#1028)
* support multiple substrate URLs * fix: rename url to urls for multiple substrate URL support Rename TfchainURL to TfchainURLs, Tfchain_url to Tfchain_urls, and url parameter to urls throughout the bridge code and docs to reflect that the field is now a string slice, not a single string. Addresses review feedback on #1028. * fix(bridge): update tfchainurl missing-param check for []string Merging development surfaced a semantic conflict: development added a required-params validation block referencing bridgeCfg.TfchainURL after this branch renamed the field to TfchainURLs ([]string). Update the check to len(bridgeCfg.TfchainURLs) == 0 so the bridge still builds and the "tfchainurl" param is reported missing when no URL is supplied. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dcedd1f commit 9dac2ed

6 files changed

Lines changed: 33 additions & 33 deletions

File tree

bridge/docs/observability.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ the source field set contains all fields which are included in the source object
137137
| Instance_public_key | string | yes | Instance public key which you can use to filter logs by instance |
138138
| Bridge_wallet_address | string | yes | The bridge account address which you can use to filter logs by bridge |
139139
| Stellar_network | string | yes | Stellar network name which you can use to filter logs by environment |
140-
| Tfchain_url | string | yes | The url of the substrate rpc node which you can use to filter logs by environment |
140+
| Tfchain_urls | []string | yes | The urls of the substrate rpc nodes which you can use to filter logs by environment |
141141

142142
#### Event-specific fields:
143143

@@ -1014,7 +1014,7 @@ the filtered result would be similar to the one below:
10141014
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10151015
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10161016
"Stellar_network": "testnet",
1017-
"Tfchain_url": "ws://localhost:9944"
1017+
"Tfchain_urls": ["ws://localhost:9944"]
10181018
},
10191019
"trace_id": "16d8b06b59aaa5514c645260263e5477bb8aad211502c56cb8849ed5b423d354",
10201020
"event_action": "payment_received",
@@ -1036,7 +1036,7 @@ the filtered result would be similar to the one below:
10361036
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10371037
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10381038
"Stellar_network": "testnet",
1039-
"Tfchain_url": "ws://localhost:9944"
1039+
"Tfchain_urls": ["ws://localhost:9944"]
10401040
},
10411041
"trace_id": "16d8b06b59aaa5514c645260263e5477bb8aad211502c56cb8849ed5b423d354",
10421042
"event_action": "transfer_initiated",
@@ -1055,7 +1055,7 @@ the filtered result would be similar to the one below:
10551055
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10561056
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10571057
"Stellar_network": "testnet",
1058-
"Tfchain_url": "ws://localhost:9944"
1058+
"Tfchain_urls": ["ws://localhost:9944"]
10591059
},
10601060
"trace_id": "16d8b06b59aaa5514c645260263e5477bb8aad211502c56cb8849ed5b423d354",
10611061
"event_action": "mint_proposed",
@@ -1076,7 +1076,7 @@ the filtered result would be similar to the one below:
10761076
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10771077
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10781078
"Stellar_network": "testnet",
1079-
"Tfchain_url": "ws://localhost:9944"
1079+
"Tfchain_urls": ["ws://localhost:9944"]
10801080
},
10811081
"trace_id": "16d8b06b59aaa5514c645260263e5477bb8aad211502c56cb8849ed5b423d354",
10821082
"event_action": "mint_completed",
@@ -1092,7 +1092,7 @@ the filtered result would be similar to the one below:
10921092
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10931093
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
10941094
"Stellar_network": "testnet",
1095-
"Tfchain_url": "ws://localhost:9944"
1095+
"Tfchain_urls": ["ws://localhost:9944"]
10961096
},
10971097
"trace_id": "16d8b06b59aaa5514c645260263e5477bb8aad211502c56cb8849ed5b423d354",
10981098
"event_action": "transfer_completed",
@@ -1131,7 +1131,7 @@ This time, the transfer was not completed on the other network and was instead r
11311131
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11321132
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11331133
"Stellar_network": "testnet",
1134-
"Tfchain_url": "ws://localhost:9944"
1134+
"Tfchain_urls": ["ws://localhost:9944"]
11351135
},
11361136
"trace_id": "10",
11371137
"event_action": "event_burn_tx_created_received",
@@ -1147,7 +1147,7 @@ This time, the transfer was not completed on the other network and was instead r
11471147
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11481148
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11491149
"Stellar_network": "testnet",
1150-
"Tfchain_url": "ws://localhost:9944"
1150+
"Tfchain_urls": ["ws://localhost:9944"]
11511151
},
11521152
"trace_id": "10",
11531153
"event_action": "transfer_initiated",
@@ -1166,7 +1166,7 @@ This time, the transfer was not completed on the other network and was instead r
11661166
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11671167
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11681168
"Stellar_network": "testnet",
1169-
"Tfchain_url": "ws://localhost:9944"
1169+
"Tfchain_urls": ["ws://localhost:9944"]
11701170
},
11711171
"trace_id": "10",
11721172
"event_action": "mint_proposed",
@@ -1187,7 +1187,7 @@ This time, the transfer was not completed on the other network and was instead r
11871187
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11881188
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
11891189
"Stellar_network": "testnet",
1190-
"Tfchain_url": "ws://localhost:9944"
1190+
"Tfchain_urls": ["ws://localhost:9944"]
11911191
},
11921192
"trace_id": "10",
11931193
"event_action": "mint_completed",
@@ -1203,7 +1203,7 @@ This time, the transfer was not completed on the other network and was instead r
12031203
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12041204
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12051205
"Stellar_network": "testnet",
1206-
"Tfchain_url": "ws://localhost:9944"
1206+
"Tfchain_urls": ["ws://localhost:9944"]
12071207
},
12081208
"trace_id": "10",
12091209
"event_action": "transfer_completed",
@@ -1239,7 +1239,7 @@ For a more simplified view, you can filter events by the transfer category to di
12391239
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12401240
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12411241
"Stellar_network": "testnet",
1242-
"Tfchain_url": "ws://localhost:9944"
1242+
"Tfchain_urls": ["ws://localhost:9944"]
12431243
},
12441244
"trace_id": "13",
12451245
"event_action": "event_burn_tx_created_received",
@@ -1255,7 +1255,7 @@ For a more simplified view, you can filter events by the transfer category to di
12551255
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12561256
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12571257
"Stellar_network": "testnet",
1258-
"Tfchain_url": "ws://localhost:9944"
1258+
"Tfchain_urls": ["ws://localhost:9944"]
12591259
},
12601260
"trace_id": "13",
12611261
"event_action": "transfer_initiated",
@@ -1274,7 +1274,7 @@ For a more simplified view, you can filter events by the transfer category to di
12741274
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12751275
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12761276
"Stellar_network": "testnet",
1277-
"Tfchain_url": "ws://localhost:9944"
1277+
"Tfchain_urls": ["ws://localhost:9944"]
12781278
},
12791279
"trace_id": "13",
12801280
"event_action": "withdraw_proposed",
@@ -1295,7 +1295,7 @@ For a more simplified view, you can filter events by the transfer category to di
12951295
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12961296
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
12971297
"Stellar_network": "testnet",
1298-
"Tfchain_url": "ws://localhost:9944"
1298+
"Tfchain_urls": ["ws://localhost:9944"]
12991299
},
13001300
"trace_id": "13",
13011301
"event_action": "event_burn_tx_ready_received",
@@ -1311,7 +1311,7 @@ For a more simplified view, you can filter events by the transfer category to di
13111311
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13121312
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13131313
"Stellar_network": "testnet",
1314-
"Tfchain_url": "ws://localhost:9944"
1314+
"Tfchain_urls": ["ws://localhost:9944"]
13151315
},
13161316
"trace_id": "13",
13171317
"event_action": "stellar_transaction_submitted",
@@ -1330,7 +1330,7 @@ For a more simplified view, you can filter events by the transfer category to di
13301330
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13311331
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13321332
"Stellar_network": "testnet",
1333-
"Tfchain_url": "ws://localhost:9944"
1333+
"Tfchain_urls": ["ws://localhost:9944"]
13341334
},
13351335
"trace_id": "13",
13361336
"event_action": "withdraw_completed",
@@ -1346,7 +1346,7 @@ For a more simplified view, you can filter events by the transfer category to di
13461346
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13471347
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13481348
"Stellar_network": "testnet",
1349-
"Tfchain_url": "ws://localhost:9944"
1349+
"Tfchain_urls": ["ws://localhost:9944"]
13501350
},
13511351
"trace_id": "13",
13521352
"event_action": "transfer_completed",
@@ -1380,7 +1380,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
13801380
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13811381
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
13821382
"Stellar_network": "testnet",
1383-
"Tfchain_url": "ws://localhost:9944"
1383+
"Tfchain_urls": ["ws://localhost:9944"]
13841384
},
13851385
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
13861386
"event_action": "payment_received",
@@ -1402,7 +1402,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
14021402
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14031403
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14041404
"Stellar_network": "testnet",
1405-
"Tfchain_url": "ws://localhost:9944"
1405+
"Tfchain_urls": ["ws://localhost:9944"]
14061406
},
14071407
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
14081408
"event_action": "transfer_initiated",
@@ -1421,7 +1421,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
14211421
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14221422
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14231423
"Stellar_network": "testnet",
1424-
"Tfchain_url": "ws://localhost:9944"
1424+
"Tfchain_urls": ["ws://localhost:9944"]
14251425
},
14261426
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
14271427
"event_action": "refund_proposed",
@@ -1440,7 +1440,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
14401440
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14411441
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14421442
"Stellar_network": "testnet",
1443-
"Tfchain_url": "ws://localhost:9944"
1443+
"Tfchain_urls": ["ws://localhost:9944"]
14441444
},
14451445
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
14461446
"event_action": "event_refund_tx_ready_received",
@@ -1456,7 +1456,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
14561456
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14571457
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14581458
"Stellar_network": "testnet",
1459-
"Tfchain_url": "ws://localhost:9944"
1459+
"Tfchain_urls": ["ws://localhost:9944"]
14601460
},
14611461
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
14621462
"event_action": "stellar_transaction_submitted",
@@ -1475,7 +1475,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
14751475
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14761476
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14771477
"Stellar_network": "testnet",
1478-
"Tfchain_url": "ws://localhost:9944"
1478+
"Tfchain_urls": ["ws://localhost:9944"]
14791479
},
14801480
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
14811481
"event_action": "refund_completed",
@@ -1491,7 +1491,7 @@ Also Upon reviewing the `refund_proposed` event, we found that the `reason` fiel
14911491
"Instance_public_key": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14921492
"Bridge_wallet_address": "GBD3PXJEQOCQ5VR2JSMFNXYBBQF5RDEZP5GMTXDYZWMNZQJHR6HFX3AJ",
14931493
"Stellar_network": "testnet",
1494-
"Tfchain_url": "ws://localhost:9944"
1494+
"Tfchain_urls": ["ws://localhost:9944"]
14951495
},
14961496
"trace_id": "7f0406ad7b8d4f0de6dade19eb3979ef93857a56c6daa4bf9f2b0bb22a21d84f",
14971497
"event_action": "transfer_completed",

bridge/tfchain_bridge/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func main() {
1818
var bridgeCfg pkg.BridgeConfig
1919

2020
var debug bool
21-
flag.StringVar(&bridgeCfg.TfchainURL, "tfchainurl", "", "Tfchain websocket url")
21+
flag.StringArrayVar(&bridgeCfg.TfchainURLs, "tfchainurl", []string{}, "Tfchain websocket urls")
2222
flag.StringVar(&bridgeCfg.TfchainSeed, "tfchainseed", "", "Tfchain secret seed")
2323
flag.StringVar(&bridgeCfg.StellarBridgeAccount, "bridgewallet", "", "stellar bridge wallet")
2424
flag.StringVar(&bridgeCfg.StellarSeed, "secret", "", "stellar secret")
@@ -39,7 +39,7 @@ func main() {
3939
}
4040

4141
missingParams := []string{}
42-
if bridgeCfg.TfchainURL == "" {
42+
if len(bridgeCfg.TfchainURLs) == 0 {
4343
missingParams = append(missingParams, "tfchainurl")
4444
}
4545
if bridgeCfg.TfchainSeed == "" {
@@ -82,7 +82,7 @@ func main() {
8282
Instance_public_key: address,
8383
Bridge_wallet_address: bridgeCfg.StellarBridgeAccount,
8484
Stellar_network: bridgeCfg.StellarNetwork,
85-
Tfchain_url: bridgeCfg.TfchainURL,
85+
Tfchain_urls: bridgeCfg.TfchainURLs,
8686
}
8787

8888
log.Logger = log.Logger.With().Interface("source", sourceLogEntry).Logger()

bridge/tfchain_bridge/pkg/bridge/bridge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Bridge struct {
2929
}
3030

3131
func NewBridge(ctx context.Context, cfg pkg.BridgeConfig) (*Bridge, string, error) {
32-
subClient, err := subpkg.NewSubstrateClient(cfg.TfchainURL, cfg.TfchainSeed)
32+
subClient, err := subpkg.NewSubstrateClient(cfg.TfchainURLs, cfg.TfchainSeed)
3333
if err != nil {
3434
return nil, "", err
3535
}

bridge/tfchain_bridge/pkg/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package pkg
33
import "errors"
44

55
type BridgeConfig struct {
6-
TfchainURL string
6+
TfchainURLs []string
77
TfchainSeed string
88
RescanBridgeAccount bool
99
PersistencyFile string

bridge/tfchain_bridge/pkg/logger/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type SourceCommonLogEntry struct {
2525
Instance_public_key string
2626
Bridge_wallet_address string
2727
Stellar_network string
28-
Tfchain_url string
28+
Tfchain_urls []string
2929
}
3030

3131
type refundReasonKey struct{}

bridge/tfchain_bridge/pkg/substrate/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ type SubstrateClient struct {
3232
}
3333

3434
// NewSubstrate creates a substrate client
35-
func NewSubstrateClient(url string, seed string) (*SubstrateClient, error) {
36-
mngr := substrate.NewManager(url)
35+
func NewSubstrateClient(urls []string, seed string) (*SubstrateClient, error) {
36+
mngr := substrate.NewManager(urls...)
3737
cl, err := mngr.Substrate()
3838
if err != nil {
3939
return nil, err

0 commit comments

Comments
 (0)