Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed May 9, 2023
1 parent 5f89d28 commit 998955b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions packages/protocol/contracts/L1/TaikoErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ abstract contract TaikoErrors {
error L1_INVALID_ETH_DEPOSIT();
error L1_INVALID_EVIDENCE();
error L1_INVALID_METADATA();
error L1_INVALID_OVERWRITE();
error L1_INVALID_PARAM();
error L1_INVALID_PROOF();
error L1_INVALID_SYSTEM_PROVER_CONFIG();
error L1_NOT_ORACLE_PROVER();
error L1_ORACLE_DISABLED();
error L1_INVALID_PROOF_OVERWRITE();
error L1_NOT_SPECIAL_PROVER();
error L1_ORACLE_PROVER_DISABLED();
error L1_SAME_PROOF();
error L1_SYSTEM_PROOF_PROHIBTED();
error L1_SYSTEM_PROVER_DISABLED();
error L1_SYSTEM_PROVER_PROHIBITED();
error L1_TOO_MANY_BLOCKS();
error L1_TX_LIST_NOT_EXIST();
error L1_TX_LIST_HASH();
Expand Down
40 changes: 21 additions & 19 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ library LibProving {
error L1_EVIDENCE_MISMATCH(bytes32 expected, bytes32 actual);
error L1_FORK_CHOICE_NOT_FOUND();
error L1_INVALID_EVIDENCE();
error L1_INVALID_OVERWRITE();
error L1_INVALID_PROOF();
error L1_ORACLE_DISABLED();
error L1_SYSTEM_PROOF_PROHIBTED();
error L1_NOT_ORACLE_PROVER();
error L1_INVALID_PROOF_OVERWRITE();
error L1_NOT_SPECIAL_PROVER();
error L1_ORACLE_PROVER_DISABLED();
error L1_SAME_PROOF();
error L1_SYSTEM_PROOF_DISABLED();
error L1_SYSTEM_PROVER_DISABLED();
error L1_SYSTEM_PROVER_PROHIBITED();

function proveBlock(
TaikoData.State storage state,
Expand Down Expand Up @@ -63,22 +63,29 @@ library LibProving {
if (blk.metaHash != evidence.metaHash)
revert L1_EVIDENCE_MISMATCH(blk.metaHash, evidence.metaHash);

// Separate between oracle proof (which needs to be overwritten) and non-oracle but system proofs
// Separate between oracle proof (which needs to be overwritten)
// and non-oracle but system proofs
address specialProver;
if (evidence.prover == address(0)) {
specialProver = resolver.resolve("oracle_prover", false);
specialProver = resolver.resolve("oracle_prover", true);
if (specialProver == address(0)) {
revert L1_ORACLE_PROVER_DISABLED();
}
} else if (evidence.prover == address(1)) {
specialProver = resolver.resolve("system_prover", false);
specialProver = resolver.resolve("system_prover", true);
if (specialProver == address(0)) {
revert L1_SYSTEM_PROVER_DISABLED();
}

if (
config.realProofSkipSize <= 1 ||
blockId % config.realProofSkipSize == 0
) revert L1_SYSTEM_PROOF_PROHIBTED();
) revert L1_SYSTEM_PROVER_PROHIBITED();
}

if (specialProver != address(0) && msg.sender != specialProver) {
if (evidence.proof.length != 64) {
revert L1_NOT_ORACLE_PROVER();
revert L1_NOT_SPECIAL_PROVER();
} else {
uint8 v = uint8(evidence.verifierId);
bytes32 r;
Expand All @@ -96,7 +103,7 @@ library LibProving {
if (
specialProver !=
ecrecover(keccak256(abi.encode(evidence)), v, r, s)
) revert L1_NOT_ORACLE_PROVER();
) revert L1_NOT_SPECIAL_PROVER();
}
}

Expand Down Expand Up @@ -140,20 +147,14 @@ library LibProving {
} else {
// This is the branch provers trying to overwrite
fc = blk.forkChoices[fcId];
// Only allow overwrite in case:
// - previous prover is oracle prover or system proof
// (the latter can be verified without being overwritten)
// - and blockHash/signalRoot/gasUsed are matching
// Revert otherwise.

if (fc.prover != address(0) && fc.prover != address(1))
revert L1_ALREADY_PROVEN();

if (
fc.blockHash != evidence.blockHash ||
fc.signalRoot != evidence.signalRoot ||
fc.gasUsed != evidence.gasUsed
) revert L1_INVALID_OVERWRITE();
) revert L1_INVALID_PROOF_OVERWRITE();
}

fc.blockHash = evidence.blockHash;
Expand All @@ -162,7 +163,8 @@ library LibProving {
fc.provenAt = uint64(block.timestamp);
fc.prover = evidence.prover;

// evidence.prover cannot be address(0) at this point - either oracle, system, or a regular prover
// evidence.prover cannot be address(0) at this point -
// either system or a regular prover
if (evidence.prover != address(1)) {
uint256[9] memory inputs;

Expand Down
2 changes: 0 additions & 2 deletions packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

pragma solidity ^0.8.18;

import {Test} from "forge-std/Test.sol";
import {console2} from "forge-std/console2.sol";
import {AddressResolver} from "../../common/AddressResolver.sol";
import {ISignalService} from "../../signal/ISignalService.sol";
import {LibTokenomics} from "./LibTokenomics.sol";
Expand Down

0 comments on commit 998955b

Please sign in to comment.