diff --git a/packages/protocol/contracts/L1/TaikoErrors.sol b/packages/protocol/contracts/L1/TaikoErrors.sol index da411712c34..a94a128bc24 100644 --- a/packages/protocol/contracts/L1/TaikoErrors.sol +++ b/packages/protocol/contracts/L1/TaikoErrors.sol @@ -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(); diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index a63ccd8370d..3fb9b149d80 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -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, @@ -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; @@ -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(); } } @@ -140,12 +147,6 @@ 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(); @@ -153,7 +154,7 @@ library LibProving { 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; @@ -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; diff --git a/packages/protocol/contracts/L1/libs/LibVerifying.sol b/packages/protocol/contracts/L1/libs/LibVerifying.sol index ef69b6d9399..8b8953bac6c 100644 --- a/packages/protocol/contracts/L1/libs/LibVerifying.sol +++ b/packages/protocol/contracts/L1/libs/LibVerifying.sol @@ -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";