generated from zama-ai/fhevm-hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff48016
Showing
54 changed files
with
11,308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"path": "cz-conventional-changelog" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# EditorConfig http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# All files | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.sol] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" | ||
export MNEMONIC="adapt mosquito move limb mobile illegal tree voyage juice mosquito burger raise father hope layer" | ||
export PRIVATE_KEY_GATEWAY_DEPLOYER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6" | ||
export PRIVATE_KEY_GATEWAY_OWNER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6" | ||
export PRIVATE_KEY_GATEWAY_RELAYER="7ec931411ad75a7c201469a385d6f18a325d4923f9f213bd882bbea87e160b67" | ||
|
||
# Block explorer API keys | ||
export ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" | ||
export BSCSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" | ||
export ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" | ||
export OPTIMISM_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" | ||
export POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" | ||
export SNOWTRACE_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: "CI" | ||
|
||
env: | ||
DOTENV_CONFIG_PATH: "./.env.example" | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
ci: | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: "Check out the repo" | ||
uses: "actions/checkout@v3" | ||
|
||
- name: "Install Pnpm" | ||
uses: "pnpm/action-setup@v2" | ||
with: | ||
version: "8" | ||
|
||
- name: "Install Node.js" | ||
uses: "actions/setup-node@v3" | ||
with: | ||
cache: "pnpm" | ||
node-version: "lts/*" | ||
|
||
- name: "Install the dependencies" | ||
run: "pnpm install" | ||
|
||
- name: "Lint the code" | ||
run: "pnpm lint" | ||
|
||
- name: "Add lint summary" | ||
run: | | ||
echo "## Lint results" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY | ||
- name: "Compile the contracts and generate the TypeChain bindings" | ||
run: "pnpm typechain" | ||
|
||
- name: "Test the contracts and generate the coverage report" | ||
run: "pnpm coverage:mock" | ||
|
||
- name: "Add test summary" | ||
run: | | ||
echo "## Test results" >> $GITHUB_STEP_SUMMARY | ||
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# directories | ||
.coverage_artifacts | ||
.coverage_cache | ||
.coverage_contracts | ||
artifacts | ||
build | ||
cache | ||
coverage | ||
dist | ||
node_modules | ||
types | ||
deployments | ||
kms-fhe-keys/ | ||
network-fhe-keys/ | ||
fhevmTemp/ | ||
abi/ | ||
|
||
# files | ||
*.env | ||
*.log | ||
.DS_Store | ||
.pnp.* | ||
coverage.json | ||
package-lock.json | ||
yarn.lock | ||
|
||
res/ | ||
running_node/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
image: "gitpod/workspace-node:latest" | ||
|
||
tasks: | ||
- init: "pnpm install" | ||
|
||
vscode: | ||
extensions: | ||
- "esbenp.prettier-vscode" | ||
- "NomicFoundation.hardhat-solidity" | ||
- "ritwickdey.LiveServer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# directories | ||
.coverage_artifacts | ||
.coverage_cache | ||
.coverage_contracts | ||
artifacts | ||
build | ||
cache | ||
coverage | ||
dist | ||
node_modules | ||
types | ||
|
||
# files | ||
*.env | ||
*.log | ||
.DS_Store | ||
.pnp.* | ||
coverage.json | ||
package-lock.json | ||
pnpm-lock.yaml | ||
yarn.lock | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
bracketSpacing: true | ||
plugins: | ||
- "@trivago/prettier-plugin-sort-imports" | ||
- "prettier-plugin-solidity" | ||
printWidth: 120 | ||
proseWrap: "always" | ||
singleQuote: false | ||
tabWidth: 2 | ||
trailingComma: "all" | ||
|
||
overrides: | ||
- files: "*.sol" | ||
options: | ||
compiler: "0.8.24" | ||
parser: "solidity-parse" | ||
tabWidth: 4 | ||
- files: "*.ts" | ||
options: | ||
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"] | ||
importOrderParserPlugins: ["typescript"] | ||
importOrderSeparation: true | ||
importOrderSortSpecifiers: true | ||
parser: "typescript" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
istanbulReporter: ["html", "lcov"], | ||
providerOptions: { | ||
mnemonic: process.env.MNEMONIC, | ||
}, | ||
skipFiles: ["test", "fhevmTemp"], | ||
mocha: { | ||
fgrep: "[skip-on-coverage]", | ||
invert: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"const-name-snakecase": "off", | ||
"no-global-import": "off", | ||
"reason-string": "off", | ||
"state-visibility": "off", | ||
"custom-errors": "off", | ||
"code-complexity": ["error", 8], | ||
"compiler-version": ["error", ">=0.8.4"], | ||
"func-visibility": ["error", { "ignoreConstructors": true }], | ||
"max-line-length": ["error", 120], | ||
"named-parameters-mapping": "off", | ||
"no-console": "off", | ||
"not-rely-on-time": "off", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"endOfLine": "auto" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# directories | ||
**/artifacts | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode", "NomicFoundation.hardhat-solidity"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true, | ||
"prettier.documentSelectors": ["**/*.sol"], | ||
"solidity.formatter": "prettier" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ethers } from "ethers"; | ||
import { ProviderWrapper } from "hardhat/plugins"; | ||
import type { EIP1193Provider, RequestArguments } from "hardhat/types"; | ||
|
||
interface Test { | ||
request: EIP1193Provider["request"]; | ||
} | ||
|
||
class CustomProvider extends ProviderWrapper implements Test { | ||
public lastBlockSnapshot: number; | ||
public lastCounterRand: number; | ||
public lastBlockSnapshotForDecrypt: number; | ||
|
||
constructor(protected readonly _wrappedProvider: EIP1193Provider) { | ||
super(_wrappedProvider); | ||
this.lastBlockSnapshot = 0; // Initialize the variable | ||
this.lastCounterRand = 0; | ||
this.lastBlockSnapshotForDecrypt = 0; | ||
} | ||
|
||
async request(args: RequestArguments): ReturnType<EIP1193Provider["request"]> { | ||
if (args.method === "eth_estimateGas") { | ||
const estimatedGasLimit = BigInt((await this._wrappedProvider.request(args)) as bigint); | ||
const increasedGasLimit = ethers.toBeHex((estimatedGasLimit * 120n) / 100n); // override estimated gasLimit by 120%, to avoid some edge case with ethermint gas estimation | ||
return increasedGasLimit; | ||
} | ||
if (args.method === "evm_revert") { | ||
const result = await this._wrappedProvider.request(args); | ||
const blockNumberHex = (await this._wrappedProvider.request({ method: "eth_blockNumber" })) as string; | ||
this.lastBlockSnapshot = parseInt(blockNumberHex); | ||
this.lastBlockSnapshotForDecrypt = parseInt(blockNumberHex); | ||
|
||
const callData = { | ||
to: "0x000000000000000000000000000000000000005d", | ||
data: "0x1f20d85c", | ||
}; | ||
this.lastCounterRand = (await this._wrappedProvider.request({ | ||
method: "eth_call", | ||
params: [callData, "latest"], | ||
})) as number; | ||
return result; | ||
} | ||
if (args.method === "get_lastBlockSnapshot") { | ||
return [this.lastBlockSnapshot, this.lastCounterRand]; | ||
} | ||
if (args.method === "get_lastBlockSnapshotForDecrypt") { | ||
return this.lastBlockSnapshotForDecrypt; | ||
} | ||
if (args.method === "set_lastBlockSnapshot") { | ||
this.lastBlockSnapshot = Array.isArray(args.params!) && args.params[0]; | ||
return this.lastBlockSnapshot; | ||
} | ||
if (args.method === "set_lastBlockSnapshotForDecrypt") { | ||
this.lastBlockSnapshotForDecrypt = Array.isArray(args.params!) && args.params[0]; | ||
return this.lastBlockSnapshotForDecrypt; | ||
} | ||
const result = this._wrappedProvider.request(args); | ||
return result; | ||
} | ||
} | ||
|
||
export default CustomProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Paul Razvan Berg | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/make -f | ||
|
||
include .env | ||
|
||
KEY_GEN = false | ||
BINDIR ?= $(GOPATH)/bin | ||
ETHERMINT_BINARY = ethermintd | ||
ETHERMINT_DIR = ethermint | ||
|
||
|
||
# This version must the same as in docker-compose-full.yml | ||
# TODO add check | ||
KMS_DEV_VERSION ?= v0.7.1 | ||
|
||
export GO111MODULE = on | ||
|
||
# Default target executed when no arguments are given to make. | ||
default_target: all | ||
|
||
.PHONY: default_target | ||
|
||
# process build tags | ||
|
||
############################################################################### | ||
### Single validator ### | ||
############################################################################### | ||
|
||
|
||
|
||
generate-fhe-keys: | ||
@bash ./scripts/copy_fhe_keys.sh $(KMS_DEV_VERSION) $(PWD)/network-fhe-keys $(PWD)/kms-fhe-keys | ||
|
||
run-full: | ||
$(MAKE) generate-fhe-keys | ||
@docker compose -f docker-compose/docker-compose-full.yml up --detach | ||
@echo 'sleep a little to let the docker start up' | ||
sleep 5 | ||
|
||
stop-full: | ||
@docker compose -f docker-compose/docker-compose-full.yml down | ||
|
||
|
||
clean: | ||
$(MAKE) stop-full | ||
rm -rf network-fhe-keys | ||
rm -rf kms-fhe-keys | ||
|
||
|
||
print-info: | ||
@echo 'KMS_DEV_VERSION: $(KMS_DEV_VERSION) for KEY_GEN---extracted from Makefile' |
Oops, something went wrong.