-
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.
Merge branch 'main' into bridge_button
- Loading branch information
Showing
118 changed files
with
1,985 additions
and
1,596 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
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 |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
{ | ||
"files": ["*.sol", "*.ts"], | ||
"options": { | ||
"tabWidth": 4 | ||
"tabWidth": 4, | ||
"compiler": "^0.8.18" | ||
} | ||
} | ||
], | ||
|
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 |
---|---|---|
|
@@ -4,20 +4,17 @@ | |
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.9; | ||
pragma solidity ^0.8.18; | ||
|
||
import "../common/EssentialContract.sol"; | ||
import "../libs/LibZKP.sol"; | ||
import "../thirdparty/LibMerkleTrie.sol"; | ||
import {EssentialContract} from "../common/EssentialContract.sol"; | ||
import {LibZKP} from "../libs/LibZKP.sol"; | ||
import {LibMerkleTrie} from "../thirdparty/LibMerkleTrie.sol"; | ||
|
||
/// @author dantaik <[email protected]> | ||
interface IProofVerifier { | ||
function verifyZKP( | ||
string memory verifierId, | ||
bytes calldata zkproof, | ||
bytes32 blockHash, | ||
address prover, | ||
bytes32 txListHash | ||
bytes32 instance | ||
) external view returns (bool verified); | ||
|
||
function verifyMKP( | ||
|
@@ -36,17 +33,13 @@ contract ProofVerifier is IProofVerifier, EssentialContract { | |
function verifyZKP( | ||
string memory verifierId, | ||
bytes calldata zkproof, | ||
bytes32 blockHash, | ||
address prover, | ||
bytes32 txListHash | ||
bytes32 instance | ||
) external view returns (bool) { | ||
return | ||
LibZKP.verify({ | ||
plonkVerifier: resolve(verifierId, false), | ||
zkproof: zkproof, | ||
blockHash: blockHash, | ||
prover: prover, | ||
txListHash: txListHash | ||
instance: instance | ||
}); | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: MIT | ||
// _____ _ _ _ _ | ||
// |_ _|_ _(_) |_____ | | __ _| |__ ___ | ||
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.18; | ||
|
||
abstract contract TaikoCustomErrors { | ||
// The following custom errors must match the definitions in other V1 libraries. | ||
error L1_0_FEE_BASE(); | ||
error L1_ANCHOR_CALLDATA(); | ||
error L1_ANCHOR_DEST(); | ||
error L1_ANCHOR_GAS_LIMIT(); | ||
error L1_ANCHOR_RECEIPT_ADDR(); | ||
error L1_ANCHOR_RECEIPT_DATA(); | ||
error L1_ANCHOR_RECEIPT_LOGS(); | ||
error L1_ANCHOR_RECEIPT_PROOF(); | ||
error L1_ANCHOR_RECEIPT_STATUS(); | ||
error L1_ANCHOR_RECEIPT_TOPICS(); | ||
error L1_ANCHOR_SIG_R(); | ||
error L1_ANCHOR_SIG_S(); | ||
error L1_ANCHOR_TX_PROOF(); | ||
error L1_ANCHOR_TYPE(); | ||
error L1_BLOCK_NUMBER(); | ||
error L1_CANNOT_BE_FIRST_PROVER(); | ||
error L1_CIRCUIT_LENGTH(); | ||
error L1_COMMITTED(); | ||
error L1_CONFLICT_PROOF(); | ||
error L1_DUP_PROVERS(); | ||
error L1_EXTRA_DATA(); | ||
error L1_GAS_LIMIT(); | ||
error L1_HALTED(); | ||
error L1_HALT_CONDITION(); | ||
error L1_ID(); | ||
error L1_INPUT_SIZE(); | ||
error L1_METADATA_FIELD(); | ||
error L1_META_MISMATCH(); | ||
error L1_NOT_COMMITTED(); | ||
error L1_NOT_FIRST_PROVER(); | ||
error L1_PROOF_LENGTH(); | ||
error L1_PROVER(); | ||
error L1_SOLO_PROPOSER(); | ||
error L1_TOO_LATE(); | ||
error L1_TOO_MANY(); | ||
error L1_TOO_MANY_PROVERS(); | ||
error L1_TX_LIST(); | ||
error L1_ZKP(); | ||
} |
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 |
---|---|---|
|
@@ -4,9 +4,8 @@ | |
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.9; | ||
pragma solidity ^0.8.18; | ||
|
||
/// @author dantaik <[email protected]> | ||
library TaikoData { | ||
struct Config { | ||
uint256 chainId; | ||
|
@@ -38,9 +37,10 @@ library TaikoData { | |
uint64 proofTimeCap; | ||
uint64 bootstrapDiscountHalvingPeriod; | ||
uint64 initialUncleDelay; | ||
uint64 proverRewardRandomizedPercentage; | ||
bool enableTokenomics; | ||
bool enablePublicInputsCheck; | ||
bool enableProofValidation; | ||
bool enableAnchorValidation; | ||
bool enableOracleProver; | ||
} | ||
|
||
|
@@ -75,15 +75,14 @@ library TaikoData { | |
|
||
// This struct takes 9 slots. | ||
struct State { | ||
// block id => block hash (some blocks' hashes won't be persisted, | ||
// only the latest one if verified in a batch) | ||
mapping(uint256 => bytes32) l2Hashes; | ||
// block id => ProposedBlock | ||
mapping(uint256 => ProposedBlock) proposedBlocks; | ||
// block id => parent hash => fork choice | ||
mapping(uint256 => mapping(bytes32 => ForkChoice)) forkChoices; | ||
// proposer => commitSlot => hash(commitHash, commitHeight) | ||
mapping(address => mapping(uint256 => bytes32)) commits; | ||
// some blocks' hashes won't be persisted, | ||
// only the latest one if verified in a batch | ||
mapping(uint256 blockId => bytes32 blockHash) l2Hashes; | ||
mapping(uint256 blockId => ProposedBlock proposedBlock) proposedBlocks; | ||
// solhint-disable-next-line max-line-length | ||
mapping(uint256 blockId => mapping(bytes32 parentHash => ForkChoice forkChoice)) forkChoices; | ||
// solhint-disable-next-line max-line-length | ||
mapping(address proposerAddress => mapping(uint256 commitSlot => bytes32 commitHash)) commits; | ||
// Never or rarely changed | ||
uint64 genesisHeight; | ||
uint64 genesisTimestamp; | ||
|
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 |
---|---|---|
|
@@ -4,20 +4,15 @@ | |
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.9; | ||
pragma solidity ^0.8.18; | ||
|
||
import "./TaikoData.sol"; | ||
import {TaikoData} from "./TaikoData.sol"; | ||
|
||
/// @author david <[email protected]> | ||
abstract contract TaikoEvents { | ||
// The following events must match the definitions in other V1 libraries. | ||
event BlockVerified(uint256 indexed id, bytes32 blockHash); | ||
|
||
event BlockCommitted( | ||
uint64 commitSlot, | ||
uint64 commitHeight, | ||
bytes32 commitHash | ||
); | ||
event BlockCommitted(uint64 commitSlot, bytes32 commitHash); | ||
|
||
event BlockProposed(uint256 indexed id, TaikoData.BlockMetadata meta); | ||
|
||
|
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 |
---|---|---|
|
@@ -4,23 +4,27 @@ | |
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.9; | ||
pragma solidity ^0.8.18; | ||
|
||
import "../common/EssentialContract.sol"; | ||
import "../common/IHeaderSync.sol"; | ||
import "../libs/LibAnchorSignature.sol"; | ||
import "../libs/LibSharedConfig.sol"; | ||
import "./TaikoData.sol"; | ||
import "./TaikoEvents.sol"; | ||
import "./libs/LibProposing.sol"; | ||
import "./libs/LibProving.sol"; | ||
import "./libs/LibUtils.sol"; | ||
import "./libs/LibVerifying.sol"; | ||
import {EssentialContract} from "../common/EssentialContract.sol"; | ||
import {IHeaderSync} from "../common/IHeaderSync.sol"; | ||
import {LibAnchorSignature} from "../libs/LibAnchorSignature.sol"; | ||
import {LibSharedConfig} from "../libs/LibSharedConfig.sol"; | ||
import {TaikoData} from "./TaikoData.sol"; | ||
import {TaikoEvents} from "./TaikoEvents.sol"; | ||
import {TaikoCustomErrors} from "./TaikoCustomErrors.sol"; | ||
import {LibProposing} from "./libs/LibProposing.sol"; | ||
import {LibProving} from "./libs/LibProving.sol"; | ||
import {LibUtils} from "./libs/LibUtils.sol"; | ||
import {LibVerifying} from "./libs/LibVerifying.sol"; | ||
import {AddressResolver} from "../common/AddressResolver.sol"; | ||
|
||
/** | ||
* @author dantaik <[email protected]> | ||
*/ | ||
contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents { | ||
contract TaikoL1 is | ||
EssentialContract, | ||
IHeaderSync, | ||
TaikoEvents, | ||
TaikoCustomErrors | ||
{ | ||
using LibUtils for TaikoData.State; | ||
|
||
TaikoData.State public state; | ||
|
@@ -89,7 +93,7 @@ contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents { | |
}); | ||
LibVerifying.verifyBlocks({ | ||
state: state, | ||
config: getConfig(), | ||
config: config, | ||
resolver: AddressResolver(this), | ||
maxBlocks: config.maxVerificationsPerTx, | ||
checkHalt: false | ||
|
@@ -192,7 +196,7 @@ contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents { | |
} | ||
|
||
function getBlockFee() public view returns (uint256) { | ||
(, uint fee, uint deposit) = LibProposing.getBlockFee( | ||
(, uint256 fee, uint256 deposit) = LibProposing.getBlockFee( | ||
state, | ||
getConfig() | ||
); | ||
|
@@ -281,6 +285,12 @@ contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents { | |
return LibUtils.getUncleProofDelay(state, getConfig(), blockId); | ||
} | ||
|
||
function getProverRewardBips( | ||
uint256 numProvers | ||
) public view returns (uint256[] memory) { | ||
return LibVerifying.getProverRewardBips(getConfig(), numProvers); | ||
} | ||
|
||
function getConfig() public pure virtual returns (TaikoData.Config memory) { | ||
return LibSharedConfig.getConfig(); | ||
} | ||
|
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 |
---|---|---|
|
@@ -4,16 +4,20 @@ | |
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
|
||
pragma solidity ^0.8.9; | ||
pragma solidity ^0.8.18; | ||
|
||
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol"; | ||
import { | ||
SafeCastUpgradeable | ||
} from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol"; | ||
|
||
import "../common/EssentialContract.sol"; | ||
import "../common/IMintableERC20.sol"; | ||
import "../libs/LibMath.sol"; | ||
import "../thirdparty/ERC20Upgradeable.sol"; | ||
import {EssentialContract} from "../common/EssentialContract.sol"; | ||
import {IMintableERC20} from "../common/IMintableERC20.sol"; | ||
import {LibMath} from "../libs/LibMath.sol"; | ||
import { | ||
ERC20Upgradeable, | ||
IERC20Upgradeable | ||
} from "../thirdparty/ERC20Upgradeable.sol"; | ||
|
||
/// @author dantaik <[email protected]> | ||
/// @dev This is Taiko's governance and fee token. | ||
contract TkoToken is EssentialContract, ERC20Upgradeable, IMintableERC20 { | ||
using LibMath for uint256; | ||
|
Oops, something went wrong.