-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(protocol): improve mainnet gas efficiency with addresses cac…
…hed (#17791)
- Loading branch information
Showing
11 changed files
with
123 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...es/protocol/contracts/L1/TaikoL1Hekla.sol → ...protocol/contracts/hekla/HeklaTaikoL1.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "./TaikoL1.sol"; | ||
import "../L1/TaikoL1.sol"; | ||
|
||
/// @title TaikoL1Hekla | ||
/// @title HeklaTaikoL1 | ||
/// @dev Labeled in AddressResolver as "taiko" | ||
/// @custom:security-contact [email protected] | ||
contract TaikoL1Hekla is TaikoL1 { | ||
contract HeklaTaikoL1 is TaikoL1 { | ||
/// @inheritdoc ITaikoL1 | ||
function getConfig() public pure override returns (TaikoData.Config memory) { | ||
return TaikoData.Config({ | ||
|
57 changes: 0 additions & 57 deletions
57
packages/protocol/contracts/mainnet/L1RollupAddressManager.sol
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../common/LibStrings.sol"; | ||
|
||
/// @title LibAddressCache | ||
/// @custom:security-contact [email protected] | ||
library LibAddressCache { | ||
function getAddress( | ||
uint64 _chainId, | ||
bytes32 _name | ||
) | ||
internal | ||
pure | ||
returns (bool found, address addr) | ||
{ | ||
if (_chainId == 1) { | ||
if (_name == LibStrings.B_TAIKO_TOKEN) { | ||
return (true, 0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800); | ||
} | ||
if (_name == LibStrings.B_SIGNAL_SERVICE) { | ||
return (true, 0x9e0a24964e5397B566c1ed39258e21aB5E35C77C); | ||
} | ||
if (_name == LibStrings.B_BRIDGE) { | ||
return (true, 0xd60247c6848B7Ca29eDdF63AA924E53dB6Ddd8EC); | ||
} | ||
if (_name == LibStrings.B_TAIKO) { | ||
return (true, 0x06a9Ab27c7e2255df1815E6CC0168d7755Feb19a); | ||
} | ||
if (_name == LibStrings.B_TIER_ROUTER) { | ||
return (true, 0x6E997f1F22C40ba37F633B08f3b07E10Ed43155a); | ||
} | ||
if (_name == LibStrings.B_TIER_SGX) { | ||
return (true, 0xb0f3186FC1963f774f52ff455DC86aEdD0b31F81); | ||
} | ||
if (_name == LibStrings.B_TIER_GUARDIAN_MINORITY) { | ||
return (true, 0x579A8d63a2Db646284CBFE31FE5082c9989E985c); | ||
} | ||
if (_name == LibStrings.B_TIER_GUARDIAN) { | ||
return (true, 0xE3D777143Ea25A6E031d1e921F396750885f43aC); | ||
} | ||
if (_name == LibStrings.B_AUTOMATA_DCAP_ATTESTATION) { | ||
return (true, 0x8d7C954960a36a7596d7eA4945dDf891967ca8A3); | ||
} | ||
} | ||
return (false, address(0)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../team/proving/ProverSet.sol"; | ||
import "./LibAddressCache.sol"; | ||
|
||
/// @title MainnetProverSet | ||
/// @notice See the documentation in {ProverSet}. | ||
/// @custom:security-contact [email protected] | ||
contract MainnetProverSet is ProverSet { | ||
function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { | ||
(bool found, address addr) = LibAddressCache.getAddress(_chainId, _name); | ||
return found ? addr : super._getAddress(_chainId, _name); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/protocol/contracts/mainnet/MainnetRollupAddressManager.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../common/AddressManager.sol"; | ||
import "../common/LibStrings.sol"; | ||
import "./LibAddressCache.sol"; | ||
|
||
/// @title MainnetRollupAddressManager | ||
/// @notice See the documentation in {IAddressManager}. | ||
/// @custom:security-contact [email protected] | ||
contract MainnetRollupAddressManager is AddressManager { | ||
function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { | ||
(bool found, address addr) = LibAddressCache.getAddress(_chainId, _name); | ||
return found ? addr : super._getAddress(_chainId, _name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,31 +4,17 @@ pragma solidity 0.8.24; | |
import "../common/AddressManager.sol"; | ||
import "../common/LibStrings.sol"; | ||
|
||
/// @title L1SharedAddressManager | ||
/// @title MainnetSharedAddressManager | ||
/// @notice See the documentation in {IAddressManager}. | ||
/// @dev This contract shall NOT be used to upgrade existing implementation unless the name-address | ||
/// registration becomes stable in 0xEf9EaA1dd30a9AA1df01c36411b5F082aA65fBaa. | ||
/// @custom:security-contact [email protected] | ||
contract L1SharedAddressManager is AddressManager { | ||
/// @notice Gets the address mapped to a specific chainId-name pair. | ||
/// @dev Sub-contracts can override this method to avoid reading from storage. | ||
/// Some names are not cached as they are not used frequently or | ||
/// its address is likely to change. | ||
function _getOverride( | ||
uint64 _chainId, | ||
bytes32 _name | ||
) | ||
internal | ||
pure | ||
override | ||
returns (address addr_) | ||
{ | ||
contract MainnetSharedAddressManager is AddressManager { | ||
function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { | ||
if (_chainId == 1) { | ||
if (_name == LibStrings.B_TAIKO_TOKEN) { | ||
return 0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800; | ||
} | ||
if (_name == LibStrings.B_SIGNAL_SERVICE) { | ||
return 0x9e0a24964e5397B566c1ed39258e21aB5E35C77C; | ||
if (_name == LibStrings.B_QUOTA_MANAGER) { | ||
return 0x91f67118DD47d502B1f0C354D0611997B022f29E; | ||
} | ||
if (_name == LibStrings.B_BRIDGE) { | ||
return 0xd60247c6848B7Ca29eDdF63AA924E53dB6Ddd8EC; | ||
|
@@ -42,8 +28,8 @@ contract L1SharedAddressManager is AddressManager { | |
if (_name == LibStrings.B_ERC1155_VAULT) { | ||
return 0xaf145913EA4a56BE22E120ED9C24589659881702; | ||
} | ||
if (_name == LibStrings.B_QUOTA_MANAGER) { | ||
return 0x91f67118DD47d502B1f0C354D0611997B022f29E; | ||
if (_name == LibStrings.B_SIGNAL_SERVICE) { | ||
return 0x9e0a24964e5397B566c1ed39258e21aB5E35C77C; | ||
} | ||
} else if (_chainId == 167_000) { | ||
if (_name == LibStrings.B_BRIDGE) { | ||
|
@@ -63,6 +49,6 @@ contract L1SharedAddressManager is AddressManager { | |
} | ||
} | ||
|
||
return address(0); | ||
return super._getAddress(_chainId, _name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "../L1/TaikoL1.sol"; | ||
import "./LibAddressCache.sol"; | ||
|
||
/// @title MainnetTaikoL1 | ||
/// @notice See the documentation in {TaikoL1}. | ||
/// @custom:security-contact [email protected] | ||
contract MainnetTaikoL1 is TaikoL1 { | ||
function _getAddress(uint64 _chainId, bytes32 _name) internal view override returns (address) { | ||
(bool found, address addr) = LibAddressCache.getAddress(_chainId, _name); | ||
return found ? addr : super._getAddress(_chainId, _name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters