Skip to content

Commit 49e34c2

Browse files
authored
chore: httpz to fhevm, relayer debug docker compose, relayer update (#259)
* feat(relayer): support private decryption * feat(relayer): support public decryption * chore: httpz to fhevm, relayer debug docker compose, relayer update * chore: fhevm -> httpz * chore: pin submodules tags * chore: create makefile command groups * chore: add private-decryption readiness check/wait
1 parent 137526c commit 49e34c2

53 files changed

Lines changed: 1640 additions & 504 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[submodule "apps/relayer/fhevm-relayer"]
22
path = apps/relayer/fhevm-relayer
33
url = git@github.com:zama-ai/fhevm-relayer.git
4-
branch = fd0r/traits
4+
tag = v0.1.0-rc7
55
[submodule "external/httpz-test-suite"]
66
path = external/httpz-test-suite
77
url = git@github.com:zama-ai/httpz-test-suite.git
8+
commit = 8804c051c9521264012e428d59f396bd789e9458

Makefile

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,81 @@ publish-web3-fhe-event-requested:
3333
--region eu-central-1 \
3434
--message-body '{"type": "web3:fhe-event:detected", "payload": {"chainId": "123456", "address": "0xa5e1defb98EFe38EBb2D958CEe052410247F4c80"}, "meta": {"correlationId": "ea0ca1c2-3fde-4f80-8abb-08aecee4107c"}}'
3535

36-
# HTTPZ
37-
httpz-up:
38-
bash scripts/httpz-up.sh
39-
httpz-down:
40-
bash scripts/httpz-down.sh
36+
# fhevm
37+
.PHONY: fhevm-up fhevm-down
38+
fhevm-up:
39+
bash scripts/fhevm-up.sh
40+
fhevm-down:
41+
bash scripts/fhevm-down.sh
4142

42-
# HTTPZ Tests
43-
httpz-test-public-decrypt:
44-
bash scripts/httpz-test-public-decrypt.sh
45-
httpz-test-private-decrypt:
46-
bash scripts/httpz-test-private-decrypt.sh
47-
httpz-test-input:
48-
bash scripts/httpz-test-input.sh
43+
# fhevm Tests
44+
.PHONY: fhevm-test-public-decrypt fhevm-test-private-decrypt fhevm-test-input
45+
fhevm-test-public-decrypt:
46+
bash scripts/fhevm-test-public-decrypt.sh
47+
48+
fhevm-test-private-decrypt:
49+
bash scripts/fhevm-test-private-decrypt.sh
50+
51+
fhevm-test-input:
52+
bash scripts/fhevm-test-input.sh
4953

5054
# Console + Docker
55+
.PHONY: console-build console-up console-down console-infra-up console-infra-down console-build-service console-up-service
5156
console-build:
5257
docker compose -f ./docker-compose.02.console.build.yaml -f ./docker-compose.04.console.ghcr.yaml -f ./docker-compose.04.console.migrate.ghcr.yaml build
5358

5459
console-up:
5560
bash scripts/console-up.sh
5661

5762
console-down:
58-
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.03.console.run.yaml down --volumes --remove-orphans
63+
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.03.console.run.yaml -p console down --volumes --remove-orphans
5964

6065
console-infra-up:
61-
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.04.console.migrate.ghcr.yaml up -d --wait
66+
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.04.console.migrate.ghcr.yaml -p console up -d --wait
6267

6368
console-infra-down:
64-
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.04.console.migrate.ghcr.yaml down --volumes --remove-orphans
69+
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.04.console.migrate.ghcr.yaml -p console down --volumes --remove-orphans
70+
71+
console-build-service:
72+
docker compose -f ./docker-compose.02.console.build.yaml -f ./docker-compose.04.console.ghcr.yaml -f ./docker-compose.04.console.migrate.ghcr.yaml build $(service-name)
73+
74+
console-up-service:
75+
docker compose -f ./docker-compose.01.infra.yaml -f ./docker-compose.03.console.migrate.yaml -f ./docker-compose.03.console.run.yaml -f docker-compose.04.console.ghcr.yaml -f docker-compose.04.console.migrate.ghcr.yaml -p console up -d --wait --remove-orphans $(service-name)
6576

6677
# Relayer
78+
.PHONY: relayer-run relayer-build relayer-run-debug relayer-lint
6779
relayer-run:
6880
cd $(TOP)apps/relayer && cargo run --bin zws-relayer
6981

7082
relayer-build:
7183
cd $(TOP)apps/relayer && cargo build --bin zws-relayer
7284

85+
relayer-lint:
86+
cd $(TOP)apps/relayer && cargo clippy --all-targets --all-features --workspace --exclude fhevm-relayer -- -D warnings
87+
7388
relayer-run-debug:
7489
cd $(TOP)apps/relayer && cargo run --bin zws-relayer -- --config-file debug.toml
7590

91+
.PHONY: down
92+
down: fhevm-down console-down
93+
94+
.PHONY: build-and-up
95+
build-and-up: console-build down
96+
$(MAKE) fhevm-up
97+
$(MAKE) console-up
98+
99+
.PHONY: test
100+
test:
101+
$(MAKE) fhevm-test-input
102+
$(MAKE) fhevm-test-private-decrypt
103+
$(MAKE) fhevm-test-public-decrypt
104+
105+
all:
106+
$(MAKE) build-and-up
107+
echo "Waiting to make sure that everything is ready (all healthcheck are not implemented in the Console stack)"
108+
sleep 10
109+
$(MAKE) test
110+
111+
112+
113+

apps/back/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"eslint-plugin-prettier": "^5.0.0",
9090
"globals": "^15.11.0",
9191
"prettier": "catalog:",
92-
"prisma": "catalog:",
92+
"prisma": "^6.6.0",
9393
"source-map-support": "^0.5.21",
9494
"supertest": "^7.0.0",
9595
"ts-loader": "^9.4.3",

apps/back/src/dapps/use-cases/validate-address.use-case.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const VALIDATE_ADDRESS = 'VALIDATE_ADDRESS'
3838
export class ValidateAddress implements IValidateAddress {
3939
private readonly logger = new Logger(ValidateAddress.name)
4040

41-
constructor(@Inject(PRODUCER) private readonly producer: IProducer) {}
41+
constructor(@Inject(PRODUCER) private readonly producer: IProducer) { }
4242

4343
execute = (
4444
input: ValidateAddressInput,
@@ -109,9 +109,9 @@ export class ValidateAddressWithSync implements IValidateAddress {
109109
return data.type === 'back:address:validation:confirmed'
110110
? Task.of({ check: true })
111111
: Task.of({
112-
check: false,
113-
message: data.payload.reason,
114-
})
112+
check: false,
113+
message: data.payload.reason,
114+
})
115115
}
116116
this.logger.warn(
117117
`invalid event received: ${JSON.stringify(data)}`,

apps/back/src/httpz/test/input-proof.e2e-spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ describe('input proof', () => {
9292
describe('when they request for an input proof', () => {
9393
let contractChainId: string
9494
let userAddress: string
95-
let ciphertextWithZkpok: string
95+
let ciphertextWithInputVerification: string
9696
let handles: string[]
9797
let signatures: string[]
9898

9999
beforeEach(() => {
100100
contractChainId = faker.string.numeric(5)
101101
userAddress = faker.string.hexadecimal({ length: 40 })
102-
ciphertextWithZkpok = faker.string.hexadecimal({
102+
ciphertextWithInputVerification = faker.string.hexadecimal({
103103
length: { min: 40, max: 100 },
104104
prefix: '',
105105
})
@@ -115,7 +115,7 @@ describe('input proof', () => {
115115
contractChainId,
116116
contractAddress: address,
117117
userAddress,
118-
ciphertextWithZkpok,
118+
ciphertextWithInputVerification,
119119
})
120120
.set('Content-Type', 'application/json')
121121
.set('Accept', 'application/json')
@@ -170,15 +170,15 @@ describe('input proof', () => {
170170
let contractChainId: string
171171
let contractAddress: string
172172
let userAddress: string
173-
let ciphertextWithZkpok: string
173+
let ciphertextWithInputVerification: string
174174
let handles: string[]
175175
let signatures: string[]
176176

177177
beforeEach(() => {
178178
contractChainId = faker.string.numeric(5)
179179
contractAddress = faker.string.hexadecimal({ length: 40 })
180180
userAddress = faker.string.hexadecimal({ length: 40 })
181-
ciphertextWithZkpok = faker.string.hexadecimal({
181+
ciphertextWithInputVerification = faker.string.hexadecimal({
182182
length: { min: 40, max: 100 },
183183
prefix: '',
184184
})
@@ -194,7 +194,7 @@ describe('input proof', () => {
194194
contractChainId,
195195
contractAddress,
196196
userAddress,
197-
ciphertextWithZkpok,
197+
ciphertextWithInputVerification,
198198
})
199199
.set('Content-Type', 'application/json')
200200
.set('Accept', 'application/json')

apps/back/src/httpz/use-cases/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export {
66
InputProofWithApiKey,
77
InputProofWithSync,
88
} from './input-proof.use-case.js'
9+
export { PrivateDecrypt } from './private-decrypt.use-case.js'

apps/back/src/httpz/use-cases/input-proof.use-case.spec.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('InputProof', () => {
3434
let contractChainId: string
3535
let contractAddress: string
3636
let userAddress: string
37-
let ciphertextWithZkpok: string
37+
let ciphertextWithInputVerification: string
3838

3939
beforeEach(async () => {
4040
requestId = faker.string.uuid()
@@ -48,7 +48,7 @@ describe('InputProof', () => {
4848
contractChainId = faker.string.numeric(5)
4949
contractAddress = faker.string.hexadecimal({ length: 40 })
5050
userAddress = faker.string.hexadecimal({ length: 40 })
51-
ciphertextWithZkpok = faker.string.hexadecimal({
51+
ciphertextWithInputVerification = faker.string.hexadecimal({
5252
length: { min: 40, max: 100 },
5353
})
5454

@@ -66,7 +66,7 @@ describe('InputProof', () => {
6666
contractChainId,
6767
contractAddress,
6868
userAddress,
69-
ciphertextWithZkpok,
69+
ciphertextWithInputVerification,
7070
},
7171
{ requestId },
7272
)
@@ -103,7 +103,7 @@ describe('InputProof', () => {
103103
contractChainId,
104104
contractAddress,
105105
userAddress,
106-
ciphertextWithZkpok,
106+
ciphertextWithInputVerification,
107107
},
108108
{
109109
requestId,
@@ -124,7 +124,7 @@ describe('InputProofWithSync', () => {
124124
let contractChainId: string
125125
let contractAddress: string
126126
let userAddress: string
127-
let ciphertextWithZkpok: string
127+
let ciphertextWithInputVerification: string
128128

129129
beforeEach(async () => {
130130
const { unit, unitRef } =
@@ -141,7 +141,7 @@ describe('InputProofWithSync', () => {
141141
contractChainId = faker.string.numeric(5)
142142
contractAddress = faker.string.hexadecimal({ length: 40 })
143143
userAddress = faker.string.hexadecimal({ length: 40 })
144-
ciphertextWithZkpok = faker.string.hexadecimal({
144+
ciphertextWithInputVerification = faker.string.hexadecimal({
145145
length: { min: 40, max: 100 },
146146
})
147147
})
@@ -181,7 +181,7 @@ describe('InputProofWithSync', () => {
181181
contractChainId,
182182
contractAddress,
183183
userAddress,
184-
ciphertextWithZkpok,
184+
ciphertextWithInputVerification,
185185
})
186186
.toPromise()
187187
expect(result).toEqual({ handles, signatures })
@@ -205,7 +205,7 @@ describe('InputProofWithSync', () => {
205205
contractChainId,
206206
contractAddress,
207207
userAddress,
208-
ciphertextWithZkpok,
208+
ciphertextWithInputVerification,
209209
})
210210
.toPromise(),
211211
).rejects.toThrowError(/timeout/i)
@@ -230,7 +230,7 @@ describe('InputProofWithSync', () => {
230230
contractChainId,
231231
contractAddress,
232232
userAddress,
233-
ciphertextWithZkpok,
233+
ciphertextWithInputVerification,
234234
})
235235
.toPromise(),
236236
).rejects.toThrowError(message)
@@ -246,7 +246,7 @@ describe('InputProofWithApiKey', () => {
246246
let contractChainId: string
247247
let contractAddress: string
248248
let userAddress: string
249-
let ciphertextWithZkpok: string
249+
let ciphertextWithInputVerification: string
250250

251251
beforeEach(async () => {
252252
const { unit, unitRef } =
@@ -264,7 +264,7 @@ describe('InputProofWithApiKey', () => {
264264
contractChainId = faker.string.numeric(5)
265265
contractAddress = faker.string.hexadecimal({ length: 40 })
266266
userAddress = faker.string.hexadecimal({ length: 40 })
267-
ciphertextWithZkpok = faker.string.hexadecimal({
267+
ciphertextWithInputVerification = faker.string.hexadecimal({
268268
length: { min: 40, max: 100 },
269269
})
270270
})
@@ -280,12 +280,12 @@ describe('InputProofWithApiKey', () => {
280280
beforeEach(() => {
281281
handles = [faker.string.hexadecimal({ length: 40 })]
282282
signatures = [faker.string.hexadecimal({ length: 40 })]
283-
;(
284-
apiKeyAllowsRequest.execute as Mock<IApiKeyAllowsRequest['execute']>
285-
).mockReturnValue(Task.of(void 0))
286-
;(inputProof.execute as Mock<IInputProof['execute']>).mockReturnValue(
287-
Task.of({ handles, signatures }),
288-
)
283+
; (
284+
apiKeyAllowsRequest.execute as Mock<IApiKeyAllowsRequest['execute']>
285+
).mockReturnValue(Task.of(void 0))
286+
; (inputProof.execute as Mock<IInputProof['execute']>).mockReturnValue(
287+
Task.of({ handles, signatures }),
288+
)
289289
})
290290
test('should call the input proof use case', async () => {
291291
await useCase
@@ -294,7 +294,7 @@ describe('InputProofWithApiKey', () => {
294294
contractChainId,
295295
contractAddress,
296296
userAddress,
297-
ciphertextWithZkpok,
297+
ciphertextWithInputVerification,
298298
},
299299
{},
300300
)
@@ -304,7 +304,7 @@ describe('InputProofWithApiKey', () => {
304304
contractChainId,
305305
contractAddress,
306306
userAddress,
307-
ciphertextWithZkpok,
307+
ciphertextWithInputVerification,
308308
},
309309
expect.anything(),
310310
)
@@ -316,7 +316,7 @@ describe('InputProofWithApiKey', () => {
316316
contractChainId,
317317
contractAddress,
318318
userAddress,
319-
ciphertextWithZkpok,
319+
ciphertextWithInputVerification,
320320
})
321321
.toPromise()
322322
expect(result).toEqual({ handles, signatures })
@@ -325,7 +325,7 @@ describe('InputProofWithApiKey', () => {
325325

326326
describe('when request is not allowed', () => {
327327
beforeEach(() => {
328-
;(
328+
; (
329329
apiKeyAllowsRequest.execute as Mock<IApiKeyAllowsRequest['execute']>
330330
).mockReturnValue(Task.reject(unauthorizedError()))
331331
})
@@ -337,7 +337,7 @@ describe('InputProofWithApiKey', () => {
337337
contractChainId,
338338
contractAddress,
339339
userAddress,
340-
ciphertextWithZkpok,
340+
ciphertextWithInputVerification,
341341
})
342342
.toPromise(),
343343
).rejects.toThrowError(/unauthorized/i)
@@ -350,7 +350,7 @@ describe('InputProofWithApiKey', () => {
350350
contractChainId,
351351
contractAddress,
352352
userAddress,
353-
ciphertextWithZkpok,
353+
ciphertextWithInputVerification,
354354
})
355355
.toPromise()
356356
expect.fail('should have failed')

0 commit comments

Comments
 (0)