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

fix: conversion from callbackData bytes to l2BlockRangeAccepted uint256 #202

Merged
merged 13 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
2 changes: 1 addition & 1 deletion packages/linea-ens-resolver/test/testL1Resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe("Crosschain Resolver", () => {
commands2Test,
constantsTest,
proofsEncoded,
AbiCoder.defaultAbiCoder().encode(["uint256"], [blockNo])
86400
);
} catch (error) {
expect(error.reason).to.equal(
Expand Down
9 changes: 6 additions & 3 deletions packages/linea-state-verifier/contracts/EVMFetchTarget.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract contract EVMFetchTarget {

/**
* @dev Internal callback function invoked by CCIP-Read in response to a `getStorageSlots` request.
* @dev Only the first 32 bytes are used for callbackData and is never longer than 32 bytes
*/
function getStorageSlotsCallback(
bytes calldata response,
Expand All @@ -27,17 +28,19 @@ abstract contract EVMFetchTarget {
bytes32[] memory commands,
bytes[] memory constants,
bytes4 callback,
uint256 l2BlockRangeAccepted
bytes memory callbackData
) = abi.decode(
extradata,
(IEVMVerifier, address, bytes32[], bytes[], bytes4, uint256)
(IEVMVerifier, address, bytes32[], bytes[], bytes4, bytes)
);

uint256 acceptedL2BlockRangeLength = uint256(bytes32(callbackData));
bytes[] memory values = verifier.getStorageValues(
addr,
commands,
constants,
proof,
l2BlockRangeAccepted
acceptedL2BlockRangeLength
);
if (values.length != commands.length) {
revert ResponseLengthMismatch(values.length, commands.length);
Expand Down
2 changes: 1 addition & 1 deletion packages/linea-state-verifier/contracts/IEVMVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ interface IEVMVerifier {
bytes32[] memory commands,
bytes[] memory constants,
bytes memory proof,
uint256 l2BlockRangeAccepted
uint256 acceptedL2BlockRangeLength
) external view returns (bytes[] memory values);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract LineaSparseProofVerifier is IEVMVerifier {
bytes32[] memory commands,
bytes[] memory constants,
bytes memory proof,
uint256 l2BlockRangeAccepted
uint256 acceptedL2BlockRangeLength
) external view returns (bytes[] memory values) {
(
uint256 blockNo,
Expand All @@ -40,9 +40,9 @@ contract LineaSparseProofVerifier is IEVMVerifier {
// Check that the L2 block number used is a recent one and is part of the range accepted
uint256 currentL2BlockNumber = IRollup(_rollup).currentL2BlockNumber();
require(
(currentL2BlockNumber <= l2BlockRangeAccepted &&
(currentL2BlockNumber <= acceptedL2BlockRangeLength &&
blockNo <= currentL2BlockNumber) ||
blockNo >= currentL2BlockNumber - l2BlockRangeAccepted,
blockNo >= currentL2BlockNumber - acceptedL2BlockRangeLength,
"LineaSparseProofVerifier: block not in range accepted"
);

Expand Down
Loading