Skip to content

Commit

Permalink
feat(protocol): simplify protocol and remove prover pool from core pr…
Browse files Browse the repository at this point in the history
…otocol (#14541)

Co-authored-by: adaki2004 <keszeydani@gmail.com>
Co-authored-by: David <david@taiko.xyz>
Co-authored-by: Jeffery Walsh <cyberhorsey@gmail.com>
Co-authored-by: D <51912515+adaki2004@users.noreply.github.com>
  • Loading branch information
5 people authored Aug 27, 2023
1 parent 81d9ac0 commit 001b722
Show file tree
Hide file tree
Showing 66 changed files with 1,444 additions and 3,756 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
- **protocol:** add parentGasUsed to blockproven ([#13704](https://github.com/taikoxyz/taiko-mono/issues/13704)) ([2ce8787](https://github.com/taikoxyz/taiko-mono/commit/2ce8787b66537dd6142a040b223bd1f4d8b19f89))
- **protocol:** add TaikoGovernor and improve TaikoToken ([#13711](https://github.com/taikoxyz/taiko-mono/issues/13711)) ([ad75cd5](https://github.com/taikoxyz/taiko-mono/commit/ad75cd5476d10886b337c8da2e95a2c5ea043a57))
- **protocol:** Change back token decimals ([#13707](https://github.com/taikoxyz/taiko-mono/issues/13707)) ([82f1677](https://github.com/taikoxyz/taiko-mono/commit/82f1677b18c8dd90f2afc3fcefe5f60a9d8df670))
- **protocol:** Introduce oracle and system prover concept ([#13729](https://github.com/taikoxyz/taiko-mono/issues/13729)) ([e8ba716](https://github.com/taikoxyz/taiko-mono/commit/e8ba7168231f9a8bbef1378fa93448b11c4267ac))
- **protocol:** Introduce oracle prover concept ([#13729](https://github.com/taikoxyz/taiko-mono/issues/13729)) ([e8ba716](https://github.com/taikoxyz/taiko-mono/commit/e8ba7168231f9a8bbef1378fa93448b11c4267ac))
- **protocol:** L2/L3 contracts proxied ([#13725](https://github.com/taikoxyz/taiko-mono/issues/13725)) ([7e6291f](https://github.com/taikoxyz/taiko-mono/commit/7e6291f3be215789759d5d36e2451fab3154979f))
- **protocol:** major protocol upgrade for alpha-3 testnet ([#13640](https://github.com/taikoxyz/taiko-mono/issues/13640)) ([02552f2](https://github.com/taikoxyz/taiko-mono/commit/02552f2aa001893d326062ce627004c61b46cd26))
- **protocol:** make sure system proof delay is proofTimeTarget ([#13742](https://github.com/taikoxyz/taiko-mono/issues/13742)) ([c359dd9](https://github.com/taikoxyz/taiko-mono/commit/c359dd9c39657ca4deac23d8cd7765a5ae58e8f3))
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/L1/IProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ interface IProofVerifier {
/// @param blockId Unique identifier for the block.
/// @param blockProofs Raw bytes representing the proof(s).
/// @param instance Hashed evidence & config data. If set to zero, proof is
/// assumed to be from oracle/system prover.
/// assumed to be from oracle prover.
function verifyProofs(
uint256 blockId,
uint64 blockId,
bytes calldata blockProofs,
bytes32 instance
)
Expand Down
28 changes: 28 additions & 0 deletions packages/protocol/contracts/L1/IProver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.20;

import { TaikoData } from "./TaikoData.sol";

/// @title IProver Interface
/// @notice Defines the function that handle prover assignment.
interface IProver {
/// @notice Assigns a prover to a specific block or reverts if this prover
/// is not available.
/// @param blockId The ID of the proposed block. Note that the ID is only
/// known when the block is proposed, therefore, it should not be used for
/// verifying prover authorization.
/// @param input The block's BlockMetadataInput data.
/// @param assignment The assignment to evaluate
function onBlockAssigned(
uint64 blockId,
TaikoData.BlockMetadataInput calldata input,
TaikoData.ProverAssignment calldata assignment
)
external
payable;
}
41 changes: 0 additions & 41 deletions packages/protocol/contracts/L1/IProverPool.sol

This file was deleted.

41 changes: 21 additions & 20 deletions packages/protocol/contracts/L1/ProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ pragma solidity ^0.8.20;

import { AddressResolver } from "../common/AddressResolver.sol";
import { EssentialContract } from "../common/EssentialContract.sol";
import { Proxied } from "../common/Proxied.sol";
import { LibZKPVerifier } from "./libs/verifiers/LibZKPVerifier.sol";
import { IProofVerifier } from "./IProofVerifier.sol";
import { LibBytesUtils } from "../thirdparty/LibBytesUtils.sol";
import { LibZKPVerifier } from "./libs/verifiers/LibZKPVerifier.sol";
import { Proxied } from "../common/Proxied.sol";

/// @title ProofVerifier
/// @notice See the documentation in {IProofVerifier}.
Expand All @@ -30,35 +30,36 @@ contract ProofVerifier is EssentialContract, IProofVerifier {
function verifyProofs(
// blockId is unused now, but can be used later when supporting
// different types of proofs.
uint256,
uint64,
bytes calldata blockProofs,
bytes32 instance
)
external
view
{
// If instance is zero, proof is considered as from oracle/system prover
// If instance is zero, proof is considered as from oracle prover
// and not checked.
if (instance == 0) return;

// Validate the instance using bytes utilities.
if (
!LibBytesUtils.equal(
LibBytesUtils.slice(blockProofs, 2, 32),
bytes.concat(bytes16(0), bytes16(instance))
)
) {
revert L1_INVALID_PROOF();
}
// TODO(david & yue): we need to fix the code below
// if (
// !LibBytesUtils.equal(
// LibBytesUtils.slice(blockProofs, 2, 32),
// bytes.concat(bytes16(0), bytes16(instance))
// )
// ) {
// revert L1_INVALID_PROOF();
// }

if (
!LibBytesUtils.equal(
LibBytesUtils.slice(blockProofs, 34, 32),
bytes.concat(bytes16(0), bytes16(uint128(uint256(instance))))
)
) {
revert L1_INVALID_PROOF();
}
// if (
// !LibBytesUtils.equal(
// LibBytesUtils.slice(blockProofs, 34, 32),
// bytes.concat(bytes16(0), bytes16(uint128(uint256(instance))))
// )
// ) {
// revert L1_INVALID_PROOF();
// }

// Extract verifier ID from the proof.
uint16 verifierId = uint16(bytes2(blockProofs[0:2]));
Expand Down
Loading

0 comments on commit 001b722

Please sign in to comment.