From bc5ec89b7049d924b4eea85d232e06c39a8941fd Mon Sep 17 00:00:00 2001 From: ys-0212 <65277457+qi-0826@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:32:38 +0800 Subject: [PATCH 1/4] docs: fix typos (#1038) --- bridge-history-api/abi/backend_abi.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge-history-api/abi/backend_abi.go b/bridge-history-api/abi/backend_abi.go index 940cd2df10..c4615862ff 100644 --- a/bridge-history-api/abi/backend_abi.go +++ b/bridge-history-api/abi/backend_abi.go @@ -45,7 +45,7 @@ var ( L2BatchWithdrawERC721Sig common.Hash L2BatchWithdrawERC1155Sig common.Hash - // scroll mono repo + // scroll monorepo // ScrollChainABI holds information about ScrollChain's context and available invokable methods. ScrollChainABI *abi.ABI @@ -323,7 +323,7 @@ type L1RelayedMessageEvent struct { MessageHash common.Hash } -// L2AppendMessageEvent represents a AppendMessage event raised by the L2MessageQueue contract. +// L2AppendMessageEvent represents an AppendMessage event raised by the L2MessageQueue contract. type L2AppendMessageEvent struct { Index *big.Int MessageHash common.Hash From 2e627f781a3f06f850954776f0f0a3112a166e97 Mon Sep 17 00:00:00 2001 From: Xargin Date: Mon, 11 Dec 2023 15:46:13 +0800 Subject: [PATCH 2/4] fix: add connection timeout for db conn pool (#1032) Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- bridge-history-api/utils/database.go | 2 ++ common/database/db.go | 3 +++ common/version/version.go | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bridge-history-api/utils/database.go b/bridge-history-api/utils/database.go index 916372e042..5d7383c165 100644 --- a/bridge-history-api/utils/database.go +++ b/bridge-history-api/utils/database.go @@ -74,6 +74,8 @@ func InitDB(config *config.DBConfig) (*gorm.DB, error) { return nil, pingErr } + sqlDB.SetConnMaxLifetime(time.Minute * 10) + sqlDB.SetConnMaxIdleTime(time.Minute * 5) sqlDB.SetMaxOpenConns(config.MaxOpenNum) sqlDB.SetMaxIdleConns(config.MaxIdleNum) diff --git a/common/database/db.go b/common/database/db.go index 8d5a54842a..322ba27115 100644 --- a/common/database/db.go +++ b/common/database/db.go @@ -70,6 +70,9 @@ func InitDB(config *Config) (*gorm.DB, error) { return nil, pingErr } + sqlDB.SetConnMaxLifetime(time.Minute * 10) + sqlDB.SetConnMaxIdleTime(time.Minute * 5) + sqlDB.SetMaxOpenConns(config.MaxOpenNum) sqlDB.SetMaxIdleConns(config.MaxIdleNum) diff --git a/common/version/version.go b/common/version/version.go index ca6aadc483..a97953e2db 100644 --- a/common/version/version.go +++ b/common/version/version.go @@ -5,7 +5,7 @@ import ( "runtime/debug" ) -var tag = "v4.3.42" +var tag = "v4.3.43" var commit = func() string { if info, ok := debug.ReadBuildInfo(); ok { From 566fb23b9d74c383f36772ef346c92cabff73f00 Mon Sep 17 00:00:00 2001 From: Thompson <532322451@qq.com> Date: Mon, 11 Dec 2023 15:57:15 +0800 Subject: [PATCH 3/4] refactor(common): use `strings.ToLower` for `LOG_DOCKER` env variable check to improve code readability and maintainability (#1035) Co-authored-by: luogz17 Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- common/cmd/cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cmd/cmd.go b/common/cmd/cmd.go index ba6301fe40..15750fea7b 100644 --- a/common/cmd/cmd.go +++ b/common/cmd/cmd.go @@ -15,7 +15,7 @@ var verbose bool func init() { v := os.Getenv("LOG_DOCKER") - if v == "true" || v == "TRUE" { + if strings.ToLower(v) == "true" { verbose = true } } From bf2692b7cbc45f56e96b3bd1ffa1233bca28be5d Mon Sep 17 00:00:00 2001 From: Luke Ma Date: Mon, 11 Dec 2023 16:49:29 +0800 Subject: [PATCH 4/4] refactor: add address(0) check for constructors. (#1010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Péter Garamvölgyi Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- contracts/src/L1/L1ScrollMessenger.sol | 3 +++ contracts/src/L2/L2ScrollMessenger.sol | 3 +++ contracts/src/libraries/IScrollMessenger.sol | 5 +++++ contracts/src/test/L1GatewayTestBase.t.sol | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/contracts/src/L1/L1ScrollMessenger.sol b/contracts/src/L1/L1ScrollMessenger.sol index 3f3907c17d..4941697519 100644 --- a/contracts/src/L1/L1ScrollMessenger.sol +++ b/contracts/src/L1/L1ScrollMessenger.sol @@ -95,6 +95,9 @@ contract L1ScrollMessenger is ScrollMessengerBase, IL1ScrollMessenger { address _rollup, address _messageQueue ) public initializer { + if (_counterpart == address(0) || _rollup == address(0) || _messageQueue == address(0)) { + revert ErrZeroAddress(); + } ScrollMessengerBase.__ScrollMessengerBase_init(_counterpart, _feeVault); rollup = _rollup; diff --git a/contracts/src/L2/L2ScrollMessenger.sol b/contracts/src/L2/L2ScrollMessenger.sol index fbf2788b68..76440e13d4 100644 --- a/contracts/src/L2/L2ScrollMessenger.sol +++ b/contracts/src/L2/L2ScrollMessenger.sol @@ -49,12 +49,15 @@ contract L2ScrollMessenger is ScrollMessengerBase, IL2ScrollMessenger { ***************/ constructor(address _messageQueue) { + if (_messageQueue == address(0)) revert ErrZeroAddress(); + _disableInitializers(); messageQueue = _messageQueue; } function initialize(address _counterpart) external initializer { + if (_counterpart == address(0)) revert ErrZeroAddress(); ScrollMessengerBase.__ScrollMessengerBase_init(_counterpart, address(0)); } diff --git a/contracts/src/libraries/IScrollMessenger.sol b/contracts/src/libraries/IScrollMessenger.sol index a2b149c946..353ffc7756 100644 --- a/contracts/src/libraries/IScrollMessenger.sol +++ b/contracts/src/libraries/IScrollMessenger.sol @@ -3,6 +3,11 @@ pragma solidity ^0.8.16; interface IScrollMessenger { + /*********** + * Errors * + ***********/ + error ErrZeroAddress(); + /********** * Events * **********/ diff --git a/contracts/src/test/L1GatewayTestBase.t.sol b/contracts/src/test/L1GatewayTestBase.t.sol index 2d7f2c8adc..19989560e1 100644 --- a/contracts/src/test/L1GatewayTestBase.t.sol +++ b/contracts/src/test/L1GatewayTestBase.t.sol @@ -82,7 +82,7 @@ abstract contract L1GatewayTestBase is DSTestPlus { verifier = new MockRollupVerifier(); // Deploy L2 contracts - l2Messenger = new L2ScrollMessenger(address(0)); + l2Messenger = new L2ScrollMessenger(address(1)); // Initialize L1 contracts l1Messenger.initialize(address(l2Messenger), feeVault, address(rollup), address(messageQueue));