From 8e8601b44227f77444f4cb86406701cf00054ca1 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 3 Sep 2023 20:32:57 +0800 Subject: [PATCH] feat(protocol): validate `instance` the old way (#14639) Co-authored-by: Daniel Wang <99078276+dantaik@users.noreply.github.com> --- .../protocol/contracts/L1/ProofVerifier.sol | 33 +++++++++---------- packages/protocol/test/L1/TaikoL1TestBase.sol | 1 - 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/protocol/contracts/L1/ProofVerifier.sol b/packages/protocol/contracts/L1/ProofVerifier.sol index 15b7138170c..22fbfa1f788 100644 --- a/packages/protocol/contracts/L1/ProofVerifier.sol +++ b/packages/protocol/contracts/L1/ProofVerifier.sol @@ -42,24 +42,23 @@ contract ProofVerifier is EssentialContract, IProofVerifier { if (instance == 0) return; // Validate the instance using bytes utilities. - // TODO(david & yue): we need to fix the code below - // if ( - // !LibBytesUtils.equal( - // LibBytesUtils.slice(blockProofs, 2, 32), - // bytes.concat(bytes16(0), bytes16(instance)) - // ) - // ) { - // revert L1_INVALID_PROOF(); - // } + if ( + !LibBytesUtils.equal( + LibBytesUtils.slice(blockProofs, 2, 32), + bytes.concat(bytes16(0), bytes16(instance)) + ) + ) { + revert L1_INVALID_PROOF(); + } - // if ( - // !LibBytesUtils.equal( - // LibBytesUtils.slice(blockProofs, 34, 32), - // bytes.concat(bytes16(0), bytes16(uint128(uint256(instance)))) - // ) - // ) { - // revert L1_INVALID_PROOF(); - // } + if ( + !LibBytesUtils.equal( + LibBytesUtils.slice(blockProofs, 34, 32), + bytes.concat(bytes16(0), bytes16(uint128(uint256(instance)))) + ) + ) { + revert L1_INVALID_PROOF(); + } // Extract verifier ID from the proof. uint16 verifierId = uint16(bytes2(blockProofs[0:2])); diff --git a/packages/protocol/test/L1/TaikoL1TestBase.sol b/packages/protocol/test/L1/TaikoL1TestBase.sol index 0a1ff63749e..1632d2f639c 100644 --- a/packages/protocol/test/L1/TaikoL1TestBase.sol +++ b/packages/protocol/test/L1/TaikoL1TestBase.sol @@ -166,7 +166,6 @@ abstract contract TaikoL1TestBase is TestBase { bytes32 instance = LibProving.getInstance(evidence); uint16 verifierId = 100; - // TODO(daniel & yue): we need to fix here evidence.proofs = bytes.concat( bytes2(verifierId), bytes16(0),