@corpus-core/colibri-stateless 0.1.0 → 0.1.1
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.
- package/README.md +1189 -0
- package/c4_logo.png +0 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,1189 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<img src="c4_logo.png" alt="C4 Logo" width="300"/>
|
|
4
|
+
|
|
5
|
+
# C4 (corpus core colibri client)
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
[](https://github.com/corpus-core/c4/actions/workflows/cmake-multi-platform.yml)
|
|
9
|
+
## Index
|
|
10
|
+
|
|
11
|
+
- [Index](#index)
|
|
12
|
+
- [Concept](#concept)
|
|
13
|
+
- [Updating the sync committee](#updating-the-sync-committee)
|
|
14
|
+
- [Verifying Blockhashes](#verifying-blockhashes)
|
|
15
|
+
- [Merkle Proofs](#merkle-proofs)
|
|
16
|
+
- [Patricia Merkle Proof](#patricia-merkle-proof)
|
|
17
|
+
- [SSZ Merkle Proof](#ssz-merkle-proof)
|
|
18
|
+
- [RPC Proofs](#rpc-proofs)
|
|
19
|
+
- [eth_getBalance](#eth_getbalance)
|
|
20
|
+
- [eth_getCode](#eth_getcode)
|
|
21
|
+
- [eth_getNonce](#eth_getnonce)
|
|
22
|
+
- [eth_getProof](#eth_getproof)
|
|
23
|
+
- [eth_getStorageAt](#eth_getstorageat)
|
|
24
|
+
- [eth_getTransactionReceipt](#eth_gettransactionreceipt)
|
|
25
|
+
- [eth_getTransactionByHash](#eth_gettransactionbyhash)
|
|
26
|
+
- [eth_getTransactionByBlockHashAndIndex](#eth_gettransactionbyblockhashandindex)
|
|
27
|
+
- [Building](#building)
|
|
28
|
+
- [Build Javascript bindings (WASM)](#build-javascript-bindings-(wasm))
|
|
29
|
+
- [CMake Options](#cmake-options)
|
|
30
|
+
- [SSZ Types](#ssz-types)
|
|
31
|
+
- [Attestation](#attestation)
|
|
32
|
+
- [AttestationData](#attestationdata)
|
|
33
|
+
- [AttesterSlashing](#attesterslashing)
|
|
34
|
+
- [BeaconBlock](#beaconblock)
|
|
35
|
+
- [BeaconBlockBody](#beaconblockbody)
|
|
36
|
+
- [BeaconBlockHeader](#beaconblockheader)
|
|
37
|
+
- [BlockHashProof](#blockhashproof)
|
|
38
|
+
- [BlsToExecutionChange](#blstoexecutionchange)
|
|
39
|
+
- [C4Request](#c4request)
|
|
40
|
+
- [Checkpoint](#checkpoint)
|
|
41
|
+
- [Deposit](#deposit)
|
|
42
|
+
- [DepositData](#depositdata)
|
|
43
|
+
- [Eth1Data](#eth1data)
|
|
44
|
+
- [EthAccessListData](#ethaccesslistdata)
|
|
45
|
+
- [EthAccountProof](#ethaccountproof)
|
|
46
|
+
- [EthLogsBlock](#ethlogsblock)
|
|
47
|
+
- [EthLogsTx](#ethlogstx)
|
|
48
|
+
- [EthReceiptData](#ethreceiptdata)
|
|
49
|
+
- [EthReceiptDataLog](#ethreceiptdatalog)
|
|
50
|
+
- [EthReceiptProof](#ethreceiptproof)
|
|
51
|
+
- [EthStateProof](#ethstateproof)
|
|
52
|
+
- [EthStorageProof](#ethstorageproof)
|
|
53
|
+
- [EthTransactionProof](#ethtransactionproof)
|
|
54
|
+
- [EthTxData](#ethtxdata)
|
|
55
|
+
- [ExecutionPayload](#executionpayload)
|
|
56
|
+
- [ExecutionPayloadHeader](#executionpayloadheader)
|
|
57
|
+
- [ForkData](#forkdata)
|
|
58
|
+
- [IndexAttestation](#indexattestation)
|
|
59
|
+
- [LightClientHeader](#lightclientheader)
|
|
60
|
+
- [LightClientUpdate](#lightclientupdate)
|
|
61
|
+
- [ProposerSlashing](#proposerslashing)
|
|
62
|
+
- [SignedBeaconBlock](#signedbeaconblock)
|
|
63
|
+
- [SignedBeaconBlockheader](#signedbeaconblockheader)
|
|
64
|
+
- [SignedBlsToExecutionChange](#signedblstoexecutionchange)
|
|
65
|
+
- [SignedVoluntaryExit](#signedvoluntaryexit)
|
|
66
|
+
- [SigningData](#signingdata)
|
|
67
|
+
- [SyncAggregate](#syncaggregate)
|
|
68
|
+
- [SyncCommittee](#synccommittee)
|
|
69
|
+
- [VoluntaryExit](#voluntaryexit)
|
|
70
|
+
- [Withdrawal](#withdrawal)
|
|
71
|
+
- [License](#license)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Concept
|
|
75
|
+
|
|
76
|
+
```mermaid
|
|
77
|
+
flowchart
|
|
78
|
+
P[Proofer] --> V[Verifier]
|
|
79
|
+
V --> P
|
|
80
|
+
P -.-> RPC
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The idea behind C4 is to create a ultra light client or better verifier which can be used in Websites, Mobile applications, but especially in embedded systems. The Proofer is a library which can used within you mobile app or in the backend to create Proof that the given data is valid. The Verifier is a library which can be used within the embedded system to verify this Proof.
|
|
84
|
+
|
|
85
|
+
The verifier itself is almost stateless and only needs to store the state of the sync committee, which changes every 27h. But with the latest sync committee the verifier is able to verify any proof with the signatures matching the previously verified public keys of the sync committee.
|
|
86
|
+
This allows independent Verification and security on any devices without the need to process every blockheader (as light clients usually would do).
|
|
87
|
+
|
|
88
|
+
### Updating the sync committee
|
|
89
|
+
|
|
90
|
+
A Sync Committee holds 512 validators signing every block. Every 27h the validators are updated. Since the verifier is passive, it will not activly sync. So whenever a proof is presented requiring a newer sync committee than the last state, it will tell it as part of the response to the proofer. The Proofer will then fetch the LightClientUpdates from any Beacon Chain API and push them to the verifier along with the Proof-Request. The verifier will then verify the LightClientUpdates and update the sync committee stored.
|
|
91
|
+
|
|
92
|
+
The Data in the [LightClientUpdate](#lightclientupdate) is used to verify the transition between two periods of the SyncCommittee. This is done oin 2 Steps:
|
|
93
|
+
|
|
94
|
+
1. calculate the SigningRoot by calculating the hash_tree_root of the new validator pubkeys and following the merkle proof down to the blockBodyRoot hash adn finally the SigningRoot
|
|
95
|
+
2. verify the BLS signature against the Signing Root as message and the aggregated pubkey of the old sync committee
|
|
96
|
+
|
|
97
|
+
The following diagram shows the Structure of the Merkle Tree leading to the SigningRoot:
|
|
98
|
+
|
|
99
|
+
```mermaid
|
|
100
|
+
flowchart BT
|
|
101
|
+
|
|
102
|
+
classDef noBorder fill:none,stroke:none;
|
|
103
|
+
subgraph "header"
|
|
104
|
+
Slot
|
|
105
|
+
proposerIndex
|
|
106
|
+
parentRoot
|
|
107
|
+
stateRoot
|
|
108
|
+
bodyRoot
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
subgraph "SigningData"
|
|
112
|
+
blockheaderhash
|
|
113
|
+
Domain
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
subgraph "BeaconState"
|
|
117
|
+
beacon_mode(" ... ")
|
|
118
|
+
current_sync_committee
|
|
119
|
+
next_sync_committee
|
|
120
|
+
inactivity_scores
|
|
121
|
+
finalized_checkpoint
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
class beacon_mode noBorder
|
|
125
|
+
|
|
126
|
+
subgraph "SyncCommittee"
|
|
127
|
+
pubkeys
|
|
128
|
+
aggregate_pubkey
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
subgraph "ValidatorPubKeys"
|
|
132
|
+
Val1["Val 1"]
|
|
133
|
+
Val1_a["[0..31]"]
|
|
134
|
+
Val1_b["[32..64]"]
|
|
135
|
+
Val2["Val 2"]
|
|
136
|
+
Val2_a["[0..31]"]
|
|
137
|
+
Val2_b["[32..48]"]
|
|
138
|
+
val_mode(" ... ")
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
class val_mode noBorder
|
|
142
|
+
|
|
143
|
+
blockheaderhash --> SigningRoot
|
|
144
|
+
Domain --> SigningRoot
|
|
145
|
+
4{4} --> blockheaderhash
|
|
146
|
+
5{5} --> blockheaderhash
|
|
147
|
+
8{8} --> 4
|
|
148
|
+
9{9} --> 4
|
|
149
|
+
10{10} --> 5
|
|
150
|
+
11{11} --> 5
|
|
151
|
+
Slot --> 8
|
|
152
|
+
proposerIndex --> 8
|
|
153
|
+
parentRoot --> 9
|
|
154
|
+
stateRoot --> 9
|
|
155
|
+
bodyRoot --> 10
|
|
156
|
+
21{"zero"} --> 10
|
|
157
|
+
22{"zero"} --> 11
|
|
158
|
+
23{"zero"} --> 11
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
38{38} --> stateRoot
|
|
162
|
+
39{39} --> stateRoot
|
|
163
|
+
|
|
164
|
+
76{76} --> 38
|
|
165
|
+
77{77} --> 38
|
|
166
|
+
78{78} --> 39
|
|
167
|
+
79{79} --> 39
|
|
168
|
+
|
|
169
|
+
156{156} -->78
|
|
170
|
+
157{157} -->78
|
|
171
|
+
|
|
172
|
+
158("...") --> 79
|
|
173
|
+
|
|
174
|
+
314{314} --> 157
|
|
175
|
+
315{315} --> 157
|
|
176
|
+
|
|
177
|
+
finalized_checkpoint --> 314
|
|
178
|
+
inactivity_scores --> 314
|
|
179
|
+
current_sync_committee --> 315
|
|
180
|
+
next_sync_committee --> 315
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
pubkeys --> next_sync_committee
|
|
184
|
+
aggregate_pubkey --> next_sync_committee
|
|
185
|
+
|
|
186
|
+
2524{2524} --> pubkeys
|
|
187
|
+
2525{2525} --> pubkeys
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
5048{5048} --> 2524
|
|
191
|
+
5049{5049} --> 2524
|
|
192
|
+
10096{10096} --> 5048
|
|
193
|
+
10097{10097} --> 5048
|
|
194
|
+
20192{20192} --> 10096
|
|
195
|
+
20193{20193} --> 10096
|
|
196
|
+
40384{40384} --> 20192
|
|
197
|
+
40385{40385} --> 20192
|
|
198
|
+
80768{80768} --> 40384
|
|
199
|
+
80769{80769} --> 40384
|
|
200
|
+
161536{161536} --> 80768
|
|
201
|
+
161537{161537} --> 80768
|
|
202
|
+
323072{323072} --> 161536
|
|
203
|
+
323073{323073} --> 161536
|
|
204
|
+
Val1 --> 323072
|
|
205
|
+
Val2 --> 323072
|
|
206
|
+
|
|
207
|
+
Val1_a --> Val1
|
|
208
|
+
Val1_b --> Val1
|
|
209
|
+
Val2_a --> Val2
|
|
210
|
+
Val2_b --> Val2
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class 158 noBorder
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
In order to validate, we need to calculate
|
|
218
|
+
- 512 x sha256 for each pubkey
|
|
219
|
+
- 512 x sha256 merkle proof for the pubkeys
|
|
220
|
+
- 2 x sha256 for the SyncCommittee
|
|
221
|
+
- 5 x sha256 for the stateRoot
|
|
222
|
+
- 3 x sha256 for the blockheader hash
|
|
223
|
+
- 1 x for the SigningRoot
|
|
224
|
+
|
|
225
|
+
So in total, we need to verify 1035 hashes and 1 bls signature.
|
|
226
|
+
|
|
227
|
+
### Verifying Blockhashes
|
|
228
|
+
|
|
229
|
+
Blocks in the execution layer are always verified by the blocks in the consensus layer. Each BeaconBlock has a executionPayload which holds the data of the Block in the execution layer. So many information like transactions, blockNumber and blockHash can directly be verified with the beacon block, while others like the receipts or the stateRoot, still needs Patricia Merkle Proofs from the execution layer to be verified.
|
|
230
|
+
|
|
231
|
+
But the most ciritcal verification is checking that a BeaconBlock is valid. This is done by using the SyncCommittee, which holds 512 public keys of validators and change very period (about every 27 hours). Having the correct keys is critical to verify the blockhash.
|
|
232
|
+
Now the C4 Client is always trying to hold the SyncCommittees public keys up to date, having the latest sync committee so we can checking the aggregated BLS Signature of them to verify blockhashes.
|
|
233
|
+
|
|
234
|
+
But what happens, if you want to verify a blockhash of an older block, because you need an older transaction?
|
|
235
|
+
In this case the you can use a new BeaconState and and create a MerkleProof for the historical roots. Since this is a list, there is practiclly no limit ( https://ethereum.github.io/consensus-specs/specs/phase0/beacon-chain/#state-list-lengths HISTORICAL_ROOTS_LIMIT = 2 ** 40 = 52262 years).
|
|
236
|
+
Since the capella Fork the state contains the [HistoricalSuummary](https://ethereum.github.io/consensus-specs/specs/capella/beacon-chain/#historicalsummary) which holds all the bloclhashes and state roots, so you can create a proof for the historical roots.
|
|
237
|
+
Unfortunatly the current specification for the [Beacon API](https://ethereum.github.io/beacon-APIs/) does not support providing proofs for those data yet, but we are planning to create an EIP to change this.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
### Merkle Proofs
|
|
242
|
+
|
|
243
|
+
The Proofs contain different types of Merkle Proofs.
|
|
244
|
+
|
|
245
|
+
#### Patricia Merkle Proof
|
|
246
|
+
|
|
247
|
+
The [Patricia Merkle Proof](https://github.com/corpus-core/c4/blob/main/src/util/ssz_merkle.c#L100) is a proof for a single leaf and used in the execution layer of ethereum for states of accounts and storage, transaction receipts and more. This is what you get when calling eth_getProof.
|
|
248
|
+
|
|
249
|
+
#### SSZ Merkle Proof
|
|
250
|
+
|
|
251
|
+
This Merkle trees are used withn the beacon chain. The Structure is based on the defition of the SSZ Types and allows to proof individual properties.
|
|
252
|
+
Another feature is the option to [proof multiple leafs](https://ethereum.org/de/developers/docs/data-structures-and-encoding/ssz/#multiproofs) at once which is used in different types of proofs in the c4 client.
|
|
253
|
+
|
|
254
|
+
All ssz proofs for single or multiple leafs are following the same structure:
|
|
255
|
+
|
|
256
|
+
- Only required node (32 bytess each) are added.
|
|
257
|
+
- The nodes are alwayys sorted by their [generalized index](https://ethereum.org/de/developers/docs/data-structures-and-encoding/ssz/#generalized-index) starting with highest number.
|
|
258
|
+
|
|
259
|
+
WHile a merkle proof for a single proof has always the same fixed size (which is equal to its depth), the size of a multi proof depends on the number of leafs and their position within the tree.
|
|
260
|
+
So in order to verify a multi proof, we first need to figure out which nodes ( represented by ther generalized index) are required. For example a multi proof for a small tree with 4 leafes, would end up with as empty list if you actually request all 4 leafes because there would be no nodes left to proof.
|
|
261
|
+
|
|
262
|
+
```c
|
|
263
|
+
// define a small tree with 3 leafes
|
|
264
|
+
ssz_def_t TEST_SUB[] = {
|
|
265
|
+
SSZ_UINT8("a"),
|
|
266
|
+
SSZ_UINT8("b"),
|
|
267
|
+
SSZ_UINT8("c"),
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
ssz_def_t TEST_ROOT[] = {
|
|
271
|
+
SSZ_UINT8("count"),
|
|
272
|
+
SSZ_CONTAINER("sub", TEST_SUB),
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
ssz_def_t TEST_TYPE_CONTAINER = SSZ_CONTAINER("TEST_ROOT", TEST_ROOT);
|
|
276
|
+
|
|
277
|
+
// create a container with the defined ssz type
|
|
278
|
+
uint8_t ssz_data[] = {1, 2, 3, 4}; // serialized data of the container
|
|
279
|
+
ssz_ob_t val = ssz_ob(TEST_TYPE_CONTAINER, bytes(ssz_data, 4));
|
|
280
|
+
|
|
281
|
+
// create a multi proof the properties count, a and b
|
|
282
|
+
bytes_t multi_proof = ssz_create_multi_proof(res, 3,
|
|
283
|
+
ssz_gindex(res.def, 1, "count"),
|
|
284
|
+
ssz_gindex(res.def, 2, "sub", "a"),
|
|
285
|
+
ssz_gindex(res.def, 2, "sub", "b")
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
// this proof has only one witness
|
|
289
|
+
|
|
290
|
+
// verify the proof
|
|
291
|
+
// create a leafes array for the required leafes
|
|
292
|
+
uint8_t leafes[96] = {0};
|
|
293
|
+
leafes[0] = 1; // count = 1
|
|
294
|
+
leafes[32] = 2; // a = 2
|
|
295
|
+
leafes[64] = 3; // b = 3
|
|
296
|
+
|
|
297
|
+
// define the gindexes of the required lproperties
|
|
298
|
+
gindex_t gindexes[] = {
|
|
299
|
+
ssz_gindex(res.def, 1, "count"),
|
|
300
|
+
ssz_gindex(res.def, 2, "sub", "a"),
|
|
301
|
+
ssz_gindex(res.def, 2, "sub", "b")};
|
|
302
|
+
|
|
303
|
+
// verify the proof and store the calculated root hash in proofed_root
|
|
304
|
+
bytes32_t proofed_root = {0};
|
|
305
|
+
ssz_verify_multi_merkle_proof(multi_proof, bytes(leafes, sizeof(leafes)), gindexes, proofed_root);
|
|
306
|
+
|
|
307
|
+
// now the root contains the root hash, which you can compare with the hash_tree_root of the container
|
|
308
|
+
bytes32_t root = {0};
|
|
309
|
+
ssz_hash_tree_root(val, root);
|
|
310
|
+
|
|
311
|
+
// assert
|
|
312
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(root, proofed_root, 32, "root hash must be the same after merkle proof");
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
## RPC Proofs
|
|
318
|
+
|
|
319
|
+
All requests send to the verifier are encoded using SSZ. The request itself is sepcified by the [C4Request](#c4request) type. This objects suports different types as data or proofs.
|
|
320
|
+
|
|
321
|
+
In order to proof the RPC-Request, the proofer will use different proofs.
|
|
322
|
+
|
|
323
|
+
### eth_getBalance
|
|
324
|
+
|
|
325
|
+
- Data: Bytes32
|
|
326
|
+
- Proof: [EthAccountProof](#ethaccountproof)
|
|
327
|
+
|
|
328
|
+
### eth_getCode
|
|
329
|
+
|
|
330
|
+
- Data: Bytes
|
|
331
|
+
- Proof: [EthAccountProof](#ethaccountproof)
|
|
332
|
+
|
|
333
|
+
### eth_getNonce
|
|
334
|
+
|
|
335
|
+
- Data: Bytes32
|
|
336
|
+
- Proof: [EthAccountProof](#ethaccountproof)
|
|
337
|
+
|
|
338
|
+
### eth_getProof
|
|
339
|
+
|
|
340
|
+
not implemented yet
|
|
341
|
+
|
|
342
|
+
### eth_getStorageAt
|
|
343
|
+
|
|
344
|
+
not implemented yet
|
|
345
|
+
|
|
346
|
+
### eth_getTransactionReceipt
|
|
347
|
+
|
|
348
|
+
- Data: [EthReceiptData](#ethreceiptdata)
|
|
349
|
+
- Proof: [EthReceiptProof](#ethreceiptproof)
|
|
350
|
+
|
|
351
|
+
### eth_getTransactionByHash
|
|
352
|
+
|
|
353
|
+
- Data: [EthTransactionData](#ethtransactiondata)
|
|
354
|
+
- Proof: [EthTransactionProof](#ethtransactionproof)
|
|
355
|
+
|
|
356
|
+
### eth_getTransactionByBlockHashAndIndex
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
- Data: [EthTransactionData](#ethtransactiondata)
|
|
360
|
+
- Proof: [EthTransactionProof](#ethtransactionproof)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
## Building
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
```sh
|
|
370
|
+
#clone
|
|
371
|
+
git clone https://github.com/colibri-labs/c4.git
|
|
372
|
+
cd c4
|
|
373
|
+
|
|
374
|
+
#build
|
|
375
|
+
mkdir build
|
|
376
|
+
cd build
|
|
377
|
+
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|
378
|
+
make
|
|
379
|
+
|
|
380
|
+
#run
|
|
381
|
+
bin/verify ../test/data/proof_data.ssz
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Build Javascript bindings (WASM)
|
|
386
|
+
|
|
387
|
+
In order to build the Javascript bindings, you need to have [emscripten installed](https://emscripten.org/docs/getting_started/downloads.html).
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
cd build
|
|
391
|
+
emcmake cmake -DWASM=true -DCURL=false ..
|
|
392
|
+
make
|
|
393
|
+
```
|
|
394
|
+
The js-module will be in the `build/emscripten` folder.
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
### CMake Options
|
|
398
|
+
|
|
399
|
+
- **-DBLS_DESERIALIZE**: if true bls keys will be stored deserialized, which increases the state per sync committee period from 25kB to 50kB, but make verification 5x faster
|
|
400
|
+
Default: ON
|
|
401
|
+
Usage: `cmake -DBLS_DESERIALIZE=ON` ..
|
|
402
|
+
|
|
403
|
+
- **-DCLI**: generates the CLI tools.
|
|
404
|
+
Default: ON
|
|
405
|
+
Usage: `cmake -DCLI=ON` ..
|
|
406
|
+
|
|
407
|
+
- **-DCMAKE_BUILD_TYPE**: Build type
|
|
408
|
+
Default: Release
|
|
409
|
+
Options: Debug, Release, RelWithDebInfo, MinSizeRel
|
|
410
|
+
Usage: `cmake -DCMAKE_BUILD_TYPE=Release` ..
|
|
411
|
+
|
|
412
|
+
- **-DCOVERAGE**: if true the coverage will be build
|
|
413
|
+
Default: OFF
|
|
414
|
+
Usage: `cmake -DCOVERAGE=OFF` ..
|
|
415
|
+
|
|
416
|
+
- **-DCURL**: if true curl will be used as transport
|
|
417
|
+
Default: ON
|
|
418
|
+
Usage: `cmake -DCURL=ON` ..
|
|
419
|
+
|
|
420
|
+
- **-DFILE_STORAGE**: if activated the verfifier will use a simple file-implementaion to store states in the current folder or in a folder specified by the env varC4_STATE_DIR
|
|
421
|
+
Default: ON
|
|
422
|
+
Usage: `cmake -DFILE_STORAGE=ON` ..
|
|
423
|
+
|
|
424
|
+
- **-DMESSAGES**: if activated the binaries will contain error messages, but for embedded systems this is not needed and can be turned off to save memory
|
|
425
|
+
Default: ON
|
|
426
|
+
Usage: `cmake -DMESSAGES=ON` ..
|
|
427
|
+
|
|
428
|
+
- **-DPRECOMPILE_ZERO_HASHES**: if activated zero hashes are cached which costs up to 1kb in RAM, but are needed in order to calc BeaconBodys in the proofer, but not in the verfier
|
|
429
|
+
Default: ON
|
|
430
|
+
Usage: `cmake -DPRECOMPILE_ZERO_HASHES=ON` ..
|
|
431
|
+
|
|
432
|
+
- **-DSHAREDLIB**: if true the shared library will be build
|
|
433
|
+
Default: OFF
|
|
434
|
+
Usage: `cmake -DSHAREDLIB=OFF` ..
|
|
435
|
+
|
|
436
|
+
- **-DTEST**: if true the test will be build
|
|
437
|
+
Default: OFF
|
|
438
|
+
Usage: `cmake -DTEST=OFF` ..
|
|
439
|
+
|
|
440
|
+
- **-DWASM**: if true the wasm will be build
|
|
441
|
+
Default: OFF
|
|
442
|
+
Usage: `cmake -DWASM=OFF` ..
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
## SSZ Types
|
|
446
|
+
|
|
447
|
+
### Attestation
|
|
448
|
+
|
|
449
|
+
an attestation is a list of aggregation bits, a data and a signature
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L66).
|
|
453
|
+
|
|
454
|
+
```python
|
|
455
|
+
class Attestation(Container):
|
|
456
|
+
aggregationBits: BitList [2048]
|
|
457
|
+
data : AttestationData
|
|
458
|
+
signature : ByteVector [96]
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### AttestationData
|
|
462
|
+
|
|
463
|
+
the data of an attestation
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L25).
|
|
467
|
+
|
|
468
|
+
```python
|
|
469
|
+
class AttestationData(Container):
|
|
470
|
+
slot : Uint64 # the slot of the attestation
|
|
471
|
+
index : Uint64 # the index of the attestation
|
|
472
|
+
beaconBlockRoot: Bytes32 # the root of the beacon block
|
|
473
|
+
source : Checkpoint # the source of the attestation
|
|
474
|
+
target : Checkpoint # the target of the attestation
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### AttesterSlashing
|
|
478
|
+
|
|
479
|
+
an attester slashing is a list of two index attestations
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L53).
|
|
483
|
+
|
|
484
|
+
```python
|
|
485
|
+
class AttesterSlashing(Container):
|
|
486
|
+
signedHeader1: IndexAttestation
|
|
487
|
+
signedHeader2: IndexAttestation
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### BeaconBlock
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L158).
|
|
494
|
+
|
|
495
|
+
```python
|
|
496
|
+
class BeaconBlock(Container):
|
|
497
|
+
slot : Uint64 # the slot of the block or blocknumber
|
|
498
|
+
proposerIndex: Uint64 # the index of the validator proposing the block
|
|
499
|
+
parentRoot : Bytes32 # the hash_tree_root of the parent block header
|
|
500
|
+
stateRoot : Bytes32 # the hash_tree_root of the state at the end of the block
|
|
501
|
+
body : BeaconBlockBody
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### BeaconBlockBody
|
|
505
|
+
|
|
506
|
+
const ssz_def_t ssz_bls_pubky[] = {
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L143).
|
|
510
|
+
|
|
511
|
+
```python
|
|
512
|
+
class BeaconBlockBody(Container):
|
|
513
|
+
randaoReveal : ByteVector [96]
|
|
514
|
+
eth1Data : Eth1Data
|
|
515
|
+
graffiti : Bytes32
|
|
516
|
+
proposerSlashings : List [ProposerSlashing, MAX_PROPOSER_SLASHINGS]
|
|
517
|
+
attesterSlashings : List [AttesterSlashing, MAX_ATTESTER_SLASHINGS]
|
|
518
|
+
attestations : List [Attestation, MAX_ATTESTATIONS]
|
|
519
|
+
deposits : List [Deposit, MAX_DEPOSITS]
|
|
520
|
+
voluntaryExits : List [SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
|
|
521
|
+
syncAggregate : SyncAggregate
|
|
522
|
+
executionPayload : ExecutionPayload
|
|
523
|
+
blsToExecutionChanges: List [SignedBlsToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES]
|
|
524
|
+
blobKzgCommitments : List [blsPubky, 4096]
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### BeaconBlockHeader
|
|
528
|
+
|
|
529
|
+
the header of a beacon block
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
The Type is defined in [verifier/types_beacon.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_beacon.c#L8).
|
|
533
|
+
|
|
534
|
+
```python
|
|
535
|
+
class BeaconBlockHeader(Container):
|
|
536
|
+
slot : Uint64 # the slot of the block or blocknumber
|
|
537
|
+
proposerIndex: Uint64 # the index of the validator proposing the block
|
|
538
|
+
parentRoot : Bytes32 # the hash_tree_root of the parent block header
|
|
539
|
+
stateRoot : Bytes32 # the hash_tree_root of the state at the end of the block
|
|
540
|
+
bodyRoot : Bytes32 # the hash_tree_root of the block body
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### BlockHashProof
|
|
544
|
+
|
|
545
|
+
the block hash proof is used as part of different other types since it contains all relevant
|
|
546
|
+
proofs to validate the blockhash of the execution layer
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L12).
|
|
550
|
+
|
|
551
|
+
```python
|
|
552
|
+
class BlockHashProof(Container):
|
|
553
|
+
blockhash_proof : List [bytes32, 256] # the merkle prooof from the executionPayload.blockhash down to the blockBodyRoot hash
|
|
554
|
+
header : BeaconBlockHeader # the header of the beacon block
|
|
555
|
+
sync_committee_bits : BitVector [512] # the bits of the validators that signed the block
|
|
556
|
+
sync_committee_signature: ByteVector [96] # the signature of the sync committee
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### BlsToExecutionChange
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L123).
|
|
563
|
+
|
|
564
|
+
```python
|
|
565
|
+
class BlsToExecutionChange(Container):
|
|
566
|
+
validatorIndex : Uint64
|
|
567
|
+
fromBlsPubkey : ByteVector [48]
|
|
568
|
+
toExecutionAddress: Address
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### C4Request
|
|
572
|
+
|
|
573
|
+
the main container defining the incoming data processed by the verifier
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L283).
|
|
577
|
+
|
|
578
|
+
```python
|
|
579
|
+
class C4Request(Container):
|
|
580
|
+
data : Union[ # the data to proof
|
|
581
|
+
None,
|
|
582
|
+
Bytes32 # the blochash which is used for blockhash proof,
|
|
583
|
+
Bytes32 # the balance of an account,
|
|
584
|
+
EthTxData # the transaction data,
|
|
585
|
+
EthReceiptData # the transaction receipt,
|
|
586
|
+
List [EthReceiptDataLog, 1024] # result of eth_getLogs
|
|
587
|
+
]
|
|
588
|
+
proof : Union[ # the proof of the data
|
|
589
|
+
None,
|
|
590
|
+
BlockHashProof,
|
|
591
|
+
EthAccountProof,
|
|
592
|
+
EthTransactionProof,
|
|
593
|
+
EthReceiptProof # a Proof of a TransactionReceipt,
|
|
594
|
+
List [EthLogsBlock, 256] # a Proof for multiple Receipts and txs
|
|
595
|
+
]
|
|
596
|
+
sync_data: Union[ # the sync data containing proofs for the transition between the two periods
|
|
597
|
+
None,
|
|
598
|
+
List [LightClientUpdate, 512] # this light client update can be fetched directly from the beacon chain API
|
|
599
|
+
]
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Checkpoint
|
|
603
|
+
|
|
604
|
+
a checkpoint is a tuple of epoch and root
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L19).
|
|
608
|
+
|
|
609
|
+
```python
|
|
610
|
+
class Checkpoint(Container):
|
|
611
|
+
epoch: Uint64 # the epoch of the checkpoint
|
|
612
|
+
root : Bytes32 # the root of the checkpoint
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### Deposit
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L79).
|
|
619
|
+
|
|
620
|
+
```python
|
|
621
|
+
class Deposit(Container):
|
|
622
|
+
proof: Vector [bytes32, 33]
|
|
623
|
+
data : DepositData
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### DepositData
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L72).
|
|
630
|
+
|
|
631
|
+
```python
|
|
632
|
+
class DepositData(Container):
|
|
633
|
+
pubkey : ByteVector [48]
|
|
634
|
+
withdrawalCredentials: Bytes32
|
|
635
|
+
amount : Uint64
|
|
636
|
+
signature : ByteVector [96]
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### Eth1Data
|
|
640
|
+
|
|
641
|
+
the eth1 data is a deposit root, a deposit count and a block hash
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L59).
|
|
645
|
+
|
|
646
|
+
```python
|
|
647
|
+
class Eth1Data(Container):
|
|
648
|
+
depositRoot : Bytes32
|
|
649
|
+
depositCount: Uint64
|
|
650
|
+
blockHash : Bytes32
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### EthAccessListData
|
|
654
|
+
|
|
655
|
+
Entry in thr access list
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L38).
|
|
659
|
+
|
|
660
|
+
```python
|
|
661
|
+
class EthAccessListData(Container):
|
|
662
|
+
address : Address
|
|
663
|
+
storageKeys: List [bytes32, 256]
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
### EthAccountProof
|
|
667
|
+
|
|
668
|
+
1. **Patricia Merkle Proof** for the Account Object in the execution layer (balance, nonce, codeHash, storageHash) and the storage values with its own Proofs. (using eth_getProof): Result StateRoot
|
|
669
|
+
2. **State Proof** is a SSZ Merkle Proof from the StateRoot to the ExecutionPayload over the BeaconBlockBody to its root hash which is part of the header.
|
|
670
|
+
3. **BeaconBlockHeader** is passed because also need the slot in order to find out which period and which sync committee is used.
|
|
671
|
+
4. **Signature of the SyncCommittee** (taken from the following block) is used to verify the SignData where the blockhash is part of the message and the Domain is calculated from the fork and the Genesis Validator Root.
|
|
672
|
+
```mermaid
|
|
673
|
+
flowchart TB
|
|
674
|
+
subgraph "ExecutionLayer"
|
|
675
|
+
class ExecutionLayer transparent
|
|
676
|
+
subgraph "Account"
|
|
677
|
+
balance --> account
|
|
678
|
+
nonce --> account
|
|
679
|
+
codeHash --> account
|
|
680
|
+
storageHash --> account
|
|
681
|
+
end
|
|
682
|
+
subgraph "Storage"
|
|
683
|
+
key1 --..PM..-->storageHash
|
|
684
|
+
key2 --..PM..-->storageHash
|
|
685
|
+
key3 --..PM..-->storageHash
|
|
686
|
+
end
|
|
687
|
+
end
|
|
688
|
+
subgraph "ConsensusLayer"
|
|
689
|
+
subgraph "ExecutionPayload"
|
|
690
|
+
account --..PM..--> stateRoot
|
|
691
|
+
end
|
|
692
|
+
subgraph "BeaconBlockBody"
|
|
693
|
+
stateRoot --SSZ D:5--> executionPayload
|
|
694
|
+
m[".."]
|
|
695
|
+
end
|
|
696
|
+
subgraph "BeaconBlockHeader"
|
|
697
|
+
slot
|
|
698
|
+
proposerIndex
|
|
699
|
+
parentRoot
|
|
700
|
+
s[stateRoot]
|
|
701
|
+
executionPayload --SSZ D:4--> bodyRoot
|
|
702
|
+
end
|
|
703
|
+
end
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L245).
|
|
708
|
+
|
|
709
|
+
```python
|
|
710
|
+
class EthAccountProof(Container):
|
|
711
|
+
accountProof: List [bytes_1024, 256] # Patricia merkle proof
|
|
712
|
+
address : Address # the address of the account
|
|
713
|
+
balance : Bytes32 # the balance of the account
|
|
714
|
+
codeHash : Bytes32 # the code hash of the account
|
|
715
|
+
nonce : Bytes32 # the nonce of the account
|
|
716
|
+
storageHash : Bytes32 # the storage hash of the account
|
|
717
|
+
storageProof: List [EthStorageProof, 256] # the storage proofs of the selected
|
|
718
|
+
state_proof : EthStateProof # the state proof of the account
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
### EthLogsBlock
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L149).
|
|
725
|
+
|
|
726
|
+
```python
|
|
727
|
+
class EthLogsBlock(Container):
|
|
728
|
+
blockNumber : Uint64 # the number of the execution block containing the transaction
|
|
729
|
+
blockHash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
730
|
+
proof : List [bytes32, 64] # the multi proof of the transaction, receipt_root,blockNumber and blockHash
|
|
731
|
+
header : BeaconBlockHeader # the header of the beacon block
|
|
732
|
+
sync_committee_bits : BitVector [512] # the bits of the validators that signed the block
|
|
733
|
+
sync_committee_signature: ByteVector [96] # the signature of the sync committee
|
|
734
|
+
txs : List [EthLogsTx, 256] # the transactions of the block
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
### EthLogsTx
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L142).
|
|
741
|
+
|
|
742
|
+
```python
|
|
743
|
+
class EthLogsTx(Container):
|
|
744
|
+
transaction : Bytes[1073741824] # the raw transaction payload
|
|
745
|
+
transactionIndex: Uint32 # the index of the transaction in the block
|
|
746
|
+
proof : List [bytes_1024, 64] # the Merklr Patricia Proof of the transaction receipt ending in the receipt root
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
### EthReceiptData
|
|
750
|
+
|
|
751
|
+
the transaction data
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L83).
|
|
755
|
+
|
|
756
|
+
```python
|
|
757
|
+
class EthReceiptData(Container):
|
|
758
|
+
blockHash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
759
|
+
blockNumber : Uint64 # the number of the execution block containing the transaction
|
|
760
|
+
transactionHash : Bytes32 # the hash of the transaction
|
|
761
|
+
transactionIndex : Uint32 # the index of the transaction in the block
|
|
762
|
+
type : Uint8 # the type of the transaction
|
|
763
|
+
from : Address # the sender of the transaction
|
|
764
|
+
to : Bytes[20] # the target of the transaction
|
|
765
|
+
cumulativeGasUsed: Uint64 # the cumulative gas used
|
|
766
|
+
gasUsed : Uint64 # the gas address of the created contract
|
|
767
|
+
logs : List [EthReceiptDataLog, 256] # the logs of the transaction
|
|
768
|
+
logsBloom : ByteVector [256] # the bloom filter of the logs
|
|
769
|
+
status : Uint8 # the status of the transaction
|
|
770
|
+
effectiveGasPrice: Uint64 # the effective gas price of the transaction
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
### EthReceiptDataLog
|
|
774
|
+
|
|
775
|
+
a log entry in the receipt
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L69).
|
|
779
|
+
|
|
780
|
+
```python
|
|
781
|
+
class EthReceiptDataLog(Container):
|
|
782
|
+
blockHash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
783
|
+
blockNumber : Uint64 # the number of the execution block containing the transaction
|
|
784
|
+
transactionHash : Bytes32 # the hash of the transaction
|
|
785
|
+
transactionIndex: Uint32 # the index of the transaction in the block
|
|
786
|
+
address : Address # the address of the log
|
|
787
|
+
logIndex : Uint32 # the index of the log in the transaction
|
|
788
|
+
removed : Boolean # whether the log was removed
|
|
789
|
+
topics : List [bytes32, 8] # the topics of the log
|
|
790
|
+
data : Bytes[1073741824] # the data of the log
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
### EthReceiptProof
|
|
794
|
+
|
|
795
|
+
the gasPrice of the transaction
|
|
796
|
+
represents the proof for a transaction receipt
|
|
797
|
+
1. All Receipts of the execution blocks are serialized into a Patricia Merkle Trie and the merkle proof is created for the requested receipt.
|
|
798
|
+
2. The **payload of the transaction** is used to create its SSZ Hash Tree Root from the BeaconBlock. This is needed in order to verify that the receipt actually belongs to the given transactionhash.
|
|
799
|
+
3. The **SSZ Multi Merkle Proof** from the Transactions, Receipts, BlockNumber and BlockHash of the ExecutionPayload to the BlockBodyRoot. (Total Depth: 29)
|
|
800
|
+
4. **BeaconBlockHeader** is passed because also need the slot in order to find out which period and which sync committee is used.
|
|
801
|
+
5. **Signature of the SyncCommittee** (taken from the following block) is used to verify the SignData where the blockhash is part of the message and the Domain is calculated from the fork and the Genesis Validator Root.
|
|
802
|
+
```mermaid
|
|
803
|
+
flowchart TB
|
|
804
|
+
subgraph "ExecutionPayload"
|
|
805
|
+
transactions
|
|
806
|
+
receipts
|
|
807
|
+
blockNumber
|
|
808
|
+
blockHash
|
|
809
|
+
end
|
|
810
|
+
Receipt --PM--> receipts
|
|
811
|
+
TX --SSZ D:21--> transactions
|
|
812
|
+
subgraph "BeaconBlockBody"
|
|
813
|
+
transactions --SSZ D:5--> executionPayload
|
|
814
|
+
blockNumber --SSZ D:5--> executionPayload
|
|
815
|
+
blockHash --SSZ D:5--> executionPayload
|
|
816
|
+
m[".."]
|
|
817
|
+
end
|
|
818
|
+
subgraph "BeaconBlockHeader"
|
|
819
|
+
slot
|
|
820
|
+
proposerIndex
|
|
821
|
+
parentRoot
|
|
822
|
+
s[stateRoot]
|
|
823
|
+
executionPayload --SSZ D:4--> bodyRoot
|
|
824
|
+
end
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L131).
|
|
829
|
+
|
|
830
|
+
```python
|
|
831
|
+
class EthReceiptProof(Container):
|
|
832
|
+
transaction : Bytes[1073741824] # the raw transaction payload
|
|
833
|
+
transactionIndex : Uint32 # the index of the transaction in the block
|
|
834
|
+
blockNumber : Uint64 # the number of the execution block containing the transaction
|
|
835
|
+
blockHash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
836
|
+
receipt_proof : List [bytes_1024, 64] # the Merklr Patricia Proof of the transaction receipt ending in the receipt root
|
|
837
|
+
block_proof : List [bytes32, 64] # the multi proof of the transaction, receipt_root,blockNumber and blockHash
|
|
838
|
+
header : BeaconBlockHeader # the header of the beacon block
|
|
839
|
+
sync_committee_bits : BitVector [512] # the bits of the validators that signed the block
|
|
840
|
+
sync_committee_signature: ByteVector [96] # the signature of the sync committee
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### EthStateProof
|
|
844
|
+
|
|
845
|
+
the stateRoot proof is used as part of different other types since it contains all relevant
|
|
846
|
+
proofs to validate the stateRoot of the execution layer
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L20).
|
|
850
|
+
|
|
851
|
+
```python
|
|
852
|
+
class EthStateProof(Container):
|
|
853
|
+
state_proof : List [bytes32, 256] # the merkle prooof from the executionPayload.state down to the blockBodyRoot hash
|
|
854
|
+
header : BeaconBlockHeader # the header of the beacon block
|
|
855
|
+
sync_committee_bits : BitVector [512] # the bits of the validators that signed the block
|
|
856
|
+
sync_committee_signature: ByteVector [96] # the signature of the sync committee
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
### EthStorageProof
|
|
860
|
+
|
|
861
|
+
represents the storage proof of a key
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L29).
|
|
865
|
+
|
|
866
|
+
```python
|
|
867
|
+
class EthStorageProof(Container):
|
|
868
|
+
key : Bytes32 # the key to be proven
|
|
869
|
+
proof: List [bytes_1024, 5] # Patricia merkle proof
|
|
870
|
+
value: Bytes32
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
### EthTransactionProof
|
|
874
|
+
|
|
875
|
+
represents the account and storage values, including the Merkle proof, of the specified account.
|
|
876
|
+
1. The **payload of the transaction** is used to create its SSZ Hash Tree Root.
|
|
877
|
+
2. The **SSZ Merkle Proof** from the Transactions of the ExecutionPayload to the BlockBodyRoot. (Total Depth: 29)
|
|
878
|
+
3. **BeaconBlockHeader** is passed because also need the slot in order to find out which period and which sync committee is used.
|
|
879
|
+
4. **Signature of the SyncCommittee** (taken from the following block) is used to verify the SignData where the blockhash is part of the message and the Domain is calculated from the fork and the Genesis Validator Root.
|
|
880
|
+
```mermaid
|
|
881
|
+
flowchart TB
|
|
882
|
+
subgraph "ExecutionPayload"
|
|
883
|
+
transactions
|
|
884
|
+
blockNumber
|
|
885
|
+
blockHash
|
|
886
|
+
end
|
|
887
|
+
TX --SSZ D:21--> transactions
|
|
888
|
+
subgraph "BeaconBlockBody"
|
|
889
|
+
transactions --SSZ D:5--> executionPayload
|
|
890
|
+
blockNumber --SSZ D:5--> executionPayload
|
|
891
|
+
blockHash --SSZ D:5--> executionPayload
|
|
892
|
+
m[".."]
|
|
893
|
+
end
|
|
894
|
+
subgraph "BeaconBlockHeader"
|
|
895
|
+
slot
|
|
896
|
+
proposerIndex
|
|
897
|
+
parentRoot
|
|
898
|
+
s[stateRoot]
|
|
899
|
+
executionPayload --SSZ D:4--> bodyRoot
|
|
900
|
+
end
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L189).
|
|
905
|
+
|
|
906
|
+
```python
|
|
907
|
+
class EthTransactionProof(Container):
|
|
908
|
+
transaction : Bytes[1073741824] # the raw transaction payload
|
|
909
|
+
transactionIndex : Uint32 # the index of the transaction in the block
|
|
910
|
+
blockNumber : Uint64 # the number of the execution block containing the transaction
|
|
911
|
+
blockHash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
912
|
+
proof : List [bytes32, 64] # the multi proof of the transaction, blockNumber and blockHash
|
|
913
|
+
header : BeaconBlockHeader # the header of the beacon block
|
|
914
|
+
sync_committee_bits : BitVector [512] # the bits of the validators that signed the block
|
|
915
|
+
sync_committee_signature: ByteVector [96] # the signature of the sync committee
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
### EthTxData
|
|
919
|
+
|
|
920
|
+
the transaction data
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
The Type is defined in [verifier/types_verify.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_verify.c#L45).
|
|
924
|
+
|
|
925
|
+
```python
|
|
926
|
+
class EthTxData(Container):
|
|
927
|
+
blockHash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
928
|
+
blockNumber : Uint64 # the number of the execution block containing the transaction
|
|
929
|
+
hash : Bytes32 # the blockHash of the execution block containing the transaction
|
|
930
|
+
transactionIndex : Uint32 # the index of the transaction in the block
|
|
931
|
+
type : Uint8 # the type of the transaction
|
|
932
|
+
nonce : Uint64 # the gasPrice of the transaction
|
|
933
|
+
input : Bytes[1073741824] # the raw transaction payload
|
|
934
|
+
r : Bytes32 # the r value of the transaction
|
|
935
|
+
s : Bytes32 # the s value of the transaction
|
|
936
|
+
chainId : Uint32 # the s value of the transaction
|
|
937
|
+
v : Uint8 # the v value of the transaction
|
|
938
|
+
gas : Uint64 # the gas limnit
|
|
939
|
+
from : Address # the sender of the transaction
|
|
940
|
+
to : Bytes[20] # the target of the transaction
|
|
941
|
+
value : Uint256 # the value of the transaction
|
|
942
|
+
gasPrice : Uint64
|
|
943
|
+
maxFeePerGas : Uint64
|
|
944
|
+
maxPriorityFeePerGas: Uint64
|
|
945
|
+
accessList : List [EthAccessListData, 256]
|
|
946
|
+
blobVersionedHashes : List [bytes32, 16]
|
|
947
|
+
yParity : Uint8 # the gasPrice of the transaction
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
### ExecutionPayload
|
|
951
|
+
|
|
952
|
+
the block header of the execution layer proved within the beacon block
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L104).
|
|
956
|
+
|
|
957
|
+
```python
|
|
958
|
+
class ExecutionPayload(Container):
|
|
959
|
+
parentHash : Bytes32 # the hash of the parent block
|
|
960
|
+
feeRecipient : Address # the address of the fee recipient
|
|
961
|
+
stateRoot : Bytes32 # the merkle root of the state at the end of the block
|
|
962
|
+
receiptsRoot : Bytes32 # the merkle root of the transactionreceipts
|
|
963
|
+
logsBloom : ByteVector [256] # the bloom filter of the logs
|
|
964
|
+
prevRandao : Bytes32 # the randao of the previous block
|
|
965
|
+
blockNumber : Uint64 # the block number
|
|
966
|
+
gasLimit : Uint64 # the gas limit of the block
|
|
967
|
+
gasUsed : Uint64 # the gas used of the block
|
|
968
|
+
timestamp : Uint64 # the timestamp of the block
|
|
969
|
+
extraData : Bytes[32] # the extra data of the block
|
|
970
|
+
baseFeePerGas: Uint256 # the base fee per gas of the block
|
|
971
|
+
blockHash : Bytes32 # the hash of the block
|
|
972
|
+
transactions : List [transactionsBytes, 1048576] # the list of transactions
|
|
973
|
+
withdrawals : List [Withdrawal, 16] # the list of withdrawels
|
|
974
|
+
blobGasUsed : Uint64 # the gas used for the blob transactions
|
|
975
|
+
excessBlobGas: Uint64 # the excess blob gas of the block
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
### ExecutionPayloadHeader
|
|
979
|
+
|
|
980
|
+
the block header of the execution layer proved within the beacon block
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
The Type is defined in [verifier/types_beacon.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_beacon.c#L23).
|
|
984
|
+
|
|
985
|
+
```python
|
|
986
|
+
class ExecutionPayloadHeader(Container):
|
|
987
|
+
parentHash : Bytes32 # the hash of the parent block
|
|
988
|
+
feeRecipient : Address # the address of the fee recipient
|
|
989
|
+
stateRoot : Bytes32 # the merkle root of the state at the end of the block
|
|
990
|
+
receiptsRoot : Bytes32 # the merkle root of the transactionreceipts
|
|
991
|
+
logsBloom : ByteVector [256] # the bloom filter of the logs
|
|
992
|
+
prevRandao : Bytes32 # the randao of the previous block
|
|
993
|
+
blockNumber : Uint64 # the block number
|
|
994
|
+
gasLimit : Uint64 # the gas limit of the block
|
|
995
|
+
gasUsed : Uint64 # the gas used of the block
|
|
996
|
+
timestamp : Uint64 # the timestamp of the block
|
|
997
|
+
extraData : Bytes[32] # the extra data of the block
|
|
998
|
+
baseFeePerGas : Uint256 # the base fee per gas of the block
|
|
999
|
+
blockHash : Bytes32 # the hash of the block
|
|
1000
|
+
transactionsRoot: Bytes32 # the merkle root of the transactions
|
|
1001
|
+
withdrawalsRoot : Bytes32 # the merkle root of the withdrawals
|
|
1002
|
+
blobGasUsed : Uint64 # the gas used for the blob transactions
|
|
1003
|
+
excessBlobGas : Uint64 # the excess blob gas of the block
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
### ForkData
|
|
1007
|
+
|
|
1008
|
+
the fork data is used to create the domain
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
The Type is defined in [verifier/verify_blockhash_proof.c](https://github.com/corpus-core/c4/blob/main/src/verifier/verify_blockhash_proof.c#L24).
|
|
1012
|
+
|
|
1013
|
+
```python
|
|
1014
|
+
class ForkData(Container):
|
|
1015
|
+
version: ByteVector [4] # the version of the fork
|
|
1016
|
+
state : Bytes32 # the state of the Genisis Block
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
### IndexAttestation
|
|
1020
|
+
|
|
1021
|
+
an index attestation is a list of attesting indices, a data and a signature
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L34).
|
|
1025
|
+
|
|
1026
|
+
```python
|
|
1027
|
+
class IndexAttestation(Container):
|
|
1028
|
+
attestingIndices: List [uint8, 2048] # the list of attesting indices
|
|
1029
|
+
data : AttestationData # the data of the attestation
|
|
1030
|
+
signature : ByteVector [96] # the BLS signature of the attestation
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
### LightClientHeader
|
|
1034
|
+
|
|
1035
|
+
the header of the light client update
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
The Type is defined in [verifier/types_beacon.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_beacon.c#L48).
|
|
1039
|
+
|
|
1040
|
+
```python
|
|
1041
|
+
class LightClientHeader(Container):
|
|
1042
|
+
beacon : BeaconBlockHeader # the header of the beacon block
|
|
1043
|
+
execution : ExecutionPayloadHeader # the header of the execution layer proved within the beacon block
|
|
1044
|
+
executionBranch: Vector [bytes32, 4] # the merkle proof of the execution layer proved within the beacon block
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
### LightClientUpdate
|
|
1048
|
+
|
|
1049
|
+
the light client update is used to verify the transition between two periods of the SyncCommittee.
|
|
1050
|
+
This data will be fetched directly through the beacon Chain API since it contains all required data.
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
The Type is defined in [verifier/types_beacon.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_beacon.c#L55).
|
|
1054
|
+
|
|
1055
|
+
```python
|
|
1056
|
+
class LightClientUpdate(Container):
|
|
1057
|
+
attestedHeader : LightClientHeader # the header of the beacon block attested by the sync committee
|
|
1058
|
+
nextSyncCommittee : SyncCommittee
|
|
1059
|
+
nextSyncCommitteeBranch: Vector [bytes32, 5] # will be 6 in electra
|
|
1060
|
+
finalizedHeader : LightClientHeader # the header of the finalized beacon block
|
|
1061
|
+
finalityBranch : Vector [bytes32, 6] # will be 7 in electra
|
|
1062
|
+
syncAggregate : SyncAggregate # the aggregates signature of the sync committee
|
|
1063
|
+
signatureSlot : Uint64 # the slot of the signature
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
### ProposerSlashing
|
|
1067
|
+
|
|
1068
|
+
a proposer slashing is a list of two signed beacon block headers
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L47).
|
|
1072
|
+
|
|
1073
|
+
```python
|
|
1074
|
+
class ProposerSlashing(Container):
|
|
1075
|
+
signedHeader1: SignedBeaconBlockheader
|
|
1076
|
+
signedHeader2: SignedBeaconBlockheader
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
### SignedBeaconBlock
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L165).
|
|
1083
|
+
|
|
1084
|
+
```python
|
|
1085
|
+
class SignedBeaconBlock(Container):
|
|
1086
|
+
message : BeaconBlock
|
|
1087
|
+
signature: ByteVector [96]
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
### SignedBeaconBlockheader
|
|
1091
|
+
|
|
1092
|
+
a signed beacon block header is a beacon block header and a signature
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L41).
|
|
1096
|
+
|
|
1097
|
+
```python
|
|
1098
|
+
class SignedBeaconBlockheader(Container):
|
|
1099
|
+
message : BeaconBlockHeader # the beacon block header
|
|
1100
|
+
signature: ByteVector [96] # the BLS signature of the beacon block header
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
### SignedBlsToExecutionChange
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L129).
|
|
1107
|
+
|
|
1108
|
+
```python
|
|
1109
|
+
class SignedBlsToExecutionChange(Container):
|
|
1110
|
+
message : BlsToExecutionChange
|
|
1111
|
+
signature: ByteVector [96]
|
|
1112
|
+
```
|
|
1113
|
+
|
|
1114
|
+
### SignedVoluntaryExit
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L89).
|
|
1118
|
+
|
|
1119
|
+
```python
|
|
1120
|
+
class SignedVoluntaryExit(Container):
|
|
1121
|
+
message : VoluntaryExit
|
|
1122
|
+
signature: ByteVector [96]
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
### SigningData
|
|
1126
|
+
|
|
1127
|
+
combining the root with a domain to ensure uniqueness of the signing message
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
The Type is defined in [verifier/verify_blockhash_proof.c](https://github.com/corpus-core/c4/blob/main/src/verifier/verify_blockhash_proof.c#L17).
|
|
1131
|
+
|
|
1132
|
+
```python
|
|
1133
|
+
class SigningData(Container):
|
|
1134
|
+
root : Bytes32 # the hashed root of the data to sign
|
|
1135
|
+
domain: Bytes32 # the domain of the data to sign
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
### SyncAggregate
|
|
1139
|
+
|
|
1140
|
+
the aggregates signature of the sync committee
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
The Type is defined in [verifier/types_beacon.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_beacon.c#L43).
|
|
1144
|
+
|
|
1145
|
+
```python
|
|
1146
|
+
class SyncAggregate(Container):
|
|
1147
|
+
syncCommitteeBits : BitVector [512] # the bits of the validators that signed the block (each bit represents a validator)
|
|
1148
|
+
syncCommitteeSignature: ByteVector [96] # the signature of the sync committee
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1151
|
+
### SyncCommittee
|
|
1152
|
+
|
|
1153
|
+
the public keys sync committee used within a period ( about 27h)
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
The Type is defined in [verifier/types_beacon.c](https://github.com/corpus-core/c4/blob/main/src/verifier/types_beacon.c#L18).
|
|
1157
|
+
|
|
1158
|
+
```python
|
|
1159
|
+
class SyncCommittee(Container):
|
|
1160
|
+
pubkeys : Vector [blsPubky, 512] # the 512 pubkeys (each 48 bytes) of the validators in the sync committee
|
|
1161
|
+
aggregatePubkey: ByteVector [48] # the aggregate pubkey (48 bytes) of the sync committee
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
### VoluntaryExit
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L84).
|
|
1168
|
+
|
|
1169
|
+
```python
|
|
1170
|
+
class VoluntaryExit(Container):
|
|
1171
|
+
epoch : Uint64
|
|
1172
|
+
validatorIndex: Uint64
|
|
1173
|
+
```
|
|
1174
|
+
|
|
1175
|
+
### Withdrawal
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
The Type is defined in [proofer/ssz_types.c](https://github.com/corpus-core/c4/blob/main/src/proofer/ssz_types.c#L94).
|
|
1179
|
+
|
|
1180
|
+
```python
|
|
1181
|
+
class Withdrawal(Container):
|
|
1182
|
+
index : Uint64
|
|
1183
|
+
validatorIndex: Uint64
|
|
1184
|
+
address : Address
|
|
1185
|
+
amount : Uint64
|
|
1186
|
+
```
|
|
1187
|
+
## License
|
|
1188
|
+
|
|
1189
|
+
MIT
|
package/c4_logo.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corpus-core/colibri-stateless",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Colibri is a stateless and trustless ethereum client, which is optimized for the mobile apps or embedded devices, because it does not hols the state, but verifies on demand.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {},
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|