Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): proof verification aggregation #17938

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
/// @inheritdoc ITaikoL1
function proveBlocks(
uint64[] calldata _blockIds,
bytes[] calldata _inputArr
bytes[] calldata _inputArr,
bytes proof
)
external
whenNotPaused
Expand All @@ -162,9 +163,14 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {

TaikoData.Config memory config = getConfig();

IVerifier.Context[] memory ctxs = new IVerifier.Context[](_blockIds.length);
TaikoData.Transition[] memory trans = new TaikoData.Transition[](_blockIds.length);

for (uint256 i; i < _blockIds.length; ++i) {
_proveBlock(_blockIds[i], _inputArr[i], config);
(ctxs[i], trans[i]) = _proveBlock(_blockIds[i], _inputArr[i], config);
}

IVerifier(verifier).verifyProof(ctxs, trans, proof);
Copy link
Contributor

@adaki2004 adaki2004 Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a compilation error, due to this outter verifyProof(), the verifier variable is not know. It is coming from the tier configuration itself (now, in our current design).

And also this yields into another problem, with an example:
The block tiers (and hence the tier verifiers) can be for example:
block nr. 102: SGX only
block nr. 103: SGX+RISC0
block nr. 104: SGX+SP1
block nr. 105: SGX only again

And thus, the verifier contract address itself differs from block to block. so aggregating multiple, continuous blocks and verify with one go, will only work (in the current design at least!) if we have the exact same logic (contract) to verify (so same tiers), otherwise no.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can only aggregate proofs for the same tier together, but the proofs may correspond to blocks that are not consecutive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but then with ever 500-100th zk tier blocks in practice it will be useful for tee only. (At least for now.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have now added the required checks to make sure only the same proofs can be aggregrated.

}

/// @inheritdoc ITaikoL1
Expand Down
6 changes: 2 additions & 4 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ library LibProving {
bytes calldata _input
)
public
returns (IVerifier.Context memory ctx, TaikoData.Transition memory tran)
{
Local memory local;

Expand All @@ -144,7 +145,6 @@ library LibProving {
local.postFork = _blockId >= _config.ontakeForkHeight;

TaikoData.BlockMetadataV2 memory meta;
TaikoData.Transition memory tran;
TaikoData.TierProof memory proof;

if (local.postFork) {
Expand Down Expand Up @@ -260,7 +260,7 @@ library LibProving {
address verifier = _resolver.resolve(local.tier.verifierName, false);
bool isContesting = proof.tier == ts.tier && local.tier.contestBond != 0;

IVerifier.Context memory ctx = IVerifier.Context({
ctx = IVerifier.Context({
metaHash: local.metaHash,
blobHash: meta.blobHash,
// Separate msgSender to allow the prover to be any address in the future.
Expand All @@ -270,8 +270,6 @@ library LibProving {
isContesting: isContesting,
blobUsed: meta.blobUsed
});

IVerifier(verifier).verifyProof(ctx, tran, proof);
}

local.isTopTier = local.tier.contestBond == 0;
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/contracts/verifiers/IVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ interface IVerifier {
/// @param _ctx The context of the proof verification.
/// @param _tran The transition to verify.
/// @param _proof The proof to verify.
function verifyProof(
Context calldata _ctx,
TaikoData.Transition calldata _tran,
function verifyProofs(
Context[] calldata _ctx,
TaikoData.Transition[] calldata _tran,
TaikoData.TierProof calldata _proof
)
external;
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/verifiers/SP1Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ contract SP1Verifier is EssentialContract, IVerifier {

/// @inheritdoc IVerifier
function verifyProof(
Context calldata _ctx,
TaikoData.Transition calldata _tran,
Context[] calldata _ctx,
TaikoData.Transition[] calldata _tran,
TaikoData.TierProof calldata _proof
)
external
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/contracts/verifiers/libs/LibPublicInput.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ library LibPublicInput {
/// @param _chainId The chain id.
/// @return The public input hash.
function hashPublicInputs(
TaikoData.Transition memory _tran,
TaikoData.Transition[] memory _tran,
address _verifierContract,
address _newInstance,
address[] memory _newInstance,
address _prover,
bytes32 _metaHash,
bytes32[] memory _metaHash,
uint64 _chainId
)
internal
Expand Down
Loading