Skip to content

Commit

Permalink
Merge pull request #78 from NethermindEth/anshu/task-manager-use-taik…
Browse files Browse the repository at this point in the history
…o-data

Use block id and metadata from Taiko
  • Loading branch information
AnshuJalan authored Aug 22, 2024
2 parents 082a45b + f6ec2ea commit bb7aa64
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 90 deletions.
10 changes: 10 additions & 0 deletions SmartContracts/src/avs/PreconfConstants.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

library PreconfConstants {
uint256 internal constant SECONDS_IN_SLOT = 12;
uint256 internal constant SECONDS_IN_EPOCH = 384; // 32 slots * 12 seconds
uint256 internal constant TWO_EPOCHS = 768;
uint256 internal constant BEACON_GENESIS_TIMESTAMP = 1606824023; // Dec-01-2020 12:00:23 PM +UTC
uint256 internal constant DISPUTE_PERIOD = 2 * SECONDS_IN_EPOCH;
}
2 changes: 1 addition & 1 deletion SmartContracts/src/avs/PreconfRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;

import {PreconfConstants} from "./libraries/PreconfConstants.sol";
import {BLS12381} from "../libraries/BLS12381.sol";
import {PreconfConstants} from "./PreconfConstants.sol";
import {BLSSignatureChecker} from "./utils/BLSSignatureChecker.sol";
import {IPreconfRegistry} from "../interfaces/IPreconfRegistry.sol";
import {IServiceManager} from "eigenlayer-middleware/interfaces/IServiceManager.sol";
Expand Down
4 changes: 2 additions & 2 deletions SmartContracts/src/avs/PreconfServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract PreconfServiceManager is ServiceManagerBase, IPreconfServiceManager {

modifier onlyPreconfTaskManager() {
if (msg.sender != address(preconfTaskManager)) {
revert IPreconfServiceManager.SenderIsNotPreconfTaskManager(msg.sender);
revert SenderIsNotPreconfTaskManager(msg.sender);
}
_;
}
Expand All @@ -44,7 +44,7 @@ contract PreconfServiceManager is ServiceManagerBase, IPreconfServiceManager {

function slashOperator(address operator) external onlyPreconfTaskManager {
if (slasher.isOperatorSlashed(operator)) {
revert IPreconfServiceManager.OperatorAlreadySlashed(operator);
revert OperatorAlreadySlashed(operator);
}
slasher.slashOperator(operator);
}
Expand Down
186 changes: 115 additions & 71 deletions SmartContracts/src/avs/PreconfTaskManager.sol

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions SmartContracts/src/avs/libraries/PreconfConstants.sol

This file was deleted.

27 changes: 17 additions & 10 deletions SmartContracts/src/interfaces/IPreconfTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
pragma solidity 0.8.25;

import {EIP4788} from "../libraries/EIP4788.sol";
import {ITaikoL1} from "./taiko/ITaikoL1.sol";

interface IPreconfTaskManager {
struct ProposedBlock {
// Proposer of the L2 block
address proposer;
// L1 block timestamp
uint96 timestamp;
// Keccak hash of the RLP transaction list of the block
bytes32 txListHash;
}

struct PreconfirmationHeader {
// The block height for which the preconfirmation is provided
uint256 blockId;
Expand Down Expand Up @@ -59,6 +51,8 @@ interface IPreconfTaskManager {
error MissedDisputeWindow();
/// @dev The disputed preconfirmation is correct
error PreconfirmationIsCorrect();
/// @dev The sent block metadata does not match the one retrieved from Taiko
error MetadataMismatch();
/// @dev The expected validator has been slashed on CL
error ExpectedValidatorMustNotBeSlashed();
/// @dev The lookahead poster for the epoch has already been slashed
Expand All @@ -75,7 +69,11 @@ interface IPreconfTaskManager {
) external payable;

/// @dev Slashes a preconfer if the txn and ordering in a signed preconf does not match the actual block
function proveIncorrectPreconfirmation(PreconfirmationHeader memory header, bytes memory signature) external;
function proveIncorrectPreconfirmation(
ITaikoL1.BlockMetadata calldata taikoBlockMetadata,
PreconfirmationHeader calldata header,
bytes calldata signature
) external;

/// @dev Slashes a preconfer if the validator lookahead pushed by them has an incorrect entry
function proveIncorrectLookahead(
Expand All @@ -85,6 +83,15 @@ interface IPreconfTaskManager {
EIP4788.InclusionProof memory validatorInclusionProof
) external;

/// @dev Returns the entire lookahead buffer
function getLookahead() external view returns (LookaheadEntry[64] memory);

/// @dev Return the parameters required for the lookahead to be set for the given epoch
function getLookaheadParamsForEpoch(uint256 epochTimestamp, bytes[32] memory validatorBLSPubKeys)
external
view
returns (LookaheadSetParam[] memory);

/// @dev Returns true is a lookahead is not posted for an epoch
/// @dev In the event that a lookahead was posted but later invalidated, this returns false
function isLookaheadRequired(uint256 epochTimestamp) external view returns (bool);
Expand Down
33 changes: 33 additions & 0 deletions SmartContracts/src/interfaces/taiko/ITaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,41 @@ interface ITaikoL1 {
uint64 id;
}

struct SlotA {
uint64 genesisHeight;
uint64 genesisTimestamp;
uint64 lastSyncedBlockId;
uint64 lastSynecdAt; // typo!
}

struct SlotB {
uint64 numBlocks;
uint64 lastVerifiedBlockId;
bool provingPaused;
uint8 __reservedB1;
uint16 __reservedB2;
uint32 __reservedB3;
uint64 lastUnpausedAt;
}

struct BlockV2 {
bytes32 metaHash;
address assignedProver;
uint96 livenessBond;
uint64 blockId;
uint64 proposedAt;
uint64 proposedIn;
uint24 nextTransitionId;
bool livenessBondReturned;
uint24 verifiedTransitionId;
}

function proposeBlock(bytes calldata _params, bytes calldata _txList)
external
payable
returns (BlockMetadata memory meta_, EthDeposit[] memory deposits_);

function getStateVariables() external view returns (SlotA memory, SlotB memory);

function getBlockV2(uint64 _blockId) external view returns (BlockV2 memory blk_);
}

0 comments on commit bb7aa64

Please sign in to comment.