Skip to content

Commit

Permalink
refactor(protocol): optimize core protocol and bridge implementation (#…
Browse files Browse the repository at this point in the history
…14310)

Co-authored-by: Daniel Wang <99078276+dantaik@users.noreply.github.com>
Co-authored-by: dantaik <dantaik@users.noreply.github.com>
Co-authored-by: dave | d1onys1us <13951458+d1onys1us@users.noreply.github.com>
Co-authored-by: adaki2004 <adaki2004@users.noreply.github.com>
Co-authored-by: jeff <113397187+cyberhorsey@users.noreply.github.com>
Co-authored-by: Francisco Ramos <jscriptcoder@gmail.com>
Co-authored-by: David <david@taiko.xyz>
Co-authored-by: Kenk <kenghin_lim@hotmail.com>
Co-authored-by: mfinestone <36642873+mfinestone@users.noreply.github.com>
Co-authored-by: hideonbug <92258181+whohideonbug@users.noreply.github.com>
Co-authored-by: megumii <98658943+Megumiiiiii@users.noreply.github.com>
Co-authored-by: Tomaž <venooxpersonal@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Daniel Wang <dong77@gmail.com>
Co-authored-by: Jeffery Walsh <cyberhorsey@gmail.com>
Co-authored-by: cyberhorsey <cyberhorsey@users.noreply.github.com>
Co-authored-by: Brecht Devos <Brechtp.Devos@gmail.com>
Co-authored-by: d1onys1us <d1onys1us@users.noreply.github.com>
Co-authored-by: Roger <50648015+RogerLamTd@users.noreply.github.com>
Co-authored-by: Korbinian <KorbinianK@users.noreply.github.com>
  • Loading branch information
21 people authored Aug 27, 2023
1 parent 547cd1c commit 437763a
Show file tree
Hide file tree
Showing 121 changed files with 12,832 additions and 7,469 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.

43 changes: 22 additions & 21 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 All @@ -71,5 +72,5 @@ contract ProofVerifier is EssentialContract, IProofVerifier {
}

/// @title ProxiedProofVerifier
/// @notice Proxied version of the ProofVerifier contract.
/// @notice Proxied version of the parent contract.
contract ProxiedProofVerifier is Proxied, ProofVerifier { }
Loading

0 comments on commit 437763a

Please sign in to comment.