Skip to content

Commit 52358bc

Browse files
committed
update contracts
1 parent 9d8b604 commit 52358bc

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

protocol-units/dispute/remappings.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
murky/=./lib/murky/
2+
forge-std/=./lib/forge-std/src/
3+
openzeppelin/=./lib/openzeppelin-contracts/

protocol-units/dispute/src/Dispute.sol

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
pragma solidity ^0.8.13;
33

44
import {Output, OutputLib, Receipt, ReceiptClaim, ReceiptClaimLib, IRiscZeroVerifier, SystemExitCode, ExitCode} from "./IRiscZeroVerifier.sol";
5+
import {Groth16Verifier} from "./groth16/Groth16Verifier.sol";
56
import {SafeCast} from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol";
67

7-
contract Dispute is IRISC0Verifier {
8+
contract Dispute is IRiscZeroVerifier, Groth16Verifier {
89
struct Validator {
910
bool isRegistered;
1011
uint256 stake;
@@ -42,24 +43,29 @@ contract Dispute is IRISC0Verifier {
4243
uint256 public constant MIN_STAKE = 1 ether;
4344
uint256 public delta; // Time window for filing a dispute
4445
uint256 public p; // Time to run the zero-knowledge proof
46+
uint256 public m; // Minimum number of validators required to accept a block
4547

4648
mapping(address => Validator) public validators;
4749
mapping(bytes => Dispute) public disputes;
4850
mapping(bytes32 => Proof) public verifiedProofs; // Maps blockHash to Proof
51+
mapping(bytes32 => OptimisticCommitment) public optimisticCommitments; // Maps blockHash to OptimisticCommitment
4952

50-
IRISC0Verifier public verifier;
53+
IRiscZeroVerifier public verifier;
5154

5255
event ValidatorRegistered(address indexed validator, uint256 stake);
5356
event ValidatorDeregistered(address indexed validator);
5457
event DisputeSubmitted(bytes indexed disputeHash, bytes blockHash, address indexed submitter);
5558
event DisputeResolved(bytes indexed disputeHash, DisputeState state);
5659
event ProofSubmitted(bytes32 indexed blockHash, bool isValid);
5760
event ProofVerified(bytes32 indexed blockHash, bool isValid);
61+
event BlockAccepted(bytes32 indexed blockHash);
62+
event OptimisticCommitmentSubmitted(bytes32 indexed blockHash, bytes stateCommitment, uint256 validatorCount);
5863

59-
constructor(uint256 _delta, uint256 _p, address _verifier) {
64+
constructor(uint256 _delta, uint256 _p, uint256 _m, address _verifier) {
6065
delta = _delta;
6166
p = _p;
62-
verifier = IRISC0Verifier(_verifier);
67+
m = _m;
68+
verifier = IRiscZeroVerifier(_verifier);
6369
}
6470

6571
function registerValidator() external payable {
@@ -96,9 +102,9 @@ contract Dispute is IRISC0Verifier {
96102
emit DisputeResolved(disputeHash, state);
97103
}
98104

99-
function submitProof(bytes32 blockHash, bytes calldata proof, bytes32[] calldata publicInputs) external {
105+
function submitProof(bytes32 blockHash, Receipt calldata receipt, bytes32[] calldata publicInputs) external {
100106
require(!verifiedProofs[blockHash].exists, "Proof already submitted for this block");
101-
bool isValid = verifier.verifyProof(proof, publicInputs);
107+
bool isValid = verifier.verify_integrity(receipt);
102108
verifiedProofs[blockHash] = Proof(blockHash, isValid, true);
103109
emit ProofSubmitted(blockHash, isValid);
104110
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2024 RISC Zero, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// SPDX-License-Identifier: Apache-2.0
16+
17+
// This file is automatically generated by:
18+
// cargo xtask bootstrap-groth16
19+
20+
pragma solidity ^0.8.9;
21+
22+
library ControlID {
23+
uint256 public constant CONTROL_ID_0 = 0x51a3d73938c3681118ba0a2549f7c188;
24+
uint256 public constant CONTROL_ID_1 = 0x44f39e6e6cef91de6d743e7f5b7a1e67;
25+
uint256 public constant BN254_CONTROL_ID = 0x10ff834dbef62ccbba201ecd26a772e3036a075aacbaf47200679a11dcdcf10d;
26+
}

protocol-units/dispute/test/Counter.t.sol

-24
This file was deleted.

0 commit comments

Comments
 (0)