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

feat(protocol): pacaya fork with simplified based rollup protocol #18535

Open
wants to merge 138 commits into
base: main
Choose a base branch
from

Conversation

dantaik
Copy link
Contributor

@dantaik dantaik commented Nov 29, 2024

Summary

This PR introduces significant changes, focusing on the following improvements:

  • Simplified Taiko Rollup Protocol:
    The protocol has been streamlined by removing tier proofs and contestation mechanisms. The updated assumption is straightforward: the validity proof is trusted. Existing TaikoL1 tests have been removed, and only a limited number of new tests have been added, resulting in low overall test coverage.

    • Renamed TaikoL1 to TaikoInbox
    • Renamed TaikoL2 to TaikoAnchor
  • Support smaller more frequent L2 blocks (replacing soft blocks)
    See feat(protocol): support smaller more frequent L2 blocks (replacing soft blocks) #18743

  • Enhanced Address Lookup:
    A new interface, IResolver, has been introduced to improve how addresses are resolved within the system.

@dantaik dantaik added option.pinned Will not be marked as stale automatically option.do-not-merge labels Nov 29, 2024
@dantaik dantaik marked this pull request as ready for review November 29, 2024 13:54
@dantaik dantaik requested a review from smtmfft November 29, 2024 13:55
Copy link

openzeppelin-code bot commented Nov 29, 2024

feat(protocol): pacaya fork with simplified based rollup protocol

Generated at commit: e662952236ce72861219808a2b97605553b8a3f3

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
3
0
10
40
56
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@xiaodino xiaodino self-requested a review November 30, 2024 04:41
@dantaik dantaik requested a review from AnshuJalan January 13, 2025 14:40
@dantaik dantaik requested a review from davidtaikocha January 14, 2025 01:32
__Taiko_init(_owner, _rollupResolver, _genesisBlockHash);
}

/// @notice Proposes multiple batches.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dantaik I don't think this allows for proposing multiple batches, does it?

/// @param blockHash The hash of the verified batch.
event BatchesVerified(uint64 batchId, bytes32 blockHash);

error AnchorBlockIdSmallerThanParent();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dantaik How about we add error selectors as comments for each error definition? It is very helpful to read and debug. If you agree, I can submit a PR later to do that.

/// @param blockHash The hash of the verified batch.
event BatchesVerified(uint64 batchId, bytes32 blockHash);

error AnchorBlockIdSmallerThanParent();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error AnchorBlockIdSmallerThanParent();
// @dev Error selectors: 0xfe1698b2
error AnchorBlockIdSmallerThanParent();

Here's what it looks like

state.stats1.genesisHeight = uint64(block.number);

state.stats2.lastProposedIn = uint56(block.number);
state.stats2.numBatches = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastVerifiedBatchId also needs to start from 1 ?

uint256 stopBatchId = (_config.maxBatchesToVerify * _length + _stats2.lastVerifiedBatchId)
.min(_stats2.numBatches);

for (++batchId; batchId < stopBatchId; ++batchId) {
Copy link
Contributor

@mask-pp mask-pp Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numBatches already += 1 before this function, so _config.maxBatchesToVerify * _length + _stats2.lastVerifiedBatchId also needs to +1 to keep aligned with numBatches.

///
/// @dev Registered in the address resolver as "taiko".
/// @custom:security-contact security@taiko.xyz
abstract contract TaikoInbox is EssentialContract, ITaikoInbox, ITaiko, IFork {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any test about the contract size after moving such much code into one contract from lib contracts?

Co-authored-by: Daniel Wang <dan@taiko.xyz>

// SSTORE #3 {{
if (stats2.numBatches == config.forkHeights.pacaya) {
batch.lastBlockId = batch.batchId + uint8(params.blocks.length) - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
batch.lastBlockId = batch.batchId + uint8(params.blocks.length) - 1;
batch.lastBlockId = batch.batchId + uint64(params.blocks.length) - 1;

Copy link
Contributor

@mask-pp mask-pp Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params.blocks length limitation is maxBlocksPerBatch(768).

if (stats2.numBatches == config.forkHeights.pacaya) {
batch.lastBlockId = batch.batchId + uint8(params.blocks.length) - 1;
} else {
batch.lastBlockId = lastBatch.lastBlockId + uint8(params.blocks.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
batch.lastBlockId = lastBatch.lastBlockId + uint8(params.blocks.length);
batch.lastBlockId = lastBatch.lastBlockId + uint64(params.blocks.length);

bytes32 _genesisBlockHash
)
external
initializer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a reinitializer?


/// @notice Initializes the contract.
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero.
/// @param _resolver The address of the {DefaultResolver} contract.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states that _resolver is the DefaultResolver contract, but I see that this initialiser either uses RollupResolver or SharedResolver, and neither of these resolvers implement DefaultResolver, they only inherit from ResolverBase

require(!stats2.paused, ContractPaused());

Config memory config = getConfig();
require(stats2.numBatches >= config.forkHeights.pacaya, InvalidForkHeight());
Copy link
Contributor

@mask-pp mask-pp Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the first call of this proposeBatch function, the inited value of numBatches(1) can't match the pacaya height, which means that the first call will never succeed.

The two variables in this judgment have nothing to do with the calling parameters of the function, which means that whether the requirements are met is certain and cannot be modified in the current call.


unchecked {
require(
stats2.numBatches < stats2.lastVerifiedBatchId + config.maxBatchProposals,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area.protocol option.do-not-merge option.pinned Will not be marked as stale automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants