Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Updates to fhevm 0.6 #44

Merged
merged 73 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
6e50457
build: Bump FHEVM to 0.5
PacificYield Oct 21, 2024
f989af4
chore: Updates hardhat config
PacificYield Oct 21, 2024
a24c1df
chore: Updates tasks for fhevm 0.5
PacificYield Oct 21, 2024
2182ebe
chore: Updates EIP1193 custom provider
PacificYield Oct 21, 2024
0329676
fix: Example env
PacificYield Oct 21, 2024
0e7a0f5
chore: Gitignore
PacificYield Oct 21, 2024
47e473a
fix: TestAsyncDecrypt for 0.5
PacificYield Oct 21, 2024
9e0fa60
build: Bump to Solidity 0.8.24
PacificYield Oct 21, 2024
5d72e27
chore: Updates lockfile
PacificYield Oct 21, 2024
08da3f4
chore: Update hardhat version for tstorage
PacificYield Oct 22, 2024
898e90a
chore: Updates config
PacificYield Oct 22, 2024
8d5bc94
build: Lockfile
PacificYield Oct 22, 2024
21c073f
feat: IEncryptedERC20 and EncryptedERC20
PacificYield Oct 23, 2024
133c420
refactor: TestAsyncDecrypt
PacificYield Oct 23, 2024
0c9621e
refactor: Test helpers for v0.5
PacificYield Oct 23, 2024
4acfa1e
test: EncryptedERC20
PacificYield Oct 23, 2024
f02c910
refactor: Decimals
PacificYield Oct 24, 2024
70e548e
refactor: Virtual _isSenderAllowedForAmount
PacificYield Oct 24, 2024
d54db0f
build: Fix the version of OZ
PacificYield Oct 24, 2024
a313310
fix: EncryptedERC20Mintable.sol
PacificYield Oct 24, 2024
b15dac0
fix: Modifier
PacificYield Oct 24, 2024
8bec091
docs: Natspec
PacificYield Oct 24, 2024
b755f56
feat: Add checks for handle types
PacificYield Oct 24, 2024
09b3759
feat: Add more checks for handle types
PacificYield Oct 24, 2024
c1cd85d
fix: Logic error
PacificYield Oct 24, 2024
0e99dce
build: OZ fixed version
PacificYield Oct 25, 2024
aba6307
build: FHEVM 0.6
PacificYield Oct 28, 2024
d3156a5
build: FHEVM 0.6
PacificYield Oct 28, 2024
e095408
build: FHEVM 0.6
PacificYield Oct 28, 2024
5326584
refactor: EncryptedERC20 for FHEVM 0.6
PacificYield Oct 28, 2024
4d0ecf3
test: Adjustments for FHEVM 0.6
PacificYield Oct 28, 2024
904df24
style: Prettier
PacificYield Oct 28, 2024
2d61656
chore: Remove TestAsyncDecrypt.sol and test
PacificYield Oct 28, 2024
4d60dac
chore: Remove old test
PacificYield Oct 28, 2024
054c928
style: Prettier
PacificYield Oct 28, 2024
6742fa1
refactor: EncryptedErrors for EncryptedERC20
PacificYield Oct 29, 2024
b095982
test: EncryptedERC20WithErrors
PacificYield Oct 29, 2024
290517d
feat: Add mint function
PacificYield Oct 29, 2024
11207a0
refactor: Comp.sol
PacificYield Oct 30, 2024
1ff5f4d
refactor: Contract names and natspec
PacificYield Oct 30, 2024
1be227f
feat: Add checks for address(0)
PacificYield Oct 31, 2024
a868e16
test: Comp.sol tests
PacificYield Oct 31, 2024
5c45281
ci: Change workflows
PacificYield Oct 31, 2024
bbedd9f
fix: Workflow
PacificYield Oct 31, 2024
d9a81aa
fix: Minor changes
PacificYield Nov 4, 2024
cb31d7b
feat: WIP updates GovernorZama
PacificYield Nov 4, 2024
dfbbde1
fix: Comp.sol
PacificYield Nov 6, 2024
76495c7
docs: Natspec
PacificYield Nov 6, 2024
5000265
refactor: Custom errors GovernorAlphaZama.sol
PacificYield Nov 6, 2024
c996867
test: Rename file
PacificYield Nov 6, 2024
56ad043
test: Minor changes
PacificYield Nov 6, 2024
04a117f
test: Refactor fixture for GovernorAlphaZama
PacificYield Nov 6, 2024
1dfe245
refactor: Optimizations
PacificYield Nov 6, 2024
7fa85c9
fix: Minor fixes GovernorAlphaZama.sol
PacificYield Nov 6, 2024
5de6649
test: GovernorAlphaZama
PacificYield Nov 6, 2024
30b7560
chore: Updates for solhint
PacificYield Nov 6, 2024
e13d374
refactor: Contracts
PacificYield Nov 7, 2024
02b08e0
test: Adjustments
PacificYield Nov 7, 2024
32b38ae
refactor: Change folder name
PacificYield Nov 7, 2024
3c986c4
docs: NatSpec updates
PacificYield Nov 7, 2024
d06396e
chore: Config updates
PacificYield Nov 7, 2024
75e5aba
refactor: Set functions for FHEVM/Gateway
PacificYield Nov 7, 2024
36a79eb
test: EncryptedERC20 onlyOwner
PacificYield Nov 7, 2024
e63271e
chore: NPM release config
PacificYield Nov 7, 2024
0f5ca08
refactor: Make contracts that require TFHE/Gateway to be set abstract
PacificYield Nov 7, 2024
3335102
docs: Comp NatSpec
PacificYield Nov 7, 2024
47579fa
test: Comp.sol
PacificYield Nov 7, 2024
af186d7
refactor: External functions set to public
PacificYield Nov 7, 2024
3bcb0d6
docs: NatSpec
PacificYield Nov 7, 2024
722411a
fix: GovernorAlphaZama
PacificYield Nov 8, 2024
6325371
test: GovernorAlphaZama
PacificYield Nov 8, 2024
69c3636
refactor: Virtual functions
PacificYield Nov 8, 2024
31a03c8
docs: NatSpec for Enum
PacificYield Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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_ORACLE_DEPLOYER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_ORACLE_OWNER="717fd99986df414889fd8b51069d4f90a50af72e542c58ee065f5883779099c6"
export PRIVATE_KEY_ORACLE_RELAYER="7ec931411ad75a7c201469a385d6f18a325d4923f9f213bd882bbea87e160b67"
export MNEMONIC="exchange vintage ocean narrow danger return culture ignore trim solve clock hidden buddy wise emotion"
export PRIVATE_KEY_FHEVM_DEPLOYER="f2caf1b49a8f33e5a95fc55b0903daddd261d5a874ff154dc5d809a5f1c90449"
export PRIVATE_KEY_GATEWAY_DEPLOYER="e956ca0c96995551256523af64ac2f134c6b65d3e9d5c7b24ac4cd0a12f07bfd"
export PRIVATE_KEY_GATEWAY_RELAYER="049bdaae72bcc269f5edf17be5a01d61374e139b425984431242a3a74f73e92a"
export NUM_KMS_SIGNERS="1"
export PRIVATE_KEY_KMS_SIGNER_0="d5b160a52fe6015861d0a1bea9523aaab3699d52af8f3cede5fcdbdfdd4c77cc"
export PRIVATE_KEY_COPROCESSOR_ACCOUNT="83e0173b9d07abd53958da9f417df515b0957c4f8afd7171b518d192b52ae313"
export IS_COPROCESSOR="true"

# 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"
export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export ETHERSCAN_API_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Pull request tests
on:
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: large_ubuntu_16
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testmock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
jobs:
build:
runs-on: large_ubuntu_16
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
Expand Down
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ dist
node_modules
types
deployments
kms-fhe-keys/
network-fhe-keys/
fhevmTemp/
abi/

# files
*.env
Expand All @@ -18,4 +22,9 @@ deployments
.pnp.*
coverage.json
package-lock.json
yarn.lock
yarn.lock

res/
running_node/

docker-compose/docker-compose-full.yml
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*
!contracts/**
!package.json
!README.md
!LICENSE
2 changes: 1 addition & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trailingComma: "all"
overrides:
- files: "*.sol"
options:
compiler: "0.8.22"
compiler: "0.8.24"
parser: "solidity-parse"
tabWidth: 4
- files: "*.ts"
Expand Down
14 changes: 8 additions & 6 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
istanbulReporter: ["html", "lcov"],
providerOptions: {
mnemonic: process.env.MNEMONIC,
},
skipFiles: ["test"],
export const istanbulReporter = ["html", "lcov"];
export const providerOptions = {
mnemonic: process.env.MNEMONIC,
};
export const skipFiles = ["test", "fhevmTemp"];
export const mocha = {
fgrep: "[skip-on-coverage]",
invert: true,
};
10 changes: 8 additions & 2 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"compiler-version": ["error", ">=0.8.24"],
"func-visibility": [
"error",
{
"ignoreConstructors": true
}
],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-console": "off",
"no-global-import": "off",
"not-rely-on-time": "off",
"prettier/prettier": [
"error",
Expand Down
62 changes: 62 additions & 0 deletions CustomProvider.ts
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;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pnpm add fhevm-contracts
```solidity
// SPDX-License-Identifier: BSD-3-Clause-Clear

pragma solidity ^0.8.20;
pragma solidity ^0.8.24;

import "fhevm/lib/TFHE.sol";
import "fhevm-contracts/contracts/token/ERC20/EncryptedERC20.sol";
Expand Down
Loading
Loading