Skip to content

Commit 31a3a34

Browse files
authored
chore(gateway-contracts): update mock script, makefile and forge version (#163)
1 parent 7541490 commit 31a3a34

File tree

12 files changed

+193
-50
lines changed

12 files changed

+193
-50
lines changed

.github/workflows/gateway-contracts-integrity-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Install Foundry
5151
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c # v1.3.1
5252
with:
53-
version: v1.2.1
53+
version: v1.2.2
5454

5555
- name: Install dependencies
5656
working-directory: gateway-contracts

gateway-contracts/.husky/pre-commit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ printf "> make check-selectors\n\n"
1414
make check-selectors
1515

1616
# Lints the crate's code.
17-
printf "> cd rust_bindings && cargo clippy -- -D warnings && cd ..\n\n"
18-
cd rust_bindings && cargo clippy -- -D warnings && cd ..
17+
printf "> make lint-bindings\n\n"
18+
make lint-bindings
1919

2020
# Check license compliance
2121
printf "> make check-licenses\n\n"

gateway-contracts/.prettierignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build outputs
5+
artifacts/
6+
cache/
7+
8+
# Version control
9+
.git/
10+
.gitignore
11+
12+
# Environment
13+
.env
14+
15+
# Rust
16+
rust_bindings/
17+
18+
# Typechain
19+
typechain-types/

gateway-contracts/Makefile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ start-local-node: clean
2626

2727
deploy-contracts-local:
2828
cp $(ENV_PATH) .env
29-
HARDHAT_NETWORK=$(LOCAL_NETWORK_NAME) npx hardhat task:faucetToPrivate --private-key $(DEPLOYER_PRIVATE_KEY)
3029
HARDHAT_NETWORK=$(LOCAL_NETWORK_NAME) npx hardhat task:deployAllGatewayContracts
3130
HARDHAT_NETWORK=$(LOCAL_NETWORK_NAME) npx hardhat task:addHostChainsToGatewayConfig --use-internal-gateway-config-address true
3231

@@ -51,6 +50,9 @@ check-bindings: ensure-addresses
5150
update-bindings: ensure-addresses
5251
python3 scripts/bindings_update.py update
5352

53+
lint-bindings:
54+
cd rust_bindings && cargo clippy -- -D warnings && cd ..
55+
5456
check-mocks:
5557
node scripts/mock_contracts_cli.js check
5658

@@ -73,11 +75,15 @@ update-selectors: ensure-addresses
7375
# Conform to pre-commit checks
7476
conformance: prettier update-bindings update-mocks update-selectors
7577

76-
# Ensure that the empty proxy addresses exists. These are required for contract compilation.
78+
# Deploy the empty proxy addresses
79+
deploy-empty-proxies:
80+
DOTENV_CONFIG_PATH=$(ENV_PATH) npx hardhat task:deployEmptyUUPSProxies
81+
82+
# Ensure that the empty proxy addresses exists as these are required for contract compilation.
83+
# In addition, ensure that the addresses match the ones used in local development in order to
84+
# avoid discrepancies between local and CI (e.g., when generating and checking rust bindings).
7785
ensure-addresses:
78-
@if [ ! -d addresses ]; then \
79-
DOTENV_CONFIG_PATH=$(ENV_PATH) npx hardhat task:deployEmptyUUPSProxies; \
80-
fi
86+
ENV_PATH=$(ENV_PATH) npx ts-node scripts/ensure_proxy_addresses.ts
8187

8288
# Make sure we only use allowed licenses for dependencies
8389
check-licenses:
@@ -96,4 +102,8 @@ check-licenses:
96102
prerelease:
97103
npm version prerelease
98104
$(MAKE) update-bindings
99-
git add ./rust_bindings && git commit --amend --no-edit
105+
git add ./rust_bindings && git commit --amend --no-edit
106+
107+
# Get the size of the contracts
108+
get-contracts-sized:
109+
forge build --sizes

gateway-contracts/contracts/mocks/CiphertextCommitsMock.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ contract CiphertextCommitsMock {
1717
bytes32 snsCiphertextDigest
1818
) external {
1919
address[] memory coprocessorTxSenders = new address[](1);
20+
2021
emit AddCiphertextMaterial(ctHandle, ciphertextDigest, snsCiphertextDigest, coprocessorTxSenders);
2122
}
2223
}

gateway-contracts/contracts/mocks/DecryptionMock.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ contract DecryptionMock {
2727
_decryptionRequestCounter++;
2828
uint256 decryptionId = _decryptionRequestCounter;
2929
SnsCiphertextMaterial[] memory snsCtMaterials = new SnsCiphertextMaterial[](1);
30+
3031
emit PublicDecryptionRequest(decryptionId, snsCtMaterials);
3132
}
3233

@@ -36,6 +37,7 @@ contract DecryptionMock {
3637
bytes calldata signature
3738
) external {
3839
bytes[] memory signatures = new bytes[](1);
40+
3941
emit PublicDecryptionResponse(decryptionId, decryptedResult, signatures);
4042
}
4143

@@ -79,6 +81,7 @@ contract DecryptionMock {
7981
) external {
8082
bytes[] memory userDecryptedShares = new bytes[](1);
8183
bytes[] memory signatures = new bytes[](1);
84+
8285
emit UserDecryptionResponse(decryptionId, userDecryptedShares, signatures);
8386
}
8487
}

gateway-contracts/contracts/mocks/GatewayConfigMock.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ contract GatewayConfigMock {
3535
uint256 mpcThreshold;
3636
KmsNode[] memory kmsNodes = new KmsNode[](1);
3737
Coprocessor[] memory coprocessors = new Coprocessor[](1);
38+
3839
emit Initialization(pauser, metadata, mpcThreshold, kmsNodes, coprocessors);
3940
}
4041

gateway-contracts/contracts/mocks/InputVerificationMock.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ contract InputVerificationMock {
3030

3131
function verifyProofResponse(uint256 zkProofId, bytes32[] calldata ctHandles, bytes calldata signature) external {
3232
bytes[] memory signatures = new bytes[](1);
33+
3334
emit VerifyProofResponse(zkProofId, ctHandles, signatures);
3435
}
3536

gateway-contracts/contracts/mocks/KmsManagementMock.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ contract KmsManagementMock {
3838
_preKeygenRequestCounter++;
3939
uint256 preKeygenRequestId = _preKeygenRequestCounter;
4040
bytes32 fheParamsDigest;
41+
4142
emit PreprocessKeygenRequest(preKeygenRequestId, fheParamsDigest);
4243
}
4344

@@ -49,6 +50,7 @@ contract KmsManagementMock {
4950
_preKskgenRequestCounter++;
5051
uint256 preKskgenRequestId = _preKskgenRequestCounter;
5152
bytes32 fheParamsDigest;
53+
5254
emit PreprocessKskgenRequest(preKskgenRequestId, fheParamsDigest);
5355
}
5456

@@ -58,34 +60,40 @@ contract KmsManagementMock {
5860

5961
function keygenRequest(uint256 preKeyId) external {
6062
bytes32 fheParamsDigest;
63+
6164
emit KeygenRequest(preKeyId, fheParamsDigest);
6265
}
6366

6467
function keygenResponse(uint256 preKeyId, uint256 keyId) external {
6568
uint256 keygenId;
6669
bytes32 fheParamsDigest;
70+
6771
emit KeygenResponse(preKeyId, keygenId, fheParamsDigest);
6872
}
6973

7074
function crsgenRequest(string calldata fheParamsName) external {
7175
_crsgenRequestCounter++;
7276
uint256 crsgenRequestId = _crsgenRequestCounter;
7377
bytes32 fheParamsDigest;
78+
7479
emit CrsgenRequest(crsgenRequestId, fheParamsDigest);
7580
}
7681

7782
function crsgenResponse(uint256 crsgenRequestId, uint256 crsId) external {
7883
bytes32 fheParamsDigest;
84+
7985
emit CrsgenResponse(crsgenRequestId, crsId, fheParamsDigest);
8086
}
8187

8288
function kskgenRequest(uint256 preKskId, uint256 sourceKeyId, uint256 destKeyId) external {
8389
bytes32 fheParamsDigest;
90+
8491
emit KskgenRequest(preKskId, sourceKeyId, destKeyId, fheParamsDigest);
8592
}
8693

8794
function kskgenResponse(uint256 preKskId, uint256 kskId) external {
8895
bytes32 fheParamsDigest;
96+
8997
emit KskgenResponse(preKskId, kskId, fheParamsDigest);
9098
}
9199

gateway-contracts/scripts/bindings_update.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
GW_CONTRACTS_DIR = GW_ROOT_DIR.joinpath("contracts")
1717
GW_MOCKS_DIR = GW_CONTRACTS_DIR.joinpath("mocks")
1818

19-
ALLOWED_FORGE_VERSIONS = ["1.2.1-v1.2.1", "1.2.1-stable"]
19+
ALLOWED_FORGE_VERSIONS = ["1.2.2-v1.2.2", "1.2.2-stable"]
2020

2121

2222
def init_cli() -> ArgumentParser:
@@ -131,8 +131,7 @@ def check_bindings_up_to_date(self):
131131
if return_code != 0:
132132
log_error("ERROR: Some binding files are outdated.")
133133
log_info(
134-
"Run `./scripts/bindings_update.py update` to update the "
135-
"bindings."
134+
"Run `make update-bindings` to update the bindings."
136135
)
137136
sys.exit(ExitStatus.BINDINGS_NOT_UP_TO_DATE.value)
138137

@@ -189,8 +188,7 @@ def check_version(self):
189188
f"Cargo.toml version: {cargo_toml_version}\n"
190189
)
191190
log_info(
192-
"Run `./bindings_update.py update` to update the crate's "
193-
"version."
191+
"Run `make update-bindings` to update the crate's version."
194192
)
195193
sys.exit(ExitStatus.CRATE_VERSION_NOT_UP_TO_DATE.value)
196194
log_success(

0 commit comments

Comments
 (0)