-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol): use num proposals to measure forced inclusion deadline (
- Loading branch information
Showing
12 changed files
with
160 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
packages/protocol/contracts/layer1/forced-inclusion/IForcedInclusionInbox.sol
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import "src/layer1/verifiers/IVerifier.sol"; | |
import "src/layer1/based/TaikoInbox.sol"; | ||
import "./ForcedInclusionStore.sol"; | ||
|
||
/// @title ForcedInclusionInbox | ||
/// @title TaikoWrapper | ||
/// @dev This contract is part of a delayed inbox implementation to enforce the inclusion of | ||
/// transactions. | ||
/// The current design is a simplified and can be improved with the following ideas: | ||
|
@@ -38,12 +38,18 @@ import "./ForcedInclusionStore.sol"; | |
/// consumption. | ||
/// | ||
/// @custom:security-contact [email protected] | ||
contract ForcedInclusionInbox is EssentialContract { | ||
|
||
contract TaikoWrapper is EssentialContract { | ||
using LibMath for uint256; | ||
|
||
/// @dev Event emitted when a forced inclusion is processed. | ||
event ForcedInclusionProcessed(IForcedInclusionStore.ForcedInclusion); | ||
/// @dev Error thrown when the oldest forced inclusion is due. | ||
|
||
error OldestForcedInclusionDue(); | ||
|
||
uint16 public constant MAX_FORCED_TXS_PER_FORCED_INCLUSION = 512; | ||
|
||
uint256[50] private __gap; | ||
|
||
constructor(address _resolver) EssentialContract(_resolver) { } | ||
|
@@ -52,12 +58,14 @@ contract ForcedInclusionInbox is EssentialContract { | |
__Essential_init(_owner); | ||
} | ||
|
||
/// @notice Proposes a batch of blocks. | ||
/// @notice Proposes a batch of blocks with forced inclusion. | ||
/// @param _forcedInclusionParams An optional ABI-encoded BlockParams for the forced inclusion | ||
/// batch. | ||
/// @param _params ABI-encoded BlockParams. | ||
/// @param _txList The transaction list in calldata. If the txList is empty, blob will be used | ||
/// for data availability. | ||
/// @return info_ The info of the proposed batch. | ||
/// @return meta_ The metadata of the proposed batch. | ||
function proposeBatchWithForcedInclusion( | ||
bytes calldata _forcedInclusionParams, | ||
bytes calldata _params, | ||
|
@@ -68,21 +76,18 @@ contract ForcedInclusionInbox is EssentialContract { | |
returns (ITaikoInbox.BatchInfo memory info_, ITaikoInbox.BatchMetadata memory meta_) | ||
{ | ||
ITaikoInbox inbox = ITaikoInbox(resolve(LibStrings.B_TAIKO, false)); | ||
(info_, meta_) = inbox.proposeBatch(_params, _txList); | ||
|
||
// Process the next forced inclusion. | ||
IForcedInclusionStore store = | ||
IForcedInclusionStore(resolve(LibStrings.B_FORCED_INCLUSION_STORE, false)); | ||
|
||
IForcedInclusionStore.ForcedInclusion memory inclusion = | ||
store.consumeForcedInclusion(msg.sender); | ||
if (_forcedInclusionParams.length == 0) { | ||
require(!store.isOldestForcedInclusionDue(), OldestForcedInclusionDue()); | ||
} else { | ||
IForcedInclusionStore.ForcedInclusion memory inclusion = | ||
store.consumeOldestForcedInclusion(msg.sender); | ||
|
||
if (inclusion.createdAt != 0) { | ||
ITaikoInbox.BatchParams memory params; | ||
|
||
if (_forcedInclusionParams.length != 0) { | ||
params = abi.decode(_forcedInclusionParams, (ITaikoInbox.BatchParams)); | ||
} | ||
ITaikoInbox.BatchParams memory params = | ||
abi.decode(_forcedInclusionParams, (ITaikoInbox.BatchParams)); | ||
|
||
// Overwrite the batch params to have only 1 block and up to | ||
// MAX_FORCED_TXS_PER_FORCED_INCLUSION transactions | ||
|
@@ -102,5 +107,7 @@ contract ForcedInclusionInbox is EssentialContract { | |
inbox.proposeBatch(abi.encode(params), ""); | ||
emit ForcedInclusionProcessed(inclusion); | ||
} | ||
|
||
(info_, meta_) = inbox.proposeBatch(_params, _txList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.