blobstream-contracts 0.0.1-security → 3.1.0
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 +40 -0
- package/package.json +29 -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,396 @@
|
|
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
|
+
/*
|
23
|
+
The data used to generate the proof:
|
24
|
+
|
25
|
+
The block used contains a single share:
|
26
|
+
0x0000000000000000000000000000000000000000000000000000000001010000014500000026c3020a95010a92010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412720a2f63656c657374696131746b376c776a77336676616578657770687237687833333472766b67646b736d636537666b66122f63656c65737469613167616b61646d63386a73667873646c676e6d64643867773736346739796165776e32726d386d1a0e0a0475746961120631303030303012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103f3e16481ff7c9c2a677f08a30a887e5f9c14313cb624b8c5f7f955d143c81d9212040a020801180112130a0d0a04757469611205323230303010d0e80c1a4068f074601f1bb923f6d6e69d2e3fc3af145c9252eceeb0ac4fba9f661ca0428326f0080478cc969129c0074c3d97ae925de34c5f9d98a458cd47a565a2bb08cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
27
|
+
|
28
|
+
The extended block is:
|
29
|
+
0x0000000000000000000000000000000000000000000000000000000001010000014500000026c3020a95010a92010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412720a2f63656c657374696131746b376c776a77336676616578657770687237687833333472766b67646b736d636537666b66122f63656c65737469613167616b61646d63386a73667873646c676e6d64643867773736346739796165776e32726d386d1a0e0a0475746961120631303030303012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103f3e16481ff7c9c2a677f08a30a887e5f9c14313cb624b8c5f7f955d143c81d9212040a020801180112130a0d0a04757469611205323230303010d0e80c1a4068f074601f1bb923f6d6e69d2e3fc3af145c9252eceeb0ac4fba9f661ca0428326f0080478cc969129c0074c3d97ae925de34c5f9d98a458cd47a565a2bb08cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
30
|
+
0x0000000000000000000000000000000000000000000000000000000001010000014500000026c3020a95010a92010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412720a2f63656c657374696131746b376c776a77336676616578657770687237687833333472766b67646b736d636537666b66122f63656c65737469613167616b61646d63386a73667873646c676e6d64643867773736346739796165776e32726d386d1a0e0a0475746961120631303030303012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103f3e16481ff7c9c2a677f08a30a887e5f9c14313cb624b8c5f7f955d143c81d9212040a020801180112130a0d0a04757469611205323230303010d0e80c1a4068f074601f1bb923f6d6e69d2e3fc3af145c9252eceeb0ac4fba9f661ca0428326f0080478cc969129c0074c3d97ae925de34c5f9d98a458cd47a565a2bb08cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
31
|
+
0x0000000000000000000000000000000000000000000000000000000001010000014500000026c3020a95010a92010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412720a2f63656c657374696131746b376c776a77336676616578657770687237687833333472766b67646b736d636537666b66122f63656c65737469613167616b61646d63386a73667873646c676e6d64643867773736346739796165776e32726d386d1a0e0a0475746961120631303030303012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103f3e16481ff7c9c2a677f08a30a887e5f9c14313cb624b8c5f7f955d143c81d9212040a020801180112130a0d0a04757469611205323230303010d0e80c1a4068f074601f1bb923f6d6e69d2e3fc3af145c9252eceeb0ac4fba9f661ca0428326f0080478cc969129c0074c3d97ae925de34c5f9d98a458cd47a565a2bb08cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
32
|
+
0x0000000000000000000000000000000000000000000000000000000001010000014500000026c3020a95010a92010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e6412720a2f63656c657374696131746b376c776a77336676616578657770687237687833333472766b67646b736d636537666b66122f63656c65737469613167616b61646d63386a73667873646c676e6d64643867773736346739796165776e32726d386d1a0e0a0475746961120631303030303012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103f3e16481ff7c9c2a677f08a30a887e5f9c14313cb624b8c5f7f955d143c81d9212040a020801180112130a0d0a04757469611205323230303010d0e80c1a4068f074601f1bb923f6d6e69d2e3fc3af145c9252eceeb0ac4fba9f661ca0428326f0080478cc969129c0074c3d97ae925de34c5f9d98a458cd47a565a2bb08cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
33
|
+
|
34
|
+
The row roots:
|
35
|
+
0x00000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001787bf77b567506b6e1d0048bfd89edd352a4fbc102e62f07cc9fe6b4cbe5ee69
|
36
|
+
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7329c7d336d0140840837fc0d8eafa2403f4f6b019b602581cd9f04e28026eae
|
37
|
+
|
38
|
+
The column roots:
|
39
|
+
0x00000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001787bf77b567506b6e1d0048bfd89edd352a4fbc102e62f07cc9fe6b4cbe5ee69
|
40
|
+
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7329c7d336d0140840837fc0d8eafa2403f4f6b019b602581cd9f04e28026eae
|
41
|
+
|
42
|
+
The data root: 0x55cfc29fc0cd263906122d5cb859091224495b141fc0c51529612d7ab8962950
|
43
|
+
|
44
|
+
The height: 3
|
45
|
+
|
46
|
+
The blocks data roots used to create the commitment:
|
47
|
+
1. 0x3d96b7d238e7e0456f6af8e7cdf0a67bd6cf9c2089ecb559c659dcaa1f880353
|
48
|
+
2. 0x3d96b7d238e7e0456f6af8e7cdf0a67bd6cf9c2089ecb559c659dcaa1f880353
|
49
|
+
3. 0x55cfc29fc0cd263906122d5cb859091224495b141fc0c51529612d7ab8962950
|
50
|
+
4. 0x3d96b7d238e7e0456f6af8e7cdf0a67bd6cf9c2089ecb559c659dcaa1f880353
|
51
|
+
|
52
|
+
The nonce: 2
|
53
|
+
|
54
|
+
The data root tuple root: 0xf89859a09c0f2b1bbb039618d0fe60432b8c247f7ccde97814655f2acffb3434
|
55
|
+
*/
|
56
|
+
|
57
|
+
contract DAVerifierTest is DSTest {
|
58
|
+
// Private keys used for test signatures.
|
59
|
+
uint256 constant testPriv1 = 0x64a1d6f0e760a8d62b4afdde4096f16f51b401eaaecc915740f71770ea76a8ad;
|
60
|
+
|
61
|
+
Blobstream bridge;
|
62
|
+
TestFixture fixture;
|
63
|
+
|
64
|
+
Validator[] private validators;
|
65
|
+
uint256 private votingPower = 5000;
|
66
|
+
|
67
|
+
// Set up Foundry cheatcodes.
|
68
|
+
CheatCodes cheats = CheatCodes(HEVM_ADDRESS);
|
69
|
+
|
70
|
+
// deploy a Blobstream contract and submit the following:
|
71
|
+
// - initial valset.
|
72
|
+
// - data root tuple root that commits to the proofs tested below.
|
73
|
+
function setUp() public {
|
74
|
+
fixture = new TestFixture();
|
75
|
+
|
76
|
+
uint256 initialValsetNonce = 1;
|
77
|
+
|
78
|
+
validators.push(Validator(cheats.addr(testPriv1), votingPower));
|
79
|
+
bytes32 hash = computeValidatorSetHash(validators);
|
80
|
+
bytes32 checkpoint = domainSeparateValidatorSetHash(initialValsetNonce, (2 * votingPower) / 3, hash);
|
81
|
+
bridge = new Blobstream();
|
82
|
+
bridge.initialize(initialValsetNonce, (2 * votingPower) / 3, checkpoint);
|
83
|
+
|
84
|
+
bytes32 newDataRootTupleRoot =
|
85
|
+
domainSeparateDataRootTupleRoot(fixture.dataRootTupleRootNonce(), fixture.dataRootTupleRoot());
|
86
|
+
|
87
|
+
// Signature for the update.
|
88
|
+
Signature[] memory sigs = new Signature[](1);
|
89
|
+
bytes32 digest_eip191 = ECDSA.toEthSignedMessageHash(newDataRootTupleRoot);
|
90
|
+
(uint8 v, bytes32 r, bytes32 s) = cheats.sign(testPriv1, digest_eip191);
|
91
|
+
sigs[0] = Signature(v, r, s);
|
92
|
+
|
93
|
+
Validator[] memory valSet = new Validator[](1);
|
94
|
+
valSet[0] = Validator(cheats.addr(testPriv1), votingPower);
|
95
|
+
|
96
|
+
bridge.submitDataRootTupleRoot(
|
97
|
+
fixture.dataRootTupleRootNonce(), initialValsetNonce, fixture.dataRootTupleRoot(), valSet, sigs
|
98
|
+
);
|
99
|
+
|
100
|
+
assertEq(bridge.state_eventNonce(), fixture.dataRootTupleRootNonce());
|
101
|
+
assertEq(bridge.state_dataRootTupleRoots(fixture.dataRootTupleRootNonce()), fixture.dataRootTupleRoot());
|
102
|
+
|
103
|
+
assertTrue(
|
104
|
+
bridge.verifyAttestation(
|
105
|
+
fixture.dataRootTupleRootNonce(), fixture.getDataRootTuple(), fixture.getDataRootTupleProof()
|
106
|
+
)
|
107
|
+
);
|
108
|
+
}
|
109
|
+
|
110
|
+
function testVerifySharesToDataRootTupleRoot() public {
|
111
|
+
bytes[] memory _data = new bytes[](1);
|
112
|
+
_data[0] = fixture.shareData();
|
113
|
+
|
114
|
+
NamespaceMerkleMultiproof[] memory _shareProofs = new NamespaceMerkleMultiproof[](1);
|
115
|
+
_shareProofs[0] = fixture.getShareToRowRootProof();
|
116
|
+
|
117
|
+
NamespaceNode[] memory _rowRoots = new NamespaceNode[](1);
|
118
|
+
_rowRoots[0] = fixture.getFirstRowRootNode();
|
119
|
+
|
120
|
+
BinaryMerkleProof[] memory _rowProofs = new BinaryMerkleProof[](1);
|
121
|
+
_rowProofs[0] = fixture.getRowRootToDataRootProof();
|
122
|
+
|
123
|
+
AttestationProof memory attestationProof = AttestationProof(
|
124
|
+
fixture.dataRootTupleRootNonce(), fixture.getDataRootTuple(), fixture.getDataRootTupleProof()
|
125
|
+
);
|
126
|
+
SharesProof memory sharesProof =
|
127
|
+
SharesProof(_data, _shareProofs, fixture.getNamespace(), _rowRoots, _rowProofs, attestationProof);
|
128
|
+
|
129
|
+
(bool valid, DAVerifier.ErrorCodes errorCode) = DAVerifier.verifySharesToDataRootTupleRoot(bridge, sharesProof);
|
130
|
+
assertTrue(valid);
|
131
|
+
assertEq(uint8(errorCode), uint8(DAVerifier.ErrorCodes.NoError));
|
132
|
+
}
|
133
|
+
|
134
|
+
function testVerifyRowRootToDataRootTupleRoot() public {
|
135
|
+
AttestationProof memory attestationProof = AttestationProof(
|
136
|
+
fixture.dataRootTupleRootNonce(), fixture.getDataRootTuple(), fixture.getDataRootTupleProof()
|
137
|
+
);
|
138
|
+
|
139
|
+
(bool valid, DAVerifier.ErrorCodes errorCode) = DAVerifier.verifyRowRootToDataRootTupleRoot(
|
140
|
+
bridge, fixture.getFirstRowRootNode(), fixture.getRowRootToDataRootProof(), attestationProof
|
141
|
+
);
|
142
|
+
assertTrue(valid);
|
143
|
+
assertEq(uint8(errorCode), uint8(DAVerifier.ErrorCodes.NoError));
|
144
|
+
}
|
145
|
+
|
146
|
+
function testVerifyMultiRowRootsToDataRootTupleRoot() public {
|
147
|
+
NamespaceNode[] memory _rowRoots = new NamespaceNode[](1);
|
148
|
+
_rowRoots[0] = fixture.getFirstRowRootNode();
|
149
|
+
|
150
|
+
BinaryMerkleProof[] memory _rowProofs = new BinaryMerkleProof[](1);
|
151
|
+
_rowProofs[0] = fixture.getRowRootToDataRootProof();
|
152
|
+
|
153
|
+
AttestationProof memory attestationProof = AttestationProof(
|
154
|
+
fixture.dataRootTupleRootNonce(), fixture.getDataRootTuple(), fixture.getDataRootTupleProof()
|
155
|
+
);
|
156
|
+
|
157
|
+
(bool valid, DAVerifier.ErrorCodes errorCode) =
|
158
|
+
DAVerifier.verifyMultiRowRootsToDataRootTupleRoot(bridge, _rowRoots, _rowProofs, attestationProof);
|
159
|
+
assertTrue(valid);
|
160
|
+
assertEq(uint8(errorCode), uint8(DAVerifier.ErrorCodes.NoError));
|
161
|
+
}
|
162
|
+
|
163
|
+
function testComputeSquareSizeFromRowProof() public {
|
164
|
+
(bool validMerkleProof, BinaryMerkleTree.ErrorCodes error) =
|
165
|
+
BinaryMerkleTree.verify(fixture.dataRoot(), fixture.getRowRootToDataRootProof(), fixture.firstRowRoot());
|
166
|
+
assertEq(uint256(error), uint256(BinaryMerkleTree.ErrorCodes.NoError));
|
167
|
+
assertTrue(validMerkleProof);
|
168
|
+
|
169
|
+
// check that the computed square size is correct
|
170
|
+
uint256 expectedSquareSize = 1;
|
171
|
+
(uint256 actualSquareSize, DAVerifier.ErrorCodes errorCode) =
|
172
|
+
DAVerifier.computeSquareSizeFromRowProof(fixture.getRowRootToDataRootProof());
|
173
|
+
assertEq(actualSquareSize, expectedSquareSize);
|
174
|
+
assertEq(uint8(errorCode), uint8(DAVerifier.ErrorCodes.NoError));
|
175
|
+
}
|
176
|
+
|
177
|
+
function testComputeSquareSizeFromShareProof() public {
|
178
|
+
bytes[] memory _data = new bytes[](1);
|
179
|
+
_data[0] = fixture.shareData();
|
180
|
+
|
181
|
+
// check that the merkle proof is valid
|
182
|
+
bool validMerkleProof = NamespaceMerkleTree.verifyMulti(
|
183
|
+
fixture.getFirstRowRootNode(), fixture.getShareToRowRootProof(), fixture.getNamespace(), _data
|
184
|
+
);
|
185
|
+
assertTrue(validMerkleProof);
|
186
|
+
|
187
|
+
// check that the computed square size is correct
|
188
|
+
uint256 expectedSquareSize = 1;
|
189
|
+
uint256 actualSquareSize = DAVerifier.computeSquareSizeFromShareProof(fixture.getShareToRowRootProof());
|
190
|
+
assertEq(actualSquareSize, expectedSquareSize);
|
191
|
+
}
|
192
|
+
|
193
|
+
function testValidSlice() public {
|
194
|
+
bytes[] memory data = new bytes[](4);
|
195
|
+
data[0] = "a";
|
196
|
+
data[1] = "b";
|
197
|
+
data[2] = "c";
|
198
|
+
data[3] = "d";
|
199
|
+
|
200
|
+
(bytes[] memory result, DAVerifier.ErrorCodes error) = DAVerifier.slice(data, 1, 3);
|
201
|
+
|
202
|
+
assertEq(uint256(error), uint256(DAVerifier.ErrorCodes.NoError));
|
203
|
+
assertEq(string(result[0]), string(data[1]));
|
204
|
+
assertEq(string(result[1]), string(data[2]));
|
205
|
+
}
|
206
|
+
|
207
|
+
function testInvalidSliceBeginEnd() public {
|
208
|
+
bytes[] memory data = new bytes[](4);
|
209
|
+
data[0] = "a";
|
210
|
+
data[1] = "b";
|
211
|
+
data[2] = "c";
|
212
|
+
data[3] = "d";
|
213
|
+
|
214
|
+
(bytes[] memory result, DAVerifier.ErrorCodes error) = DAVerifier.slice(data, 2, 1);
|
215
|
+
|
216
|
+
assertEq(uint256(error), uint256(DAVerifier.ErrorCodes.InvalidRange));
|
217
|
+
}
|
218
|
+
|
219
|
+
function testOutOfBoundsSlice() public {
|
220
|
+
bytes[] memory data = new bytes[](4);
|
221
|
+
data[0] = "a";
|
222
|
+
data[1] = "b";
|
223
|
+
data[2] = "c";
|
224
|
+
data[3] = "d";
|
225
|
+
|
226
|
+
(bytes[] memory result, DAVerifier.ErrorCodes error) = DAVerifier.slice(data, 2, 5);
|
227
|
+
assertEq(uint256(error), uint256(DAVerifier.ErrorCodes.OutOfBoundsRange));
|
228
|
+
|
229
|
+
(result, error) = DAVerifier.slice(data, 6, 8);
|
230
|
+
assertEq(uint256(error), uint256(DAVerifier.ErrorCodes.OutOfBoundsRange));
|
231
|
+
}
|
232
|
+
|
233
|
+
function computeValidatorSetHash(Validator[] memory _validators) private pure returns (bytes32) {
|
234
|
+
return keccak256(abi.encode(_validators));
|
235
|
+
}
|
236
|
+
|
237
|
+
function domainSeparateValidatorSetHash(uint256 _nonce, uint256 _powerThreshold, bytes32 _validatorSetHash)
|
238
|
+
private
|
239
|
+
pure
|
240
|
+
returns (bytes32)
|
241
|
+
{
|
242
|
+
bytes32 c =
|
243
|
+
keccak256(abi.encode(VALIDATOR_SET_HASH_DOMAIN_SEPARATOR, _nonce, _powerThreshold, _validatorSetHash));
|
244
|
+
|
245
|
+
return c;
|
246
|
+
}
|
247
|
+
|
248
|
+
function domainSeparateDataRootTupleRoot(uint256 _nonce, bytes32 _dataRootTupleRoot)
|
249
|
+
private
|
250
|
+
pure
|
251
|
+
returns (bytes32)
|
252
|
+
{
|
253
|
+
bytes32 c = keccak256(abi.encode(DATA_ROOT_TUPLE_ROOT_DOMAIN_SEPARATOR, _nonce, _dataRootTupleRoot));
|
254
|
+
|
255
|
+
return c;
|
256
|
+
}
|
257
|
+
}
|
258
|
+
|
259
|
+
/// @title TestFixture contains the necessary information to create proofs for the token
|
260
|
+
/// transfer transaction that happened on Celestia. It represents the data mentioned in
|
261
|
+
/// the comment at the beginning of this file.
|
262
|
+
contract TestFixture {
|
263
|
+
/// @notice the share containing the token transfer transaction on Celestia.
|
264
|
+
bytes public shareData = abi.encodePacked(
|
265
|
+
hex"0000000000000000000000000000000000000000000000000000000001010000",
|
266
|
+
hex"014500000026c3020a95010a92010a1c2f636f736d6f732e62616e6b2e763162",
|
267
|
+
hex"657461312e4d736753656e6412720a2f63656c657374696131746b376c776a77",
|
268
|
+
hex"336676616578657770687237687833333472766b67646b736d636537666b6612",
|
269
|
+
hex"2f63656c65737469613167616b61646d63386a73667873646c676e6d64643867",
|
270
|
+
hex"773736346739796165776e32726d386d1a0e0a04757469611206313030303030",
|
271
|
+
hex"12670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b31",
|
272
|
+
hex"2e5075624b657912230a2103f3e16481ff7c9c2a677f08a30a887e5f9c14313c",
|
273
|
+
hex"b624b8c5f7f955d143c81d9212040a020801180112130a0d0a04757469611205",
|
274
|
+
hex"323230303010d0e80c1a4068f074601f1bb923f6d6e69d2e3fc3af145c9252ec",
|
275
|
+
hex"eeb0ac4fba9f661ca0428326f0080478cc969129c0074c3d97ae925de34c5f9d",
|
276
|
+
hex"98a458cd47a565a2bb08cc000000000000000000000000000000000000000000",
|
277
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
278
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
279
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
280
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000"
|
281
|
+
);
|
282
|
+
|
283
|
+
/// @notice the first EDS row root.
|
284
|
+
bytes public firstRowRoot = abi.encodePacked(
|
285
|
+
hex"00000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001787bf77b567506b6e1d0048bfd89edd352a4fbc102e62f07cc9fe6b4cbe5ee69"
|
286
|
+
);
|
287
|
+
|
288
|
+
/// @notice the second EDS row root.
|
289
|
+
bytes public secondRowRoot = abi.encodePacked(
|
290
|
+
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7329c7d336d0140840837fc0d8eafa2403f4f6b019b602581cd9f04e28026eae"
|
291
|
+
);
|
292
|
+
|
293
|
+
/// @notice the first EDS column root.
|
294
|
+
bytes public firstColumnRoot = abi.encodePacked(
|
295
|
+
hex"00000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000001787bf77b567506b6e1d0048bfd89edd352a4fbc102e62f07cc9fe6b4cbe5ee69"
|
296
|
+
);
|
297
|
+
|
298
|
+
/// @notice the second EDS column root.
|
299
|
+
bytes public secondColumnRoot = abi.encodePacked(
|
300
|
+
hex"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7329c7d336d0140840837fc0d8eafa2403f4f6b019b602581cd9f04e28026eae"
|
301
|
+
);
|
302
|
+
|
303
|
+
/// @notice the data root of the block containing the token transfer transaction.
|
304
|
+
bytes32 public dataRoot = 0x55cfc29fc0cd263906122d5cb859091224495b141fc0c51529612d7ab8962950;
|
305
|
+
|
306
|
+
/// @notice the height of the block containing the submitted token transfer transaction.
|
307
|
+
uint256 public height = 3;
|
308
|
+
|
309
|
+
/// @notice the data root tuple root committing to the Celestia block.
|
310
|
+
bytes32 public dataRootTupleRoot = 0xf89859a09c0f2b1bbb039618d0fe60432b8c247f7ccde97814655f2acffb3434;
|
311
|
+
|
312
|
+
/// @notice the data root tuple root nonce in the Blobstream contract.
|
313
|
+
uint256 public dataRootTupleRootNonce = 2;
|
314
|
+
|
315
|
+
/// @notice the data root tuple to data root tuple root proof side nodes.
|
316
|
+
bytes32[] public dataRootProofSideNodes = [
|
317
|
+
bytes32(0xb5d4d27ec6b206a205bf09dde3371ffba62e5b53d27bbec4255b7f4f27ef5d90),
|
318
|
+
bytes32(0x406e22ba94989ca721453057a1391fc531edb342c86a0ab4cc722276b54036ec)
|
319
|
+
];
|
320
|
+
|
321
|
+
/// @notice shares to data root proof side nodes.
|
322
|
+
NamespaceNode[] public shareToDataRootProofSideNodes = [
|
323
|
+
NamespaceNode(
|
324
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
325
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
326
|
+
0x0ec8148c743a4a4db384f40f487cae2fd1ca0d18442d1f162916bdf1cc61b679
|
327
|
+
)
|
328
|
+
];
|
329
|
+
|
330
|
+
/// @notice row root to data root proof side nodes.
|
331
|
+
bytes32[] public rowRootToDataRootProofSideNodes = [
|
332
|
+
bytes32(0x5bc0cf3322dd5c9141a2dcd76947882351690c9aec61015802efc6742992643f),
|
333
|
+
bytes32(0xff576381b02abadc50e414f6b4efcae31091cd40a5aba75f56be52d1bb2efcae)
|
334
|
+
];
|
335
|
+
|
336
|
+
/// @notice the share's namespace.
|
337
|
+
function getNamespace() public pure returns (Namespace memory) {
|
338
|
+
return Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000001);
|
339
|
+
}
|
340
|
+
|
341
|
+
/// @notice the data root tuple of the block containing the token transfer transaction.
|
342
|
+
function getDataRootTuple() public view returns (DataRootTuple memory) {
|
343
|
+
return DataRootTuple(height, dataRoot);
|
344
|
+
}
|
345
|
+
|
346
|
+
/// @notice the data root tuple to data root tuple root proof.
|
347
|
+
function getDataRootTupleProof() public view returns (BinaryMerkleProof memory) {
|
348
|
+
return BinaryMerkleProof(dataRootProofSideNodes, 2, 4);
|
349
|
+
}
|
350
|
+
|
351
|
+
/// @notice the first EDS row root.
|
352
|
+
function getFirstRowRootNode() public pure returns (NamespaceNode memory) {
|
353
|
+
return NamespaceNode(
|
354
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000001),
|
355
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000001),
|
356
|
+
0x787bf77b567506b6e1d0048bfd89edd352a4fbc102e62f07cc9fe6b4cbe5ee69
|
357
|
+
);
|
358
|
+
}
|
359
|
+
|
360
|
+
/// @notice the second EDS row root.
|
361
|
+
function getSecondRowRootNode() public pure returns (NamespaceNode memory) {
|
362
|
+
return NamespaceNode(
|
363
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
364
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
365
|
+
0x7329c7d336d0140840837fc0d8eafa2403f4f6b019b602581cd9f04e28026eae
|
366
|
+
);
|
367
|
+
}
|
368
|
+
|
369
|
+
/// @notice the first EDS column root.
|
370
|
+
function getFirstColumnRootNode() public pure returns (NamespaceNode memory) {
|
371
|
+
return NamespaceNode(
|
372
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000001),
|
373
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000001),
|
374
|
+
0x787bf77b567506b6e1d0048bfd89edd352a4fbc102e62f07cc9fe6b4cbe5ee69
|
375
|
+
);
|
376
|
+
}
|
377
|
+
|
378
|
+
/// @notice the second EDS column root.
|
379
|
+
function getSecondColumnRootNode() public pure returns (NamespaceNode memory) {
|
380
|
+
return NamespaceNode(
|
381
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
382
|
+
Namespace(0xff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff),
|
383
|
+
0x7329c7d336d0140840837fc0d8eafa2403f4f6b019b602581cd9f04e28026eae
|
384
|
+
);
|
385
|
+
}
|
386
|
+
|
387
|
+
/// @notice shares to row root proof.
|
388
|
+
function getShareToRowRootProof() public view returns (NamespaceMerkleMultiproof memory) {
|
389
|
+
return NamespaceMerkleMultiproof(0, 1, shareToDataRootProofSideNodes);
|
390
|
+
}
|
391
|
+
|
392
|
+
/// @notice row root to data root proof.
|
393
|
+
function getRowRootToDataRootProof() public view returns (BinaryMerkleProof memory) {
|
394
|
+
return BinaryMerkleProof(rowRootToDataRootProofSideNodes, 0, 4);
|
395
|
+
}
|
396
|
+
}
|