bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 75쪽 중 30쪽
`noTest` (boolean, optional): `true` to disable Tests generation (default: `false`)
* `noHostContracts` (boolean, optional): `true` to disable host contracts generation (`HCULimit.sol`) (default: `false`)
* `tests.shuffle` (boolean, optional): `true` to shuffle the tests. (default: `false`)
* `tests.shuffleWithPseuseRand` (boolean, optional): `true` to shuffle using a deterministic random sequence. (default: `false`)
* `tests.publicDecrypt` (boolean, optional): `true` to generate tests with publicly decryptable handles, `false` to generate tests with user decryptable handles. (default: `false`)
* `tests.numberOfTestSplits` (positive integer, required): the number of test splits to generate. (default: `12`)
* `tests.overloads` (string, optional): If `--overloads` option is not used, this is the path to the directory where the `overloads.json` file is located. If the path is relative, the absolute path is resolved relatively to the `baseDir`. (default: `./overloads.json`)
* `tests.solidity` contains all the parameters related to Solidity test code generation.
* `tests.typescript` contains all the parameters related to Typescript test code generation.
* `lib.fheTypeDir` (string, optional): The path to the directory where `FheType.sol` is located. If not specified, use `lib.outDir`. If the path is relative, the absolute path is resolved relatively to `baseDir`. (default: `./lib`)
* `lib.outDir` (string, optional): The path to the FHEVM lib directory where the `FHE.sol`, `Impl.sol` are generated (default: `lib`). If the path is relative, the absolute path is resolved relatively to `baseDir`. (default: `./lib`)
* `hostContracts.outDir` (string, optional): The path to the contracts directory (where to save `HCULimit.sol`). If the path is relative, the absolute path is resolved relatively to the `baseDir`. (default: `./contracts`)
## Overloads generation
Random overloads are generated using the `overloads` CLI command. These resulting JSON files are located in a centralized folder: `<root>/library-solidity/codegen/overloads/.`. Three distinct files are available: `library-solidity.json`, `host-contracts.json`, and `e2e.json`. While these files share an identical structure, they contain different sets of random values for each package's specific testing and code generation needs.
Each package's configuration file points directly to its corresponding overload file for resolution.
## Modifying lib Solidity Files (Using Templates)
#### Using Template or Typescript code
If you need to change the behavior of FHEVM library files — `FHE.sol`, `Impl.sol`, or `FheType.sol` — you have two options:
* If your modification does **not** involve dynamically generated code, simply edit the associated template file located in `<root>/library-solidity/codegen/templates/.` (e.g., `FHE.sol-template`, `Impl.sol-template` or `FheType.sol-template`).
* If your modification **does** involve dynamically generated code, you can change the generated code by editing the corresponding ts file `templateFHEDotSol.ts`, `templateImplDotSol.ts`, `templateFheTypeDotSol.ts`.
#### Template Comments
To add comments that are removed during the final code generation step (clean-up comments), prefix the comment line with the special marker `//$$`:
```js
//$$ This comment will not appear in the final generated .sol file.
```
⚠️ Warning: It seems that there is a bug when a comment is empty.
#### Template Synthax Highlighting
To enable proper Solidity syntax coloring for the template files (which makes editing much easier), add the following entry to your VSCode settings.json (Workspace or User settings):
```json
"files.associations": {
"*.sol-template": "solidity"
}
```
## Help
```sh
cd codegen
./codegen.mjs overloads --help
./codegen.mjs lib --help
```
## Generate overloads only
Use the `overloads` command. It is not required to re-generate overloads each time the tests or the libs are modified.
```sh
cd codegen
./codegen.mjs overloads /path/to/your/new/overloads.json
```
```sh
# or by using the path of overloads.json specified in the config
cd codegen
./codegen.mjs overloads --config ./codegen.config.json
```
## Generate lib with tests
Use the `lib` command.
```sh
cd codegen
./codegen.mjs lib --config /path/to/codegen.config.json --verbose
```
or
```sh
# if you want to use specific overloads
cd codegen
./codegen.mjs lib --overloads /path/to/my/overloads.json --config /path/to/codegen.config.json --verbose
```
## Dry Run
Use the `--dry-run` options to check code generation in dry run mode.
# test-suite
### Introduction
This repository provides a docker based setup to locally run an integration of Zama FHEVM and Zama KMS (Key Management System).
For overview of the system, architecture and details on individual components, refer to our [documentation](https://docs.zama.ai/fhevm).
### Main features
KMS can be configured to two modes:
* Centralized
* Threshold
### Table of contents
* [Introduction](#introduction)
* [Main Features](#main-features)
* [Get Started](#get-started)
* [Security Policy](#security-policy)
* [Handling Sensitive Data](#handling-sensitive-data)
* [Environment Files](#environment-files)
* [Development Environment](#development-environment)
* [Common Sensitive Data](#common-sensitive-data)
* [Reporting Security Issues](#reporting-security-issues)
* [Support](#support)
### Get started
#### Quickstart
The test suite offers a unified CLI for all operations:
```sh
cd test-suite/fhevm
# Deploy the entire stack
./fhevm-cli deploy
# Run specific tests
./fhevm-cli test input-proof
# Trivial
./fhevm-cli test user-decryption
# Trivial
./fhevm-cli test public-decrypt-http-mixed
./fhevm-cli test public-decrypt-http-ebool
./fhevm-cli test erc20
# Upgrade a specific service
./fhevm-cli upgrade coprocessor
# View logs
./fhevm-cli logs relayer
# Clean up
./fhevm-cli clean
```
#### WIP - Forcing Local Builds (`--build`)
⚠️ **IMPORTANT: THIS FEATURE IS STILL A WORK IN PROGRESS!** ⚠️ We are actively working to optimize caching for local machines and GitHub runners.
🚨 **SECURITY NOTICE:** The pre-built Docker images for the FHEVM stack are currently hosted in a **private registry** and are **not publicly available** for direct pulling. This is intentional for security reasons.
Therefore, for external developers or anyone setting up the stack for the first time without access to our private registry, **using the `--build` option is the recommended and necessary way to get started:**
```sh
./fhevm-cli deploy --build
```
This command instructs Docker Compose to:
1. Build the images locally using the `Dockerfile` and context specified in the respective `docker-compose/*.yml` files for each service. This process uses the source code available in your local checkout (or cloned sub-repositories).
2. Tag the newly built images with the versions specified in the `fhevm-cli` script.
3. Then, start the services using these freshly built local images.
**Why `--build` is essential for external developers:**
* **Image Access:** Since pre-built images are private, `--build` allows you to construct the necessary images from the publicly available source code.
* **Local Modifications:** If you have made local changes to any of the Dockerfiles or the build context of a service (e.g., you've cloned one of the sub-repositories like `fhevm-contracts` or `fhevm-coprocessor` into the expected relative paths and made changes), `--build` ensures these changes are incorporated.
* **Ensuring Correct Setup:** It guarantees that you are running with images built directly from the provided source, eliminating discrepancies that could arise from attempting to pull non-existent or inaccessible public images.
🚧 **In summary:** Until public images are made available, external users should always use `./fhevm-cli deploy --build` to ensure a successful deployment.
### Security policy
#### Handling sensitive data
This document outlines security best practices for the FHEVM project, particularly regarding the handling of sensitive configuration data.
**Environment files**
Our repository contains example environment files `env/staging` that include sensitive values like private keys, mnemonics, and API keys. **These values are for testing purposes only** and should never be used in production environments.
For production deployments:
* **Do not** use the same keys, passwords, or mnemonics that appear in the example files
* **Do not** commit actual production secrets to any repository
* **Do** use a proper secrets management solution:
* Environment variables managed by your deployment platform
* HashiCorp Vault or similar secrets management service
* AWS Secrets Manager, GCP Secret Manager, or Azure Key Vault
* Kubernetes Secrets (with proper encryption)
Example of replacing sensitive data in production:
```bash
# Replace test mnemonic with environment variable reference
# TEST: MNEMONIC=coyote sketch defense hover finger envelope celery urge panther venue verb cheese
MNEMONIC=${PRODUCTION_MNEMONIC}
# Replace test private key with key stored in a secure vault
# TEST: TX_SENDER_PRIVATE_KEY=0x8f82b3f482c19a95ac29c82cf048c076ed0de2530c64a73f2d2d7d1e64b5cc6e
TX_SENDER_PRIVATE_KEY=${SECURE_PRIVATE_KEY}
```
**Development environment**
When developing locally:
* Use `.env.local` files (added to `.gitignore`) for your personal secrets
* Rotate keys regularly, especially if used for shared development environments
* Consider using environment-specific configuration files (dev, staging, prod)
* Use fake/test data for local development whenever possible
**Common sensitive data**
The following values should NEVER be committed to repositories:
* Private keys
* Mnemonics
* API keys
* Database credentials
* JWT secrets
#### Reporting security issues
Please report security vulnerabilities to `security@zama.ia` rather than creating public issues.
Include:
* Description of the vulnerability
* Steps to reproduce
* Potential impact
* Suggested mitigation (if any)
### Support
🌟 If you find this project helpful or interesting, please consider giving it a star on GitHub! Your support helps to grow the community and motivates further development.
# Changelog
## \[v0.7.0] - 2025-05-27
This version is a specific release for the fhevm architecture with tfhe-rs v0.11
## Notes
* Testing in the test-suite for fhevm is based on `v0.7.0` release.
* For anyone wanting to run the local setup to "see the magic happens" please follow instructions in [README.md](/protocol/solidity-guides/v0.10/test-suite).
* Note that some tests may take significantly longer to execute (between 20 and 150 seconds), especially due to input proof verification.
## Some References
| Name | Type | Version |
| :---------------: | :--------: | :-----: |
| fhevm | repository | v0.7.0 |
| gateway-contracts | docker | v0.7.0 |
| host-contracts | docker | v0.7.0 |
| coprocessor | docker | v0.7.0 |
| kms-connector | docker | v0.7.0 |
| test-suite | docker | v0.7.0 |
| kms-core | docker | v0.11.0 |
| relayer | docker | v0.1.0 |
# Sample Hardhat Project
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.
Try running some of the following tasks:
```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.ts
```
# Gateway Stress-Test Tool
## Introduction
A simple tool to send a configurable number of parallel decryption requests (public or user decrypts at the time of writing), at a given frequency and for a specified duration.
## Table of Contents
* [Introduction](#introduction)
* [Build](#build)
* [Configuration](#configuration)
* [Run](#run)
* [Stress testing](#stress-testing)
* [Benchmarking](#benchmarking)
* [Tracing](#tracing)
* [Bonus: Generating handles via coprocessor stress-test-generator](#bonus-generating-handles-via-coprocessor-stress-test-generator)
## Build
You can build the tool by running the `cargo build --release` command in the `test-suite/gateway-stress` directory.
Alternatively, you can run the manual `gateway-stress-tool-docker-build` workflow to trigger the build of the Docker images for the tool.
## Configuration
To configure the tool, you can must use a configuration file (TOML format).
Every configuration option is documented in the example [configuration file](https://github.com/zama-ai/fhevm/blob/release/0.10.x/test-suite/gateway-stress/config/config.toml).
Some of the configuration fields can be overridden via the CLI:
* `tests_duration`
* `tests_interval`
* `parallel_requests`
* `sequential`
## Run
### Stress testing
Once the `gateway-stress` binary has been built, you can run the following commands:
```bash
# Display CLI help
./gateway-stress help
# Run public decryption stress test using the Gateway chain
./gateway-stress -c config/config.toml gw -t public
# Run user decryption stress test using the Gateway chain
./gateway-stress -c config/config.toml gw -t user
# Override number of parallel requests during the stress tests session
./gateway-stress -c config/config.toml -p 10 gw public
# Run public decryption stress test by inserting requests in Connectors' DBs
./gateway-stress -c config/config.toml db -t public
# Run user decryption stress test by inserting requests in Connectors' DBs
./gateway-stress -c config/config.toml db -t user
# Don't clear Connectors' DBs before and after running stress tests (not recommended)
./gateway-stress -c config/config.toml db -t public --skip_clear-db
```
Or directly from `test-suite/gateway-stress` directory:
```bash
cargo run -- -c config/config.toml gw -t public
cargo run -- -c config/config.toml gw -t user
```
### Benchmarking
The `benchmark` command take a CSV file in input (and the global config file as well). Each line of this CSV represent a burst of decryption to benchmark, which is composed of:
* The number of parallel requests in the burst (1st column)
* The number of time we must measure this burst (2nd column)
* The type of decryption in the burst (`public` or `user`)
See the [templates](https://github.com/zama-ai/fhevm/blob/release/0.10.x/test-suite/gateway-stress/templates/README.md) folder for examples.
It will then run the benchmark and stores the results (average and standard deviation of latency and throughput) for each burst in a CSV file.
```bash
# Run a benchmarking session using `templates/small_bench.csv` as input and store the global
# results in `/tmp/bench.csv` (decryption requests sent using the Gateway chain)
./gateway-stress -c config/config.toml bench-gw -i templates/small_bench.csv -o /tmp/bench.csv
# Same, but also store each burst result in `tmp/full.csv`
./gateway-stress -c config/config.toml bench-gw -i templates/small_bench.csv -o /tmp/bench.csv -r /tmp/full.csv
# Run a benchmarking session using `templates/small_bench.csv` as input and store the global
# results in `/tmp/bench.csv` (decryption requests inserted in Connectors' DB)
./gateway-stress -c config/config.toml bench-db -i templates/small_bench.csv -o /tmp/bench.csv
# Same, but also store each burst result in `tmp/full.csv`
./gateway-stress -c config/config.toml bench-db -i templates/small_bench.csv -o /tmp/bench.csv -r /tmp/full.csv
```
## Tracing
This tool aims to output only essential information regarding the status of the test. The main observation of the test should be done in Grafana or within our infrastructure, not via this tool.
However, this tool uses the `tracing` crate, and if you are facing issues during a stress test session, you can get more logs by configuring the `RUST_LOG` environment variable. Example:
```bash
# Enabling "DEBUG" traces of the stress test tool alone
RUST_LOG="gateway_stress=debug" ./gateway-stress -c config/config.toml gw -t public
# Enabling "DEBUG" traces of the stress test tool and of the alloy crate
RUST_LOG="gateway_stress=debug,alloy=debug" ./gateway-stress -c config/config.toml gw -t public
# Enabling "DEBUG" traces for all crates used by the stress test tool
RUST_LOG="debug" ./gateway-stress -c config/config.toml gw -t public
```
## Bonus: Generating handles via coprocessor stress-test-generator
To use this tool, you would need already existing handles to decrypt. You could use coprocessor's `stress-test-generator` tool to generate these handles.
The tool is located at `coprocessor/fhevm-engine/stress-test-generator` in the `fhevm` repo. Then, look at the `README.md` and gather all the environment variable values needed (default values work only for e2e setup).
```bash
export EVGEN_DB_URL="TODO"
export ACL_CONTRACT_ADDRESS="TODO"
# ...
EVGEN_SCENARIO=data/minitest_003_generate_handles_for_decryption.csv make run
```
This will generate the `data/handles_for_pub_decryption` and `handles_for_usr_decryption` files.
Make sure that the 6th column of the `EVGEN_SCENARIO` file match the `allowed_contract` value of this tool's configuration, and that the 7th column match the wallet address used by the tool.
# .github
# ISSUE\_TEMPLATE
# docs(\<category>): short description
#### Category
* [x] **docs(user)** — user-facing content: guides, tutorials, concept explanations, etc.
* [ ] **docs(api)** — interfaces: contracts, SDKs, plugin APIs, etc.
* [ ] **docs(code)** — code examples, templates, scripts, tests, etc.
* [ ] **docs(misc)** — structure, navigation, styling, feedback, housekeeping, etc.
#### Context / Background
#### Target Files/Pages
#### Tasks
* [ ] Task 1
* [ ] Task 2
* [ ] Task 3
# charts
# kms-connector
A helm chart to distribute and deploy the Zama KMS Connector services.
## Chart Details
This chart deploys the following components:
* **kms-connector-db-migration**: A Kubernetes Job to run database migrations.
* **kms-connector-gw-listener**: A service that listens for events from the gateway chain.
* **kms-connector-kms-worker**: A service that interacts with the KMS-Core.
* **kms-connector-tx-sender**: A service that sends transactions to the gateway chain.
## Installing the Chart
To pull and install the OCI Helm chart from ghcr.io:
```
helm registry login ghcr.io/zama-ai/fhevm/charts
helm install kms-connector oci://ghcr.io/zama-ai/fhevm/charts/kms-connector
```
To pull and install the OCI Helm chart from hub.zama.ai:
```
helm registry login hub.zama.ai
helm install kms oci://hub.zama.ai/zama-protocol/zama-ai/fhevm/charts/kms-connector
```
## Configuration
The following table lists the configurable parameters of the `kms-connector` chart and their default values.
| Parameter | Description | Default |
| -------------------------------------------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `commonConfig.databaseUrl` | The database URL. | `postgresql://$(DATABASE_USERNAME):$(DATABASE_PASSWORD)@$(DATABASE_ENDPOINT)/connector` |
| `commonConfig.gatewayUrl` | The gateway URL. | `ws://gateway-anvil-node:8546` |
| `commonConfig.chainId` | The chain ID. | `54321` |
| `commonConfig.gatewayContractAddresses` | The contract addresses for the gateway. | `{}` |
| `commonConfig.tracing.enabled` | If `true`, enable tracing for all components. | `false` |
| `commonConfig.tracing.endpoint` | The OpenTelemetry collector endpoint. | `http://otel-deployment-opentelemetry-collector.observability.svc.cluster.local:4317` |
| `commonConfig.env` | Environment variables to be injected into all containers. | `{}` |
| `kmsConnectorDbMigration.enabled` | If `true`, run the database migration job. | `true` |
| `kmsConnectorDbMigration.image.name` | The docker image name for the database migration job. | `ghcr.io/zama-ai/fhevm/kms-connector/db-migration` |
| `kmsConnectorDbMigration.image.tag` | The docker image tag for the database migration job. | `v0.9.0` |
| `kmsConnectorGwListener.enabled` | If `true`, deplo프로젝트로 돌아가기