Skip to content

feat(protocol): 🌋 🌋 🌋 🌋 Shasta upgrade 🌋 🌋 🌋 🌋 #19298

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
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
8f62b9f
feat(protocol): introduce prover market for Proposer-Prover Separatio…
dantaik Apr 18, 2025
cf63500
Merge branch 'main' into shasta_upgrade2
dantaik Apr 18, 2025
1882356
chore(protocol): add URC (https://github.com/eth-fabric/urc main bran…
dantaik Apr 18, 2025
3daa945
chore(protocol): use txt files for logging gas and layout tables (#19…
dantaik Apr 18, 2025
297e7e6
refactor(protocol): refactor TaikoAnchor code (#19291)
dantaik Apr 19, 2025
42ed3ce
feat(protocol): introduce ShastaForkRouter with ITaikoInbox's functio…
dantaik Apr 19, 2025
5d0bdaf
revert(protocol): remove marker from batch parameter (#19309)
dantaik Apr 20, 2025
7729aad
chore(protocol): remove unused packages and add urc remapping (#19321)
AnshuJalan Apr 22, 2025
8ff0d91
feat(protocol): optimize ProverMarket gas cost (#19319)
adaki2004 Apr 22, 2025
a835d05
feat(protocol): some gas optimization for TaikoInbox (#19324)
adaki2004 Apr 23, 2025
76b223d
feat(protocol): remove average fee tracking from ProverMarket (#19325)
dantaik Apr 25, 2025
9ef757a
feat(protocol): add `getEpochTimestamp(uint epochOffset)` (#19338)
dantaik Apr 28, 2025
304311a
feat(protocol): change IProposeBatch and delete IPreconfRouter (#19337)
dantaik Apr 28, 2025
60eb411
refactor(protocol): optimize inbox tests to share configs (#19345)
dantaik Apr 28, 2025
04d7b52
refactor(protocol): make HeklaInbox inherit MainInbox (#19346)
dantaik Apr 28, 2025
3bc59c8
feat(protocol): enable 3-way base fee sharing (#19348)
dantaik Apr 28, 2025
9eb717d
feat(protocol): fix anchor tests (#19350)
adaki2004 Apr 28, 2025
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
44 changes: 44 additions & 0 deletions packages/protocol/contracts/layer1/based/IBondManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title IBondManager
/// @custom:security-contact [email protected]
interface IBondManager {
/// @notice Emitted when tokens are deposited into a user's bond balance.
/// @param user The address of the user who deposited the tokens.
/// @param amount The amount of tokens deposited.
event BondDeposited(address indexed user, uint256 amount);

/// @notice Emitted when tokens are withdrawn from a user's bond balance.
/// @param user The address of the user who withdrew the tokens.
/// @param amount The amount of tokens withdrawn.
event BondWithdrawn(address indexed user, uint256 amount);

/// @notice Emitted when a token is credited back to a user's bond balance.
/// @param user The address of the user whose bond balance is credited.
/// @param amount The amount of tokens credited.
event BondCredited(address indexed user, uint256 amount);

/// @notice Emitted when a token is debited from a user's bond balance.
/// @param user The address of the user whose bond balance is debited.
/// @param amount The amount of tokens debited.
event BondDebited(address indexed user, uint256 amount);

/// @notice Deposits TAIKO tokens into the contract to be used as liveness bond.
/// @param _amount The amount of TAIKO tokens to deposit.
function v4DepositBond(uint256 _amount) external payable;

/// @notice Withdraws a specified amount of TAIKO tokens from the contract.
/// @param _amount The amount of TAIKO tokens to withdraw.
function v4WithdrawBond(uint256 _amount) external;

/// @notice Returns the TAIKO token balance of a specific user.
/// @param _user The address of the user.
/// @return The TAIKO token balance of the user.
function v4BondBalanceOf(address _user) external view returns (uint256);

/// @notice Retrieves the Bond token address. If Ether is used as bond, this function returns
/// address(0).
/// @return The Bond token address.
function v4BondToken() external view returns (address);
}
10 changes: 6 additions & 4 deletions packages/protocol/contracts/layer1/based/IProposeBatch.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ pragma solidity ^0.8.24;
import "./ITaikoInbox.sol";

/// @title IProposeBatch
/// @notice This interface defines the proposeBatch function that is also part of the ITaikoInbox
/// @notice This interface defines the v4ProposeBatch function that is also part of the ITaikoInbox
/// interface.
/// @custom:security-contact [email protected]
interface IProposeBatch {
/// @notice Proposes a batch of blocks.
/// @param _params ABI-encoded parameters.
/// @param _txList The transaction list in calldata. If the txList is empty, blob will be used
/// for data availability.
/// @param _additionalData Additional data to be included in the batch.
/// @return info_ The info of the proposed batch.
/// @return meta_ The mmetadata of the proposed batch.
function proposeBatch(
/// @return meta_ The metadata of the proposed batch.
function v4ProposeBatch(
bytes calldata _params,
bytes calldata _txList
bytes calldata _txList,
bytes calldata _additionalData
)
external
returns (ITaikoInbox.BatchInfo memory info_, ITaikoInbox.BatchMetadata memory meta_);
Expand Down
14 changes: 14 additions & 0 deletions packages/protocol/contracts/layer1/based/IProveBatches.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title IProveBatches
/// @notice This interface defines the v4ProveBatches function.
/// @custom:security-contact [email protected]
interface IProveBatches {
/// @notice Proves state transitions for multiple batches with a single aggregated proof.
/// @param _params ABI-encoded parameter containing:
/// - metas: Array of metadata for each batch being proved.
/// - transitions: Array of batch transitions to be proved.
/// @param _proof The aggregated cryptographic proof proving the batches transitions.
function v4ProveBatches(bytes calldata _params, bytes calldata _proof) external;
}
101 changes: 38 additions & 63 deletions packages/protocol/contracts/layer1/based/ITaikoInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity ^0.8.24;

import "src/shared/based/LibSharedData.sol";
import "./IBondManager.sol";
import "./IProveBatches.sol";

/// @title TaikoInbox
/// @notice Acts as the inbox for the Taiko Alethia protocol, a simplified version of the
Expand All @@ -16,15 +18,15 @@ import "src/shared/based/LibSharedData.sol";
///
/// @dev Registered in the address resolver as "taiko".
/// @custom:security-contact [email protected]
interface ITaikoInbox {
interface ITaikoInbox is IBondManager, IProveBatches {
struct BlockParams {
// the max number of transactions in this block. Note that if there are not enough
// transactions in calldata or blobs, the block will contains as many transactions as
// transactions in calldata or blobs, the block will contain as many transactions as
// possible.
uint16 numTransactions;
// The time difference (in seconds) between the timestamp of this block and
// the timestamp of the parent block in the same batch. For the first block in a batch,
// there is not parent block in the same batch, so the time shift should be 0.
// there is no parent block in the same batch, so the time shift should be 0.
uint8 timeShift;
// Signals sent on L1 and need to sync to this L2 block.
bytes32[] signalSlots;
Expand Down Expand Up @@ -54,6 +56,7 @@ interface ITaikoInbox {
uint64 anchorBlockId;
uint64 lastBlockTimestamp;
bool revertIfNotFirstProposal;
bool optInProverMarket;
// Specifies the number of blocks to be generated from this batch.
BlobParams blobParams;
BlockParams[] blocks;
Expand All @@ -68,6 +71,7 @@ interface ITaikoInbox {
bytes32[] blobHashes;
bytes32 extraData;
address coinbase;
address proposer;
uint64 proposedIn; // Used by node/client
uint64 blobCreatedIn;
uint32 blobByteOffset;
Expand All @@ -86,7 +90,7 @@ interface ITaikoInbox {
/// @dev This struct holds batch metadata essential for proving the batch.
struct BatchMetadata {
bytes32 infoHash;
address proposer;
address prover;
uint64 batchId;
uint64 proposedAt; // Used by node/client
}
Expand Down Expand Up @@ -143,10 +147,10 @@ interface ITaikoInbox {
}

struct ForkHeights {
uint64 ontake; // measured with block number.
uint64 pacaya; // measured with the batch Id, not block number.
uint64 shasta; // measured with the batch Id, not block number.
uint64 unzen; // measured with the batch Id, not block number.
uint64 ontake; // v2, measured with block number.
uint64 pacaya; // v3, measured with the batch Id, not block number.
uint64 shasta; // v4, measured with the batch Id, not block number.
uint64 unzen; // v5, measured with the batch Id, not block number.
}

/// @notice Struct holding Taiko configuration parameters. See {TaikoConfig}.
Expand Down Expand Up @@ -180,6 +184,12 @@ interface ITaikoInbox {
uint8 maxSignalsToReceive;
/// @notice The maximum number of blocks per batch.
uint16 maxBlocksPerBatch;
/// @notice Specifies the base fee sharing percentages. The addresses are predefined in the
/// node software.
/// If address(0) is specified, the base fee will be burned. This allows for distributing
/// the base fee in three ways: for instance, 40% to address-1, 10% to address-2, and the
/// remaining 50% to the coinbase.
uint8[2] baseFeeSharings;
/// @notice Historical heights of the forks.
ForkHeights forkHeights;
}
Expand All @@ -202,26 +212,6 @@ interface ITaikoInbox {
uint256[43] __gap;
}

/// @notice Emitted when tokens are deposited into a user's bond balance.
/// @param user The address of the user who deposited the tokens.
/// @param amount The amount of tokens deposited.
event BondDeposited(address indexed user, uint256 amount);

/// @notice Emitted when tokens are withdrawn from a user's bond balance.
/// @param user The address of the user who withdrew the tokens.
/// @param amount The amount of tokens withdrawn.
event BondWithdrawn(address indexed user, uint256 amount);

/// @notice Emitted when a token is credited back to a user's bond balance.
/// @param user The address of the user whose bond balance is credited.
/// @param amount The amount of tokens credited.
event BondCredited(address indexed user, uint256 amount);

/// @notice Emitted when a token is debited from a user's bond balance.
/// @param user The address of the user whose bond balance is debited.
/// @param amount The amount of tokens debited.
event BondDebited(address indexed user, uint256 amount);

/// @notice Emitted when a batch is synced.
/// @param stats1 The Stats1 data structure.
event Stats1Updated(Stats1 stats1);
Expand Down Expand Up @@ -264,6 +254,7 @@ interface ITaikoInbox {
error BlockNotFound();
error BlobNotSpecified();
error ContractPaused();
error CurrentProverCannotWithdraw();
error CustomProposerMissing();
error CustomProposerNotAllowed();
error EtherNotPaidAsBond();
Expand All @@ -280,6 +271,7 @@ interface ITaikoInbox {
error MetaHashMismatch();
error MsgValueNotZero();
error NoBlocksToProve();
error NoProverAvailable();
error NotFirstProposal();
error NotInboxWrapper();
error ParentMetaHashMismatch();
Expand All @@ -298,59 +290,42 @@ interface ITaikoInbox {
/// @param _params ABI-encoded parameters.
/// @param _txList The transaction list in calldata. If the txList is empty, blob will be used
/// for data availability.
/// @param _additionalData Additional data to be included in the batch.
/// @return info_ The info of the proposed batch.
/// @return meta_ The metadata of the proposed batch.
function proposeBatch(
function v4ProposeBatch(
bytes calldata _params,
bytes calldata _txList
bytes calldata _txList,
bytes calldata _additionalData
)
external
returns (ITaikoInbox.BatchInfo memory info_, ITaikoInbox.BatchMetadata memory meta_);

/// @notice Proves state transitions for multiple batches with a single aggregated proof.
/// @param _params ABI-encoded parameter containing:
/// - metas: Array of metadata for each batch being proved.
/// - transitions: Array of batch transitions to be proved.
/// @param _proof The aggregated cryptographic proof proving the batches transitions.
function proveBatches(bytes calldata _params, bytes calldata _proof) external;

/// @notice Deposits TAIKO tokens into the contract to be used as liveness bond.
/// @param _amount The amount of TAIKO tokens to deposit.
function depositBond(uint256 _amount) external payable;

/// @notice Withdraws a specified amount of TAIKO tokens from the contract.
/// @param _amount The amount of TAIKO tokens to withdraw.
function withdrawBond(uint256 _amount) external;

/// @notice Returns the TAIKO token balance of a specific user.
/// @param _user The address of the user.
/// @return The TAIKO token balance of the user.
function bondBalanceOf(address _user) external view returns (uint256);

/// @notice Retrieves the Bond token address. If Ether is used as bond, this function returns
/// address(0).
/// @return The Bond token address.
function bondToken() external view returns (address);
/// @notice Verify batches by providing the length of the batches to verify.
/// @dev This function is necessary to upgrade from this fork to the next one.
/// @param _length Specifis how many batches to verify. The max number of batches to verify is
/// `v4GetConfig().maxBatchesToVerify * _length`.
function v4VerifyBatches(uint64 _length) external;

/// @notice Retrieves the first set of protocol statistics.
/// @return Stats1 structure containing the statistics.
function getStats1() external view returns (Stats1 memory);
function v4GetStats1() external view returns (Stats1 memory);

/// @notice Retrieves the second set of protocol statistics.
/// @return Stats2 structure containing the statistics.
function getStats2() external view returns (Stats2 memory);
function v4GetStats2() external view returns (Stats2 memory);

/// @notice Retrieves data about a specific batch.
/// @param _batchId The ID of the batch to retrieve.
/// @return batch_ The batch data.
function getBatch(uint64 _batchId) external view returns (Batch memory batch_);
function v4GetBatch(uint64 _batchId) external view returns (Batch memory batch_);

/// @notice Retrieves a specific transition by batch ID and transition ID. This function may
/// revert if the transition is not found.
/// @param _batchId The batch ID.
/// @param _tid The transition ID.
/// @return The specified transition state.
function getTransitionById(
function v4GetTransitionById(
uint64 _batchId,
uint24 _tid
)
Expand All @@ -363,7 +338,7 @@ interface ITaikoInbox {
/// @param _batchId The batch ID.
/// @param _parentHash The parent hash.
/// @return The specified transition state.
function getTransitionByParentHash(
function v4GetTransitionByParentHash(
uint64 _batchId,
bytes32 _parentHash
)
Expand All @@ -375,7 +350,7 @@ interface ITaikoInbox {
/// @return batchId_ The batch ID of the last verified transition.
/// @return blockId_ The block ID of the last verified block.
/// @return ts_ The last verified transition.
function getLastVerifiedTransition()
function v4GetLastVerifiedTransition()
external
view
returns (uint64 batchId_, uint64 blockId_, TransitionState memory ts_);
Expand All @@ -384,20 +359,20 @@ interface ITaikoInbox {
/// @return batchId_ The batch ID of the last synced transition.
/// @return blockId_ The block ID of the last synced block.
/// @return ts_ The last synced transition.
function getLastSyncedTransition()
function v4GetLastSyncedTransition()
external
view
returns (uint64 batchId_, uint64 blockId_, TransitionState memory ts_);

/// @notice Retrieves the transition used for verifying a batch.
/// @param _batchId The batch ID.
/// @return The transition used for verifying the batch.
function getBatchVerifyingTransition(uint64 _batchId)
function v4GetBatchVerifyingTransition(uint64 _batchId)
external
view
returns (TransitionState memory);

/// @notice Retrieves the current protocol configuration.
/// @return The current configuration.
function pacayaConfig() external view returns (Config memory);
function v4GetConfig() external view returns (Config memory);
}
Loading