Skip to content

Commit

Permalink
feat(protocol): allow disabling block reuse (#15916)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Feb 19, 2024
1 parent ea1bc7e commit 0f314c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ library TaikoData {
uint24 blobExpiry;
// True if EIP-4844 is enabled for DA
bool blobAllowedForDA;
// True if blob can be reused
bool blobReuseEnabled;
// ---------------------------------------------------------------------
// Group 3: Proof related configs
// ---------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/contracts/L1/TaikoErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ abstract contract TaikoErrors {
error L1_BLOB_NOT_FOUND();
error L1_BLOB_NOT_REUSEABLE();
error L1_BLOB_NOT_USED();
error L1_BLOB_REUSE_DISALBED();
error L1_BLOCK_MISMATCH();
error L1_CHAIN_DATA_NOT_RELAYED();
error L1_INVALID_BLOCK_ID();
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, ITierProvider, TaikoEvents, Tai
blockMaxTxListBytes: 120_000,
blobExpiry: 24 hours,
blobAllowedForDA: false,
blobReuseEnabled: false,
livenessBond: 250e18, // 250 Taiko token
// ETH deposit related.
ethDepositRingBufferSize: 1024,
Expand Down
5 changes: 4 additions & 1 deletion packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ library LibProposing {
error L1_BLOB_FOR_DA_DISABLED();
error L1_BLOB_NOT_FOUND();
error L1_BLOB_NOT_REUSEABLE();
error L1_BLOB_REUSE_DISALBED();
error L1_INVALID_HOOK();
error L1_INVALID_PARAM();
error L1_INVALID_PROVER();
Expand Down Expand Up @@ -139,6 +140,8 @@ library LibProposing {
if (!config.blobAllowedForDA) revert L1_BLOB_FOR_DA_DISABLED();

if (params.blobHash != 0) {
if (!config.blobReuseEnabled) revert L1_BLOB_REUSE_DISALBED();

// We try to reuse an old blob
if (!isBlobReusable(state, config, params.blobHash)) {
revert L1_BLOB_NOT_REUSEABLE();
Expand All @@ -156,7 +159,7 @@ library LibProposing {
// Depends on the blob data price, it may not make sense to
// cache the blob which costs 20,000 (sstore) + 631 (event)
// extra gas.
if (params.cacheBlobForReuse) {
if (config.blobReuseEnabled && params.cacheBlobForReuse) {
state.reusableBlobs[meta.blobHash] = block.timestamp;
emit BlobCached(meta.blobHash);
}
Expand Down

0 comments on commit 0f314c5

Please sign in to comment.