From f58d22f6d0f6bd9bc53492b8efe7de3c642cdcde Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Thu, 6 Jun 2024 14:29:28 +0800 Subject: [PATCH] feat(protocol): reduce gas cost by skipping reading storage for `delegates()` (#17487) Co-authored-by: Daniel Wang --- packages/protocol/contracts/tko/TaikoToken.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/protocol/contracts/tko/TaikoToken.sol b/packages/protocol/contracts/tko/TaikoToken.sol index ea52dcc83f1..5643acac3f1 100644 --- a/packages/protocol/contracts/tko/TaikoToken.sol +++ b/packages/protocol/contracts/tko/TaikoToken.sol @@ -11,9 +11,13 @@ import "./TaikoTokenBase.sol"; /// 0x10dea67478c5F8C5E2D90e5E9B26dBe60c54d800 (token.taiko.eth) /// @custom:security-contact security@taiko.xyz contract TaikoToken is TaikoTokenBase { + address private constant _TAIKO_L1 = 0x06a9Ab27c7e2255df1815E6CC0168d7755Feb19a; + address private constant _ERC20_VAULT = 0x996282cA11E5DEb6B5D122CC3B9A1FcAAD4415Ab; + /// @notice Initializes the contract. /// @param _owner The owner of this contract. msg.sender will be used if this value is zero. /// @param _recipient The address to receive initial token minting. + function init(address _owner, address _recipient) public initializer { __Essential_init(_owner); __ERC20_init("Taiko Token", "TKO"); @@ -22,4 +26,10 @@ contract TaikoToken is TaikoTokenBase { // Mint 1 billion tokens _mint(_recipient, 1_000_000_000 ether); } + + function delegates(address account) public view virtual override returns (address) { + // Special checks to avoid reading from storage slots + if (account == _TAIKO_L1 || account == _ERC20_VAULT) return address(0); + else return super.delegates(account); + } }