Skip to content

Commit 98bb247

Browse files
rach-idrootulp
andauthored
feat: add square size field to data root tuple (#145)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview As per the decision in #142, we need to add the block size to the data root tuple. <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [ ] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [ ] Linked issues closed with keywords --------- Co-authored-by: Rootul P <[email protected]>
1 parent 5edb590 commit 98bb247

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

src/DataRootTuple.sol

+2
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ struct DataRootTuple {
1111
uint256 height;
1212
// Data root.
1313
bytes32 dataRoot;
14+
// Celestia block original square size.
15+
uint256 squareSize;
1416
}

src/test/QuantumGravityBridge.t.sol

+15-12
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ contract RelayerTest is DSTest {
9595
}
9696

9797
/*
98-
the values used in the verify attestation test are in the format `<height padded to 32 bytes || data root>`, which
99-
represent an encoded `abi.encode(DataRootTuple)`:
100-
101-
0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
102-
0x00000000000000000000000000000000000000000000000000000000000000010101010101010101010101010101010101010101010101010101010101010101
103-
0x00000000000000000000000000000000000000000000000000000000000000020202020202020202020202020202020202020202020202020202020202020202
104-
0x00000000000000000000000000000000000000000000000000000000000000030303030303030303030303030303030303030303030303030303030303030303
98+
the values used in the verify attestation test are in the format
99+
`<height padded to 32 bytes || data root || original square size padded to 32 bytes>`,
100+
which represent an encoded `abi.encode(DataRootTuple)`:
101+
102+
0x000000000000000000000000000000000000000000000000000000000000000101010101010101010101010101010101010101010101010101010101010101010000000000000000000000000000000000000000000000000000000000000020
103+
0x000000000000000000000000000000000000000000000000000000000000000202020202020202020202020202020202020202020202020202020202020202020000000000000000000000000000000000000000000000000000000000000020
104+
0x000000000000000000000000000000000000000000000000000000000000000303030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000040
105+
0x000000000000000000000000000000000000000000000000000000000000000404040404040404040404040404040404040404040404040404040404040404040000000000000000000000000000000000000000000000000000000000000040
105106
*/
106107
function testVerifyAttestation() public {
107108
uint256 initialVelsetNonce = 0;
@@ -110,15 +111,16 @@ contract RelayerTest is DSTest {
110111
// commitment to a set of roots.
111112
// these values were generated using the tendermint implementation of binary merkle trees:
112113
// https://github.com/celestiaorg/celestia-core/blob/60310e7aa554bb76b735a010847a6613bcfe06e8/crypto/merkle/proof.go#L33-L48
113-
bytes32 newTupleRoot = 0x82dc1607d84557d3579ce602a45f5872e821c36dbda7ec926dfa17ebc8d5c013;
114+
bytes32 newTupleRoot = 0x3db8fb64a10316e447733af826165d0543b94b9de3b4146dcad70611f5089018;
114115
// a data root committed to by the above tuple root.
115-
bytes32 newTuple = 0x0101010101010101010101010101010101010101010101010101010101010101;
116+
bytes32 newTuple = 0x0202020202020202020202020202020202020202020202020202020202020202;
116117
// the height of the data root.
117-
uint256 height = 1;
118+
uint256 height = 2;
119+
uint256 squareSize = 32;
118120
// the binary merkle proof of the data root to the data root tuple root.
119121
bytes32[] memory sideNodes = new bytes32[](2);
120-
sideNodes[0] = 0x98ce42deef51d40269d542f5314bef2c7468d401ad5d85168bfab4c0108f75f7;
121-
sideNodes[1] = 0x575664048c9e64260eca2304d177b11d1566d0c954f1417fc76a4f9f27350063;
122+
sideNodes[0] = 0x1ce3b03bea51b24a60e147396ced1b7eec566129aa43ed98c5b5060b937b4ea8;
123+
sideNodes[1] = 0x9e7df00a432e3c8c7ec9177f9581d43a6d837a5a05467f6ce5d730fe3c4467d7;
122124
BinaryMerkleProof memory newTupleProof;
123125
newTupleProof.sideNodes = sideNodes;
124126
newTupleProof.key = 1;
@@ -143,6 +145,7 @@ contract RelayerTest is DSTest {
143145
DataRootTuple memory t;
144146
t.height = height;
145147
t.dataRoot = newTuple;
148+
t.squareSize = squareSize;
146149

147150
// verify that the tuple was committed to
148151
bool committedTo = bridge.verifyAttestation(nonce, t, newTupleProof);

0 commit comments

Comments
 (0)