Skip to content

Commit

Permalink
feat(protocol): major protocol upgrade (#13225)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeffery Walsh <[email protected]>
Co-authored-by: David <[email protected]>
  • Loading branch information
3 people authored Mar 4, 2023
1 parent 15ab0bb commit 16ea89e
Show file tree
Hide file tree
Showing 82 changed files with 639 additions and 3,752 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
working-directory: ./packages/protocol
run: pnpm test:integration

- name: protocol - Tokenomics Tests
working-directory: ./packages/protocol
run: pnpm test:tokenomics
# - name: protocol - Tokenomics Tests
# working-directory: ./packages/protocol
# run: pnpm test:tokenomics

- name: protocol - Bridge Tests
working-directory: ./packages/protocol
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ artifacts
cache
coverage*
gasReporterOutput.json
contracts/thirdparty/LibBlockHeaderDecoder.sol
4 changes: 0 additions & 4 deletions packages/protocol/.solcover.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module.exports = {
configureYulOptimizer: true,
skipFiles: [
"thirdparty/LibBlockHeaderDecoder.sol", // assembly too long
"libs/LibReceiptDecoder.sol", //integration test,
"test/libs/TestLibReceiptDecoder.sol", //integration tests
"test/thirdparty/TestLibBlockHeaderDecoder.sol", // assembly too long
],
mocha: {
grep: "^[^integration]",
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/.solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ contracts/libs/Lib1559Math.sol
contracts/libs/LibAddress.sol
contracts/libs/LibMath.sol
contracts/libs/LibUint512Math.sol
contracts/libs/LibSharedConfig.sol
contracts/L1/TaikoConfig.sol
**/contracts/thirdparty/**/*.sol
60 changes: 0 additions & 60 deletions packages/protocol/contracts/L1/ProofVerifier.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ maxNumBlocks: 61
slotSmoothingFactor: 16789
*/

library LibSharedConfig {
library TaikoConfig {
/// Returns shared configs for both TaikoL1 and TaikoL2 for production.
function getConfig() internal pure returns (TaikoData.Config memory) {
return
Expand All @@ -32,7 +32,6 @@ library LibSharedConfig {
maxNumBlocks: 2048, // owner:daniel
blockHashHistory: 40, // owner:daniel
maxVerificationsPerTx: 10, //owner:david. Each time one more block is verified, there will be ~20k more gas cost.
commitConfirmations: 0, // owner:daniel
blockMaxGasLimit: 6000000, // owner:david. Set it to 6M, since its the upper limit of the Alpha-2 testnet's circuits.
maxTransactionsPerBlock: 79, // owner:david. Set it to 79 (+1 TaikoL2.anchor transaction = 80), and 80 is the upper limit of the Alpha-2 testnet's circuits.
maxBytesPerTxList: 120000, // owner:david. Set it to 120KB, since 128KB is the upper size limit of a geth transaction, so using 120KB for the proposed transactions list calldata, 8K for the remaining tx fields.
Expand All @@ -52,8 +51,7 @@ library LibSharedConfig {
proofTimeCap: 30 minutes, // owner:daniel
bootstrapDiscountHalvingPeriod: 30 days, // owner:daniel
enableTokenomics: true,
enablePublicInputsCheck: true,
enableAnchorValidation: true
skipZKPVerification: false
});
}
}
33 changes: 19 additions & 14 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
pragma solidity ^0.8.18;

import {BlockHeader} from "../libs/LibBlockHeader.sol";
import {Snippet} from "../common/IXchainSync.sol";

library TaikoData {
struct Config {
Expand All @@ -17,7 +18,6 @@ library TaikoData {
// This number is calculated from maxNumBlocks to make
// the 'the maximum value of the multiplier' close to 20.0
uint256 maxVerificationsPerTx;
uint256 commitConfirmations;
uint256 blockMaxGasLimit;
uint256 maxTransactionsPerBlock;
uint256 maxBytesPerTxList;
Expand All @@ -37,8 +37,7 @@ library TaikoData {
uint64 proofTimeCap;
uint64 bootstrapDiscountHalvingPeriod;
bool enableTokenomics;
bool enablePublicInputsCheck;
bool enableAnchorValidation;
bool skipZKPVerification;
}

struct BlockMetadata {
Expand All @@ -47,20 +46,30 @@ library TaikoData {
bytes32 l1Hash;
address beneficiary;
bytes32 txListHash;
bytes32 txListProofHash;
bytes32 mixHash;
bytes extraData;
uint64 gasLimit;
uint64 timestamp;
uint64 commitHeight;
uint64 commitSlot;
}

struct Evidence {
struct ZKProof {
bytes data;
uint256 circuitId;
}

struct ValidBlockEvidence {
TaikoData.BlockMetadata meta;
ZKProof zkproof; // The block proof
BlockHeader header;
bytes32 signalRoot;
address prover;
bytes[] proofs;
uint16 circuitId;
}

struct InvalidBlockEvidence {
TaikoData.BlockMetadata meta;
ZKProof zkproof; // The txListProof
bytes32 parentHash;
}

// 3 slots
Expand All @@ -73,22 +82,18 @@ library TaikoData {

// 3 + n slots
struct ForkChoice {
bytes32 blockHash;
Snippet snippet;
address prover;
uint64 provenAt;
}

// This struct takes 9 slots.
struct State {
// 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;
// solhint-disable-next-line max-line-length
mapping(uint256 blockNumber => Snippet) l2Snippets;
mapping(address prover => uint256 outstandingReward) balances;
// Never or rarely changed
uint64 genesisHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,25 @@

pragma solidity ^0.8.18;

abstract contract TaikoCustomErrors {
abstract contract TaikoErrors {
// The following custom errors must match the definitions in other V1 libraries.
error L1_0_FEE_BASE();
error L1_ALREADY_PROVEN();
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_COMMITTED();
error L1_BLOCK_PROOF();
error L1_CONFLICT_PROOF();
error L1_CONTRACT_NOT_ALLOWED();
error L1_DUP_PROVERS();
error L1_EXTRA_DATA();
error L1_GAS_LIMIT();
error L1_ID();
error L1_INPUT_SIZE();
error L1_INVALID_EVIDENCE();
error L1_INVALID_PARAM();
error L1_METADATA_FIELD();
error L1_META_MISMATCH();
error L1_NOT_COMMITTED();
error L1_NOT_ORACLE_PROVER();
error L1_PROOF_LENGTH();
error L1_PROVER();
error L1_SOLO_PROPOSER();
error L1_TOO_MANY_BLOCKS();
error L1_TX_LIST_PROOF();
error L1_TX_LIST();
error L1_ZKP();
error L1_ZERO_FEE_BASE();
}
10 changes: 4 additions & 6 deletions packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@

pragma solidity ^0.8.18;

import {Snippet} from "../common/IXchainSync.sol";
import {TaikoData} from "./TaikoData.sol";

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, bytes32 commitHash);

event BlockProposed(uint256 indexed id, TaikoData.BlockMetadata meta);

event BlockProven(
uint256 indexed id,
bytes32 parentHash,
bytes32 blockHash,
address prover,
uint64 provenAt
TaikoData.ForkChoice forkChoice
);

event BlockVerified(uint256 indexed id, Snippet snippet);
}
Loading

0 comments on commit 16ea89e

Please sign in to comment.