Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(protocol): remove code not used #16909

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/protocol/contracts/L1/TaikoErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ abstract contract TaikoErrors {
error L1_NOT_ASSIGNED_PROVER();
error L1_PROVING_PAUSED();
error L1_RECEIVE_DISABLED();
error L1_TOO_LATE();
error L1_TOO_MANY_BLOCKS();
error L1_TRANSITION_ID_ZERO();
error L1_TRANSITION_NOT_FOUND();
error L1_UNAUTHORIZED();
error L1_UNEXPECTED_PARENT();
error L1_UNEXPECTED_TRANSITION_ID();
}
4 changes: 0 additions & 4 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
state.__reserve1 = 0;
}

function resetGenesisHash(bytes32 _genesisBlockHash) external onlyOwner {
LibVerifying.resetGenesisHash(state, _genesisBlockHash);
}

/// @inheritdoc ITaikoL1
function proposeBlock(
bytes calldata _params,
Expand Down
24 changes: 1 addition & 23 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ library LibProposing {
error L1_INVALID_SIG();
error L1_LIVENESS_BOND_NOT_RECEIVED();
error L1_TOO_MANY_BLOCKS();
error L1_UNAUTHORIZED();
error L1_UNEXPECTED_PARENT();

/// @dev Proposes a Taiko L2 block.
Expand Down Expand Up @@ -81,7 +80,6 @@ library LibProposing {
// ensure that only that specific address has the authority to propose
// blocks.
TaikoData.SlotB memory b = _state.slotB;
if (!_isProposerPermitted(b, _resolver)) revert L1_UNAUTHORIZED();

// It's essential to ensure that the ring buffer for proposed blocks
// still has space for at least one more block.
Expand Down Expand Up @@ -140,7 +138,7 @@ library LibProposing {
// We cannot rely on `msg.sender != tx.origin` for EOA check, as it will break after EIP
// 7645: Alias ORIGIN to SENDER
if (
_checkEOAForCalldataDA && meta_.id != 1
_checkEOAForCalldataDA
&& ECDSA.recover(meta_.blobHash, params.signature) != msg.sender
) {
revert L1_INVALID_SIG();
Expand Down Expand Up @@ -229,24 +227,4 @@ library LibProposing {
depositsProcessed: deposits_
});
}

function _isProposerPermitted(
TaikoData.SlotB memory _slotB,
IAddressResolver _resolver
)
private
view
returns (bool)
{
if (_slotB.numBlocks == 1) {
// Only proposer_one can propose the first block after genesis
address proposerOne = _resolver.resolve(LibStrings.B_PROPOSER_ONE, true);
if (proposerOne != address(0)) {
return msg.sender == proposerOne;
}
}

address proposer = _resolver.resolve(LibStrings.B_PROPOSER, true);
return proposer == address(0) || msg.sender == proposer;
}
}
64 changes: 24 additions & 40 deletions packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ library LibVerifying {
error L1_INVALID_CONFIG();
error L1_INVALID_GENESIS_HASH();
error L1_TRANSITION_ID_ZERO();
error L1_TOO_LATE();

/// @notice Initializes the Taiko protocol state.
/// @param _state The state to initialize.
Expand All @@ -55,14 +54,33 @@ library LibVerifying {
internal
{
if (!_isConfigValid(_config)) revert L1_INVALID_CONFIG();
if (_genesisBlockHash == 0) revert L1_INVALID_GENESIS_HASH();

_setupGenesisBlock(_state, _genesisBlockHash);
}
// Init state
_state.slotA.genesisHeight = uint64(block.number);
_state.slotA.genesisTimestamp = uint64(block.timestamp);
_state.slotB.numBlocks = 1;

function resetGenesisHash(TaikoData.State storage _state, bytes32 _genesisBlockHash) internal {
if (_state.slotB.numBlocks != 1) revert L1_TOO_LATE();
// Init the genesis block
TaikoData.Block storage blk = _state.blocks[0];
blk.nextTransitionId = 2;
blk.proposedAt = uint64(block.timestamp);
blk.verifiedTransitionId = 1;
blk.metaHash = bytes32(uint256(1)); // Give the genesis metahash a non-zero value.

_setupGenesisBlock(_state, _genesisBlockHash);
// Init the first state transition
TaikoData.TransitionState storage ts = _state.transitions[0][1];
ts.blockHash = _genesisBlockHash;
ts.prover = address(0);
ts.timestamp = uint64(block.timestamp);

emit BlockVerified({
blockId: 0,
prover: address(0),
blockHash: _genesisBlockHash,
stateRoot: 0,
tier: 0
});
}

/// @dev Verifies up to N blocks.
Expand Down Expand Up @@ -193,40 +211,6 @@ library LibVerifying {
emit StateVariablesUpdated({ slotB: _state.slotB });
}

function _setupGenesisBlock(
TaikoData.State storage _state,
bytes32 _genesisBlockHash
)
private
{
if (_genesisBlockHash == 0) revert L1_INVALID_GENESIS_HASH();
// Init state
_state.slotA.genesisHeight = uint64(block.number);
_state.slotA.genesisTimestamp = uint64(block.timestamp);
_state.slotB.numBlocks = 1;

// Init the genesis block
TaikoData.Block storage blk = _state.blocks[0];
blk.nextTransitionId = 2;
blk.proposedAt = uint64(block.timestamp);
blk.verifiedTransitionId = 1;
blk.metaHash = bytes32(uint256(1)); // Give the genesis metahash a non-zero value.

// Init the first state transition
TaikoData.TransitionState storage ts = _state.transitions[0][1];
ts.blockHash = _genesisBlockHash;
ts.prover = address(0);
ts.timestamp = uint64(block.timestamp);

emit BlockVerified({
blockId: 0,
prover: address(0),
blockHash: _genesisBlockHash,
stateRoot: 0,
tier: 0
});
}

function _syncChainData(
TaikoData.State storage _state,
TaikoData.Config memory _config,
Expand Down
2 changes: 0 additions & 2 deletions packages/protocol/contracts/common/LibStrings.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +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 = bytes32("proposer");
bytes32 internal constant B_PROPOSER_ONE = bytes32("proposer_one");
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 @@ -13,8 +13,6 @@ contract L1RollupAddressManager 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.
/// The following names are not cached:
/// - B_PROPOSER
/// - B_PROPOSER_ONE
/// - B_TIER_PROVIDER
function _getOverride(
uint64 _chainId,
Expand Down