From ec502297d734007425386fd0cac367a90a12b0cd Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 29 Jan 2023 11:40:42 +0800 Subject: [PATCH 1/5] enable sub-circuits --- packages/protocol/contracts/L1/libs/LibProving.sol | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index 2b6d550032f..8a3fe646ba7 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -29,6 +29,7 @@ library LibProving { BlockHeader header; address prover; bytes[] proofs; // The first zkProofsPerBlock are ZKPs + uint8[] circuitIds; //= size == zkProofsPerBlock } bytes32 public constant INVALIDATE_BLOCK_LOG_TOPIC = @@ -58,6 +59,7 @@ library LibProving { // Check and decode inputs require(inputs.length == 3, "L1:inputs:size"); Evidence memory evidence = abi.decode(inputs[0], (Evidence)); + bytes calldata anchorTx = inputs[1]; bytes calldata anchorReceipt = inputs[2]; @@ -69,6 +71,10 @@ library LibProving { evidence.proofs.length == 2 + zkProofsPerBlock, "L1:proof:size" ); + require( + evidence.circuitIds.length == zkProofsPerBlock, + "L1:circuitIds:size" + ); { // Check anchor tx is valid @@ -256,7 +262,12 @@ library LibProving { require( proofVerifier.verifyZKP({ verifierId: string( - abi.encodePacked("plonk_verifier_", i) + abi.encodePacked( + "plonk_verifier_", + i, + "_", + evidence.circuitIds[i] + ) ), zkproof: evidence.proofs[i], blockHash: blockHash, From 4d60cf35700106d5db56fefe7311452cb3b0268b Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 29 Jan 2023 11:45:33 +0800 Subject: [PATCH 2/5] more --- packages/protocol/contracts/L1/libs/LibProving.sol | 10 +++++----- packages/protocol/tasks/deploy_L1.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index 8a3fe646ba7..ee2361566e9 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -28,8 +28,8 @@ library LibProving { TaikoData.BlockMetadata meta; BlockHeader header; address prover; - bytes[] proofs; // The first zkProofsPerBlock are ZKPs - uint8[] circuitIds; //= size == zkProofsPerBlock + bytes[] proofs; // The first zkProofsPerBlock are ZKPs, followed by MKPs. + uint8[] circuits; // THe circuits IDs (size === zkProofsPerBlock) } bytes32 public constant INVALIDATE_BLOCK_LOG_TOPIC = @@ -72,8 +72,8 @@ library LibProving { "L1:proof:size" ); require( - evidence.circuitIds.length == zkProofsPerBlock, - "L1:circuitIds:size" + evidence.circuits.length == zkProofsPerBlock, + "L1:circuits:size" ); { @@ -266,7 +266,7 @@ library LibProving { "plonk_verifier_", i, "_", - evidence.circuitIds[i] + evidence.circuits[i] ) ), zkproof: evidence.proofs[i], diff --git a/packages/protocol/tasks/deploy_L1.ts b/packages/protocol/tasks/deploy_L1.ts index 4c338b00b6b..33209187668 100644 --- a/packages/protocol/tasks/deploy_L1.ts +++ b/packages/protocol/tasks/deploy_L1.ts @@ -197,8 +197,8 @@ export async function deployContracts(hre: any) { `${chainId}.${Buffer.from( ethers.utils.arrayify( ethers.utils.solidityPack( - ["string", "uint256"], - ["plonk_verifier_", 0] + ["string", "uint256", "string", "uint8"], + ["plonk_verifier_", 0, "_", 0] ) ) ).toString()}`, From db2a6e4080e8a78c9d572cd0b69c84cfa4f7811e Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 29 Jan 2023 11:50:19 +0800 Subject: [PATCH 3/5] Update LibProving.sol --- packages/protocol/contracts/L1/libs/LibProving.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index ee2361566e9..fa0ec06ed69 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -28,7 +28,8 @@ library LibProving { TaikoData.BlockMetadata meta; BlockHeader header; address prover; - bytes[] proofs; // The first zkProofsPerBlock are ZKPs, followed by MKPs. + bytes[] proofs; // The first zkProofsPerBlock are ZKPs, + // followed by MKPs. uint8[] circuits; // THe circuits IDs (size === zkProofsPerBlock) } From 8ccc697c1e7f0063a4bca5dd4e329906acfc3af1 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 29 Jan 2023 11:51:18 +0800 Subject: [PATCH 4/5] more --- packages/protocol/contracts/L1/libs/LibProving.sol | 2 +- packages/protocol/tasks/deploy_L1.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index fa0ec06ed69..7a03e1fa2b7 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -30,7 +30,7 @@ library LibProving { address prover; bytes[] proofs; // The first zkProofsPerBlock are ZKPs, // followed by MKPs. - uint8[] circuits; // THe circuits IDs (size === zkProofsPerBlock) + uint16[] circuits; // THe circuits IDs (size === zkProofsPerBlock) } bytes32 public constant INVALIDATE_BLOCK_LOG_TOPIC = diff --git a/packages/protocol/tasks/deploy_L1.ts b/packages/protocol/tasks/deploy_L1.ts index 33209187668..d05d261ec97 100644 --- a/packages/protocol/tasks/deploy_L1.ts +++ b/packages/protocol/tasks/deploy_L1.ts @@ -197,7 +197,7 @@ export async function deployContracts(hre: any) { `${chainId}.${Buffer.from( ethers.utils.arrayify( ethers.utils.solidityPack( - ["string", "uint256", "string", "uint8"], + ["string", "uint256", "string", "uint16"], ["plonk_verifier_", 0, "_", 0] ) ) From caf4a7e0904d469bd16685d3deaba4164446123e Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Sun, 29 Jan 2023 20:24:52 +0800 Subject: [PATCH 5/5] Update packages/protocol/contracts/L1/libs/LibProving.sol Co-authored-by: David --- packages/protocol/contracts/L1/libs/LibProving.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index 7a03e1fa2b7..32579470421 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -30,7 +30,7 @@ library LibProving { address prover; bytes[] proofs; // The first zkProofsPerBlock are ZKPs, // followed by MKPs. - uint16[] circuits; // THe circuits IDs (size === zkProofsPerBlock) + uint16[] circuits; // The circuits IDs (size === zkProofsPerBlock) } bytes32 public constant INVALIDATE_BLOCK_LOG_TOPIC =