From ac20a0045cb0b6c79bec69e9a1f74ae5edbe2806 Mon Sep 17 00:00:00 2001 From: colin <102356659+colinlyguo@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:16:31 +0800 Subject: [PATCH] fix(bridge-history): address validation (#1063) Co-authored-by: colinlyguo --- bridge-history-api/conf/config.json | 3 +-- bridge-history-api/internal/logic/l1_fetcher.go | 6 ++++-- bridge-history-api/internal/logic/l2_fetcher.go | 6 ++++-- common/version/version.go | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bridge-history-api/conf/config.json b/bridge-history-api/conf/config.json index 8b20106e42..3e94fbece6 100644 --- a/bridge-history-api/conf/config.json +++ b/bridge-history-api/conf/config.json @@ -34,8 +34,7 @@ "USDCGatewayAddr": "0x33B60d5Dd260d453cAC3782b0bDC01ce84672142", "LIDOGatewayAddr": "0x8aE8f22226B9d789A36AC81474e633f8bE2856c9", "DAIGatewayAddr": "0xaC78dff3A87b5b534e366A93E785a0ce8fA6Cc62", - "GatewayRouterAddr": "0x4C0926FF5252A435FD19e10ED15e5a249Ba19d79", - "MessageQueueAddr": "0x5300000000000000000000000000000000000000" + "GatewayRouterAddr": "0x4C0926FF5252A435FD19e10ED15e5a249Ba19d79" }, "db": { "dsn": "postgres://postgres:123456@localhost:5444/test?sslmode=disable", diff --git a/bridge-history-api/internal/logic/l1_fetcher.go b/bridge-history-api/internal/logic/l1_fetcher.go index 97550d219d..26410d3802 100644 --- a/bridge-history-api/internal/logic/l1_fetcher.go +++ b/bridge-history-api/internal/logic/l1_fetcher.go @@ -66,14 +66,16 @@ func NewL1FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.C } // Optional erc20 gateways. - if cfg.USDCGatewayAddr != "" { + if common.HexToAddress(cfg.USDCGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.USDCGatewayAddr)) } - if cfg.LIDOGatewayAddr != "" { + if common.HexToAddress(cfg.LIDOGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.LIDOGatewayAddr)) } + log.Info("L1 Fetcher configured with the following address list", "addresses", addressList) + f := &L1FetcherLogic{ db: db, crossMessageOrm: orm.NewCrossMessage(db), diff --git a/bridge-history-api/internal/logic/l2_fetcher.go b/bridge-history-api/internal/logic/l2_fetcher.go index 457df0448e..ad9e24acb5 100644 --- a/bridge-history-api/internal/logic/l2_fetcher.go +++ b/bridge-history-api/internal/logic/l2_fetcher.go @@ -61,14 +61,16 @@ func NewL2FetcherLogic(cfg *config.LayerConfig, db *gorm.DB, client *ethclient.C } // Optional erc20 gateways. - if cfg.USDCGatewayAddr != "" { + if common.HexToAddress(cfg.USDCGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.USDCGatewayAddr)) } - if cfg.LIDOGatewayAddr != "" { + if common.HexToAddress(cfg.LIDOGatewayAddr) != (common.Address{}) { addressList = append(addressList, common.HexToAddress(cfg.LIDOGatewayAddr)) } + log.Info("L2 Fetcher configured with the following address list", "addresses", addressList) + f := &L2FetcherLogic{ db: db, crossMessageOrm: orm.NewCrossMessage(db), diff --git a/common/version/version.go b/common/version/version.go index 0cfd443e50..c1f272df63 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.46" +var tag = "v4.3.47" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok {