Skip to content

Commit

Permalink
feat(protocol): add DevnetTaikoL1 (#17900)
Browse files Browse the repository at this point in the history
Co-authored-by: davidtaikocha <[email protected]>
Co-authored-by: Daniel Wang <[email protected]>
Co-authored-by: dantaik <[email protected]>
  • Loading branch information
4 people authored Aug 12, 2024
1 parent 579a8f3 commit d864cea
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 51 deletions.
4 changes: 3 additions & 1 deletion packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
}

/// @inheritdoc ITaikoL1
function verifyBlocks(uint64 _maxBlocksToVerify)
function verifyBlocks(
uint64 _maxBlocksToVerify
)
external
whenNotPaused
whenProvingNotPaused
Expand Down
12 changes: 9 additions & 3 deletions packages/protocol/contracts/L1/libs/LibData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ library LibData {
bytes32 internal constant EMPTY_ETH_DEPOSIT_HASH =
0x569e75fc77c1a856f6daaf9e69d8a9566ca34aa47f9133711ce065a571af0cfd;

function blockParamsV1ToV2(TaikoData.BlockParams memory _v1)
function blockParamsV1ToV2(
TaikoData.BlockParams memory _v1
)
internal
pure
returns (TaikoData.BlockParamsV2 memory)
Expand All @@ -27,7 +29,9 @@ library LibData {
});
}

function blockMetadataV2toV1(TaikoData.BlockMetadataV2 memory _v2)
function blockMetadataV2toV1(
TaikoData.BlockMetadataV2 memory _v2
)
internal
pure
returns (TaikoData.BlockMetadata memory)
Expand All @@ -50,7 +54,9 @@ library LibData {
});
}

function blockMetadataV1toV2(TaikoData.BlockMetadata memory _v1)
function blockMetadataV1toV2(
TaikoData.BlockMetadata memory _v1
)
internal
pure
returns (TaikoData.BlockMetadataV2 memory)
Expand Down
4 changes: 3 additions & 1 deletion packages/protocol/contracts/L1/tiers/TierProviderBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ abstract contract TierProviderBase is ITierProvider {
uint16 public constant GRACE_PERIOD = 240; // 4 hours

/// @inheritdoc ITierProvider
function getTier(uint16 _tierId)
function getTier(
uint16 _tierId
)
public
pure
virtual
Expand Down
7 changes: 5 additions & 2 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ contract TaikoL2 is EssentialContract {

if (block.number == 0) {
// This is the case in real L2 genesis
} else if (block.number == 1) {
}
else if (block.number == 1) {
// This is the case in tests
uint256 parentHeight = block.number - 1;
l2Hashes[parentHeight] = blockhash(parentHeight);
Expand Down Expand Up @@ -345,7 +346,9 @@ contract TaikoL2 is EssentialContract {
emit Anchored(parentHash, newGasExcess);
}

function _calcPublicInputHash(uint256 _blockId)
function _calcPublicInputHash(
uint256 _blockId
)
private
view
returns (bytes32 publicInputHashOld, bytes32 publicInputHashNew)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ contract AutomataDcapV3Attestation is IAttestation, EssentialContract {
emit TcbInfoJsonConfigured(fmspc, tcbInfoInput);
}

function configureQeIdentityJson(EnclaveIdStruct.EnclaveId calldata qeIdentityInput)
function configureQeIdentityJson(
EnclaveIdStruct.EnclaveId calldata qeIdentityInput
)
external
onlyOwner
{
Expand All @@ -146,7 +148,9 @@ contract AutomataDcapV3Attestation is IAttestation, EssentialContract {
emit LocalReportCheckToggled(checkLocalEnclaveReport);
}

function _attestationTcbIsValid(TCBInfoStruct.TCBStatus status)
function _attestationTcbIsValid(
TCBInfoStruct.TCBStatus status
)
internal
pure
virtual
Expand Down Expand Up @@ -195,7 +199,9 @@ contract AutomataDcapV3Attestation is IAttestation, EssentialContract {
return _verifyParsedQuote(parsedV3Quote);
}

function _verifyQEReportWithIdentity(V3Struct.EnclaveReport memory quoteEnclaveReport)
function _verifyQEReportWithIdentity(
V3Struct.EnclaveReport memory quoteEnclaveReport
)
private
view
returns (bool, EnclaveIdStruct.EnclaveIdStatus status)
Expand Down Expand Up @@ -268,7 +274,9 @@ contract AutomataDcapV3Attestation is IAttestation, EssentialContract {
return true;
}

function _verifyCertChain(IPEMCertChainLib.ECSha256Certificate[] memory certs)
function _verifyCertChain(
IPEMCertChainLib.ECSha256Certificate[] memory certs
)
private
view
returns (bool)
Expand Down Expand Up @@ -375,7 +383,9 @@ contract AutomataDcapV3Attestation is IAttestation, EssentialContract {
/// @dev For all valid quote verification, returns the following data:
/// (_attestationTcbIsValid())
/// @dev exitCode is defined in the {{ TCBInfoStruct.TCBStatus }} enum
function verifyParsedQuote(V3Struct.ParsedV3QuoteStruct calldata v3quote)
function verifyParsedQuote(
V3Struct.ParsedV3QuoteStruct calldata v3quote
)
external
view
override
Expand All @@ -384,7 +394,9 @@ contract AutomataDcapV3Attestation is IAttestation, EssentialContract {
return _verifyParsedQuote(v3quote);
}

function _verifyParsedQuote(V3Struct.ParsedV3QuoteStruct memory v3quote)
function _verifyParsedQuote(
V3Struct.ParsedV3QuoteStruct memory v3quote
)
internal
view
returns (bool, bytes memory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { V3Struct } from "../lib/QuoteV3Auth/V3Struct.sol";
/// @custom:security-contact [email protected]
interface IAttestation {
function verifyAttestation(bytes calldata data) external returns (bool);
function verifyParsedQuote(V3Struct.ParsedV3QuoteStruct calldata v3quote)
function verifyParsedQuote(
V3Struct.ParsedV3QuoteStruct calldata v3quote
)
external
returns (bool success, bytes memory retData);
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ contract PEMCertChainLib is IPEMCertChainLib {
success = true;
}

function _removeHeadersAndFooters(string memory pemData)
function _removeHeadersAndFooters(
string memory pemData
)
private
pure
returns (bool success, bytes memory extracted, uint256 endIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ library V3Parser {
success = true;
}

function validateParsedInput(V3Struct.ParsedV3QuoteStruct memory v3Quote)
function validateParsedInput(
V3Struct.ParsedV3QuoteStruct memory v3Quote
)
internal
pure
returns (
Expand Down Expand Up @@ -147,7 +149,9 @@ library V3Parser {
authDataV3 = v3Quote.v3AuthData;
}

function parseEnclaveReport(bytes memory rawEnclaveReport)
function parseEnclaveReport(
bytes memory rawEnclaveReport
)
internal
pure
returns (V3Struct.EnclaveReport memory enclaveReport)
Expand Down Expand Up @@ -179,7 +183,9 @@ library V3Parser {
}
}

function parseAndVerifyHeader(bytes memory rawHeader)
function parseAndVerifyHeader(
bytes memory rawHeader
)
private
pure
returns (bool success, V3Struct.Header memory header)
Expand Down Expand Up @@ -258,7 +264,9 @@ library V3Parser {
/// in bytes should be in big endian according to Intel spec.
/// @param enclaveReport enclave report
/// @return packedQEReport enclave report in bytes
function packQEReport(V3Struct.EnclaveReport memory enclaveReport)
function packQEReport(
V3Struct.EnclaveReport memory enclaveReport
)
internal
pure
returns (bytes memory packedQEReport)
Expand Down
12 changes: 9 additions & 3 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ contract Bridge is EssentialContract, IBridge {
}

/// @inheritdoc IBridge
function sendMessage(Message calldata _message)
function sendMessage(
Message calldata _message
)
external
payable
override
Expand Down Expand Up @@ -353,7 +355,9 @@ contract Bridge is EssentialContract, IBridge {
}

/// @inheritdoc IBridge
function failMessage(Message calldata _message)
function failMessage(
Message calldata _message
)
external
sameChain(_message.destChainId)
diffChain(_message.srcChainId)
Expand Down Expand Up @@ -429,7 +433,9 @@ contract Bridge is EssentialContract, IBridge {
/// @param _chainId The destination chain ID.
/// @return enabled_ True if the destination chain is enabled.
/// @return destBridge_ The bridge of the destination chain.
function isDestChainEnabled(uint64 _chainId)
function isDestChainEnabled(
uint64 _chainId
)
public
view
returns (bool enabled_, address destBridge_)
Expand Down
4 changes: 3 additions & 1 deletion packages/protocol/contracts/bridge/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ interface IBridge {
/// @param _message The message to be sent.
/// @return msgHash_ The hash of the sent message.
/// @return message_ The updated message sent.
function sendMessage(Message calldata _message)
function sendMessage(
Message calldata _message
)
external
payable
returns (bytes32 msgHash_, Message memory message_);
Expand Down
27 changes: 27 additions & 0 deletions packages/protocol/contracts/devnet/DevnetTaikoL1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "../L1/TaikoL1.sol";

/// @title DevnetTaikoL1
/// @dev Labeled in AddressResolver as "taiko"
/// @custom:security-contact [email protected]
contract DevnetTaikoL1 is TaikoL1 {
/// @inheritdoc ITaikoL1
function getConfig() public pure override returns (TaikoData.Config memory) {
return TaikoData.Config({
chainId: 167_001,
blockMaxProposals: 324_000,
blockRingBufferSize: 360_000,
maxBlocksToVerify: 16,
blockMaxGasLimit: 240_000_000,
livenessBond: 125e18, // 125 Taiko token
stateRootSyncInternal: 16,
maxAnchorHeightOffset: 64,
basefeeAdjustmentQuotient: 8,
basefeeSharingPctg: 75,
gasIssuancePerSecond: 5_000_000,
ontakeForkHeight: 2
});
}
}
12 changes: 12 additions & 0 deletions packages/protocol/contracts/devnet/DevnetTaikoL2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "../L2/TaikoL2.sol";

/// @title DevnetTaikoL2
/// @custom:security-contact [email protected]
contract DevnetTaikoL2 is TaikoL2 {
function ontakeForkHeight() public pure override returns (uint64) {
return 2;
}
}
4 changes: 3 additions & 1 deletion packages/protocol/contracts/tko/BridgedTaikoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ contract BridgedTaikoToken is TaikoTokenBase, IBridgedERC20 {
_mint(_account, _amount);
}

function burn(uint256 _amount)
function burn(
uint256 _amount
)
external
override
whenNotPaused
Expand Down
4 changes: 3 additions & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ contract BridgedERC20 is
return super._beforeTokenTransfer(_from, _to, _amount);
}

function _authorizedMintBurn(address addr)
function _authorizedMintBurn(
address addr
)
private
onlyFromOwnerOrNamed(LibStrings.B_ERC20_VAULT)
{ }
Expand Down
4 changes: 3 additions & 1 deletion packages/protocol/contracts/tokenvault/BridgedERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ contract BridgedERC721 is
}

/// @inheritdoc IBridgedERC721
function burn(uint256 _tokenId)
function burn(
uint256 _tokenId
)
external
whenNotPaused
onlyFromNamed(LibStrings.B_ERC721_VAULT)
Expand Down
16 changes: 12 additions & 4 deletions packages/protocol/contracts/tokenvault/ERC1155Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable {
/// @param _op Option for sending the ERC1155 token.
/// @return message_ The constructed message.

function sendToken(BridgeTransferOp calldata _op)
function sendToken(
BridgeTransferOp calldata _op
)
external
payable
whenNotPaused
Expand Down Expand Up @@ -184,7 +186,9 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable {
/// @dev See {BaseVault-supportsInterface}.
/// @param _interfaceId The interface identifier.
/// @return true if supports, else otherwise.
function supportsInterface(bytes4 _interfaceId)
function supportsInterface(
bytes4 _interfaceId
)
public
view
override(BaseVault, ERC1155ReceiverUpgradeable)
Expand Down Expand Up @@ -231,7 +235,9 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable {
/// @param _op BridgeTransferOp data.
/// @return msgData_ Encoded message data.
/// @return ctoken_ The canonical token.
function _handleMessage(BridgeTransferOp calldata _op)
function _handleMessage(
BridgeTransferOp calldata _op
)
private
returns (bytes memory msgData_, CanonicalNFT memory ctoken_)
{
Expand Down Expand Up @@ -269,7 +275,9 @@ contract ERC1155Vault is BaseNFTVault, ERC1155ReceiverUpgradeable {
/// @dev Retrieve or deploy a bridged ERC1155 token contract.
/// @param _ctoken CanonicalNFT data.
/// @return btoken_ Address of the bridged token contract.
function _getOrDeployBridgedToken(CanonicalNFT memory _ctoken)
function _getOrDeployBridgedToken(
CanonicalNFT memory _ctoken
)
private
returns (address btoken_)
{
Expand Down
Loading

0 comments on commit d864cea

Please sign in to comment.