Skip to content

Commit

Permalink
Merge pull request #343 from 0xPolygonHermez/feature/sp1-e2e-update
Browse files Browse the repository at this point in the history
Update e2e with l1InfoTree + upgrade verifier to v2
  • Loading branch information
invocamanman authored Oct 7, 2024
2 parents d0b44f2 + d947b94 commit 82d3577
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 63 deletions.
2 changes: 0 additions & 2 deletions contracts/v2/interfaces/ISP1Verifier.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

// imported from: https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1Verifier.sol

/// @title SP1 Verifier Interface
/// @author Succinct Labs
/// @notice This contract is the interface for the SP1 Verifier.
Expand Down
38 changes: 19 additions & 19 deletions contracts/verifiers/PlonkVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,49 +57,49 @@ contract PlonkVerifier {
uint256 private constant VK_OMEGA =
19200870435978225707111062059747084165650991997241425080699860725083300967194;
uint256 private constant VK_QL_COM_X =
20791018202796501791851109643831626010857592750396866610160202525341548104975;
7407214510609079145773511377600669946182675406099819935159338773180963032920;
uint256 private constant VK_QL_COM_Y =
5226061715293647066826628267680220853478003875325565109026897987462899458934;
3889572140636551481918367605181004843678060827549237388417633453568279634611;
uint256 private constant VK_QR_COM_X =
17704828802915832559088923039609398221401810694301345977639386873055299309953;
13185587283948207039104909600533393134642892790477195397204788972655935187034;
uint256 private constant VK_QR_COM_Y =
11505746596354645523327106298502472694854757882353990600194589846954496245852;
6451325745723191433786431885069978482139162540042467099835998301383703554688;
uint256 private constant VK_QM_COM_X =
8632375487221918401254404349520984498817891912271126365916892067491373235811;
7831121084190844355678123756695098161028116896368533348735307958954908573570;
uint256 private constant VK_QM_COM_Y =
18415064246668245762581392760606059429812772223698459476573964344262178019204;
21423217261232968699613611347737906259833622177052298937517042548376276313438;
uint256 private constant VK_QO_COM_X =
8087969089479778581426802786766605298548725543517399982902049379760156324465;
12419033777431380552505290008781347497974878014421729798707093080965200361938;
uint256 private constant VK_QO_COM_Y =
4779090953040789618776097250791090447780600065080041765846917953077650190480;
14405784914363318893588095549313718460584773062530955039336108755620243930516;
uint256 private constant VK_QK_COM_X =
10309503866905785707178640727209791380348799027238603521718690548633411043468;
4811396650865004697225019631507960299372172242731495526799354745511476203569;
uint256 private constant VK_QK_COM_Y =
2592253320469291239204015457281188297098202731734862712210951168997817663533;
10570898863026195981286955019805202755257962416067906968977768446967627177077;

uint256 private constant VK_S1_COM_X =
1691236927603889293036991293307837152105169001969876410429311940723859549214;
6968952419837705449998661901501008975958799249703100090180103311190010965871;
uint256 private constant VK_S1_COM_Y =
14671292974808286966476340691395602210499383933767336479707207228316624796067;
1249467605411785301185223257548811095553790625974289413299263690359522154232;

uint256 private constant VK_S2_COM_X =
8488985819633767661392296162379719853061350968173906335566567292000856455547;
4146220958340634117711137018067570486438638661164597634569826319047340086504;
uint256 private constant VK_S2_COM_Y =
21135097961399174006459419593931869224566225356178559833797507995994008138431;
11514940594097180306355347346721706752308488755168473282895462849476778731992;

uint256 private constant VK_S3_COM_X =
6948983180741800379137546378229012057117410422170200269119279410455497222279;
9448994237127116300590468875689047378195790180478128432750829709164772937855;
uint256 private constant VK_S3_COM_Y =
2168023664758765470467815652478171461884955470414723045130810573559142201536;
19105625469644071502486127957107459666205424766333120347163247063872894908167;

uint256 private constant VK_COSET_SHIFT = 5;

uint256 private constant VK_QCP_0_X =
15094628898981014851230294832922767350330234022809606393203152940416977514848;
17454416295032677617185412985505503605684799782830882030707498476438392095244;
uint256 private constant VK_QCP_0_Y =
3056768420174140117719575194791127678251100292295026433168587815162498899224;
19541761788913122331184139395510543772651753333302925962600032923013908029361;

uint256 private constant VK_INDEX_COMMIT_API_0 = 20988588;
uint256 private constant VK_INDEX_COMMIT_API_0 = 18030217;
uint256 private constant VK_NB_CUSTOM_GATES = 1;

// ------------------------------------------------
Expand Down
14 changes: 4 additions & 10 deletions contracts/verifiers/SP1Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ pragma solidity ^0.8.20;
import {ISP1Verifier, ISP1VerifierWithHash} from "../v2/interfaces/ISP1Verifier.sol";
import {PlonkVerifier} from "./PlonkVerifier.sol";

// Current deployments: https://github.com/succinctlabs/sp1-contracts/tree/main/contracts/deployments
// Local deployments should deploy this contract. Any existing chain should use already deployed contracts by SP1

/// @title SP1 Verifier
/// @author Succinct Labs
/// @notice This contracts implements a solidity verifier for SP1.
Expand All @@ -21,20 +18,17 @@ contract SP1Verifier is PlonkVerifier, ISP1VerifierWithHash {
error InvalidProof();

function VERSION() external pure returns (string memory) {
return "v1.1.0";
return "v2.0.0";
}

/// @inheritdoc ISP1VerifierWithHash
function VERIFIER_HASH() public pure returns (bytes32) {
return
0xc430ff7f31a22c5f7607f3ed2a2f5621af340bc45a44179319cba5761664e1f0;
return 0x4aca240a3e5296e6a565f98dc728c6f48f8de4792a8fa365038c3b86952176f5;
}

/// @notice Hashes the public values to a field elements inside Bn254.
/// @param publicValues The public values.
function hashPublicValues(
bytes calldata publicValues
) public pure returns (bytes32) {
function hashPublicValues(bytes calldata publicValues) public pure returns (bytes32) {
return sha256(publicValues) & bytes32(uint256((1 << 253) - 1));
}

Expand Down Expand Up @@ -62,4 +56,4 @@ contract SP1Verifier is PlonkVerifier, ISP1VerifierWithHash {
revert InvalidProof();
}
}
}
}
27 changes: 5 additions & 22 deletions test/contractsv2/real-prover-sp1/e2e-verify-proof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,28 +281,11 @@ describe("Polygon Rollup Manager with Polygon Pessimistic Consensus", () => {
.verifyPessimisticTrustedAggregator(pessimisticRollupID, l1InfoTreeLeafCount, newLER, newPPRoot, proofPP)
).to.be.revertedWithCustomError(rollupManagerContract, "L1InfoTreeLeafCountInvalid");

// Set lastGlobal exit root (mock)

// const tokenAddress = ethers.ZeroAddress;
// for(const bridge of inputProof.bridges) {
// await polygonZkEVMBridgeContract.bridgeAsset(
// bridge.destinationNetwork,
// bridge.destinationAddress,
// String(bridge.amount),
// tokenAddress,
// true,
// "0x",
// {
// value: String(bridge.amount),
// }
// );
// }
//const existingGER = await polygonZkEVMGlobalExitRoot.getLastGlobalExitRoot();
const existingGER = inputProof["pp-inputs"]["selected-ger"];
const l1InfoRoot = inputProof["pp-inputs"]["l1-info-root"];
// check JS function computeInputPessimisticBytes
const inputPessimisticBytes = await rollupManagerContract.getInputPessimisticBytes(
pessimisticRollupID,
existingGER,
l1InfoRoot,
inputProof["pp-inputs"]["new-local-exit-root"],
inputProof["pp-inputs"]["new-pessimistic-root"]
);
Expand All @@ -314,7 +297,7 @@ describe("Polygon Rollup Manager with Polygon Pessimistic Consensus", () => {
const expectedInputPessimisticBytes = computeInputPessimisticBytes(
infoRollup[4],
infoRollup[10],
existingGER,
l1InfoRoot,
pessimisticRollupID,
consensusHash,
newLER,
Expand All @@ -323,8 +306,8 @@ describe("Polygon Rollup Manager with Polygon Pessimistic Consensus", () => {

expect(inputPessimisticBytes).to.be.equal(expectedInputPessimisticBytes);
// Mock selected GER
await polygonZkEVMGlobalExitRoot.injectGER(existingGER, l1InfoTreeLeafCount);
// Mock las LER and last Pesimistic root
await polygonZkEVMGlobalExitRoot.injectGER(l1InfoRoot, l1InfoTreeLeafCount);
// Mock last LER and last Pessimistic root
await rollupManagerContract.setRollupData(
pessimisticRollupID,
inputProof["pp-inputs"]["prev-local-exit-root"],
Expand Down
20 changes: 10 additions & 10 deletions test/contractsv2/real-prover-sp1/test-inputs/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
}
],
"pp-inputs": {
"prev-local-exit-root": "0xf99fbc86af88be1a031b1d3aa12352bbc35c660f84f127100d98c722980dd5d7",
"prev-pessimistic-root": "0xf5aeb1f1ad04ad302db5c8b20c383fb9aa35f05afc96d40ba9397a2fdde43aa7",
"selected-ger": "0xa116e19a7984f21055d07b606c55628a5ffbf8ae1261c1e9f4e3a61620cf810a",
"prev-local-exit-root": "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757",
"prev-pessimistic-root": "0x2152f3808cb81b33b5a47a7a256d61ab9ea916c66030c405ca9b2aaad3b00f0a",
"l1-info-root": "0x9f1d0c7713a6a5f1e79222623c0687242c3feed74ebecb6f9d0e87e7572cdeca",
"origin-network": 1,
"consensus-hash": "0x4435f540481ae2612db862af753ab6a2a7cec28c28c91de998a8ca9617b9136a",
"new-local-exit-root": "0x7bb571bfb7bd5920abcb1bfa026e8487b76696f2870c9ba8616e4fd2723d6f72",
"new-pessimistic-root": "0x6491904287b9ced596158d4b7467d76cfeed6e46039523845cda989483e9ed61"
"consensus-hash": "0x1ef9f46a148e3ed26c4f25e1eda10fbbd137695aec0b6df56cbe45111c38fc8f",
"new-local-exit-root": "0x062ceaf957ff72ca68a79fd0b1df2a0a942eaaa790b64f8843f6826a0cb0893b",
"new-pessimistic-root": "0x8cbdfd2e979a425d37b3aec1b3f1d050faf45e5a77811cbfaa435fdc91c9b2ec"
},
"signer": "0xbe34dc9cee837f5c2ce4510b293fce2a2bfe0678",
"vkey": "0x00318c46e4de2184c0cebba16582cd587e3002b976cda252797793ed181bd8cc",
"public-values": "0xf99fbc86af88be1a031b1d3aa12352bbc35c660f84f127100d98c722980dd5d7f5aeb1f1ad04ad302db5c8b20c383fb9aa35f05afc96d40ba9397a2fdde43aa7a116e19a7984f21055d07b606c55628a5ffbf8ae1261c1e9f4e3a61620cf810a000000014435f540481ae2612db862af753ab6a2a7cec28c28c91de998a8ca9617b9136a7bb571bfb7bd5920abcb1bfa026e8487b76696f2870c9ba8616e4fd2723d6f726491904287b9ced596158d4b7467d76cfeed6e46039523845cda989483e9ed61",
"proof": "0xc430ff7f1f55796074f7e8ff95a0d1f795c246d52f9b8f78ccdb24b47e12b6ca4d26608824d2a42e28226ff6da7badbd84a6f7565911cee3ad87e223f43d178a69806ef62ee66813eb1cee16c05dbcde6e010cde039e2b3e0d762e447d6c424ec688a0e808ca17b60843906973fac5315a56626a19430b9ed4cae95053b3ddaaf35ef9de0f9ef3cfb308eca152c3f127250c49c36b778a1f2719ba6e73137e26b0ccf94d0296bcd688fa1fa92818dd07e12b653bd5d7380b7f52ba75ee60709b5700737b043ed8630492be20eeef770460280287ece3548b5a967fc252ffb2fdc81bb7160cf130a49d5ae4407a900b924cc38478ba05239d2d985ed1a55c68637e61daba07c84078c9b73d8e4352f8318558a518b0e3fb8779d06bb5863f9a7d5986153f271a51addbf761b685d87e7517c409d1d3085cd36ce0b3500f1ade89cc9e46b725fb7d70e9824a9ba3ce08ff0828b93b54ae6d5363378ce1fbde8f5601e4452e08a6ff71973a07d7e8cacbac2d64896fe3437b6451e9810935c4f3d2f80260bd1c3aa2aee47f3578a5aef9e0e49ec898638a9a64c801d76ad519a1927593501e2e939d2a9e996ff04515148907b0ab14da2ffe8d7f24b1a0e23d29449a5be52d28d87ded967d342098c2d90e453c5ac593fad5cceb0c57098ff8d9946f0bc92f0392dc1f08704837d18d9d4e02cd35e2e777d474cb9d0621de1552bbca8523072ef584e03d1dfaa45fab6608cf0db495b227c553c631193584207e414a40c19f1cf39ecda2d8ec4156257e319d8afaf10bb134addec55996d6a9223cccc0aca21010c03a27b588459328c4f34c0ccbf79729d2fa5da6c029438e021fd3dc122a0b3a07628d0a42d530ca67436e12f8943bcdfda9cbfd32cce16bf98ca1f7c4a125b714899ac3624fce9adca3e0d58bd4c79d52abbacd27c3eda15ea3b19c03a30f47c97882b7ddd708812d483422605b329eea86c506a45c2e46387e893a65101ced810b17a9c3398820ffb8e62981f80afdf58f2a38458a04b9962a039430b32dc636196fe8b42caecaf69c2188d501deb94b5a14a88576d927abe9a2bfe4d90b458fc548922be2d563705524a081a361a1f8fce13ef1837c41b9827f0627c328a0a777533c1e1a357cf79dad2b339356c901100a982c9267b6f4c3f1d5943327cc77a6abb2f7c5c0424509cfc5b62b45d3e17afb445c34e1ac2861270e56e5"
"signer": "0x8049f41a5c1794fe230054ec16b08844bce6a8e6",
"vkey": "0x00c74571524172c084366264f2a1e00307c6203bb60bb330052bbcf99b431424",
"public-values": "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d7572152f3808cb81b33b5a47a7a256d61ab9ea916c66030c405ca9b2aaad3b00f0a9f1d0c7713a6a5f1e79222623c0687242c3feed74ebecb6f9d0e87e7572cdeca000000011ef9f46a148e3ed26c4f25e1eda10fbbd137695aec0b6df56cbe45111c38fc8f062ceaf957ff72ca68a79fd0b1df2a0a942eaaa790b64f8843f6826a0cb0893b8cbdfd2e979a425d37b3aec1b3f1d050faf45e5a77811cbfaa435fdc91c9b2ec",
"proof": "0x4aca240a0b97952ecb1a0e71fba2ff570f093fa6d60ec76a8dfccc2220c9deb19191195b0f3ff28450a4e731eec136fce1b25e24aced5d57ba76e185bc732061e078b4fa254219fe4e2b287eb4751950410355e31ce3dd6a99b229e659d911cb5fc757ac2d070af68aa4189bcb0138d6f169b3d7c4db8d151db1a86c3844d8930c78b8f8206cf79464ccccee11f63143025b0a840d841da2f7fadc563cba29b3733e2baa1f17261067f6326a649eebff82db4230b4a70c7691db32b57e55b7b90cdcbea1226d960751ca8c7b48f36d87fbe49f0af796336f91c15d5bbc8361151335b2350ef0589e1dc608b3ca0668cf2f1e80221f3ae0dfa2ce11f14cb00af278d1d7902fe9231cef1cab176be0b7d124ffe8a2c01246228baf7409fe1f97cc094c91742f7490fda3d1519d316b5b5bb50caa316f491e57e687a195c69c0732955b0cab0b9003eebd2dea760001e3760ad9104c470d8457a6a93b639a9cc95c66ccaea025aa4387891a51eacd841a25fc8dcfac6e4a3da7019a0b6c9961d4ef8c0ed9a81ff00a46e1bd4d35a804935647ff071574f3557ab23b8fc8bfb87f7bed2f79c11a60ef7434e0dec67ab562ac89f8bd5d99dd364e75716aad718a1c2a4795be9c054345206305e7dcd5b3349866aea2c5b7f4e8c79b4bf586004b551d35779bba0978977394d1530499b3c8c24350adf4760e5aa75c5fb8c96691607159a920f123d65c9818d07280ea34e6430f7fd6c496ea8219cec0283eb689f9e2a8f031dd1609da946a76277c324ace53da703dfce9efbee8bb8abd096dc3860e7acf7d0b186ea19421b85c4095e3c9a4f459509448d649d8540d51874bd3fb9b77c0eab518af7b37f9584c76b7b5ed9124689b75e8562cd0f4d4aad34f6b0ad3333a72fb0ac16aa40470780f88760678405832037671b27b4bf19dc8da74eddd8598740508fa9da973e2db26bfaec49dc52e8e8b0cacd4a288c55523cee293b3ab6897750495b66a5966d2e5123c9b49d3df1184742967c98a84ca2d699dc89afded763b27b690ad8295bb89e9f2cfbc6a52345365e472c88cdd0cdae349c13d7322f54b27e83d266932df954c5b11f699aefad24912437b2970fb3681e267ba548068b518790a5d1b71ff55425e2ca2b26242728ef060ad5bb23f23501e765685c5ad2a13c6c12646762ea1b1d73cda340140b26738e72e06b4e436d321e80fc00d22a0"
}

0 comments on commit 82d3577

Please sign in to comment.