blobstream-contracts 0.0.1-security → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of blobstream-contracts might be problematic. Click here for more details.
- package/.codecov.yml +51 -0
- package/.github/CODEOWNERS +7 -0
- package/.github/dependabot.yml +18 -0
- package/.github/workflows/code-analysis.yml +41 -0
- package/.github/workflows/contract-inheritance-check.yml +28 -0
- package/.github/workflows/go-check.yml +25 -0
- package/.github/workflows/labels.yml +19 -0
- package/.github/workflows/lint.yml +37 -0
- package/.github/workflows/tests.yml +72 -0
- package/.gitmodules +12 -0
- package/.golangci.yml +64 -0
- package/.markdownlint.yaml +5 -0
- package/.markdownlint.yml +4 -0
- package/.markdownlintignore +1 -0
- package/.prettierrc.json +11 -0
- package/LICENSE +201 -0
- package/Makefile +18 -0
- package/README.md +102 -5
- package/docs/inclusion-proofs.md +69 -0
- package/foundry.toml +4 -0
- package/go.mod +34 -0
- package/go.sum +212 -0
- package/hardhat.config.ts +46 -0
- package/index.js +43 -0
- package/package.json +31 -3
- package/remappings.txt +6 -0
- package/scripts/Dockerfile_Environment +39 -0
- package/scripts/deploy.ts +12 -0
- package/scripts/gen.sh +34 -0
- package/scripts/upgradability_check.sh +22 -0
- package/slither.config.json +3 -0
- package/src/Blobstream.sol +366 -0
- package/src/Constants.sol +10 -0
- package/src/DataRootTuple.sol +15 -0
- package/src/IDAOracle.sol +18 -0
- package/src/lib/tree/Constants.sol +23 -0
- package/src/lib/tree/Types.sol +37 -0
- package/src/lib/tree/Utils.sol +106 -0
- package/src/lib/tree/binary/BinaryMerkleMultiproof.sol +12 -0
- package/src/lib/tree/binary/BinaryMerkleProof.sol +12 -0
- package/src/lib/tree/binary/BinaryMerkleTree.sol +256 -0
- package/src/lib/tree/binary/TreeHasher.sol +23 -0
- package/src/lib/tree/binary/test/BinaryMerkleTree.t.sol +365 -0
- package/src/lib/tree/binary/test/TreeHasher.t.sol +40 -0
- package/src/lib/tree/namespace/NamespaceMerkleMultiproof.sol +14 -0
- package/src/lib/tree/namespace/NamespaceMerkleProof.sol +14 -0
- package/src/lib/tree/namespace/NamespaceMerkleTree.sol +306 -0
- package/src/lib/tree/namespace/NamespaceNode.sol +23 -0
- package/src/lib/tree/namespace/TreeHasher.sol +69 -0
- package/src/lib/tree/namespace/test/NamespaceMerkleMultiproof.t.sol +108 -0
- package/src/lib/tree/namespace/test/NamespaceMerkleTree.t.sol +644 -0
- package/src/lib/tree/namespace/test/TreeHasher.t.sol +66 -0
- package/src/lib/tree/test/Utils.t.sol +48 -0
- package/src/lib/tree/test/blob.dat +0 -0
- package/src/lib/tree/test/header.dat +0 -0
- package/src/lib/tree/test/proofs.json +1 -0
- package/src/lib/verifier/DAVerifier.sol +328 -0
- package/src/lib/verifier/test/DAVerifier.t.sol +396 -0
- package/src/lib/verifier/test/RollupInclusionProofs.t.sol +589 -0
- package/src/test/Blobstream.t.sol +200 -0
- package/src/test/BlobstreamBenchmark.t.sol +137 -0
- package/tsconfig.json +11 -0
- package/wrappers/Blobstream.sol/wrapper.go +1325 -0
- package/wrappers/ERC1967Proxy.sol/wrapper.go +668 -0
@@ -0,0 +1,589 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.22;
|
3
|
+
|
4
|
+
import "openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol";
|
5
|
+
|
6
|
+
import "../../../Constants.sol";
|
7
|
+
import "../../../DataRootTuple.sol";
|
8
|
+
import "../DAVerifier.sol";
|
9
|
+
import "../../../Blobstream.sol";
|
10
|
+
import "../../tree/binary/BinaryMerkleProof.sol";
|
11
|
+
import "../../tree/namespace/NamespaceMerkleMultiproof.sol";
|
12
|
+
import "../../tree/Types.sol";
|
13
|
+
|
14
|
+
import "ds-test/test.sol";
|
15
|
+
|
16
|
+
interface CheatCodes {
|
17
|
+
function addr(uint256 privateKey) external returns (address);
|
18
|
+
|
19
|
+
function sign(uint256 privateKey, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
|
20
|
+
}
|
21
|
+
|
22
|
+
/// @notice A span sequence defines the location of the rollup transaction data
|
23
|
+
/// inside the Celestia block.
|
24
|
+
/// For this tutorial, we will be posting the rollup data to a single block. Thus, all
|
25
|
+
/// we will need is the height, the index and the length of the data.
|
26
|
+
/// This can be generalized to multiple Celestia blocks.
|
27
|
+
struct SpanSequence {
|
28
|
+
// Celestia block height where the rollup data was posted.
|
29
|
+
uint256 height;
|
30
|
+
// Index of the first share containing the rollup transaction data
|
31
|
+
// inside the Celestia block
|
32
|
+
uint256 index;
|
33
|
+
// Number of shares that the rollup transaction data spans on.
|
34
|
+
uint256 length;
|
35
|
+
}
|
36
|
+
|
37
|
+
/// @notice A rollup header is a simple example of the fields a Celestium header
|
38
|
+
/// would contain.
|
39
|
+
struct RollupHeader {
|
40
|
+
// The rollup state root.
|
41
|
+
bytes32 stateRoot;
|
42
|
+
// The reference to the position of the rollup block inside
|
43
|
+
// the Celestia block.
|
44
|
+
SpanSequence sequence;
|
45
|
+
}
|
46
|
+
|
47
|
+
/// @notice a rollup transaction is a simple transfer transaction in the Rollup.
|
48
|
+
struct RollupTransaction {
|
49
|
+
address from;
|
50
|
+
address to;
|
51
|
+
uint256 amount;
|
52
|
+
}
|
53
|
+
|
54
|
+
/*
|
55
|
+
The data used to generate the Celestia proofs:
|
56
|
+
==============================================
|
57
|
+
|
58
|
+
Original data square:
|
59
|
+
=====================
|
60
|
+
|
61
|
+
The block used contains four shares. In row major order:
|
62
|
+
// PFB share
|
63
|
+
0x0000000000000000000000000000000000000000000000000000000004010000015c00000026da020ace020aa0010a9d010a202f63656c65737469612e626c6f622e76312e4d7367506179466f72426c6f627312790a2f63656c657374696131666e796e676c6175766a6c677472706e306c7a37793864346a67786339703775336e676e7735121d00000000000000000000000000000000000000121312324243243288991a0297022220adf9685b533f637df3943da5baf78310b673afd705f76fb67936889885a137da42010012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2102ef3c3faf700de2c13a40afc24aa17caebf2bb3a4213831682a5d359f7ba8f39f12040a020801180112130a0d0a04757469611205323130303010d0e80c1a40bec3bdabdcb154f9115e85384ad100ca1acca881b0851c078cbc16365f6ab05a591f2954e4a42da5334d7598b9c0132103c633b97e6d8e61996311be24839f6f1201011a04494e4458000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
64
|
+
// blob share
|
65
|
+
0x00000000000000000000000000000000000000121312324243243288990100000117283078623130393742314439393239623837336641304132413830383134313339446231323838323932362c3078623130393742314439393239623837336641304132413830383134313339446231323838323932372c313030293b283078623130393742314439393239623837336641304132413830383134313339446231323838323932362c3078623130393742314439393239623837336641304132413830383134313339446231323838323932382c3230303030293b283078623130393742314439393239623837336641304132413830383134313339446231323838323932362c3078623130393742314439393239623837336641304132413830383134313339446231323838323932392c31303030302900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
66
|
+
// tail padding share
|
67
|
+
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffe010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
68
|
+
// tail padding share
|
69
|
+
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffe010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
70
|
+
|
71
|
+
Extended data square:
|
72
|
+
=====================
|
73
|
+
|
74
|
+
The extended block contains 16 shares. In row major order:
|
75
|
+
0x0000000000000000000000000000000000000000000000000000000004010000015c00000026da020ace020aa0010a9d010a202f63656c65737469612e626c6f622e76312e4d7367506179466f72426c6f627312790a2f63656c657374696131666e796e676c6175766a6c677472706e306c7a37793864346a67786339703775336e676e7735121d00000000000000000000000000000000000000121312324243243288991a0297022220adf9685b533f637df3943da5baf78310b673afd705f76fb67936889885a137da42010012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2102ef3c3faf700de2c13a40afc24aa17caebf2bb3a4213831682a5d359f7ba8f39f12040a020801180112130a0d0a04757469611205323130303010d0e80c1a40bec3bdabdcb154f9115e85384ad100ca1acca881b0851c078cbc16365f6ab05a591f2954e4a42da5334d7598b9c0132103c633b97e6d8e61996311be24839f6f1201011a04494e4458000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
76
|
+
0x00000000000000000000000000000000000000121312324243243288990100000117283078623130393742314439393239623837336641304132413830383134313339446231323838323932362c3078623130393742314439393239623837336641304132413830383134313339446231323838323932372c313030293b283078623130393742314439393239623837336641304132413830383134313339446231323838323932362c3078623130393742314439393239623837336641304132413830383134313339446231323838323932382c3230303030293b283078623130393742314439393239623837336641304132413830383134313339446231323838323932362c3078623130393742314439393239623837336641304132413830383134313339446231323838323932392c31303030302900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
77
|
+
0x00000000000000000000000000000000000000292b291daba93e1ddcfa01000001f8391ebb849b1f15a6aa18e712157e129b0708e1645def6ed550ec00eeebe1e101d88f81fcd9e3c1e2d1fae2f4f74c6ae1da2ad5af015ce0e6ecd557e9ea32665cde5ced5decd5dae4e3ecd7d6646932ead131dd3aef35cbecdde013d41bd59769ece8db36902ea211111d119f13151f95aa1eaa1daa131e131c2f24243e4b750632477e23107a16260af60ee5cbc13255d2377437556a04402f6f51e691a7865f63de32487a40593325761f1d28e319c319f4372e03e0ebdacfe7fd004558dcd8d9e0b5d853efd73232bee838014761e345ec6a2808170b15b83a36ee5914b1a939f55da5fb75d3f4e90f635a0280315b01cb3e735e53807daea41aab18a92c1d282410141b1f6957e6e2281e323c333f1d269db61520d375bb7742887cdc9139d85c2bec8000bd3eb240527f5c310c5a743521dbf87fd6d43312dca34b1c482ce0cb6e79b9381702b62c79ccf45bff6dfe39751a5362f53b03033e0eeee2e6d7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
78
|
+
0x000000000000000000000000000000000000003b383b2fe9ea1a2f546701000001b3112ec3c0702d265fea23032a26d12af31f10b16770ba5c9378b51eb4b6bab21c97facd8098bca9b1918ebbaa855867b299019be71f7bbcb3bb9f41b8bc3066739773b870b59094bfbbba909d506533b4933e963bb9368dba95b3039f0490dc65bab69534c002e628282f28fd2b222cf3eb2eeb2feb2b2e2b2d090605354d541332f7df0b2bdf22281a2395bca0ab3a749e80d933c2e991fb08ea440876e34371ed973cf1d6f4cb3dbb562f2f02bc21aa218a11031cb3b4998bb3a61e5e48949894b8d99a72b59e323eeabb3e1c7155b14fbb52021b251b23663530054b2861503b87cb5587f89f223415e0c714fa317712af39d547c344d1dae120e822e90c2c02062e2822225841beb102233234313601077d6e290abacb78cae954cd88682886d913a6510077247ee8d3cfd92d0bd6c823178492cf8c8d2c3b8847ef31ed1fadbef6c0792b3601701fc0b299d59ef49d28cb3ed0fd9a290202240aa7aca28f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
79
|
+
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffe010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
80
|
+
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffe010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
81
|
+
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffe010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
82
|
+
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffe010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
83
|
+
0x616161616161616161616161616161616161616161616161616161616d01000003d90000001b870104b30104450304630304141dfef1f7f1c4c8faff1efdf7f5fd1ec92d1ee0c4f0d2ffc0e7f5c7e9f7f5fdc43bc0041dfef1f7f1c4c8faff2df3f6c0f6f0f7ffcbc9f8f7f0c8c7c6f62ef7c222c02bf220f8f0c3fe28c622cb2cf6f0f6ca233b32000000000000000000000000000000000000003b383b2fe9ea1a2f546d3e01670115144d91f9d5d027fece956526487b9b533a70c44c8f0d9bf570c021546e5c462287e903003bf004d204e704331dfef5c4f4f5c41efec7c0c6c8f51ec4f1fec62f2321fb2d1ed2cbfdeff1c03b16041701a425274cc608acba2ae84cb8ec46cd4f76137d4b172b2df910da2362c14095623b0e040105033f033b380408040ecbc8faff3b0d2f2d2e2e2e3a83a80b3ee875bb7742887cdc9139d85c2bec8000bd3eb240527f5c310c5a743521dbf87fd6d43312dca34b1c482ce0cb6e79b9381702b62c79ccf45bff6dfe39751a5362f53b03033e0eeee2e6d7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
84
|
+
0x616161616161616161616161616161616161615a595a4e888b7b4e350e0100000336112ec3fd2d2e2822e92de628282f28fd2b222cf3eb2eeb2feb2b2e2b2d202d2c28e6fd2d2f2b2b2f282f211f2ec3fd2d2e2822e92de628282f28fd2b222cf3eb2eeb2feb2b2e2b2d202d2c28e6fd2d2f2b2b2f282f221f2d2e2e1229112ec3fd2d2e2822e92de628282f28fd2b222cf3eb2eeb2feb2b2e2b2d202d2c28e6fd2d2f2b2b2f282f211f2ec3fd2d2e2822e92de628282f28fd2b222cf3eb2eeb2feb2b2e2b2d202d2c28e6fd2d2f2b2b2f282f2b1f2f2e2e2e2e1229112ec3fd2d2e2822e92de628282f28fd2b222cf3eb2eeb2feb2b2e2b2d202d2c28e6fd2d2f2b2b2f282f211f2ec3fd2d2e2822e92de628282f28fd2b222cf3eb2eeb2feb2b2e2b2d202d2c28e6fd2d2f2b2b2f282f281f2d2e2e2e2e1200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
85
|
+
0x616161616161616161616161616161616161617372735323224553e9f001000003922830785f6c33374a413fa13b37cc3b6c0c05aef2daa4f68ed2a600a7aaaeae038658529c85afbaac8093ac999be3f8ae87108e4c03d9ada2a68edeaba92ff3d989d9a5daa68e87a3afa68f8cf2fa2fa9802d8b2aa423bea68bad388d3d8e67faa6a884216b1e443939323962383733664130413241383038311d1a1a24efcb0f2fe4cc163ac2351b04980aa0beba2fdf8222c822dff80ee81df5d1a268495edbfe892fedc2e8d42c19c9333211af3cbb3c99221e02adaa87b0a19f00e5d7888685ad7286d0a48f2f2f75a82b03e4ffafe5a6f811053607377a2a21a7d4347c43289ada4890cb8199ab09fed601512dd503be24c4d8d051ce4f4b3e423f431f32111a3a343d33fadea2ac11302f252c27321b6370371481cb78cae954cd88682886d913a6510077247ee8d3cfd92d0bd6c823178492cf8c8d2c3b8847ef31ed1fadbef6c0792b3601701fc0b299d59ef49d28cb3ed0fd9a290202240aa7aca28f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
86
|
+
0x61616161616161616161616161616161616161484a487ccac85f7cbd93010000037d391ebbb9c61c1bdba91602101b801095333a7cf0c67bd969c3723071707b7e316793b1516e74437c685b78415cd7f07e6d036ca133c1747d7862eb7a742ef3c467c47ac6726b6576787b6b63d2f12c71692464297921597b667d02620e6b88f17b706620b901a211111d119f13151f95aa1eaa1daa131e131c060f0d23e0dc382f9b8a07138a15113e16667445422ac86151852cb8ab689005a9e605c9afeac5a56725948c99be2678dd1d1d0174174117553902317d716d567d4a30d8ed656e657a856fc772612f24a9782431c5df7ce178d3013d193d16f3232e0def11ffd2295dbedf5d9262152037adb534932dca3b4c288ee4bbe68087ae14a815ab0b1f010f1e111515d7eb757c01162f202d21030ccef612047bbec3bdabdcb154f9115e85384ad100ca1acca881b0851c078cbc16365f6ab05a591f2954e4a42da5334d7598b9c0132103c633b97e6d8e61996311be24839f6f1201011a04494e4458000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
87
|
+
0x9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9701000002850000003d5d030e7d030ee5020efe020e34329d949b94b7bc939e309f9b9a9f30bf1c30adb797829eb9a19ab5ab9b9a9fb729b90e329d949b94b7bc939e1c9598b998979b9ebebf929b97bcb5b6981e9bb815b91396149297bb9d11b615be1f989798bd16292f00000000000000000000000000000000000000292b291daba93e1ddcf42403f0033734e068918e83189db366f11bedc16cd02ac6b7e358086c9ac6b917dcf6d9e7155dab020029970e820ea10e2c329d9ab7999ab7309db5b9b6bc9a30b7949db61d1617901c3082be9fa494b929350e36034b1918e3b6054e7b10a8e37aa6e7b1e1c938ceef36131c913a8716fdbae866fd290a0e030d022702292b0e050e0abebc939e29081d1c1e1e1e2a53400724a8cb78cae954cd88682886d913a6510077247ee8d3cfd92d0bd6c823178492cf8c8d2c3b8847ef31ed1fadbef6c0792b3601701fc0b299d59ef49d28cb3ed0fd9a290202240aa7aca28f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
88
|
+
0x9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9eb7b5b7833537a08342690100000221391ebb9f1c1e1115ab1ca211111d119f13151f95aa1eaa1daa131e131c141c1f11a29f1c1d13131d111d17331ebb9f1c1e1115ab1ca211111d119f13151f95aa1eaa1daa131e131c141c1f11a29f1c1d13131d111d15331c1e1e3b12391ebb9f1c1e1115ab1ca211111d119f13151f95aa1eaa1daa131e131c141c1f11a29f1c1d13131d111d17331ebb9f1c1e1115ab1ca211111d119f13151f95aa1eaa1daa131e131c141c1f11a29f1c1d13131d111d13331d1e1e1e1e3b12391ebb9f1c1e1115ab1ca211111d119f13151f95aa1eaa1daa131e131c141c1f11a29f1c1d13131d111d17331ebb9f1c1e1115ab1ca211111d119f13151f95aa1eaa1daa131e131c141c1f11a29f1c1d13131d111d11331c1e1e1e1e3b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
89
|
+
0x9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9ea5a6a5b1777484b1caf4010000026a112ec3dbf72c22eceb27462922b229f70b0d4f96874b985b824a0049414f4f025ed7d3605c4c7b4e51694e6d6caf924f5d3a5be302854d444a5b8942431d9585578548874a5b5d474c4a585a96931d43511c56104b16754a564d2b59265bf0934a405f17fb30e628282f28fd2b222cf3eb2eeb2feb2b2e2b2d323e3e1aa4be091da3b2352ab8233d0e6e0445757b1d8a5015bc158a920aa8329a8044f9eed8849d571da5b8a88d1f3cbf2c2f394c2578256d1530014d415d7f466200a08f545e5c4dc75e834b581d1dcb401302a39e4ca04a92390d210c22c21017498d20cdea116f87ed6bbe526d42069d8c03d11c8e02751ab78683d1b3e1ef24e927ea332f393e2a20262c9389444e392e1d191f182f3dfec6223452bec3bdabdcb154f9115e85384ad100ca1acca881b0851c078cbc16365f6ab05a591f2954e4a42da5334d7598b9c0132103c633b97e6d8e61996311be24839f6f1201011a04494e4458000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
90
|
+
0x9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e8c8d8cacdcddbaac160a01000002ce28307879b6313d844335013a3d513a662c2acd97b6c185fabbc72ec5c6c1cc2df0697cd1f6c8eacdf9d5c3ebd98f97ccf402f7462cbac8cec3fdaac2c81e95b7f0b7c2b6c7fbf1c9c3c1fbfe82941fc5fa1af212c017d4c1f3ce01fd0afb5494c1c6f3147903443939323962383733664130413241383038310f090816ad882b1d6c550c385537392435f3c8e5e910bcffd15c1f7a42f96b0d43a20dbf4ca9b448f019655a6d751bc38b323203c836eb36df28012dcec5f4ddceec2e86a5f1f6f1c25cf5b5c7ff1d1a43c31a2db48acdaec38103263c263595161e08a4399e8212da758ada6afd3714224d7220691cbd29e3115ba378a2515d4f3440374207330309303937378faacbcd03351d141c17020bb3983b0ec175bb7742887cdc9139d85c2bec8000bd3eb240527f5c310c5a743521dbf87fd6d43312dca34b1c482ce0cb6e79b9381702b62c79ccf45bff6dfe39751a5362f53b03033e0eeee2e6d7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
91
|
+
|
92
|
+
The row roots:
|
93
|
+
==============
|
94
|
+
|
95
|
+
1. 0x00000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000012131232424324328899eca190450f1424f4c96f50142cae150261466dcf4d47fb52b5e1cccef047f2fe
|
96
|
+
2. 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffe94ddc2da7e01f575f757fbb4fa42ba202d51a576b609a8aeb114fd226c6e7372
|
97
|
+
3. 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff33622135c2a12b0e5b3f67fd2cdacddbd58b88abbe67a9ce42e456bb88e137c7
|
98
|
+
4. 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc096faf6ef0b9f1d3439d619b29bbd4b810825e80b658ed1fa7525220dc796b0
|
99
|
+
|
100
|
+
The column roots:
|
101
|
+
=================
|
102
|
+
|
103
|
+
1. 0x0000000000000000000000000000000000000000000000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffe43e76fdc8b119c62dd02c197ad666b5c00ccc4736bf34573c9bd995558a2cf0d
|
104
|
+
2. 0x0000000000000000000000000000000000000012131232424324328899fffffffffffffffffffffffffffffffffffffffffffffffffffffffffe37a4e02492e5c60e661b531861ae3f45cf4d6ae5237bab37d857b39763373556
|
105
|
+
3. 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff215bd7509274803c556914e2a4b840826bb8b7d94de9344dfb2c2b0e71ba2d26
|
106
|
+
4. 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff35543dab513d606fd51dddbecce5a0ff86d5a5a4b1e081e6fb9afeeaa36ff6
|
107
|
+
|
108
|
+
The data root: 0xb9b0d94eae45e56a551e9415701bec462b18329d2a42bcce3e37a22a2ca83a6f
|
109
|
+
|
110
|
+
The height: 21
|
111
|
+
|
112
|
+
The blocks data roots used to create the commitment:
|
113
|
+
21. 0xb9b0d94eae45e56a551e9415701bec462b18329d2a42bcce3e37a22a2ca83a6f
|
114
|
+
22. 0x3d96b7d238e7e0456f6af8e7cdf0a67bd6cf9c2089ecb559c659dcaa1f880353
|
115
|
+
23. 0x3d96b7d238e7e0456f6af8e7cdf0a67bd6cf9c2089ecb559c659dcaa1f880353
|
116
|
+
24. 0x3d96b7d238e7e0456f6af8e7cdf0a67bd6cf9c2089ecb559c659dcaa1f880353
|
117
|
+
|
118
|
+
The nonce: 2
|
119
|
+
|
120
|
+
The data root tuple root: 0xd149f160dec348d8582b8c2629c91fab8189b8dca205c4c01bb378f2f5450c3b
|
121
|
+
*/
|
122
|
+
|
123
|
+
/*
|
124
|
+
The rollup state:
|
125
|
+
=================
|
126
|
+
|
127
|
+
We assume that the rollup state is comprised of the following key-values:
|
128
|
+
|
129
|
+
| key | value |
|
130
|
+
|--------------------------------------------|-------|
|
131
|
+
| 0xb1097B1D9929b873fA0A2A80814139Db12882926 | 20100 |
|
132
|
+
| 0xb1097B1D9929b873fA0A2A80814139Db12882927 | 10000 |
|
133
|
+
|
134
|
+
Where the key is the EVM address of an account, and the value is its balance.
|
135
|
+
*/
|
136
|
+
|
137
|
+
/*
|
138
|
+
The rollup transactions:
|
139
|
+
========================
|
140
|
+
|
141
|
+
We will define the rollup transfer transactions as follows:
|
142
|
+
{
|
143
|
+
address from;
|
144
|
+
address to;
|
145
|
+
uint256 amount;
|
146
|
+
}
|
147
|
+
|
148
|
+
And we will encode them, to be sent to a Celestia block as follows: (from, to, amount).
|
149
|
+
|
150
|
+
Example transaction:
|
151
|
+
(0xb1097B1D9929b873fA0A2A80814139Db12882926,0xb1097B1D9929b873fA0A2A80814139Db12882927,100)
|
152
|
+
which sends 100 balance from the 0xb1097B1D9929b873fA0A2A80814139Db12882926 account to
|
153
|
+
the 0xb1097B1D9929b873fA0A2A80814139Db12882927 account.
|
154
|
+
|
155
|
+
For this tutorial, the rollup block, which will be submitted to Celestia, will contain the following transactions:
|
156
|
+
- (0xb1097B1D9929b873fA0A2A80814139Db12882926,0xb1097B1D9929b873fA0A2A80814139Db12882927,100)
|
157
|
+
- (0xb1097B1D9929b873fA0A2A80814139Db12882926,0xb1097B1D9929b873fA0A2A80814139Db12882928,20000)
|
158
|
+
- (0xb1097B1D9929b873fA0A2A80814139Db12882926,0xb1097B1D9929b873fA0A2A80814139Db12882929,10000)
|
159
|
+
|
160
|
+
Given the above state, the third transaction should fail because the 0xb1097B1D9929b873fA0A2A80814139Db12882926 account
|
161
|
+
won't have anymore balance left after the first two transactions.
|
162
|
+
|
163
|
+
Also, if you look at the above raw shares, and take the blob share and convert it from its hex representation
|
164
|
+
to ASCII, you will see the above transactions there.
|
165
|
+
*/
|
166
|
+
|
167
|
+
/*
|
168
|
+
Tests overview:
|
169
|
+
===============
|
170
|
+
|
171
|
+
Given the above setup, we will prove the following inside the tests:
|
172
|
+
|
173
|
+
1. We will create an invalid header, which points to a sequence of spans outside of a Celestia block, and prove
|
174
|
+
that that transaction data is missing.
|
175
|
+
|
176
|
+
2. We will create another invalid header, which points to the correct location of the transaction data in the
|
177
|
+
Celestia block, and prove that the third transaction, as defined above, is invalid.
|
178
|
+
|
179
|
+
For the other cases, where the inclusion proof is invalid:
|
180
|
+
|
181
|
+
- The data is available and was committed to in the Celestia block. That is intrinsically verified in the second test.
|
182
|
+
Since checking the state comes after verifying that the data is available.
|
183
|
+
|
184
|
+
- The data is available, and also all the state transitions are valid, i.e. the transactions posted are valid.
|
185
|
+
This verification is just changing the conclusion of the second test, given a different state.
|
186
|
+
|
187
|
+
Thus, there is no need to add more tests for these scenarios and only keep the first ones.
|
188
|
+
|
189
|
+
Note: We will not be generating the rollup state root for this test to test against it, we will leave that
|
190
|
+
to be defined by rollups depending on how they handle their state.
|
191
|
+
*/
|
192
|
+
|
193
|
+
contract RollupInclusionProofTest is DSTest {
|
194
|
+
// Private keys used for test signatures.
|
195
|
+
uint256 constant testPriv1 = 0x64a1d6f0e760a8d62b4afdde4096f16f51b401eaaecc915740f71770ea76a8ad;
|
196
|
+
|
197
|
+
Blobstream bridge;
|
198
|
+
TestFixture fixture;
|
199
|
+
|
200
|
+
Validator[] private validators;
|
201
|
+
uint256 private votingPower = 5000;
|
202
|
+
|
203
|
+
// Set up Foundry cheatcodes.
|
204
|
+
CheatCodes cheats = CheatCodes(HEVM_ADDRESS);
|
205
|
+
|
206
|
+
// deploy a Blobstream contract and submit the following:
|
207
|
+
// - initial valset.
|
208
|
+
// - data root tuple root that commits to the proofs tested below.
|
209
|
+
function setUp() public {
|
210
|
+
uint256 initialValsetNonce = 1;
|
211
|
+
|
212
|
+
validators.push(Validator(cheats.addr(testPriv1), votingPower));
|
213
|
+
bytes32 hash = computeValidatorSetHash(validators);
|
214
|
+
bytes32 checkpoint = domainSeparateValidatorSetHash(initialValsetNonce, (2 * votingPower) / 3, hash);
|
215
|
+
bridge = new Blobstream();
|
216
|
+
bridge.initialize(initialValsetNonce, (2 * votingPower) / 3, checkpoint);
|
217
|
+
|
218
|
+
fixture = new TestFixture();
|
219
|
+
|
220
|
+
bytes32 newDataRootTupleRoot =
|
221
|
+
domainSeparateDataRootTupleRoot(fixture.dataRootTupleRootNonce(), fixture.dataRootTupleRoot());
|
222
|
+
|
223
|
+
// Signature for the update.
|
224
|
+
Signature[] memory sigs = new Signature[](1);
|
225
|
+
bytes32 digest_eip191 = ECDSA.toEthSignedMessageHash(newDataRootTupleRoot);
|
226
|
+
(uint8 v, bytes32 r, bytes32 s) = cheats.sign(testPriv1, digest_eip191);
|
227
|
+
sigs[0] = Signature(v, r, s);
|
228
|
+
|
229
|
+
Validator[] memory valSet = new Validator[](1);
|
230
|
+
valSet[0] = Validator(cheats.addr(testPriv1), votingPower);
|
231
|
+
|
232
|
+
bridge.submitDataRootTupleRoot(
|
233
|
+
fixture.dataRootTupleRootNonce(), initialValsetNonce, fixture.dataRootTupleRoot(), valSet, sigs
|
234
|
+
);
|
235
|
+
|
236
|
+
assertEq(bridge.state_eventNonce(), fixture.dataRootTupleRootNonce());
|
237
|
+
assertEq(bridge.state_dataRootTupleRoots(fixture.dataRootTupleRootNonce()), fixture.dataRootTupleRoot());
|
238
|
+
|
239
|
+
DataRootTuple memory _tuple;
|
240
|
+
_tuple.height = fixture.height();
|
241
|
+
_tuple.dataRoot = fixture.dataRoot();
|
242
|
+
|
243
|
+
assertTrue(bridge.verifyAttestation(fixture.dataRootTupleRootNonce(), _tuple, fixture.getDataRootTupleProof()));
|
244
|
+
}
|
245
|
+
|
246
|
+
// test case 1: a rollup header pointing to data that was not published to Celestia.
|
247
|
+
function testUnavailableData() public {
|
248
|
+
// let's create an arbitrary span that is out of bounds of the target Celestia block.
|
249
|
+
uint256 height = 21;
|
250
|
+
uint256 startIndex = 0;
|
251
|
+
uint256 length = 10;
|
252
|
+
SpanSequence memory sequence = SpanSequence(height, startIndex, length);
|
253
|
+
// an invalid header that points to data that don't exist in the target Celestia block.
|
254
|
+
RollupHeader memory header =
|
255
|
+
RollupHeader(0x215bd7509274803c556914e2a4b840826bb8b7d94de9344dfb2c2b0e71ba2d26, sequence);
|
256
|
+
|
257
|
+
// let's first calculate the square size of the Celestia block referenced in the header
|
258
|
+
// Note: the square size can also be computed from the shares proof.
|
259
|
+
(uint256 squareSize, DAVerifier.ErrorCodes error) =
|
260
|
+
DAVerifier.computeSquareSizeFromRowProof(fixture.getRowRootToDataRootProof());
|
261
|
+
assertEq(uint8(error), uint8(DAVerifier.ErrorCodes.NoError));
|
262
|
+
assertEq(fixture.squareSize(), squareSize);
|
263
|
+
|
264
|
+
// let's authenticate the row proof to the data root tuple root to be sure that
|
265
|
+
// the square size is valid.
|
266
|
+
AttestationProof memory attestationProof = AttestationProof(
|
267
|
+
fixture.dataRootTupleRootNonce(), fixture.getDataRootTuple(), fixture.getDataRootTupleProof()
|
268
|
+
);
|
269
|
+
bool success;
|
270
|
+
(success, error) = DAVerifier.verifyRowRootToDataRootTupleRoot(
|
271
|
+
bridge, fixture.getFirstRowRootNode(), fixture.getRowRootToDataRootProof(), attestationProof
|
272
|
+
);
|
273
|
+
assertTrue(success);
|
274
|
+
assertEq(uint8(error), uint8(DAVerifier.ErrorCodes.NoError));
|
275
|
+
|
276
|
+
// Now, we're sure that the proof is valid and the square size is valid,
|
277
|
+
// we can compare the square size against the sequence referenced in the rollup
|
278
|
+
// header to see if the data exists.
|
279
|
+
uint256 endIndex = header.sequence.index + header.sequence.length;
|
280
|
+
// This checks that indeed the data referenced in the header is out of bounds of the square.
|
281
|
+
// Thus the data doesn't exist => unavailable.
|
282
|
+
assertTrue(!(squareSize >= endIndex));
|
283
|
+
}
|
284
|
+
|
285
|
+
// test case 2: a rollup header pointing to available data that is invalid.
|
286
|
+
function testInvalidData() public {
|
287
|
+
// let's create the sequence span of the rollup data in the Celestia block.
|
288
|
+
uint256 height = 21;
|
289
|
+
uint256 startIndex = 1;
|
290
|
+
uint256 length = 1;
|
291
|
+
SpanSequence memory sequence = SpanSequence(height, startIndex, length);
|
292
|
+
// a header that points to the rollup data posted in Celestia.
|
293
|
+
RollupHeader memory header =
|
294
|
+
RollupHeader(0x215bd7509274803c556914e2a4b840826bb8b7d94de9344dfb2c2b0e71ba2d26, sequence);
|
295
|
+
|
296
|
+
// let's first calculate the square size of the Celestia block referenced in the header
|
297
|
+
uint256 squareSize = DAVerifier.computeSquareSizeFromShareProof(fixture.getShareToRowRootProof());
|
298
|
+
assertEq(fixture.squareSize(), squareSize);
|
299
|
+
|
300
|
+
// let's create the share to data root tuple root proof to be able to validate the square
|
301
|
+
// size and the data.
|
302
|
+
SharesProof memory shareProof;
|
303
|
+
bytes[] memory data = new bytes[](1);
|
304
|
+
data[0] = fixture.shareData();
|
305
|
+
shareProof.data = data;
|
306
|
+
NamespaceMerkleMultiproof[] memory shareToRowRootProof = new NamespaceMerkleMultiproof[](1);
|
307
|
+
shareToRowRootProof[0] = fixture.getShareToRowRootProof();
|
308
|
+
shareProof.shareProofs = shareToRowRootProof;
|
309
|
+
shareProof.namespace = fixture.getNamespace();
|
310
|
+
NamespaceNode[] memory rowRoots = new NamespaceNode[](1);
|
311
|
+
rowRoots[0] = fixture.getFirstRowRootNode();
|
312
|
+
shareProof.rowRoots = rowRoots;
|
313
|
+
BinaryMerkleProof[] memory rowProofs = new BinaryMerkleProof[](1);
|
314
|
+
rowProofs[0] = fixture.getRowRootToDataRootProof();
|
315
|
+
shareProof.rowProofs = rowProofs;
|
316
|
+
shareProof.attestationProof = AttestationProof(
|
317
|
+
fixture.dataRootTupleRootNonce(), fixture.getDataRootTuple(), fixture.getDataRootTupleProof()
|
318
|
+
);
|
319
|
+
|
320
|
+
// let's authenticate the share proof to the data root tuple root to be sure that
|
321
|
+
// the square size is valid.
|
322
|
+
(bool success, DAVerifier.ErrorCodes error) = DAVerifier.verifySharesToDataRootTupleRoot(bridge, shareProof);
|
323
|
+
assertTrue(success);
|
324
|
+
assertEq(uint8(error), uint8(DAVerifier.ErrorCodes.NoError));
|
325
|
+
|
326
|
+
// Now, we're sure that the proof is valid and the square size is valid,
|
327
|
+
// we can compare the square size against the sequence referenced in the rollup
|
328
|
+
// header to see if the data exists.
|
329
|
+
uint256 endIndex = header.sequence.index + header.sequence.length;
|
330
|
+
// This checks that indeed the data referenced in the header is part of the Celestia
|
331
|
+
// block, i.e. the sequence of spans in not out of the block's bounds.
|
332
|
+
assertTrue(squareSize >= endIndex);
|
333
|
+
|
334
|
+
// The last step is to prove that the share is part of the rollup data
|
335
|
+
// referenced in the rollup header.
|
336
|
+
// To do so, we will use the proof, already authenticated above, to get the index,
|
337
|
+
// Then, we will compare it against the spans sequence.
|
338
|
+
|
339
|
+
// since we're using nmt multiproofs, we have a begin key and an end key of the shares
|
340
|
+
// proven. However, in our case, we're only proving a single share.
|
341
|
+
// Thus, we can take the begin key as the index.
|
342
|
+
// Note: In the case of multiple shares in the proof, we will need to check all the shares
|
343
|
+
// if they're part of the sequence of spans. Then, only use the ones that are part of it.
|
344
|
+
uint256 shareIndexInRow = shareProof.shareProofs[0].beginKey;
|
345
|
+
uint256 shareIndexInRowMajorOrder =
|
346
|
+
shareIndexInRow + shareProof.rowProofs[0].numLeaves * shareProof.rowProofs[0].key;
|
347
|
+
|
348
|
+
// check if the share is part of the sequence of spans
|
349
|
+
assertTrue(header.sequence.index <= shareIndexInRowMajorOrder);
|
350
|
+
assertTrue(shareIndexInRowMajorOrder <= endIndex);
|
351
|
+
|
352
|
+
// At this level we can parse the share to get the transactions, and compare them to
|
353
|
+
// the rollup state. Then, we would be able to know if there is an invalid transaction
|
354
|
+
// or not.
|
355
|
+
// As explained in the test overview at the beginning of the file, the third transaction
|
356
|
+
// is an invalid transaction.
|
357
|
+
// For the sake of simplicity, we will not parse the shares as that is rollup
|
358
|
+
// specific.
|
359
|
+
}
|
360
|
+
|
361
|
+
function computeValidatorSetHash(Validator[] memory _validators) private pure returns (bytes32) {
|
362
|
+
return keccak256(abi.encode(_validators));
|
363
|
+
}
|
364
|
+
|
365
|
+
function domainSeparateValidatorSetHash(uint256 _nonce, uint256 _powerThreshold, bytes32 _validatorSetHash)
|
366
|
+
private
|
367
|
+
pure
|
368
|
+
returns (bytes32)
|
369
|
+
{
|
370
|
+
bytes32 c =
|
371
|
+
keccak256(abi.encode(VALIDATOR_SET_HASH_DOMAIN_SEPARATOR, _nonce, _powerThreshold, _validatorSetHash));
|
372
|
+
|
373
|
+
return c;
|
374
|
+
}
|
375
|
+
|
376
|
+
function domainSeparateDataRootTupleRoot(uint256 _nonce, bytes32 _dataRootTupleRoot)
|
377
|
+
private
|
378
|
+
pure
|
379
|
+
returns (bytes32)
|
380
|
+
{
|
381
|
+
bytes32 c = keccak256(abi.encode(DATA_ROOT_TUPLE_ROOT_DOMAIN_SEPARATOR, _nonce, _dataRootTupleRoot));
|
382
|
+
|
383
|
+
return c;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
/// @title TestFixture contains the necessary information to create proofs for the blob
|
388
|
+
/// that was posted to Celestia. It represents the data mentioned in the comment at
|
389
|
+
/// the beginning of this file.
|
390
|
+
contract TestFixture {
|
391
|
+
/// @notice the share containing the blob that was published to Celestia.
|
392
|
+
bytes public shareData = abi.encodePacked(
|
393
|
+
hex"0000000000000000000000000000000000000012131232424324328899010000",
|
394
|
+
hex"0117283078623130393742314439393239623837336641304132413830383134",
|
395
|
+
hex"313339446231323838323932362c307862313039374231443939323962383733",
|
396
|
+
hex"6641304132413830383134313339446231323838323932372c313030293b2830",
|
397
|
+
hex"7862313039374231443939323962383733664130413241383038313431333944",
|
398
|
+
hex"6231323838323932362c30786231303937423144393932396238373366413041",
|
399
|
+
hex"32413830383134313339446231323838323932382c3230303030293b28307862",
|
400
|
+
hex"3130393742314439393239623837336641304132413830383134313339446231",
|
401
|
+
hex"323838323932362c307862313039374231443939323962383733664130413241",
|
402
|
+
hex"3830383134313339446231323838323932392c31303030302900000000000000",
|
403
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
404
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
405
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
406
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
407
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
408
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000"
|
409
|
+
);
|
410
|
+
|
411
|
+
/// @notice the first EDS row root.
|
412
|
+
bytes public firstRowRoot = abi.encodePacked(
|
413
|
+
hex"00000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000012131232424324328899eca190450f1424f4c96f50142cae150261466dcf4d47fb52b5e1cccef047f2fe"
|
414
|
+
);
|
415
|
+
|
416
|
+
/// @notice the second EDS row root.
|
417
|
+
bytes public secondRowRoot = abi.encodePacked(
|
418
|
+
hex"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffffe94ddc2da7e01f575f757fbb4fa42ba202d51a576b609a8aeb114fd226c6e7372"
|
419
|
+
);
|
420
|
+
|
421
|
+
/// @notice the third EDS row root.
|
422
|
+
bytes public thirdRowRoot = abi.encodePacked(
|
423
|
+
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff33622135c2a12b0e5b3f67fd2cdacddbd58b88abbe67a9ce42e456bb88e137c7"
|
424
|
+
);
|
425
|
+
|
426
|
+
/// @notice the fourth EDS row root.
|
427
|
+
bytes public fourthRowRoot = abi.encodePacked(
|
428
|
+
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc096faf6ef0b9f1d3439d619b29bbd4b810825e80b658ed1fa7525220dc796b0"
|
429
|
+
);
|
430
|
+
|
431
|
+
/// @notice the first EDS column root.
|
432
|
+
bytes public firstColumnRoot = abi.encodePacked(
|
433
|
+
hex"0000000000000000000000000000000000000000000000000000000004fffffffffffffffffffffffffffffffffffffffffffffffffffffffffe43e76fdc8b119c62dd02c197ad666b5c00ccc4736bf34573c9bd995558a2cf0d"
|
434
|
+
);
|
435
|
+
|
436
|
+
/// @notice the second EDS column root.
|
437
|
+
bytes public secondColumnRoot = abi.encodePacked(
|
438
|
+
hex"0000000000000000000000000000000000000012131232424324328899fffffffffffffffffffffffffffffffffffffffffffffffffffffffffe37a4e02492e5c60e661b531861ae3f45cf4d6ae5237bab37d857b39763373556"
|
439
|
+
);
|
440
|
+
|
441
|
+
/// @notice the third EDS column root.
|
442
|
+
bytes public thirdColumnRoot = abi.encodePacked(
|
443
|
+
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff215bd7509274803c556914e2a4b840826bb8b7d94de9344dfb2c2b0e71ba2d26"
|
444
|
+
);
|
445
|
+
|
446
|
+
/// @notice the fourth EDS column root.
|
447
|
+
bytes public fourthColumnRoot = abi.encodePacked(
|
448
|
+
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff35543dab513d606fd51dddbecce5a0ff86d5a5a4b1e081e6fb9afeeaa36ff6"
|
449
|
+
);
|
450
|
+
|
451
|
+
/// @notice the data root of the block containing the submitted blob.
|
452
|
+
bytes32 public dataRoot = 0xb9b0d94eae45e56a551e9415701bec462b18329d2a42bcce3e37a22a2ca83a6f;
|
453
|
+
|
454
|
+
/// @notice the height of the block containing the submitted blob.
|
455
|
+
uint256 public height = 21;
|
456
|
+
|
457
|
+
/// @notice the original square size of the block containing the submitted blob.
|
458
|
+
uint256 public squareSize = 2;
|
459
|
+
|
460
|
+
/// @notice the data root tuple root committing to the Celestia block.
|
461
|
+
bytes32 public dataRootTupleRoot = 0xd149f160dec348d8582b8c2629c91fab8189b8dca205c4c01bb378f2f5450c3b;
|
462
|
+
|
463
|
+
/// @notice the data root tuple root nonce in the Blobstream contract.
|
464
|
+
uint256 public dataRootTupleRootNonce = 2;
|
465
|
+
|
466
|
+
/// @notice the data root tuple to data root tuple root proof side nodes.
|
467
|
+
bytes32[] public dataRootProofSideNodes = [
|
468
|
+
bytes32(0x062f1c98fda4619e8ce92c39d1fa02dc68a880fdcf2c28c9ac31cf3abb1d6ab2),
|
469
|
+
bytes32(0x8aa95c4c4ef50468dc728d4e90a07560f1c0095d2df4491879e50ef96305751d)
|
470
|
+
];
|
471
|
+
|
472
|
+
/// @notice shares to row root proof side nodes.
|
473
|
+
NamespaceNode[] public shareToRowRootProofSideNodes = [
|
474
|
+
NamespaceNode(
|
475
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000004),
|
476
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000004),
|
477
|
+
0x2505b82d3c2a3f9262539478dd5f3257fcc452496f0c159c3bc5aae77e8f85ce
|
478
|
+
),
|
479
|
+
NamespaceNode(
|
480
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
481
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
482
|
+
0x9e80fef0ef39caacaa4e0f5b4ace155b42dd0ca70ecd72a047e68a5244a3c6fa
|
483
|
+
)
|
484
|
+
];
|
485
|
+
|
486
|
+
/// @notice row root to data root proof side nodes.
|
487
|
+
bytes32[] public rowRootToDataRootProofSideNodes = [
|
488
|
+
bytes32(0xba0a74b15f58344239a4e89847b45d39db30c257c1876a375e246c98c3666cab),
|
489
|
+
bytes32(0x89d6a174bb5327c792535cb769d388e5e5904ebdf2c650dc5ff2e1c90b5eb764),
|
490
|
+
bytes32(0x5e48d0e89322b5caac9925f7acf77621dc0b06844fef864a2ab92b108fae4101)
|
491
|
+
];
|
492
|
+
|
493
|
+
/// @notice the share's namespace.
|
494
|
+
function getNamespace() public pure returns (Namespace memory) {
|
495
|
+
return Namespace(0x00, 0x00000000000000000000000000000000000012131232424324328899);
|
496
|
+
}
|
497
|
+
|
498
|
+
/// @notice the data root tuple of the block containing the submitted blob.
|
499
|
+
function getDataRootTuple() public view returns (DataRootTuple memory) {
|
500
|
+
return DataRootTuple(height, dataRoot);
|
501
|
+
}
|
502
|
+
|
503
|
+
/// @notice the data root tuple to data root tuple root proof.
|
504
|
+
function getDataRootTupleProof() public view returns (BinaryMerkleProof memory) {
|
505
|
+
return BinaryMerkleProof(dataRootProofSideNodes, 0, 4);
|
506
|
+
}
|
507
|
+
|
508
|
+
/// @notice the first EDS row root.
|
509
|
+
function getFirstRowRootNode() public pure returns (NamespaceNode memory) {
|
510
|
+
return NamespaceNode(
|
511
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000004),
|
512
|
+
Namespace(0x00, 0x00000000000000000000000000000000000012131232424324328899),
|
513
|
+
0xeca190450f1424f4c96f50142cae150261466dcf4d47fb52b5e1cccef047f2fe
|
514
|
+
);
|
515
|
+
}
|
516
|
+
|
517
|
+
/// @notice the second EDS row root.
|
518
|
+
function getSecondRowRootNode() public pure returns (NamespaceNode memory) {
|
519
|
+
return NamespaceNode(
|
520
|
+
Namespace(0xff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffe),
|
521
|
+
Namespace(0xff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffe),
|
522
|
+
0x94ddc2da7e01f575f757fbb4fa42ba202d51a576b609a8aeb114fd226c6e7372
|
523
|
+
);
|
524
|
+
}
|
525
|
+
|
526
|
+
/// @notice the third EDS row root.
|
527
|
+
function getThirdRowRootNode() public pure returns (NamespaceNode memory) {
|
528
|
+
return NamespaceNode(
|
529
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
530
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
531
|
+
0x33622135c2a12b0e5b3f67fd2cdacddbd58b88abbe67a9ce42e456bb88e137c7
|
532
|
+
);
|
533
|
+
}
|
534
|
+
|
535
|
+
/// @notice the fourth EDS row root.
|
536
|
+
function getFourthRowRootNode() public pure returns (NamespaceNode memory) {
|
537
|
+
return NamespaceNode(
|
538
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
539
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
540
|
+
0xc096faf6ef0b9f1d3439d619b29bbd4b810825e80b658ed1fa7525220dc796b0
|
541
|
+
);
|
542
|
+
}
|
543
|
+
|
544
|
+
/// @notice the first EDS column root.
|
545
|
+
function getFirstColumnRootNode() public pure returns (NamespaceNode memory) {
|
546
|
+
return NamespaceNode(
|
547
|
+
Namespace(0xff, 0x00000000000000000000000000000000000000000000000000000004),
|
548
|
+
Namespace(0xff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffe),
|
549
|
+
0x43e76fdc8b119c62dd02c197ad666b5c00ccc4736bf34573c9bd995558a2cf0d
|
550
|
+
);
|
551
|
+
}
|
552
|
+
|
553
|
+
/// @notice the second EDS column root.
|
554
|
+
function getSecondColumnRootNode() public pure returns (NamespaceNode memory) {
|
555
|
+
return NamespaceNode(
|
556
|
+
Namespace(0x00, 0x00000000000000000000000000000000000012131232424324328899),
|
557
|
+
Namespace(0xff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffe),
|
558
|
+
0x37a4e02492e5c60e661b531861ae3f45cf4d6ae5237bab37d857b39763373556
|
559
|
+
);
|
560
|
+
}
|
561
|
+
|
562
|
+
/// @notice the third EDS column root.
|
563
|
+
function getThirdColumnRootNode() public pure returns (NamespaceNode memory) {
|
564
|
+
return NamespaceNode(
|
565
|
+
Namespace(0x00, 0x00000000000000000000000000000000000012131232424324328899),
|
566
|
+
Namespace(0xff, 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffe),
|
567
|
+
0x37a4e02492e5c60e661b531861ae3f45cf4d6ae5237bab37d857b39763373556
|
568
|
+
);
|
569
|
+
}
|
570
|
+
|
571
|
+
/// @notice the fourth EDS column root.
|
572
|
+
function getFourthColumnRootNode() public pure returns (NamespaceNode memory) {
|
573
|
+
return NamespaceNode(
|
574
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
575
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
576
|
+
0x215bd7509274803c556914e2a4b840826bb8b7d94de9344dfb2c2b0e71ba2d26
|
577
|
+
);
|
578
|
+
}
|
579
|
+
|
580
|
+
/// @notice shares to row root proof.
|
581
|
+
function getShareToRowRootProof() public view returns (NamespaceMerkleMultiproof memory) {
|
582
|
+
return NamespaceMerkleMultiproof(1, 2, shareToRowRootProofSideNodes);
|
583
|
+
}
|
584
|
+
|
585
|
+
/// @notice row root to data root proof.
|
586
|
+
function getRowRootToDataRootProof() public view returns (BinaryMerkleProof memory) {
|
587
|
+
return BinaryMerkleProof(rowRootToDataRootProofSideNodes, 0, 8);
|
588
|
+
}
|
589
|
+
}
|