Skip to content

Commit

Permalink
feat(protocol): enable two dimensional circuit/verifier lookup. (#13066)
Browse files Browse the repository at this point in the history
Co-authored-by: David <david@taiko.xyz>
  • Loading branch information
dantaik and davidtaikocha committed Jan 30, 2023
1 parent beb0c33 commit 51d1f67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ library LibProving {
TaikoData.BlockMetadata meta;
BlockHeader header;
address prover;
bytes[] proofs; // The first zkProofsPerBlock are ZKPs
bytes[] proofs; // The first zkProofsPerBlock are ZKPs,
// followed by MKPs.
uint16[] circuits; // The circuits IDs (size === zkProofsPerBlock)
}

bytes32 public constant INVALIDATE_BLOCK_LOG_TOPIC =
Expand Down Expand Up @@ -58,6 +60,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];

Expand All @@ -69,6 +72,10 @@ library LibProving {
evidence.proofs.length == 2 + zkProofsPerBlock,
"L1:proof:size"
);
require(
evidence.circuits.length == zkProofsPerBlock,
"L1:circuits:size"
);

{
// Check anchor tx is valid
Expand Down Expand Up @@ -254,7 +261,12 @@ library LibProving {
require(
proofVerifier.verifyZKP({
verifierId: string(
abi.encodePacked("plonk_verifier_", i)
abi.encodePacked(
"plonk_verifier_",
i,
"_",
evidence.circuits[i]
)
),
zkproof: evidence.proofs[i],
blockHash: blockHash,
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/tasks/deploy_L1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", "uint16"],
["plonk_verifier_", 0, "_", 0]
)
)
).toString()}`,
Expand Down

0 comments on commit 51d1f67

Please sign in to comment.