You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gateway-contracts/docs/getting-started/contracts/coprocessor_contexts.md
+16-36Lines changed: 16 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
# CoprocessorContexts contract
2
2
3
-
This section describes the `CoprocessorContexts` contract. It is used to manage the lifecycle of coprocessors for the
4
-
fhevm Gateway protocol.
3
+
This section describes the `CoprocessorContexts` contract. It is used to manage the lifecycle of coprocessors for the fhevm Gateway protocol.
5
4
6
5
Several settings are stored in the contract, which can be separated in several categories:
7
6
@@ -11,21 +10,18 @@ Several settings are stored in the contract, which can be separated in several c
11
10
12
11
## Coprocessor
13
12
14
-
A coprocessor is part of a set of multiple coprocessors, called a coprocessor [context](#coprocessor-context). They are
15
-
used to :
13
+
A coprocessor is part of a set of multiple coprocessors, called a coprocessor [context](#coprocessor-context). They are used to :
16
14
17
15
- perform FHE computations on ciphertexts
18
16
- verify inputs' zero-knowledge proof of knowledge (ZKPoK) based on requests from the `InputVerification` contract
19
-
- handle access controls to ciphertexts for all registered [host chains](./gateway_config.md#host-chains), which are
20
-
centralized in the `MultichainAcl` contract
17
+
- handle access controls to ciphertexts for all registered [host chains](./gateway_config.md#host-chains), which are centralized in the `MultichainAcl` contract
21
18
22
19
Several metadata are stored for each coprocessor:
23
20
24
21
-`name` : name of the coprocessor (indicative)
25
22
-`txSenderAddress` : see [Sender and signer](#sender-and-signer) below.
26
23
-`signerAddress` : see [Sender and signer](#sender-and-signer) below.
27
-
-`s3BucketUrl` : URL of the S3 bucket where the ciphertexts are stored. In the fhevm protocol, this URL is fetched by
28
-
the KMS connector in order to download the ciphertexts needed for decryption requests.
24
+
-`s3BucketUrl` : URL of the S3 bucket where the ciphertexts are stored. In the fhevm protocol, this URL is fetched by the KMS connector in order to download the ciphertexts needed for decryption requests.
29
25
30
26
The current list of [active](#lifecycle) coprocessors can be retrieved using the following view function:
31
27
@@ -38,34 +34,27 @@ A coprocessor has both a transaction sender and a signer assigned to it:
38
34
-`txSenderAddress` : address of the account that will send transactions to the fhevm Gateway.
39
35
-`signerAddress` : address associated to the public key used to sign results sent to the fhevm Gateway.
40
36
41
-
The current list of [active](#lifecycle) coprocessors' transaction senders and signers can be retrieved using the
42
-
following view functions:
37
+
The current list of [active](#lifecycle) coprocessors' transaction senders and signers can be retrieved using the following view functions:
43
38
44
39
-`getCoprocessorTxSenders()`: get all the active coprocessors' transaction senders.
45
40
-`getCoprocessorSigners()`: get all the active coprocessors' signers.
46
41
47
42
The transaction sender and signer addresses are allowed to be the same for a given coprocessor.
48
43
49
-
Additionally, the transaction sender address is used for identifying a coprocessor and may be referred to its
50
-
"identity". In particular, these addresses can be used as inputs to following view function for [active](#lifecycle)
51
-
coprocessors:
44
+
Additionally, the transaction sender address is used for identifying a coprocessor and may be referred to its "identity". In particular, these addresses can be used as inputs to following view function for [active](#lifecycle) coprocessors:
52
45
53
46
-`getCoprocessor(address coprocessorTxSenderAddress)`: get an active coprocessor's metadata.
54
47
55
48
## Coprocessor context
56
49
57
-
A set of coprocessors is called a coprocessor context and must be constituted of at least 1 coprocessor. It stores the
58
-
following metadata:
50
+
A set of coprocessors is called a coprocessor context and must be constituted of at least 1 coprocessor. It stores the following metadata:
59
51
60
-
-`contextId`: unique non-zero identifier of the coprocessor context, defined using an incremental counter within the
61
-
`CoprocessorContexts` contract.
52
+
-`contextId`: unique non-zero identifier of the coprocessor context, defined using an incremental counter within the `CoprocessorContexts` contract.
62
53
-`previousContextId`: identifier of the previous coprocessor context.
63
54
-`featureSet`: feature set of the coprocessor context, used for updating the coprocessors' software.
64
55
-`coprocessors`: list of coprocessors in the coprocessor context.
65
56
66
-
Currently, the initial coprocessor context is set at deployment of the `CoprocessorContexts` contract and put directly
67
-
in the [`active`](#lifecycle) state. In this particular case, the `previousContextId` is set to 0 since there is no
68
-
previous coprocessor context to refer to.
57
+
Currently, the initial coprocessor context is set at deployment of the `CoprocessorContexts` contract and put directly in the [`active`](#lifecycle) state. In this particular case, the `previousContextId` is set to 0 since there is no previous coprocessor context to refer to.
69
58
70
59
Coprocessor contexts can be updated over time by the owner for the following reasons:
71
60
@@ -76,21 +65,17 @@ Coprocessor contexts can be updated over time by the owner for the following rea
76
65
77
66
### Lifecycle
78
67
79
-
Coprocessor context updates follow a lifecycle approach, a general concept applied to other parts of the fhevm Gateway
80
-
(ex: KMS nodes, Custodians, FHE keys). It is used to ensure a linear history of contexts and that there is no disruption
81
-
in the protocol when updating them.
68
+
Coprocessor context updates follow a lifecycle approach, a general concept applied to other parts of the fhevm Gateway (ex: KMS nodes, Custodians, FHE keys). It is used to ensure a linear history of contexts and that there is no disruption in the protocol when updating them.
82
69
83
-
The lifecycle of a context is defined by the following states, although some of them are not currently used in practice
84
-
for coprocessor contexts:
70
+
The lifecycle of a context is defined by the following states, although some of them are not currently used in practice for coprocessor contexts:
85
71
86
72
-`generating`: currently not used.
87
73
-`pre-activation`: the coprocessor context will be activated in a certain amount of blocks.
88
74
-`active`: the coprocessor context can be used for new requests, for example:
89
75
- input verification requests
90
76
- adding new ciphertext materials
91
77
- new allows or delegations
92
-
-`suspended`: the coprocessor context cannot be used for new requests and will be deactivated after a certain amount of
93
-
blocks. However, it can still be considered for on-going consensus phases, for example:
78
+
-`suspended`: the coprocessor context cannot be used for new requests and will be deactivated after a certain amount of blocks. However, it can still be considered for on-going consensus phases, for example:
94
79
- proof verification/rejection responses
95
80
- on-going additions of ciphertext materials
96
81
- on-going allows or delegations
@@ -100,20 +85,16 @@ for coprocessor contexts:
100
85
101
86
Additionally:
102
87
103
-
- in case of emergency (ex: bad software update), the owner can directly move a context from `suspended` back to
104
-
`active`, which deactivates the context with issues.
105
-
- an `active` context cannot be set to `compromised`,`deactivated` or `destroyed`, in order to ensure that the fhevm
106
-
Gateway always has one active context.
88
+
- in case of emergency (ex: bad software update), the owner can directly move a context from `suspended` back to `active`, which deactivates the context with issues.
89
+
- an `active` context cannot be set to `compromised`,`deactivated` or `destroyed`, in order to ensure that the fhevm Gateway always has one active context.
107
90
108
91
The complete lifecycle of a coprocessor context is represented in the following diagram:
Coprocessor context statuses that need to be updated based on the current block number are refreshed using the
115
-
`refreshCoprocessorContextStatuses` function. This function can be called by anyone, but most importantly, it is called
116
-
by any of the following functions as a pre-hook modifier:
97
+
Coprocessor context statuses that need to be updated based on the current block number are refreshed using the `refreshCoprocessorContextStatuses` function. This function can be called by anyone, but most importantly, it is called by any of the following functions as a pre-hook modifier:
117
98
118
99
- in `CiphertextCommits` contract:
119
100
-`addCiphertextMaterial`
@@ -130,8 +111,7 @@ This ensures that the statuses are always up to date when performing the above a
130
111
131
112
## Owner
132
113
133
-
Similarly to other contracts, the `CoprocessorContexts` contract is ownable. The `owner` account is allowed to perform
134
-
several restricted actions:
114
+
Similarly to other contracts, the `CoprocessorContexts` contract is ownable. The `owner` account is allowed to perform several restricted actions:
These values are crucial for the fhevm Gateway protocol and are set in the `CoprocessorContexts` contract at deployment. To understand what each value is used for, please refer to the [CoprocessorContexts](../contracts/coprocessor_contexts.md) documentation.
157
155
158
156
#### At deployment
159
157
@@ -173,10 +171,7 @@ This integer is used to identify the feature set of the coprocessors for softwar
173
171
NUM_COPROCESSORS="3"# (number)
174
172
```
175
173
176
-
`NUM_COPROCESSORS` is the number of coprocessors to register in the `CoprocessorContexts` contract. It it not stored in
177
-
it and is only used within the deployment script. The following metadata variables must be set for each coprocessor,
178
-
indexed by a coprocessor number starting from 0. If not enough variables are set, the deployment will fail. If, on the
179
-
contrary, too many variables are set, the deployment will succeed but the extra ones will be ignored.
174
+
`NUM_COPROCESSORS` is the number of coprocessors to register in the `CoprocessorContexts` contract. It it not stored in it and is only used within the deployment script. The following metadata variables must be set for each coprocessor, indexed by a coprocessor number starting from 0. If not enough variables are set, the deployment will fail. If, on the contrary, too many variables are set, the deployment will succeed but the extra ones will be ignored.
0 commit comments