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 all 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
34 changes: 17 additions & 17 deletions packages/linea-ens-resolver/contracts/L1Resolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract L1Resolver is
uint256 constant VERSIONABLE_HASHES_SLOT = 3;
uint256 constant VERSIONABLE_TEXTS_SLOT = 10;
// To check how old is the value/proof returned and is in the acceptable range
uint256 constant L2_BLOCK_RANGE_ACCEPTED = 86400;
uint256 constant ACCEPTED_L2_BLOCK_RANGE_LENGTH = 86400;
string public graphqlUrl;

event TargetSet(bytes name, address target);
Expand Down Expand Up @@ -94,6 +94,18 @@ contract L1Resolver is
l2ChainId = _l2ChainId;
}

/**
* @dev inherits from EVMFetchTarget
*/
function getAcceptedL2BlockRangeLength()
public
pure
override
returns (uint256)
{
return ACCEPTED_L2_BLOCK_RANGE_LENGTH;
}

/**
* Set target address to verify against
* @param name The encoded name to query.
Expand Down Expand Up @@ -209,10 +221,7 @@ contract L1Resolver is
.ref(0)
.element(node)
.element(COIN_TYPE_ETH)
.fetch(
this.addrCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
); // recordVersions
.fetch(this.addrCallback.selector, ""); // recordVersions
}

function addrCallback(
Expand All @@ -235,10 +244,7 @@ contract L1Resolver is
.ref(0)
.element(node)
.element(coinType)
.fetch(
this.addrCoinTypeCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.addrCoinTypeCallback.selector, "");
}

function addrCoinTypeCallback(
Expand All @@ -261,10 +267,7 @@ contract L1Resolver is
.ref(0)
.element(node)
.element(key)
.fetch(
this.textCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.textCallback.selector, "");
}

function textCallback(
Expand All @@ -285,10 +288,7 @@ contract L1Resolver is
.getDynamic(VERSIONABLE_HASHES_SLOT)
.ref(0)
.element(node)
.fetch(
this.contenthashCallback.selector,
abi.encode(L2_BLOCK_RANGE_ACCEPTED)
);
.fetch(this.contenthashCallback.selector, "");
}

function contenthashCallback(
Expand Down
16 changes: 14 additions & 2 deletions packages/linea-ens-resolver/test/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,16 @@ export const proofTest = {
};

export const extraDataTest =
"0x0000000000000000000000000b306bf915c4d645ff596e518faf3f9669b9701600000000000000000000000028f15b034f9744d43548ac64dce04ed77bdbd83200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000000";
"0x0000000000000000000000000b306bf915c4d645ff596e518faf3f9669b9701600000000000000000000000028f15b034f9744d43548ac64dce04ed77bdbd83200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000015180";

export const wrongExtraData =
"0x0000000000000000000000000b306bf915c4d645ff596e518faf3f9669b9701600000000000000000000000028f15b034f9744d43548ac64dce04ed77bdbd83100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000000";
"0x0000000000000000000000000b306bf915c4d645ff596e518faf3f9669b9701600000000000000000000000028f15b034f9744d43548ac64dce04ed77bdbd83100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000015180";

export const extraDataWithLongCallBackData =
"0x0000000000000000000000000b306bf915c4d645ff596e518faf3f9669b9701600000000000000000000000028f15b034f9744d43548ac64dce04ed77bdbd83200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000151801231242aef3450";

export const extraDataWithShortCallBackData =
"0x0000000000000000000000000b306bf915c4d645ff596e518faf3f9669b9701600000000000000000000000028f15b034f9744d43548ac64dce04ed77bdbd83200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000015180";

export const commandsTest = [
"0x000001ff00000000000000000000000000000000000000000000000000000000",
Expand All @@ -190,3 +196,9 @@ export const constantsTest = [
"0xbebd415b7c88e97082bae6b4e3ba6bd83b660b8620cd7f90d99c8564f6e8da9b",
"0x000000000000000000000000000000000000000000000000000000000000003c",
];

export const retValueTest =
"f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000015180";

export const retValueLongTest =
"f470901a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000002000001ff000000000000000000000000000000000000000000000000000000000102200304ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e4922000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000020e312102006c30788eb679837a67baf80dc450ee6bb8ee493b14b16250d3e49220000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000151801231242aef345000000000000000000000000000000000000000000000000000";
Loading
Loading