Skip to content

Commit 0e3b983

Browse files
committed
Upgrade new bridge-core version and fix issues related to the changes
1 parent 6a1d831 commit 0e3b983

File tree

14 files changed

+218
-132
lines changed

14 files changed

+218
-132
lines changed

cmd/bridge/cleaner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
)
3333

3434
type cleanerStore struct {
35-
stores.ListenHandlerStore
35+
stores.BridgeStore
3636
bridgeCoreStore.MainStore
3737
}
3838

@@ -48,7 +48,7 @@ func start(cfg *bridgeCore.Config) error {
4848
if err != nil {
4949
return err
5050
}
51-
listenHandlerStore := stores.NewListenHandlerStore(db)
51+
listenHandlerStore := stores.NewBridgeStore(db)
5252
bridgeStore := bridgeCoreStore.NewMainStore(db)
5353
store := &cleanerStore{listenHandlerStore, bridgeStore}
5454
u := bridgeCoreUtils.NewUtils()

cmd/bridge/main.go

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ func prepare(ctx *cli.Context) *bridgeCore.Config {
141141
if err := json.Unmarshal(plan, &cfg); err != nil {
142142
panic(err)
143143
}
144-
cfg.Listeners[RoninNetwork].TaskInterval *= time.Second // convert to nanosecond
145-
cfg.Listeners[RoninNetwork].TransactionCheckPeriod *= time.Second
146144
}
147145

148146
checkEnv(cfg)
@@ -154,13 +152,6 @@ func prepare(ctx *cli.Context) *bridgeCore.Config {
154152
}
155153

156154
func checkEnv(cfg *bridgeCore.Config) {
157-
setRpcUrlFromEnv(cfg, os.Getenv(roninRpc), RoninNetwork)
158-
setKeyFromEnv(cfg, true, os.Getenv(roninValidatorKey), RoninNetwork)
159-
setKeyFromEnv(cfg, false, os.Getenv(roninRelayKey), RoninNetwork)
160-
setRpcUrlFromEnv(cfg, os.Getenv(ethereumRpc), EthereumNetwork)
161-
setKeyFromEnv(cfg, true, os.Getenv(ethereumValidatorKey), EthereumNetwork)
162-
setKeyFromEnv(cfg, false, os.Getenv(ethereumRelayerKey), EthereumNetwork)
163-
164155
if cfg.DB == nil {
165156
cfg.DB = &bridgeCoreStore.Database{}
166157
}
@@ -206,42 +197,55 @@ func checkEnv(cfg *bridgeCore.Config) {
206197
cfg.NumberOfWorkers, _ = strconv.Atoi(os.Getenv(numberOfWorkers))
207198
}
208199

209-
if os.Getenv(roninTaskInterval) != "" {
210-
taskInterval, _ := strconv.Atoi(os.Getenv(roninTaskInterval))
211-
if taskInterval > 0 {
212-
cfg.Listeners[RoninNetwork].TaskInterval = time.Duration(int64(taskInterval)) * time.Second
213-
log.Info("setting TaskInterval", "value", cfg.Listeners[RoninNetwork].TaskInterval)
200+
if cfg.Listeners[RoninNetwork] != nil {
201+
202+
if os.Getenv(roninTaskInterval) != "" {
203+
taskInterval, _ := strconv.Atoi(os.Getenv(roninTaskInterval))
204+
if taskInterval > 0 {
205+
cfg.Listeners[RoninNetwork].TaskInterval = time.Duration(int64(taskInterval)) * time.Second
206+
log.Info("setting TaskInterval", "value", cfg.Listeners[RoninNetwork].TaskInterval)
207+
}
214208
}
215-
}
216209

217-
if os.Getenv(roninTransactionCheckPeriod) != "" {
218-
txPeriod, _ := strconv.Atoi(os.Getenv(roninTransactionCheckPeriod))
219-
if txPeriod > 0 {
220-
cfg.Listeners[RoninNetwork].TransactionCheckPeriod = time.Duration(int64(txPeriod)) * time.Second
221-
log.Info("setting transactionCheckPeriod", "value", cfg.Listeners[RoninNetwork].TransactionCheckPeriod)
210+
if os.Getenv(roninTransactionCheckPeriod) != "" {
211+
txPeriod, _ := strconv.Atoi(os.Getenv(roninTransactionCheckPeriod))
212+
if txPeriod > 0 {
213+
cfg.Listeners[RoninNetwork].TransactionCheckPeriod = time.Duration(int64(txPeriod)) * time.Second
214+
log.Info("setting transactionCheckPeriod", "value", cfg.Listeners[RoninNetwork].TransactionCheckPeriod)
215+
}
222216
}
223-
}
224217

225-
if os.Getenv(roninMaxProcessingTasks) != "" {
226-
tasks, _ := strconv.Atoi(os.Getenv(roninMaxProcessingTasks))
227-
if tasks > 0 {
228-
cfg.Listeners[RoninNetwork].MaxProcessingTasks = tasks
229-
log.Info("setting MaxProcessingTasks", "value", tasks)
218+
if os.Getenv(roninMaxProcessingTasks) != "" {
219+
tasks, _ := strconv.Atoi(os.Getenv(roninMaxProcessingTasks))
220+
if tasks > 0 {
221+
cfg.Listeners[RoninNetwork].MaxProcessingTasks = tasks
222+
log.Info("setting MaxProcessingTasks", "value", tasks)
223+
}
230224
}
231-
}
232225

233-
if os.Getenv(ethereumGetLogsBatchSize) != "" {
234-
batchSize, _ := strconv.Atoi(os.Getenv(ethereumGetLogsBatchSize))
235-
if batchSize > 0 {
236-
cfg.Listeners[EthereumNetwork].GetLogsBatchSize = batchSize
226+
if os.Getenv(roninMaxTasksQuery) != "" {
227+
limit, _ := strconv.Atoi(os.Getenv(roninMaxTasksQuery))
228+
if limit > 0 {
229+
cfg.Listeners[RoninNetwork].MaxTasksQuery = limit
230+
}
237231
}
232+
233+
setRpcUrlFromEnv(cfg, os.Getenv(roninRpc), RoninNetwork)
234+
setKeyFromEnv(cfg, true, os.Getenv(roninValidatorKey), RoninNetwork)
235+
setKeyFromEnv(cfg, false, os.Getenv(roninRelayKey), RoninNetwork)
238236
}
239237

240-
if os.Getenv(roninMaxTasksQuery) != "" {
241-
limit, _ := strconv.Atoi(os.Getenv(roninMaxTasksQuery))
242-
if limit > 0 {
243-
cfg.Listeners[RoninNetwork].MaxTasksQuery = limit
238+
if cfg.Listeners[EthereumNetwork] != nil {
239+
if os.Getenv(ethereumGetLogsBatchSize) != "" {
240+
batchSize, _ := strconv.Atoi(os.Getenv(ethereumGetLogsBatchSize))
241+
if batchSize > 0 {
242+
cfg.Listeners[EthereumNetwork].GetLogsBatchSize = batchSize
243+
}
244244
}
245+
246+
setRpcUrlFromEnv(cfg, os.Getenv(ethereumRpc), EthereumNetwork)
247+
setKeyFromEnv(cfg, true, os.Getenv(ethereumValidatorKey), EthereumNetwork)
248+
setKeyFromEnv(cfg, false, os.Getenv(ethereumRelayerKey), EthereumNetwork)
245249
}
246250

247251
// clean key

config/config.mainnet.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"to": "0x0CF8fF40a508bdBc39fBe1Bb679dCBa64E65C7Df",
2525
"type": 1,
2626
"handler": {
27-
"abi": "contracts/ronin/RoninGatewayV2.abi",
27+
"contract": "RoninGateway",
2828
"name": "MainchainWithdrew"
2929
},
3030
"callbacks": {
@@ -35,7 +35,7 @@
3535
"to": "0x0CF8fF40a508bdBc39fBe1Bb679dCBa64E65C7Df",
3636
"type": 1,
3737
"handler": {
38-
"abi": "contracts/ronin/RoninGatewayV2.abi",
38+
"contract": "RoninGateway",
3939
"name": "WithdrawalRequested"
4040
},
4141
"callbacks": {
@@ -46,7 +46,7 @@
4646
"to": "0x0CF8fF40a508bdBc39fBe1Bb679dCBa64E65C7Df",
4747
"type": 1,
4848
"handler": {
49-
"abi": "contracts/ronin/RoninGatewayV2.abi",
49+
"contract": "RoninGateway",
5050
"name": "WithdrawalSignaturesRequested"
5151
},
5252
"callbacks": {
@@ -77,7 +77,7 @@
7777
"to": "0x64192819Ac13Ef72bF6b5AE239AC672B43a9AF08",
7878
"type": 1,
7979
"handler": {
80-
"abi": "contracts/ethereum/MainchainGatewayV2.abi",
80+
"contract": "EthereumGateway",
8181
"name": "DepositRequested"
8282
},
8383
"callbacks": {
@@ -88,7 +88,7 @@
8888
"to": "0x64192819Ac13Ef72bF6b5AE239AC672B43a9AF08",
8989
"type": 1,
9090
"handler": {
91-
"abi": "contracts/ethereum/MainchainGatewayV2.abi",
91+
"contract": "EthereumGateway",
9292
"name": "Withdrew"
9393
},
9494
"callbacks": {

config/config.testnet.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"to": "0xA8D61A5427a778be28Bd9bb5990956b33385c738",
2525
"type": 1,
2626
"handler": {
27-
"abi": "contracts/ronin/RoninGatewayV2.abi",
27+
"contract": "RoninGateway",
2828
"name": "MainchainWithdrew"
2929
},
3030
"callbacks": {
@@ -35,7 +35,7 @@
3535
"to": "0xA8D61A5427a778be28Bd9bb5990956b33385c738",
3636
"type": 1,
3737
"handler": {
38-
"abi": "contracts/ronin/RoninGatewayV2.abi",
38+
"contract": "RoninGateway",
3939
"name": "WithdrawalRequested"
4040
},
4141
"callbacks": {
@@ -46,7 +46,7 @@
4646
"to": "0xA8D61A5427a778be28Bd9bb5990956b33385c738",
4747
"type": 1,
4848
"handler": {
49-
"abi": "contracts/ronin/RoninGatewayV2.abi",
49+
"contract": "RoninGateway",
5050
"name": "WithdrawalSignaturesRequested"
5151
},
5252
"callbacks": {
@@ -76,7 +76,7 @@
7676
"to": "0x4E4D9B21B157CCD52b978C3a3BCd1dc5eBAE7167",
7777
"type": 1,
7878
"handler": {
79-
"abi": "contracts/ethereum/MainchainGatewayV2.abi",
79+
"contract": "EthereumGateway",
8080
"name": "DepositRequested"
8181
},
8282
"callbacks": {
@@ -87,7 +87,7 @@
8787
"to": "0x4E4D9B21B157CCD52b978C3a3BCd1dc5eBAE7167",
8888
"type": 1,
8989
"handler": {
90-
"abi": "contracts/ethereum/MainchainGatewayV2.abi",
90+
"contract": "EthereumGateway",
9191
"name": "Withdrew"
9292
},
9393
"callbacks": {

config/eth.ropsten.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"to": "0x3b6371EB912bFd5C0E249A16000ffbC6B881555A",
3636
"type": 1,
3737
"handler": {
38-
"abi": "contracts/ethereum/MainchainGatewayV2.abi",
38+
"contract": "EthereumGateway",
3939
"name": "DepositRequested"
4040
},
4141
"callbacks": {
@@ -46,7 +46,7 @@
4646
"to": "0x3b6371EB912bFd5C0E249A16000ffbC6B881555A",
4747
"type": 1,
4848
"handler": {
49-
"abi": "contracts/ethereum/MainchainGatewayV2.abi",
49+
"contract": "EthereumGateway",
5050
"name": "Withdrew"
5151
},
5252
"callbacks": {

config/ronin.testnet.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"to": "0x03d1F13c7391F6B5A651143a31034cf728A93694",
2020
"type": 1,
2121
"handler": {
22-
"abi": "contracts/ronin/RoninGatewayV2.abi",
22+
"contract": "RoninGateway",
2323
"name": "MainchainWithdrew"
2424
},
2525
"callbacks": {
@@ -30,7 +30,7 @@
3030
"to": "0x03d1F13c7391F6B5A651143a31034cf728A93694",
3131
"type": 1,
3232
"handler": {
33-
"abi": "contracts/ronin/RoninGatewayV2.abi",
33+
"contract": "RoninGateway",
3434
"name": "WithdrawalRequested"
3535
},
3636
"callbacks": {
@@ -41,7 +41,7 @@
4141
"to": "0x03d1F13c7391F6B5A651143a31034cf728A93694",
4242
"type": 1,
4343
"handler": {
44-
"abi": "contracts/ronin/RoninGatewayV2.abi",
44+
"contract": "RoninGateway",
4545
"name": "WithdrawalSignaturesRequested"
4646
},
4747
"callbacks": {

go.mod

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@ require (
1818

1919
require (
2020
github.com/deckarep/golang-set v1.8.0 // indirect
21-
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
21+
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
2222
)
2323

2424
require (
2525
github.com/StackExchange/wmi v1.2.1 // indirect
26-
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
26+
github.com/VictoriaMetrics/fastcache v1.10.0 // indirect
2727
github.com/axieinfinity/bridge-contracts v0.0.0-20220731110242-d273b578b657 // indirect
28-
github.com/axieinfinity/bridge-core v0.0.0-20220802075849-77abb76e9167 // indirect
28+
github.com/axieinfinity/bridge-core v0.0.0-20220803111811-2dd817d8512e // indirect
2929
github.com/axieinfinity/bridge-migrations v0.0.0-20220803051308-adab1cd1bcca // indirect
3030
github.com/beorn7/perks v1.0.1 // indirect
3131
github.com/btcsuite/btcd v0.20.1-beta // indirect
3232
github.com/cespare/xxhash/v2 v2.1.2 // indirect
3333
github.com/davecgh/go-spew v1.1.1 // indirect
3434
github.com/edsrzf/mmap-go v1.0.0 // indirect
35-
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
35+
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
3636
github.com/go-gormigrate/gormigrate/v2 v2.0.2 // indirect
37-
github.com/go-ole/go-ole v1.2.5 // indirect
38-
github.com/go-stack/stack v1.8.0 // indirect
37+
github.com/go-ole/go-ole v1.2.6 // indirect
38+
github.com/go-stack/stack v1.8.1 // indirect
3939
github.com/golang/protobuf v1.5.2 // indirect
4040
github.com/golang/snappy v0.0.4 // indirect
41-
github.com/google/uuid v1.2.0 // indirect
42-
github.com/gorilla/websocket v1.4.2 // indirect
41+
github.com/google/uuid v1.3.0 // indirect
42+
github.com/gorilla/websocket v1.5.0 // indirect
4343
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
4444
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
4545
github.com/holiman/uint256 v1.2.0 // indirect
46-
github.com/huin/goupnp v1.0.2 // indirect
46+
github.com/huin/goupnp v1.0.3 // indirect
4747
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
4848
github.com/jackc/pgconn v1.12.1 // indirect
4949
github.com/jackc/pgio v1.0.0 // indirect
@@ -52,39 +52,41 @@ require (
5252
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
5353
github.com/jackc/pgtype v1.11.0 // indirect
5454
github.com/jackc/pgx/v4 v4.16.1 // indirect
55-
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 // indirect
55+
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
5656
github.com/jinzhu/inflection v1.0.0 // indirect
5757
github.com/jinzhu/now v1.1.5 // indirect
5858
github.com/json-iterator/go v1.1.12 // indirect
59-
github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559 // indirect
59+
github.com/karalabe/usb v0.0.2 // indirect
6060
github.com/kelseyhightower/envconfig v1.4.0 // indirect
61-
github.com/mattn/go-runewidth v0.0.9 // indirect
62-
github.com/mattn/go-sqlite3 v1.14.12 // indirect
61+
github.com/mattn/go-runewidth v0.0.13 // indirect
62+
github.com/mattn/go-sqlite3 v1.14.14 // indirect
6363
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
6464
github.com/mitchellh/mapstructure v1.4.1 // indirect
6565
github.com/mitchellh/pointerstructure v1.2.0 // indirect
6666
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6767
github.com/modern-go/reflect2 v1.0.2 // indirect
6868
github.com/olekukonko/tablewriter v0.0.5 // indirect
69-
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
69+
github.com/peterh/liner v1.2.2 // indirect
7070
github.com/pkg/errors v0.9.1 // indirect
7171
github.com/prometheus/client_golang v1.12.2 // indirect
7272
github.com/prometheus/client_model v0.2.0 // indirect
73-
github.com/prometheus/common v0.32.1 // indirect
73+
github.com/prometheus/common v0.37.0 // indirect
7474
github.com/prometheus/procfs v0.7.3 // indirect
75-
github.com/prometheus/tsdb v0.7.1 // indirect
76-
github.com/rjeczalik/notify v0.9.1 // indirect
75+
github.com/prometheus/tsdb v0.10.0 // indirect
76+
github.com/rivo/uniseg v0.2.0 // indirect
77+
github.com/rjeczalik/notify v0.9.2 // indirect
7778
github.com/robfig/cron/v3 v3.0.1 // indirect
78-
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
79+
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
7980
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4 // indirect
8081
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
81-
github.com/tklauser/go-sysconf v0.3.5 // indirect
82-
github.com/tklauser/numcpus v0.2.2 // indirect
83-
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef // indirect
84-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
82+
github.com/tklauser/go-sysconf v0.3.10 // indirect
83+
github.com/tklauser/numcpus v0.5.0 // indirect
84+
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
85+
github.com/yusufpapurcu/wmi v1.2.2 // indirect
86+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
8587
golang.org/x/text v0.3.7 // indirect
86-
google.golang.org/protobuf v1.27.1 // indirect
88+
google.golang.org/protobuf v1.28.1 // indirect
8789
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
88-
gorm.io/driver/postgres v1.3.7 // indirect
89-
gorm.io/driver/sqlite v1.3.2 // indirect
90+
gorm.io/driver/postgres v1.3.8 // indirect
91+
gorm.io/driver/sqlite v1.3.6 // indirect
9092
)

0 commit comments

Comments
 (0)