Skip to content

Commit

Permalink
replace all strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Keszey Dániel authored and Keszey Dániel committed Apr 9, 2024
1 parent aa5d36f commit 7cee93b
Show file tree
Hide file tree
Showing 28 changed files with 220 additions and 130 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
view
virtual
override
onlyFromOwnerOrNamed("chain_pauser")
onlyFromOwnerOrNamed(LibConstStrings.BYTES32_CHAIN_PAUSER)
{ }

function _checkEOAForCalldataDA() internal pure virtual returns (bool) {
Expand Down
7 changes: 6 additions & 1 deletion packages/protocol/contracts/L1/TaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";
import "../common/EssentialContract.sol";
import "../common/LibConstStrings.sol";

/// @title TaikoToken
/// @notice The TaikoToken (TKO), in the protocol is used for prover collateral
Expand Down Expand Up @@ -52,7 +53,11 @@ contract TaikoToken is EssentialContract, ERC20SnapshotUpgradeable, ERC20VotesUp
}

/// @notice Creates a new token snapshot.
function snapshot() public onlyFromOwnerOrNamed("snapshooter") returns (uint256) {
function snapshot()
public
onlyFromOwnerOrNamed(LibConstStrings.BYTES32_SNAPSHOOTER)
returns (uint256)
{
return _snapshot();
}

Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts/L1/hooks/AssignmentHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "../../common/EssentialContract.sol";
import "../../common/LibConstStrings.sol";
import "../../libs/LibAddress.sol";
import "../libs/LibConstStrings.sol";
import "../ITaikoL1.sol";
import "./IHook.sol";

Expand Down Expand Up @@ -71,7 +71,7 @@ contract AssignmentHook is EssentialContract, IHook {
)
external
payable
onlyFromNamed("taiko")
onlyFromNamed(LibConstStrings.BYTES32_TAIKO)
nonReentrant
{
// Note that
Expand Down Expand Up @@ -106,7 +106,7 @@ contract AssignmentHook is EssentialContract, IHook {
}

// Send the liveness bond to the Taiko contract
IERC20 tko = IERC20(resolve(LibConstStrings.BYTES32_STR_TKO, false));
IERC20 tko = IERC20(resolve(LibConstStrings.BYTES32_TAIKO_TOKEN, false));

// Note that we don't have to worry about
// https://github.com/crytic/slither/wiki/Detector-Documentation#arbitrary-from-in-transferfrom
Expand Down Expand Up @@ -176,7 +176,7 @@ contract AssignmentHook is EssentialContract, IHook {

return keccak256(
abi.encodePacked(
LibConstStrings.BYTES32_STR_PROVER_ASSIGNMENT,
LibConstStrings.BYTES32_PROVER_ASSIGNMENT,
ITaikoL1(_taikoL1Address).getConfig().chainId,
_taikoL1Address,
_blockProposer,
Expand Down
26 changes: 0 additions & 26 deletions packages/protocol/contracts/L1/libs/LibConstStrings.sol

This file was deleted.

11 changes: 5 additions & 6 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ pragma solidity 0.8.24;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../common/IAddressResolver.sol";
import "../../common/LibConstStrings.sol";
import "../../libs/LibAddress.sol";
import "../../libs/LibNetwork.sol";
import "../hooks/IHook.sol";
import "../tiers/ITierProvider.sol";
import "./LibConstStrings.sol";

/// @title LibProposing
/// @notice A library for handling block proposals in the Taiko protocol.
/// @custom:security-contact [email protected]
library LibProposing {
using LibAddress for address;

/// @notice Leaving this here to not forget about that this is a removed feature
// = keccak256(abi.encode(new TaikoData.EthDeposit[](0)))
bytes32 private constant _EMPTY_ETH_DEPOSIT_HASH =
0x569e75fc77c1a856f6daaf9e69d8a9566ca34aa47f9133711ce065a571af0cfd;
Expand Down Expand Up @@ -157,7 +156,7 @@ library LibProposing {

// Use the difficulty as a random number
meta_.minTier = ITierProvider(
_resolver.resolve(LibConstStrings.BYTES32_STR_TIER_PROVIDER, false)
_resolver.resolve(LibConstStrings.BYTES32_TIER_PROVIDER, false)
).getMinTier(uint256(meta_.difficulty));

// Create the block that will be stored onchain
Expand Down Expand Up @@ -186,7 +185,7 @@ library LibProposing {
}

{
IERC20 tko = IERC20(_resolver.resolve(LibConstStrings.BYTES32_STR_TKO, false));
IERC20 tko = IERC20(_resolver.resolve(LibConstStrings.BYTES32_TAIKO_TOKEN, false));
uint256 tkoBalance = tko.balanceOf(address(this));

// Run all hooks.
Expand Down Expand Up @@ -242,13 +241,13 @@ library LibProposing {
{
if (_slotB.numBlocks == 1) {
// Only proposer_one can propose the first block after genesis
address proposerOne = _resolver.resolve("proposer_one", true);
address proposerOne = _resolver.resolve(LibConstStrings.BYTES32_PROPOSER_ONE, true);
if (proposerOne != address(0)) {
return msg.sender == proposerOne;
}
}

address proposer = _resolver.resolve(LibConstStrings.BYTES32_STR_PROPOSER, true);
address proposer = _resolver.resolve(LibConstStrings.BYTES32_PROPOSER, true);
return proposer == address(0) || msg.sender == proposer;
}
}
13 changes: 6 additions & 7 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity 0.8.24;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../../common/IAddressResolver.sol";
import "../../common/LibConstStrings.sol";
import "../../verifiers/IVerifier.sol";
import "../tiers/ITierProvider.sol";
import "./LibConstStrings.sol";
import "./LibUtils.sol";

/// @title LibProving
Expand Down Expand Up @@ -154,9 +154,8 @@ library LibProving {

// Retrieve the tier configurations. If the tier is not supported, the
// subsequent action will result in a revert.
local.tier = ITierProvider(
_resolver.resolve(LibConstStrings.BYTES32_STR_TIER_PROVIDER, false)
).getTier(_proof.tier);
local.tier = ITierProvider(_resolver.resolve(LibConstStrings.BYTES32_TIER_PROVIDER, false))
.getTier(_proof.tier);

local.inProvingWindow =
!LibUtils.isPostDeadline(ts.timestamp, local.b.lastUnpausedAt, local.tier.provingWindow);
Expand Down Expand Up @@ -202,7 +201,7 @@ library LibProving {
});

IVerifier(verifier).verifyProof(ctx, _tran, _proof);
} else if (local.tier.verifierName != LibConstStrings.BYTES32_STR_TIER_OP) {
} else if (local.tier.verifierName != LibConstStrings.BYTES32_TIER_OP) {
// The verifier can be address-zero, signifying that there are no
// proof checks for the tier. In practice, this only applies to
// optimistic proofs.
Expand All @@ -211,7 +210,7 @@ library LibProving {
}

local.isTopTier = local.tier.contestBond == 0;
IERC20 tko = IERC20(_resolver.resolve(LibConstStrings.BYTES32_STR_TKO, false));
IERC20 tko = IERC20(_resolver.resolve(LibConstStrings.BYTES32_TAIKO_TOKEN, false));

local.livenessBond = blk.livenessBond;
if (local.isTopTier) {
Expand All @@ -220,7 +219,7 @@ library LibProving {
local.inProvingWindow
|| (
_proof.data.length == 32
&& bytes32(_proof.data) == LibConstStrings.HASH_STR_RETURN_LIVENESS_BOND
&& bytes32(_proof.data) == LibConstStrings.HASH_RETURN_LIVENESS_BOND
)
) {
tko.safeTransfer(local.assignedProver, local.livenessBond);
Expand Down
14 changes: 7 additions & 7 deletions packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ pragma solidity 0.8.24;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../../common/IAddressResolver.sol";
import "../../common/LibConstStrings.sol";
import "../../signal/ISignalService.sol";
import "../../signal/LibSignals.sol";
import "../tiers/ITierProvider.sol";
import "./LibConstStrings.sol";
import "./LibUtils.sol";

/// @title LibVerifying
Expand Down Expand Up @@ -120,7 +119,7 @@ library LibVerifying {
uint64 numBlocksVerified;
address tierProvider;

IERC20 tko = IERC20(_resolver.resolve(LibConstStrings.BYTES32_STR_TKO, false));
IERC20 tko = IERC20(_resolver.resolve(LibConstStrings.BYTES32_TAIKO_TOKEN, false));

// Unchecked is safe:
// - assignment is within ranges
Expand Down Expand Up @@ -152,7 +151,7 @@ library LibVerifying {
} else {
if (tierProvider == address(0)) {
tierProvider =
_resolver.resolve(LibConstStrings.BYTES32_STR_TIER_PROVIDER, false);
_resolver.resolve(LibConstStrings.BYTES32_TIER_PROVIDER, false);
}

if (
Expand Down Expand Up @@ -222,18 +221,19 @@ library LibVerifying {
)
private
{
ISignalService signalService = ISignalService(_resolver.resolve("signal_service", false));
ISignalService signalService =
ISignalService(_resolver.resolve(LibConstStrings.BYTES32_SIGNAL_SERVICE, false));

(uint64 lastSyncedBlock,) = signalService.getSyncedChainData(
_config.chainId, LibSignals.HASH_STR_STATE_ROOT, 0 /* latest block Id*/
_config.chainId, LibConstStrings.HASH_STATE_ROOT, 0 /* latest block Id*/
);

if (_lastVerifiedBlockId > lastSyncedBlock + _config.blockSyncThreshold) {
_state.slotA.lastSyncedBlockId = _lastVerifiedBlockId;
_state.slotA.lastSynecdAt = uint64(block.timestamp);

signalService.syncChainData(
_config.chainId, LibSignals.HASH_STR_STATE_ROOT, _lastVerifiedBlockId, _stateRoot
_config.chainId, LibConstStrings.HASH_STATE_ROOT, _lastVerifiedBlockId, _stateRoot
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/protocol/contracts/L1/provers/GuardianProver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.24;
import "../tiers/ITierProvider.sol";
import "../ITaikoL1.sol";
import "./Guardians.sol";
import "../../common/LibConstStrings.sol";

/// @title GuardianProver
/// @custom:security-contact [email protected]
Expand Down Expand Up @@ -57,7 +58,9 @@ contract GuardianProver is Guardians {

if (approved_) {
deleteApproval(hash);
ITaikoL1(resolve("taiko", false)).proveBlock(_meta.id, abi.encode(_meta, _tran, _proof));
ITaikoL1(resolve(LibConstStrings.BYTES32_TAIKO, false)).proveBlock(
_meta.id, abi.encode(_meta, _tran, _proof)
);
}
}
}
7 changes: 6 additions & 1 deletion packages/protocol/contracts/L2/DelegateOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.8.24;

import "../common/EssentialContract.sol";
import "../common/LibConstStrings.sol";
import "../bridge/IBridge.sol";

/// @title DelegateOwner
Expand Down Expand Up @@ -64,7 +65,11 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {
/// @inheritdoc IMessageInvocable
/// @dev Do not guard with nonReentrant as this function may re-enter the contract as _data
/// represents calls to address(this).
function onMessageInvocation(bytes calldata _data) external payable onlyFromNamed("bridge") {
function onMessageInvocation(bytes calldata _data)
external
payable
onlyFromNamed(LibConstStrings.BYTES32_BRIDGE)
{
(uint64 txId, address target, bytes memory txdata) =
abi.decode(_data, (uint64, address, bytes));

Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "../common/EssentialContract.sol";
import "../common/LibConstStrings.sol";
import "../libs/LibAddress.sol";
import "../signal/ISignalService.sol";
import "../signal/LibSignals.sol";
import "./Lib1559Math.sol";
import "./LibL2Config.sol";

Expand Down Expand Up @@ -152,8 +152,8 @@ contract TaikoL2 is EssentialContract {
if (_l1BlockId > lastSyncedBlock) {
// Store the L1's state root as a signal to the local signal service to
// allow for multi-hop bridging.
ISignalService(resolve("signal_service", false)).syncChainData(
l1ChainId, LibSignals.HASH_STR_STATE_ROOT, _l1BlockId, _l1StateRoot
ISignalService(resolve(LibConstStrings.BYTES32_SIGNAL_SERVICE, false)).syncChainData(
l1ChainId, LibConstStrings.HASH_STATE_ROOT, _l1BlockId, _l1StateRoot
);

lastSyncedBlock = _l1BlockId;
Expand All @@ -180,7 +180,7 @@ contract TaikoL2 is EssentialContract {
)
external
whenNotPaused
onlyFromOwnerOrNamed("withdrawer")
onlyFromOwnerOrNamed(LibConstStrings.BYTES32_WITHDRAWER)
nonReentrant
{
if (_to == address(0)) revert L2_INVALID_PARAM();
Expand Down
Loading

0 comments on commit 7cee93b

Please sign in to comment.