Skip to content

Commit

Permalink
feat(protocol): allow a 4 hour grace period to defer proof submission (
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Aug 6, 2024
1 parent d524e69 commit fe687b3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
6 changes: 6 additions & 0 deletions packages/protocol/contracts/L1/ITaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ interface ITaikoL1 {
/// TaikoData.TierProof) tuple.
function proveBlock(uint64 _blockId, bytes calldata _input) external;

/// @notice Proves or contests multiple block transitions.
/// @param _blockIds The indices of the blocks to prove.
/// @param _inputArr An list of abi-encoded (TaikoData.BlockMetadata, TaikoData.Transition,
/// TaikoData.TierProof) tuples.
function proveBlocks(uint64[] calldata _blockIds, bytes[] calldata _inputArr) external;

/// @notice Verifies up to a certain number of blocks.
/// @param _maxBlocksToVerify Max number of blocks to verify.
function verifyBlocks(uint64 _maxBlocksToVerify) external;
Expand Down
38 changes: 35 additions & 3 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,28 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
emitEventForClient
{
TaikoData.Config memory config = getConfig();
LibProving.proveBlock(state, config, this, _blockId, _input);
_proveBlock(_blockId, _input, config);
}

if (LibUtils.shouldVerifyBlocks(config, _blockId, false)) {
LibVerifying.verifyBlocks(state, config, this, config.maxBlocksToVerify);
/// @inheritdoc ITaikoL1
function proveBlocks(
uint64[] calldata _blockIds,
bytes[] calldata _inputArr
)
external
whenNotPaused
whenProvingNotPaused
nonReentrant
emitEventForClient
{
if (_blockIds.length == 0 || _blockIds.length != _inputArr.length) {
revert L1_INVALID_PARAMS();
}

TaikoData.Config memory config = getConfig();

for (uint256 i; i < _blockIds.length; ++i) {
_proveBlock(_blockIds[i], _inputArr[i], config);
}
}

Expand Down Expand Up @@ -313,6 +331,20 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
}
}

function _proveBlock(
uint64 _blockId,
bytes calldata _input,
TaikoData.Config memory _config
)
internal
{
LibProving.proveBlock(state, _config, this, _blockId, _input);

if (LibUtils.shouldVerifyBlocks(_config, _blockId, false)) {
LibVerifying.verifyBlocks(state, _config, this, _config.maxBlocksToVerify);
}
}

/// @dev chain_pauser is supposed to be a cold wallet.
function _authorizePause(
address,
Expand Down
19 changes: 13 additions & 6 deletions packages/protocol/contracts/L1/tiers/TierProviderBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import "./ITierProvider.sol";
/// @title TierProviderBase
/// @custom:security-contact [email protected]
abstract contract TierProviderBase is ITierProvider {
/// @dev Grace period for block proving service.
/// @notice This constant defines the time window (in minutes) during which the block proving
/// service may be paused if gas prices are excessively high. Since block proving is
/// asynchronous, this grace period allows provers to defer submissions until gas
/// prices become more favorable, potentially reducing transaction costs.
uint16 public constant GRACE_PERIOD = 240; // 4 hours

/// @inheritdoc ITierProvider
function getTier(uint16 _tierId)
public
Expand All @@ -21,7 +28,7 @@ abstract contract TierProviderBase is ITierProvider {
validityBond: 125 ether, // TKO
contestBond: 250 ether, // TKO
cooldownWindow: 1440, //24 hours
provingWindow: 15, // 15 minutes
provingWindow: GRACE_PERIOD + 15, // 15 minutes
maxBlocksToVerifyPerProof: 0
});
}
Expand All @@ -32,7 +39,7 @@ abstract contract TierProviderBase is ITierProvider {
validityBond: 125 ether, // TKO
contestBond: 820 ether, // =250TKO * 6.5625
cooldownWindow: 1440, //24 hours
provingWindow: 60, // 1 hours
provingWindow: GRACE_PERIOD + 60, // 1 hours
maxBlocksToVerifyPerProof: 0
});
}
Expand All @@ -43,7 +50,7 @@ abstract contract TierProviderBase is ITierProvider {
validityBond: 125 ether, // TKO
contestBond: 820 ether, // =250TKO * 6.5625
cooldownWindow: 1440, //24 hours
provingWindow: 60, // 1 hours
provingWindow: GRACE_PERIOD + 60, // 1 hours
maxBlocksToVerifyPerProof: 0
});
}
Expand All @@ -54,7 +61,7 @@ abstract contract TierProviderBase is ITierProvider {
validityBond: 250 ether, // TKO
contestBond: 1640 ether, // =500TKO * 6.5625
cooldownWindow: 1440, //24 hours
provingWindow: 240, // 4 hours
provingWindow: GRACE_PERIOD + 240, // 4 hours
maxBlocksToVerifyPerProof: 0
});
}
Expand All @@ -64,7 +71,7 @@ abstract contract TierProviderBase is ITierProvider {
verifierName: LibStrings.B_TIER_GUARDIAN_MINORITY,
validityBond: 250 ether, // TKO
contestBond: 1640 ether, // =500TKO * 6.5625
cooldownWindow: 240, // 4 hours
cooldownWindow: GRACE_PERIOD + 240, // 4 hours
provingWindow: 2880, // 48 hours
maxBlocksToVerifyPerProof: 0
});
Expand All @@ -76,7 +83,7 @@ abstract contract TierProviderBase is ITierProvider {
validityBond: 0, // must be 0 for top tier
contestBond: 0, // must be 0 for top tier
cooldownWindow: 1440, // 24 hours
provingWindow: 2880, // 48 hours
provingWindow: GRACE_PERIOD + 2880, // 48 hours
maxBlocksToVerifyPerProof: 0
});
}
Expand Down

0 comments on commit fe687b3

Please sign in to comment.