Skip to content

Commit

Permalink
refactor(protocol): remove ProposerAccess for easier composability (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Aug 28, 2024
1 parent 1675cec commit 80176a1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 33 deletions.
11 changes: 3 additions & 8 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
emit StateVariablesUpdated(state.slotB);
}

modifier onlyPermittedProposer() {
LibProposing.checkProposerPermission(this);
_;
}

/// @notice Initializes the contract.
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero.
/// @param _rollupAddressManager The address of the {AddressManager} contract.
Expand Down Expand Up @@ -76,7 +71,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
)
external
payable
onlyPermittedProposer
onlyFromOptionalNamed(LibStrings.B_BLOCK_PROPOSER)
whenNotPaused
nonReentrant
emitEventForClient
Expand All @@ -97,7 +92,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
bytes calldata _txList
)
external
onlyPermittedProposer
onlyFromOptionalNamed(LibStrings.B_BLOCK_PROPOSER)
whenNotPaused
nonReentrant
emitEventForClient
Expand All @@ -112,7 +107,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
bytes[] calldata _txListArr
)
external
onlyPermittedProposer
onlyFromOptionalNamed(LibStrings.B_BLOCK_PROPOSER)
whenNotPaused
nonReentrant
emitEventForClient
Expand Down
13 changes: 0 additions & 13 deletions packages/protocol/contracts/L1/access/IProposerAccess.sol

This file was deleted.

10 changes: 0 additions & 10 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity 0.8.24;

import "../../libs/LibAddress.sol";
import "../../libs/LibNetwork.sol";
import "../access/IProposerAccess.sol";
import "./LibBonds.sol";
import "./LibData.sol";
import "./LibUtils.sol";
Expand Down Expand Up @@ -260,15 +259,6 @@ library LibProposing {
}
}

function checkProposerPermission(IAddressResolver _resolver) internal view {
address proposerAccess = _resolver.resolve(LibStrings.B_PROPOSER_ACCESS, true);
if (proposerAccess == address(0)) return;

if (!IProposerAccess(proposerAccess).isProposerEligible(msg.sender)) {
revert L1_INVALID_PROPOSER();
}
}

function _encodeBaseFeeConfig(
TaikoData.BaseFeeConfig memory _baseFeeConfig
)
Expand Down
9 changes: 9 additions & 0 deletions packages/protocol/contracts/common/AddressResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ abstract contract AddressResolver is IAddressResolver, Initializable {
_;
}

/// @dev Modifier that ensures the caller is the resolved address of a given
/// name, if the name is set.
/// @param _name The name to check against.
modifier onlyFromOptionalNamed(bytes32 _name) {
address addr = resolve(_name, true);
if (addr != address(0) && msg.sender != addr) revert RESOLVER_DENIED();
_;
}

/// @dev Modifier that ensures the caller is a resolved address to either _name1 or _name2
/// name.
/// @param _name1 The first name to check against.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/common/LibStrings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma solidity 0.8.24;
/// @custom:security-contact [email protected]
library LibStrings {
bytes32 internal constant B_AUTOMATA_DCAP_ATTESTATION = bytes32("automata_dcap_attestation");
bytes32 internal constant B_BLOCK_PROPOSER = bytes32("block_proposer");
bytes32 internal constant B_BRIDGE = bytes32("bridge");
bytes32 internal constant B_BRIDGE_WATCHDOG = bytes32("bridge_watchdog");
bytes32 internal constant B_BRIDGED_ERC1155 = bytes32("bridged_erc1155");
Expand All @@ -14,7 +15,6 @@ library LibStrings {
bytes32 internal constant B_ERC1155_VAULT = bytes32("erc1155_vault");
bytes32 internal constant B_ERC20_VAULT = bytes32("erc20_vault");
bytes32 internal constant B_ERC721_VAULT = bytes32("erc721_vault");
bytes32 internal constant B_PROPOSER_ACCESS = bytes32("proposer_access");
bytes32 internal constant B_PROVER_ASSIGNMENT = bytes32("PROVER_ASSIGNMENT");
bytes32 internal constant B_PROVER_SET = bytes32("prover_set");
bytes32 internal constant B_QUOTA_MANAGER = bytes32("quota_manager");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ library LibRollupAddressCache {
if (_name == LibStrings.B_AUTOMATA_DCAP_ATTESTATION) {
return (true, 0x8d7C954960a36a7596d7eA4945dDf891967ca8A3);
}
if (_name == LibStrings.B_PROPOSER_ACCESS) {
if (_name == LibStrings.B_BLOCK_PROPOSER) {
return (true, address(0));
}
if (_name == LibStrings.B_CHAIN_WATCHDOG) {
Expand Down

0 comments on commit 80176a1

Please sign in to comment.